public FullImageWindow()
        {
            InitializeComponent();
            this.Title = string.Format("FLIR Integrated Imaging Solutions. Zoom Demo. Tier {0}", (RenderCapability.Tier >> 16).ToString());

            m_busmgr    = new ManagedBusManager();
            m_ctldlg    = new CameraControlDialog();
            m_selDlg    = new CameraSelectionDialog();
            m_image     = new ManagedImage();
            m_converted = new ManagedImage();

            m_bitmap = new BitmapImage();
            m_worker = new BackgroundWorker();
            m_worker.WorkerReportsProgress = true;
            m_worker.DoWork          += new DoWorkEventHandler(m_worker_DoWork);
            m_worker.ProgressChanged += new ProgressChangedEventHandler(m_worker_ProgressChanged);
            m_Done = new AutoResetEvent(false);

            RenderOptions.SetBitmapScalingMode(myImage, BitmapScalingMode.LowQuality);
            RenderOptions.SetEdgeMode(myImage, EdgeMode.Aliased);

            if (m_selDlg.ShowModal())
            {
                ManagedPGRGuid[] guids = m_selDlg.GetSelectedCameraGuids();

                // Determine camera interface
                var interfaceType = m_busmgr.GetInterfaceTypeFromGuid(guids[0]);

                if (interfaceType == InterfaceType.GigE)
                {
                    m_cam = new ManagedGigECamera();
                }
                else
                {
                    m_cam = new ManagedCamera();
                }

                // Connect to camera object
                m_cam.Connect(guids[0]);

                // Connect control dialog
                m_ctldlg.Connect(m_cam);

                // Start capturing
                m_cam.StartCapture();

                btn_nearfast.IsChecked = true;

                WorkerHelper helper = new WorkerHelper();
                helper.converted = m_converted;
                helper.raw       = m_image;
                helper.cam       = m_cam;
                m_continue       = true;
                m_worker.RunWorkerAsync(helper);
            }
            else
            {
                Application.Current.Shutdown();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 抓取图像
        /// </summary>
        bool StartCapture()
        {
            try
            {
#if (SDK)
                g_ManagedCameraBase.StartCapture();
#endif
                return(true);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
                return(false);
            }
        }
Ejemplo n.º 3
0
        private void toolStripButtonStart_Click(object sender, EventArgs e)
        {
            try
            {
                m_camera.StartCapture();
            }
            catch
            {
                //MessageBox.Show("Camera not detected. Make sure you have connected a camera");
            }


            m_grabImages = true;

            StartGrabLoop();

            toolStripButtonStart.Enabled = false;
            toolStripButtonStop.Enabled  = true;
        }
Ejemplo n.º 4
0
        public Bitmap GrabImage()
        {
            try
            {
                if (m_camera.IsConnected())
                {
                    m_camera.StartCapture();
                    m_camera.RetrieveBuffer(m_rawImage);
                    m_rawImage.Convert(PixelFormat.PixelFormatBgr, m_processedImage);
                    m_camera.StopCapture();
                    imageSize.Width  = (int)m_rawImage.cols;
                    imageSize.Height = (int)m_rawImage.rows;
                    timeStamp        = m_rawImage.timeStamp;
                }
            }
            catch (FC2Exception ex)
            {
                Debug.WriteLine("Error: " + ex.Message);
            }

            return(m_processedImage.bitmap);
        }
        public void StartPGRCam() {

            try {
                guidToUse.value0 = 3639281153;
                guidToUse.value1 = 3741026457;
                guidToUse.value2 = 2419196441;
                guidToUse.value3 = 2928867345;

                m_camera = new ManagedCamera();
                m_camera.Connect(guidToUse);
                m_camera.StartCapture();
                m_grabImages = true;
                StartGrabLoop();


            }
            catch (FC2Exception ex)
            {
                System.Console.WriteLine("Failed to load form successfully: " + ex.Message);

            }
        }
Ejemplo n.º 6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //MessageBox.Show("VS2013");

            textBox1.Text            = Properties.Settings.Default.mirrorAngleStep;
            textBox2.Text            = Properties.Settings.Default.mirrorAngle;
            textBoxDCMotorTime.Text  = Properties.Settings.Default.motorTime;
            textBoxDCMotor2Time.Text = Properties.Settings.Default.motor2Time;



            Directory.CreateDirectory(savepath);
            Directory.CreateDirectory(savepath + "\\SavedMaxima\\");
            PulseStopWatch.Start();

            comboBox1.Items.Clear();


            foreach (string item in System.IO.Ports.SerialPort.GetPortNames())
            {
                comboBox1.Items.Add(item);
            }
            //comboBox1.SelectedItem = Properties.Settings.Default.myserialport;
            try
            {
                comboBox1.SelectedItem = comboBox1.Items[0];
            }
            catch
            {
            }


            My_count = 0;
            Hide();
            //CameraSelectionDialog camSlnDlg = new CameraSelectionDialog();
            //bool retVal = camSlnDlg.ShowModal();
            //if (retVal)
            if (true)
            {
                try
                {
                    //ManagedPGRGuid[] selectedGuids = camSlnDlg.GetSelectedCameraGuids();
                    //ManagedPGRGuid guidToUse = selectedGuids[0];

                    ManagedBusManager busMgr = new ManagedBusManager();

                    /*InterfaceType ifType = busMgr.GetInterfaceTypeFromGuid(guidToUse);
                     * if (ifType == InterfaceType.GigE)
                     * {
                     *  m_camera = new ManagedGigECamera();
                     * }
                     * else
                     * {
                     *  m_camera = new ManagedCamera();
                     * }*/

                    m_camera = new ManagedCamera();

                    // Connect to the first selected GUID
                    //m_camera.Connect(guidToUse);
                    uint           serial1 = busMgr.GetCameraSerialNumberFromIndex(0);
                    ManagedPGRGuid guid    = busMgr.GetCameraFromSerialNumber(serial1);
                    m_camera.Connect(guid);
                    m_camCtlDlg.Connect(m_camera);

                    CameraInfo camInfo = m_camera.GetCameraInfo();
                    UpdateFormCaption(camInfo);

                    // Set embedded timestamp to on
                    EmbeddedImageInfo embeddedInfo = m_camera.GetEmbeddedImageInfo();
                    embeddedInfo.timestamp.onOff = true;
                    m_camera.SetEmbeddedImageInfo(embeddedInfo);

                    m_camera.StartCapture();

                    m_grabImages = true;

                    StartGrabLoop();
                }
                catch (FC2Exception ex)
                {
                    //MessageBox.Show("Camera not detected. Make sure you have connected a camera");
                    label14.Show();

                    Debug.WriteLine("Failed to load form successfully: " + ex.Message);
                    // Environment.ExitCode = -1;
                    //Application.Exit();
                    //return;
                }



                toolStripButtonStart.Enabled = false;
                toolStripButtonStop.Enabled  = true;
            }
            else
            {
                Environment.ExitCode = -1;
                Application.Exit();
                return;
            }

            Show();

            chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;
            chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false;
            // chart1.ChartAreas[0].AxisY.
            //chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineColor = Color.Gray;
            //chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineColor = Color.Gray;
            chart1.Series[0].BorderWidth = 3;

            /*
             * if (checkBoxGraph.Checked) { timerGraph.Start(); }
             * else { timerGraph.Stop(); }*/
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            Hide();

            CameraSelectionDialog camSlnDlg = new CameraSelectionDialog();
            bool retVal = camSlnDlg.ShowModal();

            if (retVal)
            {
                try
                {
                    ManagedPGRGuid[] selectedGuids = camSlnDlg.GetSelectedCameraGuids();
                    if (selectedGuids.Length == 0)
                    {
                        Debug.WriteLine("No cameras selected!");
                        Close();
                        return;
                    }

                    ManagedPGRGuid guidToUse = selectedGuids[0];

                    ManagedBusManager busMgr = new ManagedBusManager();
                    InterfaceType     ifType = busMgr.GetInterfaceTypeFromGuid(guidToUse);

                    if (ifType == InterfaceType.GigE)
                    {
                        m_camera = new ManagedGigECamera();
                    }
                    else
                    {
                        m_camera = new ManagedCamera();
                    }

                    // Connect to the first selected GUID
                    m_camera.Connect(guidToUse);

                    m_camCtlDlg.Connect(m_camera);

                    CameraInfo camInfo = m_camera.GetCameraInfo();
                    UpdateFormCaption(camInfo);

                    // Set embedded timestamp to on
                    EmbeddedImageInfo embeddedInfo = m_camera.GetEmbeddedImageInfo();
                    embeddedInfo.timestamp.onOff = true;
                    m_camera.SetEmbeddedImageInfo(embeddedInfo);

                    m_camera.StartCapture();

                    m_grabImages = true;

                    StartGrabLoop();
                }
                catch (FC2Exception ex)
                {
                    Debug.WriteLine("Failed to load form successfully: " + ex.Message);
                    Close();
                }
            }
            else
            {
                Close();
            }

            Show();
        }
Ejemplo n.º 8
0
        public void InitVideoCapture(int videoDeviceID, FrameRate framerate, Resolution resolution,
                                     ImageFormat format, bool grayscale)
        {
            if (cameraInitialized)
            {
                return;
            }

            this.resolution    = resolution;
            this.grayscale     = grayscale;
            this.frameRate     = framerate;
            this.videoDeviceID = videoDeviceID;
            this.format        = format;

            switch (resolution)
            {
            case Resolution._160x120:
                cameraWidth  = 160;
                cameraHeight = 120;
                break;

            case Resolution._320x240:
                cameraWidth  = 320;
                cameraHeight = 240;
                break;

            case Resolution._640x480:
                cameraWidth  = 640;
                cameraHeight = 480;
                break;

            case Resolution._800x600:
                cameraWidth  = 800;
                cameraHeight = 600;
                break;

            case Resolution._1024x768:
                cameraWidth  = 1024;
                cameraHeight = 768;
                break;

            case Resolution._1280x1024:
                cameraWidth  = 1280;
                cameraHeight = 960;
                break;

            case Resolution._1600x1200:
                cameraWidth  = 1600;
                cameraHeight = 1200;
                break;
            }

            ManagedBusManager busMgr = new ManagedBusManager();
            uint numCameras          = busMgr.GetNumOfCameras();

            if (videoDeviceID >= numCameras || videoDeviceID < 0)
            {
                throw new GoblinException("VideoDeviceID: " + videoDeviceID + " is out of range. There are only " +
                                          numCameras + " point grey camera(s) connected");
            }

            ManagedPGRGuid guid   = busMgr.GetCameraFromIndex((uint)videoDeviceID);
            InterfaceType  ifType = busMgr.GetInterfaceTypeFromGuid(guid);

            if (ifType == InterfaceType.GigE)
            {
                camera = new ManagedGigECamera();
            }
            else
            {
                camera = new ManagedCamera();
            }

            camera.Connect(guid);

            processedImage = new ManagedImage();
            pixelData      = new byte[cameraWidth * cameraHeight * 3];

            VideoMode currentVideoMode = VideoMode.NumberOfVideoModes;

            FlyCapture2Managed.FrameRate currentFrameRate = FlyCapture2Managed.FrameRate.NumberOfFrameRates;

            FlyCapture2Managed.FrameRate desiredFrameRate = FlyCapture2Managed.FrameRate.NumberOfFrameRates;

            switch (frameRate)
            {
            case FrameRate._15Hz:
                desiredFrameRate = FlyCapture2Managed.FrameRate.FrameRate15;
                break;

            case FrameRate._30Hz:
                desiredFrameRate = FlyCapture2Managed.FrameRate.FrameRate30;
                break;

            case FrameRate._60Hz:
                desiredFrameRate = FlyCapture2Managed.FrameRate.FrameRate60;
                break;

            case FrameRate._120Hz:
                desiredFrameRate = FlyCapture2Managed.FrameRate.FrameRate120;
                break;

            case FrameRate._240Hz:
                desiredFrameRate = FlyCapture2Managed.FrameRate.FrameRate240;
                break;

            default:
                throw new GoblinException(framerate.ToString() + " is not supported");
            }

            try
            {
                ((ManagedCamera)camera).GetVideoModeAndFrameRate(ref currentVideoMode, ref currentFrameRate);

                if (!isVideoModeSet)
                {
                    videoMode = currentVideoMode;
                }

                bool supported = ((ManagedCamera)camera).GetVideoModeAndFrameRateInfo(videoMode, desiredFrameRate);

                if (supported)
                {
                    ((ManagedCamera)camera).SetVideoModeAndFrameRate(videoMode, desiredFrameRate);
                }
                else
                {
                    Log.Write(desiredFrameRate.ToString() + " is not supported in " + videoMode.ToString() + " mode");
                }
            }
            catch (Exception exp)
            {
                Log.Write(exp.Message + ": " + exp.StackTrace);
            }

            camera.StartCapture(OnImageGrabbed);

            cameraInitialized = true;
        }