첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

■ 카메라 사진 크기 측정하기

------------------------------------------------------------------------------------------------------------------------


TestProject.zip


MainForm.cs

 

 

using System;

using System.Collections.Generic;

using System.Drawing;

using System.Drawing.Drawing2D;

using System.Drawing.Imaging;

using System.Globalization;

using System.IO;

using System.Text;

using System.Windows.Forms;

 

namespace TestProject

{

    /// <summary>

    /// 메인 폼

    /// </summary>

    public partial class MainForm : Form

    {

        //////////////////////////////////////////////////////////////////////////////////////////////////// Field

        ////////////////////////////////////////////////////////////////////////////////////////// Private

 

        #region Field

 

        /// <summary>

        /// 카메라 정보 리스트

        /// </summary>

        private List<CameraInfo> cameraInfoList = new List<CameraInfo>();

 

        /// <summary>

        /// 축소/확대

        /// </summary>

        private float zoom = 1;

 

        /// <summary>

        /// 시작 X 좌표

        /// </summary>

        private int startX = 0;

 

        /// <summary>

        /// 시작 Y 좌표

        /// </summary>

        private int startY = 0;

 

        /// <summary>

        /// 이동 X 좌표

        /// </summary>

        private int moveX = 0;

 

        /// <summary>

        /// 이동 Y 좌표

        /// </summary>

        private int moveY = 0;

 

        /// <summary>

        /// 측정

        /// </summary>

        private double measure = 0;

 

        /// <summary>

        /// 객체 크기

        /// </summary>

        private double objectSize = 0;

 

        /// <summary>

        /// 객체 거리

        /// </summary>

        private double objectDistance = 0;

 

        /// <summary>

        /// 객체 크기 스케일

        /// </summary>

        private double objectSizeScale = .01;

 

        /// <summary>

        /// 객체 거리 스케일

        /// </summary>

        private double objectDistanceScale = 1;

 

        /// <summary>

        /// 측정 시작 X 좌표

        /// </summary>

        private int measureStartX = 0;

 

        /// <summary>

        /// 측정 시작 Y 좌표

        /// </summary>

        private int measureStartY = 0;

 

        /// <summary>

        /// 수평 여부

        /// </summary>

        private bool horizontal = true;

 

        /// <summary>

        /// 비트맵

        /// </summary>

        private Bitmap bitmap;

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor

        ////////////////////////////////////////////////////////////////////////////////////////// Public

 

        #region 메인 폼 - MainForm()

 

        /// <summary>

        /// 메인 폼

        /// </summary>

        public MainForm()

        {

            InitializeComponent();

 

            BuildCameraMenuItem();

 

            #region 파일 열기 대화 상자를 설정한다.

 

            this.openFileDialog.FileName         = "";

            this.openFileDialog.Filter           = "이미지 파일|*.*|JPG|*.jpg";

            this.openFileDialog.RestoreDirectory = true;

 

            #endregion

 

            #region 이벤트를 설정한다.

 

            Load                                            += Form_Load;

            Resize                                          += Form_Resize;

 

            this.openImageMenuItem.Click                    += openImageMenuItem_Click;

            this.exitMenuItem.Click                         += exitMenuItem_Click;

 

            this.thumbnailPictureBox.MouseDown              += thumbnailPictureBox_MouseDown;

            this.zoomTrackBar.Scroll                        += zoomTrackBar_Scroll;

            this.foscalLengthTextBox.TextChanged            += foscalLengthTextBox_TextChanged;

            this.cameraFactoryTextBox.TextChanged           += cameraFactoryTextBox_TextChanged;

            this.sensorWidthTextBox.TextChanged             += foscalLengthTextBox_TextChanged;

            this.sensorHeightTextBox.TextChanged            += foscalLengthTextBox_TextChanged;

 

            this.objectSizeTextBox.Click                    += objectSizeTextBox_Click;

            this.objectSizeTextBox.TextChanged              += objectSizeTextBox_TextChanged;

            this.objectSizeScaleComboBox.TextChanged        += objectSizeScaleComboBox_TextChanged;

            this.objectSizeScaleComboBox.DropDownClosed     += objectSizeScaleComboBox_DropDownClosed;

            this.findDistanceButton.Click                   += findDistanceButton_Click;

            this.findSizeButton.Click                       += findSizeButton_Click;

            this.objectDistanceTextBox.Click                += objectDistanceTextBox_Click;

            this.objectDistanceTextBox.TextChanged          += objectDistanceTextBox_TextChanged;

            this.objectDistanceSacleComboBox.TextChanged    += objectDistanceSacleComboBox_TextChanged;

            this.objectDistanceSacleComboBox.DropDownClosed += objectDistanceSacleComboBox_DropDownClosed;

            this.moveImageButton.Click                      += moveImageButton_Click;

            this.measureButton.Click                        += measureButton_Click;

 

            this.mainPictureBox.MouseDown                   += mainPictureBox_MouseDown;

            this.mainPictureBox.MouseMove                   += mainPictureBox_MouseMove;

 

            #endregion

        }

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method

        ////////////////////////////////////////////////////////////////////////////////////////// Private

        //////////////////////////////////////////////////////////////////////////////// Event

 

        #region 폼 로드시 처리하기 - Form_Load(sender, e)

 

        /// <summary>

        /// 폼 로드시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void Form_Load(object sender, EventArgs e)

        {

            UpdatePictureBox();

        }

 

        #endregion

        #region 폼 크기 조정시 처리하기 - Form_Resize(sender, e)

 

        /// <summary>

        /// 폼 크기 조정시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void Form_Resize(object sender, EventArgs e)

        {

            UpdatePictureBox();

        }

 

        #endregion

 

        #region 이미지 열기 메뉴 항목 클릭시 처리하기 - openImageMenuItem_Click(sender, e)

 

        /// <summary>

        /// 이미지 열기 메뉴 항목 클릭시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void openImageMenuItem_Click(object sender, EventArgs e)

        {

            if(this.openFileDialog.ShowDialog() == DialogResult.OK)

            {

                string imageFilePath = this.openFileDialog.FileName;

 

                try

                {

                    Image image = Image.FromFile(imageFilePath);

 

                    this.thumbnailPictureBox.Image = image;

 

                    this.zoomTrackBar.Value = 50;

 

                    this.startX         = 0;

                    this.startY         = 0;

                    this.objectSize     = 0;

                    this.objectDistance = 0;

                    this.measure        = 0;

 

                    this.objectDistanceTextBox.Text = string.Empty;

                    this.objectSizeTextBox.Text     = string.Empty;

 

                    this.locationOnFileLabel.Text   = "파일상 위치 (pixel) : ";

                    this.locationOnSenserLabel.Text = "센서상 위치 (mm) : ";

                    this.sizeOnSensorLabel.Text     = "센서상 크기 (mm) : ";

 

                    this.imageWidthTextBox.Text    = string.Empty;

                    this.imageHeightTextBox.Text   = string.Empty;

                    this.foscalLengthTextBox.Text  = string.Empty;

                    this.cameraFactoryTextBox.Text = string.Empty;

 

                    SetZoom();

 

                    PropertyItem propertyItem = image.GetPropertyItem(37386);

 

                    byte[] lowByteArray  = new byte[propertyItem.Len / 2];

                    byte[] highByteArray = new byte[propertyItem.Len / 2];

 

                    Array.Copy(propertyItem.Value, 0                   , lowByteArray , 0, propertyItem.Len / 2);

                    Array.Copy(propertyItem.Value, propertyItem.Len / 2, highByteArray, 0, propertyItem.Len / 2);

 

                    this.foscalLengthTextBox.Text = Convert.ToString((float)GetUnsignedInteger(lowByteArray) /

                        GetUnsignedInteger(highByteArray));

 

                    this.imageWidthTextBox.Text  = image.PhysicalDimension.Width.ToString();

                    this.imageHeightTextBox.Text = image.PhysicalDimension.Height.ToString();

 

                    if(image.PhysicalDimension.Width > image.PhysicalDimension.Height)

                    {

                        this.horizontal = true;

                    }

                    else

                    {

                        this.horizontal = false;

                    }

 

                    Encoding encoding = Encoding.ASCII;

 

                    string cameraFactory = encoding.GetString(image.GetPropertyItem(271).Value).Replace("\0", "\r\n");

 

                    cameraFactory += encoding.GetString(image.GetPropertyItem(272).Value);

 

                    this.cameraFactoryTextBox.Text = cameraFactory;

 

                    Text = "카메라 사진 크기 측정하기 " + " - " + openFileDialog.FileName;

                }

                catch

                {

                }

            }

        }

 

        #endregion

        #region 종료 메뉴 항목 클릭시 처리하기 - exitMenuItem_Click(sender, e)

 

        /// <summary>

        /// 종료 메뉴 항목 클릭시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void exitMenuItem_Click(object sender, EventArgs e)

        {

            Application.Exit();

        }

 

        #endregion

 

        #region 썸네일 픽처 박스 마우스 DOWN 처리하기 - thumbnailPictureBox_MouseDown(sender, e)

 

        /// <summary>

        /// 썸네일 픽처 박스 마우스 DOWN 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void thumbnailPictureBox_MouseDown(object sender, MouseEventArgs e)

        {

            try

            {

                this.startX = this.thumbnailPictureBox.Image.Width  * e.X / this.thumbnailPictureBox.Width;

                this.startY = this.thumbnailPictureBox.Image.Height * e.Y / this.thumbnailPictureBox.Height;

 

                UpdatePictureBox();

            }

            catch

            {

            }

        }

 

        #endregion

        #region 축소/확대 트랙바 스크롤시 처리하기 - zoomTrackBar_Scroll(sender, e)

 

        /// <summary>

        /// 축소/확대 트랙바 스크롤시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void zoomTrackBar_Scroll(object sender, EventArgs e)

        {

            SetZoom();

        }

 

        #endregion

        #region 초점 거리 텍스트 박스 텍스트 변경시 처리하기 - foscalLengthTextBox_TextChanged(sender, e)

 

        /// <summary>

        /// 초점 거리 텍스트 박스 텍스트 변경시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void foscalLengthTextBox_TextChanged(object sender, EventArgs e)

        {

            string equivalenceString = string.Empty;

 

            try

            {

                double equivalence = Math.Pow((Math.Pow(Convert.ToSingle(this.sensorWidthTextBox.Text), 2) +

                    Math.Pow(Convert.ToSingle(this.sensorHeightTextBox.Text), 2)), 0.5);

 

                equivalence = Math.Round((43.2666153 / equivalence) * Convert.ToSingle(this.foscalLengthTextBox.Text));

 

                equivalenceString = equivalence.ToString();

            }

            catch

            {

            }

 

            this.equivalentTextBox.Text = equivalenceString;

        }

 

        #endregion

        #region 카메라 공장 텍스트 박스 텍스트 변경시 처리하기 - cameraFactoryTextBox_TextChanged(sender, e)

 

        /// <summary>

        /// 카메라 공장 텍스트 박스 텍스트 변경시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void cameraFactoryTextBox_TextChanged(object sender, EventArgs e)

        {

            SearchCamera();

        }

 

        #endregion

 

        #region 객체 크기 텍스트 박스 클릭시 처리하기 - objectSizeTextBox_Click(sender, e)

 

        /// <summary>

        /// 객체 크기 텍스트 박스 클릭시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void objectSizeTextBox_Click(object sender, EventArgs e)

        {

            this.objectSizeTextBox.SelectionStart  = 0;

            this.objectSizeTextBox.SelectionLength = this.objectSizeTextBox.Text.Length;

        }

 

        #endregion

        #region 객체 크기 텍스트 박스 텍스트 변경시 처리하기 - objectSizeTextBox_TextChanged(sender, e)

 

        /// <summary>

        /// 객체 크기 텍스트 박스 텍스트 변경시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void objectSizeTextBox_TextChanged(object sender, EventArgs e)

        {

            if(this.objectSizeTextBox.Selected)

            {

                try

                {

                    SetFindButton(true);

 

                    this.objectSize = Convert.ToDouble(this.objectSizeTextBox.Text) * this.objectSizeScale;

 

                    SetObjectDistance();

                }

                catch

                {

                }

            }

        }

 

        #endregion

        #region 객체 크기 스케일 콤보 박스 텍스트 변경시 처리하기 - objectSizeScaleComboBox_TextChanged(sender, e)

 

        /// <summary>

        /// 객체 크기 스케일 콤보 박스 텍스트 변경시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void objectSizeScaleComboBox_TextChanged(object sender, EventArgs e)

        {

            this.objectSizeScale = GetSize(this.objectSizeScaleComboBox.Text);

 

            this.objectSizeTextBox.Text = Convert.ToString(Math.Round(this.objectSize / this.objectSizeScale, 2));

        }

 

        #endregion

        #region 객체 크기 스케일 콤보 박스 드롭 다운 닫은 경우 처리하기 - objectSizeScaleComboBox_DropDownClosed(sender, e)

 

        /// <summary>

        /// 객체 크기 스케일 콤보 박스 드롭 다운 닫은 경우 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void objectSizeScaleComboBox_DropDownClosed(object sender, EventArgs e)

        {

            this.zoomTrackBar.Select();

        }

 

        #endregion

        #region 거리 찾기 버튼 클릭시 처리하기 - findDistanceButton_Click(sender, e)

 

        /// <summary>

        /// 거리 찾기 버튼 클릭시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void findDistanceButton_Click(object sender, EventArgs e)

        {

            SetFindButton(true);

        }

 

        #endregion

        #region 크기 찾기 버튼 클릭시 처리하기 - findSizeButton_Click(sender, e)

 

        /// <summary>

        /// 크기 찾기 버튼 클릭시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void findSizeButton_Click(object sender, EventArgs e)

        {

            SetFindButton(false );

        }

 

        #endregion

        #region 객체 거리 텍스트 박스 클릭시 처리하기 - objectDistanceTextBox_Click(sender, e)

 

        /// <summary>

        /// 객체 거리 텍스트 박스 클릭시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void objectDistanceTextBox_Click(object sender, EventArgs e)

        {

            this.objectDistanceTextBox.SelectionStart  = 0;

            this.objectDistanceTextBox.SelectionLength = this.objectDistanceTextBox.Text.Length;

        }

 

        #endregion

        #region 객체 거리 텍스트 박스 텍스트 변경시 처리하기 - objectDistanceTextBox_TextChanged(sender, e)

 

        /// <summary>

        /// 객체 거리 텍스트 박스 텍스트 변경시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void objectDistanceTextBox_TextChanged(object sender, EventArgs e)

        {

            if(this.objectDistanceTextBox.Selected)

            {

                try

                {

                    SetFindButton(false);

 

                    this.objectDistance = Convert.ToDouble(this.objectDistanceTextBox.Text) * this.objectDistanceScale;

 

                    SetObjectSize();

                }

                catch

                {

                }

            }

        }

 

        #endregion

        #region 객체 거리 스케일 콤보 박스 텍스트 변경시 처리하기 - objectDistanceSacleComboBox_TextChanged(sender, e)

 

        /// <summary>

        /// 객체 거리 스케일 콤보 박스 텍스트 변경시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void objectDistanceSacleComboBox_TextChanged(object sender, EventArgs e)

        {

            this.objectDistanceScale = GetSize(this.objectDistanceSacleComboBox.Text);

 

            this.objectDistanceTextBox.Text = Convert.ToString(Math.Round(this.objectDistance / this.objectDistanceScale, 2));

        }

 

        #endregion

        #region 객체 거리 스케일 콤보 박스 드롭 다운 닫은 경우 처리하기 - objectDistanceSacleComboBox_DropDownClosed(sender, e)

 

        /// <summary>

        /// 객체 거리 스케일 콤보 박스 드롭 다운 닫은 경우 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void objectDistanceSacleComboBox_DropDownClosed(object sender, EventArgs e)

        {

            this.zoomTrackBar.Select();

        }

 

        #endregion

        #region 이미지 이동 버튼 클릭시 처리하기 - moveImageButton_Click(sender, e)

 

        /// <summary>

        /// 이미지 이동 버튼 클릭시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void moveImageButton_Click(object sender, EventArgs e)

        {

            this.moveImageButton.Checked = true;

 

            this.measureButton.Checked = false;

 

            this.mainPictureBox.Cursor = Cursors.Hand;

        }

 

        #endregion

        #region 측정 버튼 클릭시 처리하기 - measureButton_Click(sender, e)

 

        /// <summary>

        /// 측정 버튼 클릭시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void measureButton_Click(object sender, EventArgs e)

        {

            this.moveImageButton.Checked = false;

 

            this.measureButton.Checked = true;

 

            this.mainPictureBox.Cursor = Cursors.Cross;

        }

 

        #endregion

 

        #region 메인 픽처 박스 마우스 DOWN 처리하기 - mainPictureBox_MouseDown(sender, e)

 

        /// <summary>

        /// 메인 픽처 박스 마우스 DOWN 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void mainPictureBox_MouseDown(object sender, MouseEventArgs e)

        {

            if(this.moveImageButton.Checked)

            {

                this.moveX = e.X;

                this.moveY = e.Y;

            }

            else

            {

                this.measureStartX = e.X;

                this.measureStartY = e.Y;

            }

        }

 

        #endregion

        #region 메인 픽처 박스 마우스 이동시 처리하기 - mainPictureBox_MouseMove(sender, e)

 

        /// <summary>

        /// 메인 픽처 박스 마우스 이동시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void mainPictureBox_MouseMove(object sender, MouseEventArgs e)

        {

            if(e.Button == MouseButtons.Left)

            {

                if(this.moveImageButton.Checked)

                {

                    this.startX -= e.X - this.moveX;

 

                    if(this.startX < 0)

                    {

                        this.startX = 0;

                    }

 

                    this.startY -= e.Y - this.moveY;

 

                    if(this.startY < 0)

                    {

                        this.startY = 0;

                    }

 

                    this.moveX = e.X;

                    this.moveY = e.Y;

 

                    UpdatePictureBox();

                }

                else

                {

                    try

                    {

                        double differenceX = Math.Abs(this.measureStartX - e.X) * this.zoom * Convert.ToSingle(this.horizontal ? 

                            this.sensorWidthTextBox.Text  : this.sensorHeightTextBox.Text) / Convert.ToSingle(this.imageWidthTextBox.Text );

                        double differenceY = Math.Abs(this.measureStartY - e.Y) * this.zoom * Convert.ToSingle(this.horizontal ? 

                            this.sensorHeightTextBox.Text : this.sensorWidthTextBox.Text ) / Convert.ToSingle(this.imageHeightTextBox.Text);

 

                        this.measure = Math.Pow((Math.Pow(differenceX, 2) + Math.Pow(differenceY, 2)), 0.5);

 

                        this.sizeOnSensorLabel.Text = "센서상 크기 (mm) : " + this.measure.ToString();

                        

                        this.mainPictureBox.Refresh();

 

                        Graphics graphics = mainPictureBox.CreateGraphics();

 

                        graphics.ResetClip();

 

                        graphics.DrawLine(new Pen(Color.Red), this.measureStartX, this.measureStartY, e.X, e.Y);

 

                        if(this.findDistanceButton.Checked)

                        {

                            SetObjectDistance();

                        }

                        else

                        {

                            SetObjectSize();

                        }

                    }

                    catch

                    {

                    }

                }

            }

 

            try

            {

                float fileX = this.startX + e.X * this.zoom;

                float fileY = this.startY + e.Y * this.zoom;

 

                float sensorX = fileX * Convert.ToSingle(this.horizontal ? this.sensorWidthTextBox.Text  : this.sensorHeightTextBox.Text) /

                    Convert.ToSingle(this.imageWidthTextBox.Text );

                float sensorY = fileY * Convert.ToSingle(this.horizontal ? this.sensorHeightTextBox.Text : this.sensorWidthTextBox.Text ) /

                    Convert.ToSingle(this.imageHeightTextBox.Text);

                

                this.locationOnFileLabel.Text  = "파일상 위치 (pixel) X :" + fileX.ToString() + " Y : " + fileY.ToString();

                this.locationOnSenserLabel.Text= "센서상 위치 (mm) X : " + sensorX.ToString() + "  Y : " + sensorY.ToString();

            }

            catch

            {

            }

        }

 

        #endregion

 

        #region 카메라 메뉴 항목 클릭시 처리하기 - cameraMenuItem_Click(sender, e)

 

        /// <summary>

        /// 카메라 메뉴 항목 클릭시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void cameraMenuItem_Click(object sender, EventArgs e)

        {

            this.cameraFactoryTextBox.Text = ((ToolStripItem)sender).OwnerItem.Text;

            this.cameraFactoryTextBox.Text += "\r\n" + ((ToolStripItem)sender).OwnerItem.Text + " " + ((ToolStripItem)sender).Text;

        }

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////// Function

 

        #region 카메라 메뉴 항목 구축하기 - BuildCameraMenuItem()

 

        /// <summary>

        /// 카메라 메뉴 항목 구축하기

        /// </summary>

        private void BuildCameraMenuItem()

        {

            this.cameraInfoList.Clear();

 

            this.cameraMenuItem.DropDownItems.Clear();

 

            string cameraListFilePath = Path.Combine(Application.StartupPath, @"DATA\CameraList.info");

 

            if(File.Exists(cameraListFilePath))

            {

                string content = File.ReadAllText(cameraListFilePath);

 

                string[] lineArray = content.Split('\n');

 

                CultureInfo cultureInfo = new CultureInfo("en-US");

 

                foreach(string line in lineArray)

                {

                    if(string.IsNullOrWhiteSpace(line))

                    {

                        continue;

                    }

 

                    if(line.StartsWith("//"))

                    {

                        continue;

                    }

 

                    string[] tokenArray = line.Split(new string[] { "," }, StringSplitOptions.None);

 

                    try

                    {

                        CameraInfo cameraInfo = new CameraInfo();

 

                        cameraInfo.Factory      = tokenArray[0].Trim();

                        cameraInfo.Model        = tokenArray[1].Trim();

                        cameraInfo.AliasName    = tokenArray[2].Trim();

                        cameraInfo.SensorType   = tokenArray[3].Trim();

                        cameraInfo.SensorWidth  = Single.Parse(tokenArray[4], cultureInfo);

                        cameraInfo.SensorHeight = Single.Parse(tokenArray[5], cultureInfo);

 

                        this.cameraInfoList.Add(cameraInfo);

 

                        bool newFactory = true;

 

                        foreach(ToolStripMenuItem menuItem in this.cameraMenuItem.DropDownItems)

                        {

                            if(menuItem.Text.Contains(cameraInfo.Factory))

                            {

                                newFactory = false;

 

                                break;

                            }

                        }

 

                        if(n