Exemple #1
0
        public Form1()
        {
            InitializeComponent();
            KSJGigeVisionApi.KSJGIGEVISION_Init();

            int nCount        = 0;
            int nAdapterIndex = KSJGigeVisionApi.KSJGIGEVISION_AdapterGetCount();
            int nCameraIndex  = 0;

            for (int i = 0; i < nAdapterIndex; i++)
            {
                nCameraIndex = KSJGigeVisionApi.KSJGIGEVISION_CameraGetCount(i);
                for (int j = 0; j < nCameraIndex; j++)
                {
                    CamareIndex[nCount, 0] = i;
                    CamareIndex[nCount, 1] = j;
                    nCount++;
                }
            }

            label1.Text = String.Format("{0} Device Found:", nCount);

            for (int i = 0; i < nCount; i++)//获取每个相机的参数插入到顶部下拉框中
            {
                string szText = String.Format("camera{0}", i + 1);
                comboBox_DEVICE_LIST.Items.Insert(i, szText);
            }

            m_nDeviceCurSel = -1;
            exitEvent       = new AutoResetEvent(false);
        }
Exemple #2
0
        public Form1()
        {
            InitializeComponent();
            KSJGigeVisionApi.KSJGIGEVISION_Init();

            int nCount        = 0;
            int nAdapterIndex = KSJGigeVisionApi.KSJGIGEVISION_AdapterGetCount();
            int nCameraIndex  = 0;

            for (int i = 0; i < nAdapterIndex; i++)
            {
                nCameraIndex = KSJGigeVisionApi.KSJGIGEVISION_CameraGetCount(i);
                for (int j = 0; j < nCameraIndex; j++)
                {
                    CamareIndex[nCount, 0] = i;
                    CamareIndex[nCount, 1] = j;
                    nCount++;
                }
            }

            label1.Text = String.Format("{0} Device Found:", nCount);
            if (nCount == 0)
            {
                return;
            }
            int Ip = 0;

            int[] ucIp = new int[4];
            for (int i = 0; i < nCount; i++)//获取每个相机的参数插入到顶部下拉框中
            {
                KSJGigeVisionApi.KSJGIGEVISION_CameraGetIp(CamareIndex[i, 0], CamareIndex[i, 1], ref Ip);
                for (int j = 0; j < 4; j++)
                {
                    ucIp[j] = (Ip >> (j * 8)) & 0xFF;
                }
                string szText = String.Format("camera {0}.{1}.{2}.{3}", ucIp[0], ucIp[1], ucIp[2], ucIp[3]);
                comboBox_DEVICE_LIST.Items.Insert(i, szText);
            }

            m_nDeviceCurSel = 0;
            comboBox_DEVICE_LIST.SelectedIndex = m_nDeviceCurSel;
            exitEvent = new AutoResetEvent(false);
            this.PictureBox_PREVIEWWND.MouseWheel += new MouseEventHandler(PictureBox_PREVIEWWND_MouseWheel);//控件滚轮事件
        }