//主程式

        private void main()
        {
            busMgr = new ManagedBusManager();
            numOfCameras = busMgr.GetNumOfCameras(); 

             if (numOfCameras == 0)
            {
                 //message
                return;
            }

            for (uint camCount = 0; camCount < numOfCameras; camCount++)
            {

                ManagedPGRGuid guid = busMgr.GetCameraFromIndex(camCount);
                cameras[camCount] = new ManagedCamera();
                processedImage[camCount] = new ManagedImage();
                rawImage[camCount] = new ManagedImage();
                cameras[camCount].Connect(guid);

                Cameras_Setup(cameras[camCount]);
                SnapSetup(cameras[camCount]);
             
                cameras[camCount].StartCapture();
               
            }

         }

       private void SnapSetup(ManagedCamera m_cam)
        {

            // Power on the camera
            richTextBox1.AppendText("camera snapsetup\n");
            const uint k_cameraPower = 0x610;
            const uint k_powerVal = 0x80000000;
            if (m_cam== null)
            {
                richTextBox1.AppendText("連接不到camera\n");
                return;
            }
            m_cam.WriteRegister(k_cameraPower, k_powerVal);
            const Int32 k_millisecondsToSleep = 100;
            uint regVal = 0;

            // Wait for camera to complete power-up
            do
            {
                System.Threading.Thread.Sleep(k_millisecondsToSleep);

                regVal = m_cam.ReadRegister(k_cameraPower);

            } while ((regVal & k_powerVal) == 0);




            // Get current trigger settings
            TriggerMode triggerMode = m_cam.GetTriggerMode();
         
            // Set camera to trigger mode 0
            // A source of 7 means software trigger
            triggerMode.onOff = true;
            triggerMode.mode = 0;
            triggerMode.parameter = 0;
            // A source of 7 means software trigger
            // triggerMode.source = 7;

            if (useSoftwareTrigger)
            {
                // A source of 7 means software trigger
                triggerMode.source = 7;
            }
            else
            {
                // Triggering the camera externally using source 0.
                triggerMode.source = 0;
            }

            // Set the trigger mode
            m_cam.SetTriggerMode(triggerMode);

            // Poll to ensure camera is ready
            bool retVal = PollForTriggerReady(m_cam);
            if (retVal != true)
            {
             
                richTextBox1.AppendText("camera disconnects\n");
                return;
            }


            if (useSoftwareTrigger)
            {
                if (CheckSoftwareTriggerPresence(m_cam) == false)
                {
           
                    richTextBox1.AppendText("SOFT_ASYNC_TRIGGER not implemented on this camera!  Stopping application\n");
                    return;
                }
            }
            else
            {
            
                richTextBox1.AppendText("Trigger the camera by sending a trigger pulse to GPIO" + triggerMode.source.ToString() + ".\n");
            }
        

        }

文章標籤
創作者介紹

colin異世界

colin 發表在 痞客邦 PIXNET 留言(0) 人氣()