Example #1
0
        static void Main(string[] args)
        {
            PrintBuildInfo();

            Program program = new Program();

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

            Console.WriteLine("Number of cameras detected: {0}", numCameras);

            // Finish if there are no cameras
            if (numCameras == 0)
            {
                Console.WriteLine("Not enough cameras!");
                Console.WriteLine("Press Enter to exit...");
                Console.ReadLine();
                return;
            }

            for (uint i = 0; i < numCameras; i++)
            {
                ManagedPGRGuid guid = busMgr.GetCameraFromIndex(i);

                program.RunSingleCamera(guid);
            }

            Console.WriteLine("Done! Press enter to exit...");
            Console.ReadLine();
        }
        // calibrator deafult constructor
        public Flea3Calibrator(PictureBox displaybox)
        {
            DisplayBox = displaybox;
            // 1. creating the camera object
            Cam = new ManagedCamera();
            // 2. creating the bus manager in order to handle (potentially)
            // multiple cameras
            BusMgr = new ManagedBusManager();

            // 3. retrieving the List of all camera ids connected to the bus
            CamIDs = new List <ManagedPGRGuid>();
            int camCount = (int)BusMgr.GetNumOfCameras();

            for (int i = 0; i < camCount; i++)
            {
                ManagedPGRGuid guid = BusMgr.GetCameraFromIndex((uint)i);
                CamIDs.Add(guid);
            }


            FrameCount      = FRAME_COUNT;
            ChessHorizCount = CHESS_HORIZ_CORNER_COUNT;
            ChessVertCount  = CHESS_VERT_CORNER_COUNT;

            RectWidth  = RECT_WIDTH;
            RectHeight = RECT_HEIGHT;

            // creatring the imageViewer to display the calibration frame sequence
            //imageViewer = new ImageViewer();


            state = ST_IDLE;
        }
Example #3
0
        /// <summary>
        /// Attempt to connect to camera
        /// </summary>
        /// <returns>True if connection is successful</returns>
        public bool Initialize()
        {
            ManagedBusManager busMgr = new ManagedBusManager();

            try
            {
                ManagedPGRGuid guid = busMgr.GetCameraFromSerialNumber(this.serial);
                this.camera.Connect(guid);
                GigEImageSettings config = this.camera.GetGigEImageSettings();
                config.height  = this.PixelHeight;
                config.width   = this.PixelWidth;
                config.offsetX = (2448 - this.PixelWidth) / 2;
                config.offsetY = (2048 - this.PixelHeight) / 2;
                this.camera.SetGigEImageSettings(config);
            }
            catch (Exception ex)
            {
                // Connection unsuccessful
                Logger.Out(ex.ToString());
                this.Connected = false;
                return(false);
            }
            // Set embedded timestamp to on
            EmbeddedImageInfo embeddedInfo = this.camera.GetEmbeddedImageInfo();

            embeddedInfo.timestamp.onOff = true;
            this.camera.SetEmbeddedImageInfo(embeddedInfo);
            // Start live capture
            this.Connected = true;
            this.Start();
            return(true);
        }
Example #4
0
        void BusResetLoop()
        {
            ManagedBusManager busMgr = new ManagedBusManager();

            List <IntPtr> callbackHandles = new List <IntPtr>();

            // Register bus events
            IntPtr busResetHandle   = busMgr.RegisterCallback(OnBusReset, ManagedCallbackType.BusReset, IntPtr.Zero);
            IntPtr busArrivalHandle = busMgr.RegisterCallback(OnBusArrival, ManagedCallbackType.Arrival, IntPtr.Zero);
            IntPtr busRemovalHandle = busMgr.RegisterCallback(OnBusRemoval, ManagedCallbackType.Removal, IntPtr.Zero);

            callbackHandles.Add(busResetHandle);
            callbackHandles.Add(busArrivalHandle);
            callbackHandles.Add(busRemovalHandle);

            // Prevent exit if CTL+C is pressed.
            Console.TreatControlCAsInput = true;

            Console.WriteLine("Press any key to exit...\n");
            ConsoleKeyInfo cki = Console.ReadKey();

            // Unregister bus events
            foreach (IntPtr currHandle in callbackHandles)
            {
                busMgr.UnregisterCallback(currHandle);
            }
        }
Example #5
0
        private void OpenCamera()
        {
            try
            {
                System.Diagnostics.Debug.WriteLine("OpenCamera:" + DateTime.Now.ToString("HH:mm:ss.fff"));
                ManagedBusManager busMgr = new ManagedBusManager();
                uint numCameras          = busMgr.GetNumOfCameras();
                if (numCameras == 0)
                {
                    System.Diagnostics.Debug.WriteLine("没有发现相机!");
                    return;
                }
                m_camera = new ManagedCamera();

                //m_processedImage = new ManagedImage();
                m_grabThreadExited = new AutoResetEvent(false);
                ManagedPGRGuid m_guid = busMgr.GetCameraFromIndex(0);

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

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

                m_camera.StartCapture();
                System.Diagnostics.Debug.WriteLine("OpenCamera:" + DateTime.Now.ToString("HH:mm:ss.fff"));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
Example #6
0
        static void Main(string[] args)
        {
            PrintBuildInfo();

            Program program = new Program();

            // Since this application saves images in the current folder
            // we must ensure that we have permission to write to this folder.
            // If we do not have permission, fail right away.
            FileStream fileStream;

            try
            {
                fileStream = new FileStream(@"test.txt", FileMode.Create);
                fileStream.Close();
                File.Delete("test.txt");
            }
            catch
            {
                Console.WriteLine("Failed to create file in current folder.  Please check permissions.\n");
                return;
            }

            ManagedBusManager busMgr = new ManagedBusManager();

            CameraInfo[] camInfos = ManagedBusManager.DiscoverGigECameras();
            Console.WriteLine("Number of cameras discovered: {0}", camInfos.Length);
            foreach (CameraInfo camInfo in camInfos)
            {
                PrintCameraInfo(camInfo);
            }

            uint numCameras = busMgr.GetNumOfCameras();

            Console.WriteLine("Number of cameras enumerated: {0}", numCameras);

            for (uint i = 0; i < numCameras; i++)
            {
                ManagedPGRGuid guid = busMgr.GetCameraFromIndex(i);
                if (busMgr.GetInterfaceTypeFromGuid(guid) != InterfaceType.GigE)
                {
                    continue;
                }

                try
                {
                    program.RunSingleCamera(guid);
                }
                catch (FC2Exception ex)
                {
                    Console.WriteLine(
                        String.Format(
                            "Error running camera {0}. Error: {1}",
                            i, ex.Message));
                }
            }

            Console.WriteLine("Done! Press any key to exit...");
            Console.ReadKey();
        }
        // calibrator constructor#2
        public Flea3Calibrator(int horiz_corner_count, int vert_corner_count,
                               float rect_width, float rect_height, int frame_count, PictureBox displaybox)
        {
            DisplayBox = displaybox;
            // 1. creating the camera object
            Cam = new ManagedCamera();
            // 2. creating the bus manager in order to handle (potentially)
            // multiple cameras
            BusMgr = new ManagedBusManager();

            // 3. retrieving the List of all camera ids connected to the bus
            CamIDs = new List <ManagedPGRGuid>();
            int camCount = (int)BusMgr.GetNumOfCameras();

            for (int i = 0; i < camCount; i++)
            {
                ManagedPGRGuid guid = BusMgr.GetCameraFromIndex((uint)i);
                CamIDs.Add(guid);
            }


            FrameCount      = frame_count;
            ChessHorizCount = horiz_corner_count;
            ChessVertCount  = vert_corner_count;

            RectWidth  = rect_width;
            RectHeight = rect_height;

            // creatring the imageViewer to display the calibration frame sequence
            //imageViewer = new ImageViewer();


            state = ST_IDLE;
        }
        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();
            }
        }
Example #9
0
        void BusResetLoop()
        {
            ManagedBusManager busMgr = new ManagedBusManager();

            List<IntPtr> callbackHandles = new List<IntPtr>();

            // Register bus events
            IntPtr busResetHandle = busMgr.RegisterCallback(OnBusReset, ManagedCallbackType.BusReset, IntPtr.Zero);
            IntPtr busArrivalHandle = busMgr.RegisterCallback(OnBusArrival, ManagedCallbackType.Arrival, IntPtr.Zero);
            IntPtr busRemovalHandle = busMgr.RegisterCallback(OnBusRemoval, ManagedCallbackType.Removal, IntPtr.Zero);

            callbackHandles.Add(busResetHandle);
            callbackHandles.Add(busArrivalHandle);
            callbackHandles.Add(busRemovalHandle);

            // Prevent exit if CTL+C is pressed.
            Console.TreatControlCAsInput = true;

            Console.WriteLine("Press any key to exit...\n");
            ConsoleKeyInfo cki = Console.ReadKey();

            // Unregister bus events
            foreach (IntPtr currHandle in callbackHandles)
            {
                busMgr.UnregisterCallback(currHandle);
            }
        }
Example #10
0
        static void Main(string[] args)
        {
            PrintBuildInfo();

            Program program = new Program();

            // Since this application saves images in the current folder
            // we must ensure that we have permission to write to this folder.
            // If we do not have permission, fail right away.
            FileStream fileStream;
            try
            {
                fileStream = new FileStream(@"test.txt", FileMode.Create);
                fileStream.Close();
                File.Delete("test.txt");
            }
            catch
            {
                Console.WriteLine("Failed to create file in current folder.  Please check permissions.\n");
                return;
            }

            ManagedBusManager busMgr = new ManagedBusManager();

            CameraInfo[] camInfos = ManagedBusManager.DiscoverGigECameras();
            Console.WriteLine("Number of cameras discovered: {0}", camInfos.Length);
            foreach (CameraInfo camInfo in camInfos)
            {
                PrintCameraInfo(camInfo);
            }

            uint numCameras = busMgr.GetNumOfCameras();
            Console.WriteLine("Number of cameras enumerated: {0}", numCameras);

            for (uint i = 0; i < numCameras; i++)
            {
                ManagedPGRGuid guid = busMgr.GetCameraFromIndex(i);
                if ( busMgr.GetInterfaceTypeFromGuid(guid) != InterfaceType.GigE )
                {
                    continue;
                }

                try
                {
                    program.RunSingleCamera(guid);
                }
                catch (FC2Exception ex)
                {
                    Console.WriteLine(
                        String.Format(
                        "Error running camera {0}. Error: {1}",
                        i, ex.Message));
                }
            }

            Console.WriteLine("Done! Press any key to exit...");
            Console.ReadKey();
        }
Example #11
0
        static void Main(string[] args)
        {
            PrintBuildInfo();
            Program    program = new Program();
            SerialPort pyboard = new SerialPort("COM5", 115200);

            pyboard.Open();
            pyboard.WriteLine("import rig_load\r");
            FileStream fileStream;
            //try
            //{
            //    fileStream = new FileStream(@"test.txt", FileMode.Create);
            //    fileStream.Close();
            //    File.Delete("test.txt");
            //}
            //catch
            //{
            //    Console.WriteLine("Failed to create file in current folder.  Please check permissions.\n");
            //    return;
            //}

// Here want to take the ID number of the experiment instead of the total number of frames. The number of frames will be set by the set experiment parameters established. Have user input from console.writeline "Please Enter Experiment ID". saveto will occur after the input of this line, and will be "D:/"+idstring+"cam0.AVI". etc. int frames, instead of being framestring, will just be a constant. calculate this tomorrow after you've established the exact paradigm.

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

            Console.WriteLine("Number of cameras detected: {0}", numCameras);

            // List<string> save_to = new List<string>{"D:/Movies/cam0.AVI","E:/Movies/cam1.AVI"};
            Console.WriteLine("Please Enter Experiment ID: ");
            string        idstring = Console.ReadLine();
            List <string> save_to  = new List <string> {
                "D:/Movies/" + idstring + "_cam0.AVI", "E:/Movies/" + idstring + "_cam1.AVI"
            };

            Console.WriteLine("Please Enter Number of Frames: ");
            string framestring = Console.ReadLine();
            int    frames      = Convert.ToInt32(framestring);

            if (numCameras == 1)
            {
                ManagedPGRGuid guid = busMgr.GetCameraFromIndex(0);
                program.RunSingleCamera(guid, "C:/Users/Deadpool/Desktop/flea3.AVI", frames);
            }
            else if (numCameras == 2)
            {
                ManagedPGRGuid camid1     = busMgr.GetCameraFromIndex(0);
                ManagedPGRGuid camid2     = busMgr.GetCameraFromIndex(1);
                Thread         camthread1 = new Thread(() => program.RunSingleCamera(camid1, save_to[0], frames));
                camthread1.Start();
// have to declare this way if your return is a void but you pass variables to the function
                Thread camthread2 = new Thread(() => program.RunSingleCamera(camid2, save_to[1], frames));
                camthread2.Start();
                pyboard.WriteLine("rig_load.full_experiment(True,True)\r");
//                pyboard.WriteLine("rig_load.full_experiment(True,True)\r");
//                pyboard.WriteLine("rig_load.light_test()\r");
            }
        }
Example #12
0
        private void StartForceAutoIP(object data)
        {
            lock (this)
            {
                List <CameraInfo> infos      = (List <CameraInfo>)data;
                LoadingWindow     loadingWnd = new LoadingWindow();
                using (loadingWnd)
                {
                    loadingWnd.Show();
                    loadingWnd.SetProgressBar(0, "Start auto forcing IP...");
                    foreach (CameraInfo info in infos)
                    {
                        try
                        {
                            ManagedBusManager.ForceAllIPAddressesAutomatically(info.serialNumber);
                        }
                        catch (FC2Exception ex)
                        {
                            loadingWnd.SetProgressBar(10, "Error auto forcing IP...");
                            MessageBox.Show(
                                ex.Message,
                                "Error auto forcing IP",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                            Enabled = true;
                            ex.Dispose();
                            return;
                        }
                    }

                    loadingWnd.SetProgressBar(30, "Configuration completed... Please wait for 5 second...");

                    // Sleep for 5s before refreshing
                    for (int i = 0; i < 50; i++)
                    {
                        Thread.Sleep(100);
                        loadingWnd.SetProgressBar(30 + i);
                    }

                    loadingWnd.SetProgressBar(90, "Auto forcing IP completed... Refreshing camera list...");
                    loadingWnd.Hide();
                    loadingWnd.Close();

                    // bring to front
                    //this.Activate();

                    if (InvokeRequired == true)
                    {
                        Invoke(new RefreshCameraListCallback(RefreshCameraList));
                    }
                    else
                    {
                        RefreshCameraList();
                    }
                }
            }
        }
Example #13
0
        public void ChooseCamera()
        {
            StopStreaming();
            DeleteCamera();

beginSelecCamera:
            CameraSelectionDialog selectDialog = new CameraSelectionDialog();

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

                if (guids.Length < 1)
                {
                    if (MessageBox.Show("You have not selected a camera. Do you want to restart camera selection diaolog?", "No camera", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                    {
                        goto beginSelecCamera;
                    }
                    else
                    {
                        Application.Current.Shutdown();
                    }
                }
                m_busManager = new ManagedBusManager();

                var interfaceType = m_busManager.GetInterfaceTypeFromGuid(guids[0]);
                if (interfaceType == InterfaceType.GigE)
                {
                    m_camera = new ManagedGigECamera();
                }
                else
                {
                    m_camera = new ManagedCamera();
                }

                m_camera.Connect(guids[0]);

                EmbeddedImageInfo embeddedInfo = m_camera.GetEmbeddedImageInfo();
                embeddedInfo.timestamp.onOff = true;
                embeddedInfo.exposure.onOff  = true;
                embeddedInfo.shutter.onOff   = true;
                embeddedInfo.gain.onOff      = true;
                m_camera.SetEmbeddedImageInfo(embeddedInfo);

                float shutterMin = m_camera.GetPropertyInfo(PropertyType.Shutter).absMin, shutterMax = m_camera.GetPropertyInfo(PropertyType.Shutter).absMax;
                m_commonViewModel.CameraShutterRangeBegin = shutterMin; m_commonViewModel.CameraShutterRangeEnd = shutterMax;
                FC2Config config = m_camera.GetConfiguration();
                config.grabMode = GrabMode.BufferFrames;
                m_camera.SetConfiguration(config);
                m_cameraCtrlDialog.Connect(m_camera);
                m_commonViewModel.IsCameraChosen        = true;
                m_commonViewModel.IsStreamingWasStarted = false;
            }
        }
Example #14
0
        private void PopulateRegisterPage(uint port, Register[] registerInfoArray)
        {
            ManagedBusManager busMgr = new ManagedBusManager();

            m_nodeInformationDataGridView.Rows.Clear();
            uint currAddr = 0;
            uint prevAddr = 0;
            uint regValue = 0;
            bool isFirst  = true;

            foreach (Register iter in registerInfoArray)
            {
                prevAddr = currAddr;
                currAddr = iter.Address;
                if (isFirst || currAddr != prevAddr)
                {
                    try
                    {
                        regValue = busMgr.ReadPhyRegister(m_selectedGuid, 0, port, iter.Address);
                    }
                    catch (FC2Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                        ex.Dispose();
                        return;
                    }

                    isFirst = false;
                }

                // add result to table
                try
                {
                    int rowNum = m_nodeInformationDataGridView.Rows.Add(new DataGridViewRow());
                    m_nodeInformationDataGridView.Rows[rowNum].Cells[0].Value = iter.Name;
                    m_nodeInformationDataGridView.Rows[rowNum].Cells[1].Value = GetField(iter, regValue);
                }
                catch (InvalidOperationException ex)
                {
                    Debug.WriteLine("Error appending new row.");
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                }
                catch (ArgumentOutOfRangeException ex)
                {
                    Debug.WriteLine("The information data table is full.");
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                }
            }
        }
Example #15
0
        private void InitializePage()
        {
            m_busMgr      = new ManagedBusManager();
            m_imageWidth  = m_drawingArea.Width;
            m_imageHeight = m_drawingArea.Height;
            ResetNodeInformation();
            OnRefreshTopology();
            SetColors();

            if (m_camInfo != null)
            {
                m_currCameraGuid = m_busMgr.GetCameraFromSerialNumber(m_camInfo.serialNumber);
            }
        }
Example #16
0
        static void Main(string[] args)
        {
            PrintBuildInfo();

            Program program = new Program();

            // Since this application saves images in the current folder
            // we must ensure that we have permission to write to this folder.
            // If we do not have permission, fail right away.
            FileStream fileStream;

            try
            {
                fileStream = new FileStream(@"test.txt", FileMode.Create);
                fileStream.Close();
                File.Delete("test.txt");
            }
            catch
            {
                Console.WriteLine("Failed to create file in current folder. Please check permissions.");
                Console.WriteLine("Press Enter to exit...");
                Console.ReadLine();
                return;
            }

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

            Console.WriteLine("Number of cameras detected: {0}", numCameras);

            // Finish if there are no cameras
            if (numCameras == 0)
            {
                Console.WriteLine("Not enough cameras!");
                Console.WriteLine("Press Enter to exit...");
                Console.ReadLine();
                return;
            }

            for (uint i = 0; i < numCameras; i++)
            {
                ManagedPGRGuid guid = busMgr.GetCameraFromIndex(i);

                program.RunCamera(guid);
            }

            Console.WriteLine("Done! Press enter to exit...");
            Console.ReadLine();
        }
Example #17
0
        public bool Connect()
        {
            bool flag = false;
            CameraSelectionDialog camSlnDlg = new CameraSelectionDialog();

            camSlnDlg.Show();
            camSlnDlg.Hide();

            //if (camSlnDlg.ShowModal())
            {
                try {
                    ManagedPGRGuid[] selectedGuids = camSlnDlg.GetSelectedCameraGuids();
                    ManagedPGRGuid   guidToUse     = selectedGuids[0];

                    ManagedBusManager busMgr = new ManagedBusManager();
                    m_camera = new ManagedCamera();

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

                    CameraInfo camInfo = m_camera.GetCameraInfo();
                    camInfo.vendorName = "MicroTest";
                    camInfo.modelName  = "v1";
                    // UpdateFormCaption(camInfo);

                    // Set embedded timestamp to on
                    EmbeddedImageInfo embeddedInfo = m_camera.GetEmbeddedImageInfo();
                    embeddedInfo.timestamp.onOff = true;
                    //embeddedInfo.exposure.onOff = true;
                    embeddedInfo.shutter.onOff = true;
                    //tbox_uptime.Text = embeddedInfo.timestamp.ToString();
                    m_camera.SetEmbeddedImageInfo(embeddedInfo);
                    flag = true;
                }
                catch (IndexOutOfRangeException e) {
                    m_camCtlDlg.Disconnect();

                    if (m_camera != null)
                    {
                        m_camera.Disconnect();
                    }
                    flag = false;
                    throw e;
                }
            }

            return(flag);
        }
Example #18
0
        static void Main()
        {
            ManagedBusManager busMgr = new ManagedBusManager();

            // Pop up the camera selection dialog
            FlyCapture2Managed.Gui.CameraSelectionDialog camSlnDlg = new FlyCapture2Managed.Gui.CameraSelectionDialog();
            if (camSlnDlg.ShowModal() == false)
            {
                MessageBox.Show("No cameras selected.", "Flycapture2", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            ManagedPGRGuid[] selectedGuids = camSlnDlg.GetSelectedCameraGuids();

            // Only start the first selected camera
            ManagedPGRGuid    guid = selectedGuids[0];
            InterfaceType     ifType;
            ManagedCameraBase camera;

            try
            {
                ifType = busMgr.GetInterfaceTypeFromGuid(guid);//unable to handle this error
            }
            catch (FC2Exception ex)
            {
                string error = string.Format("Failed to get interface for camera. {0}", ex.Message);
                Console.WriteLine(error);
                MessageBox.Show(error, "Flycapture 2", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (ifType == InterfaceType.GigE)
            {
                camera = new ManagedGigECamera();
            }
            else
            {
                camera = new ManagedCamera();
            }
            camera.Connect(guid);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            CameraControlMainFrame mainWindow = new CameraControlMainFrame();

            mainWindow.Connect(camera);
            mainWindow.ShowWindow();
        }
Example #19
0
        public bool CamConnection(uint[] serialList)
        {
            NumCameras = serialList.Length;
            ManagedBusManager busMgr = new ManagedBusManager();

            mCameras = new ManagedGigECamera[NumCameras];

            for (uint i = 0; i < NumCameras; i++)
            {
                if (serialList[i] == 0)
                {
                    continue;
                }

                mCameras[i] = new ManagedGigECamera();

                try
                {
                    ManagedPGRGuid guid = busMgr.GetCameraFromSerialNumber(serialList[i]);

                    // Connect to a camera
                    mCameras[i].Connect(guid);

                    // Turn trigger mode off
                    TriggerMode trigMode = new TriggerMode();
                    trigMode.onOff = false;
                    mCameras[i].SetTriggerMode(trigMode);

                    // Turn Timestamp on
                    EmbeddedImageInfo imageInfo = new EmbeddedImageInfo();
                    imageInfo.timestamp.onOff = true;
                    mCameras[i].SetEmbeddedImageInfo(imageInfo);

                    //IsConnected[i] = true;

                    GV.IsCameraConnected = true;
                }
                catch (Exception ex)
                {
                    //IsConnected[i] = false;

                    GV.IsCameraConnected = false;
                    return(false);
                }
            }
            return(true);
        }
Example #20
0
        /// <summary>
        ///Initialize a point Grey Camera, it take the first that it detect if their is more than one.
        ///Give the default setting.
        /// </summary>
        /// <exception cref="NoCameraDetectedException">Thrown if no camera is detected.</exception>
        public PtGreyCamera()
        {
            using ManagedBusManager busMgr = new ManagedBusManager();
            setting = new PtGreyCameraSetting();
            uint numCameras = busMgr.GetNumOfCameras();

            if (numCameras == 0)
            {
                throw new NoCameraDetectedException {
                          Source = "PointGrey"
                };
            }

            ManagedPGRGuid guid = busMgr.GetCameraFromIndex(0); //If there is more than 1 camera, we take the first one

            cam = new ManagedCamera();
            cam.Connect(guid);
            SetProp();
        }
Example #21
0
        private void InitializeCameraSelectionData()
        {
            HideGigEInformation();
            m_busMgr          = new ManagedBusManager();
            m_cameraInfoPanel = new CameraInformationDisplayPanel();
            m_cameraInfoDisplayPanel.Controls.Add(m_cameraInfoPanel);
            m_GigEEnumerationIsDisabled = EnumerationController.IsEnumerationDisabled(InterfaceType.GigE);
            m_gigEInfoPanel             = new GigEInformationDisplayPanel();
            m_gigeInfoDisplayPanel.Controls.Add(m_gigEInfoPanel);

            m_activeDialogs = new Dictionary <uint, DialogHolder>();

            m_timer          = new System.Windows.Forms.Timer();
            m_timer.Interval = 2000;
            m_timer.Tick    += new EventHandler(m_timer_Tick);

            try
            {
                m_busResetHandle = m_busMgr.RegisterCallback(OnBusReset, ManagedCallbackType.BusReset, IntPtr.Zero);
            }
            catch (FC2Exception ex)
            {
                BasePage.ShowErrorMessageDialog("Error registering bus reset callback.", ex);
                ex.Dispose();
            }

            m_isLadybugGUI = LadybugChecker.IsLadybugDLLPresent();
            if (m_isLadybugGUI == true)
            {
                this.Text = "Ladybug Camera Selection";
            }
            else
            {
                FC2Version version = ManagedUtilities.libraryVersion;
                this.Text = string.Format(
                    "FlyCapture2 Camera Selection {0}.{1}.{2}.{3}",
                    version.major,
                    version.minor,
                    version.type,
                    version.build);
            }
        }
Example #22
0
        /// <summary>
        ///Initialize a point Grey Camera, it take the first that it detect if their is more than one.
        ///Utilize the given settings to initialize the camera.
        /// </summary>
        /// <exception cref="NoCameraDetectedException">Thrown if no camera is detected.</exception>
        /// <param name="setting">Setting used for the camera</param>
        public PtGreyCamera(PtGreyCameraSetting setting)
        {
            using ManagedBusManager busMgr = new ManagedBusManager();
            this.setting = setting;
            uint numCameras = busMgr.GetNumOfCameras();

            Console.WriteLine(numCameras);
            // Finish if there are no cameras
            if (numCameras == 0)
            {
                throw new NoCameraDetectedException();
            }

            ManagedPGRGuid guid = busMgr.GetCameraFromIndex(0); //If there is more than 1 camera, we take the first one

            cam = new ManagedCamera();

            cam.Connect(guid);

            SetProp();
        }
Example #23
0
        static void Main(string[] args)
        {
            PrintBuildInfo();

            Program program = new Program();

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

            Console.WriteLine("Number of cameras detected: {0}", numCameras);

            for (uint i = 0; i < numCameras; i++)
            {
                ManagedPGRGuid guid = busMgr.GetCameraFromIndex(i);

                program.RunSingleCamera(guid);
            }

            Console.WriteLine("Done! Press any key to exit...");
            Console.ReadKey();
        }
Example #24
0
        static void Main(string[] args)
        {
            PrintBuildInfo();

            Program program = new Program();

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

            Console.WriteLine("Number of cameras detected: {0}", numCameras);

            for (uint i = 0; i < numCameras; i++)
            {
                ManagedPGRGuid guid = busMgr.GetCameraFromIndex(i);

                program.RunSingleCamera(guid);
            }

            Console.WriteLine("Done! Press any key to exit...");
            Console.ReadKey();
        }
Example #25
0
        static void Main(string[] args)
        {
            PrintBuildInfo();

            Program program = new Program();

            // Since this application saves images in the current folder
            // we must ensure that we have permission to write to this folder.
            // If we do not have permission, fail right away.
            FileStream fileStream;
            try
            {
                fileStream = new FileStream(@"test.txt", FileMode.Create);
                fileStream.Close();
                File.Delete("test.txt");
            }
            catch
            {
                Console.WriteLine("Failed to create file in current folder.  Please check permissions.\n");
                return;
            }

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

            Console.WriteLine("Number of cameras detected: {0}", numCameras);

            for (uint i = 0; i < numCameras; i++)
            {
                ManagedPGRGuid guid = busMgr.GetCameraFromIndex(i);

                program.RunSingleCamera(guid);
            }

            Console.WriteLine("Done! Press any key to exit...");
            Console.ReadKey();
        }
Example #26
0
        /// <summary>
        /// 连接相机
        /// </summary>
        /// <param name="SerialNumber"></param>
        /// <returns></returns>
        bool ConnectCamera(string SerialNumber)
        {
            try
            {
#if (SDK)
                ManagedBusManager busMgr = new ManagedBusManager();
                //相机索引号
                uint           intSerialNumber = uint.Parse(SerialNumber);
                ManagedPGRGuid guid            = busMgr.GetCameraFromSerialNumber(intSerialNumber);
                InterfaceType  Type            = busMgr.GetInterfaceTypeFromGuid(guid);

                if (Type == InterfaceType.GigE)
                {
                    g_ManagedCameraBase = new ManagedGigECamera();
                    g_ManagedCameraBase.Connect(guid);

                    SetGigEPacketResend();//设置丢帧重传
                }
                else
                {
                    g_ManagedCameraBase = new ManagedCamera();
                    g_ManagedCameraBase.Connect(guid);
                }

                if (g_BaseParCamera.BlUsingTrigger)
                {
                    SetSoftTrriger(true);//设置触发
                }
#endif
                return(true);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
                return(false);
            }
        }
        // A timer used to sample the IMU during the intervals betweem frame captures
        //private System.Timers.Timer IMUSamplingTimer;


        public Flea3Recorder(GPSReceiver gpsReceiver, IMUCommsDevice imu)
        {
            int i;

            IMUcomms = imu;



            // 1. creating the camera object
            Cam = new ManagedCamera();
            // 2. creating the bus manager in order to handle (potentially)
            // multiple cameras
            BusMgr = new ManagedBusManager();

            // 3. retrieving the List of all camera ids connected to the bus
            CamIDs = new List <ManagedPGRGuid>();
            int camCount = (int)BusMgr.GetNumOfCameras();

            for (i = 0; i < camCount; i++)
            {
                ManagedPGRGuid guid = BusMgr.GetCameraFromIndex((uint)i);
                CamIDs.Add(guid);
            }

            // 4. assigning values to properties
            GpsReceiver = gpsReceiver;

            // 5. init flags
            RecordingThreadActive = false;

            RecordToFile = false;

            OutOfRecordingThread = OutOfDumpingThread = true;

            // 6. Creating the Frame data queue
            FrameQueue = new ManagedImageRollingBuffer(MAX_FRAMEQUEUE_LEN);
        }
Example #28
0
        static void Main(string[] args)
        {
            PrintBuildInfo();

            Program program = new Program();

            // Create bus manager and find number of attached cameras
            ManagedBusManager busMgr = new ManagedBusManager();
            uint numCameras          = busMgr.GetNumOfCameras();

            Console.WriteLine("Number of cameras detected: {0}", numCameras);

            if (numCameras < 1)
            {
                Console.WriteLine("Insufficient number of cameras... press any key to exit.");
                Console.ReadKey();
                return;
            }

            program.RunAllCameras(busMgr, numCameras);

            Console.WriteLine("Done! Press enter to exit...");
            Console.ReadLine();
        }
Example #29
0
        private void PopulateCameraList()
        {
            uint numCameras = 0;

            CameraInfo[] discoveredCameras = new CameraInfo[0];

            try
            {
                numCameras        = m_busMgr.GetNumOfCameras();
                discoveredCameras = ManagedBusManager.DiscoverGigECameras();
            }
            catch (FC2Exception ex)
            {
                BasePage.ShowErrorMessageDialog("Error getting number of cameras.", ex);
            }

            if (numCameras == 0 && discoveredCameras.Length == 0)
            {
                m_cameraListLabel.Text = string.Format("Camera List (No cameras detected)");
                m_cameraDataGridView.Rows.Clear();
                m_cameraInfoPanel.ClearInformation();
                HideGigEInformation();
                AdjustWindowMinimumSize();
                this.Height = this.MinimumSize.Height;
                m_needShrinkWindowHeight = false;
                return;
            }

            SortedDictionary <uint, CameraInfo> discoveredCameraInfo = new SortedDictionary <uint, CameraInfo>();

            m_badCameraInfo  = new Dictionary <string, CameraInfo>();
            m_goodCameraInfo = new Dictionary <ManagedPGRGuid, CameraInfo>();

            for (uint currCamIdx = 0; currCamIdx < discoveredCameras.Length; currCamIdx++)
            {
                try
                {
                    Debug.WriteLine(
                        String.Format(
                            "Discovered camera: {0} ({1})",
                            discoveredCameras[currCamIdx].modelName,
                            discoveredCameras[currCamIdx].serialNumber));

                    // Check if the camera already exists - we sometimes get duplicate cameras
                    // returned from the discover call
                    if (!discoveredCameraInfo.ContainsKey(discoveredCameras[currCamIdx].serialNumber))
                    {
                        discoveredCameraInfo.Add(
                            discoveredCameras[currCamIdx].serialNumber,
                            discoveredCameras[currCamIdx]);
                    }
                }
                catch (ArgumentNullException ex)
                {
                    Debug.WriteLine("A null key was specified for discovered camera lookup.");
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                    continue;
                }
                catch (ArgumentException ex)
                {
                    Debug.WriteLine("An element with the same key already exists in the discovered camera dictionary.");
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                    continue;
                }
                catch (System.Exception ex)
                {
                    Debug.WriteLine("An error occurred while updating the discovered GigE camera list.");
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                    continue;
                }
            }

            List <DataGridViewRow> goodCameraList = new List <DataGridViewRow>();
            List <DataGridViewRow> badCameraList  = new List <DataGridViewRow>();

            for (uint i = 0; i < numCameras; i++)
            {
                try
                {
                    ManagedPGRGuid guid;
                    guid = m_busMgr.GetCameraFromIndex(i);

                    InterfaceType currInterface;
                    currInterface = m_busMgr.GetInterfaceTypeFromGuid(guid);

                    using (ManagedCamera camera = new ManagedCamera())
                    {
                        bool   compatibleDriver = true;
                        string errorMessage     = string.Empty;

                        try
                        {
                            camera.Connect(guid);
                        }
                        catch (FC2Exception ex)
                        {
                            if (ex.Type == ErrorType.IncompatibleDriver)
                            {
                                compatibleDriver = false;
                                errorMessage     = ex.Message;
                            }
                        }

                        CameraInfo camInfo;

                        if (compatibleDriver)
                        {
                            camInfo = camera.GetCameraInfo();

                            if (discoveredCameraInfo.ContainsKey(camInfo.serialNumber) == true)
                            {
                                // Remove good camera from dictionary
                                discoveredCameraInfo.Remove(camInfo.serialNumber);
                                m_goodCameraInfo.Add(guid, camInfo);
                            }

                            // Append the camera to the list
                            try
                            {
                                DataGridViewRow           newCamera = new DataGridViewRow();
                                DataGridViewTextBoxCell[] cells     = new DataGridViewTextBoxCell[4];
                                for (int ci = 0; ci < cells.Length; ci++)
                                {
                                    cells[ci] = new DataGridViewTextBoxCell();
                                }

                                cells[0].Value = camInfo.serialNumber.ToString();
                                cells[1].Value = camInfo.modelName;
                                cells[2].Value = InterfaceTranslator.GetInterfaceString(currInterface);
                                cells[3].Value = camInfo.ipAddress.Equals(new IPAddress(0))
                                    ? "N/A"
                                    : camInfo.ipAddress.ToString();

                                newCamera.Cells.AddRange(cells);
                                goodCameraList.Add(newCamera);
                            }
                            catch (InvalidOperationException ex)
                            {
                                Debug.WriteLine("Error appending new row to camera list.");
                                Debug.WriteLine(ex.Message);
                                Debug.WriteLine(ex.StackTrace);
                                continue;
                            }
                            catch (ArgumentNullException ex)
                            {
                                Debug.WriteLine("The cell in camera list contains null value.");
                                Debug.WriteLine(ex.Message);
                                Debug.WriteLine(ex.StackTrace);
                                continue;
                            }
                        }
                        else
                        {
                            camInfo = new CameraInfo();

                            DataGridViewRow newCamera = new DataGridViewRow();

                            newCamera.DefaultCellStyle.BackColor = IMCOMPATIBLE_DRIVER;
                            DataGridViewTextBoxCell[] cells = new DataGridViewTextBoxCell[4];
                            for (int ci = 0; ci < cells.Length; ci++)
                            {
                                cells[ci] = new DataGridViewTextBoxCell();
                            }

                            cells[0].Value = "N/A";
                            cells[1].Value = ManagedUtilities.GetDriverDeviceName(guid);
                            cells[2].Value = "Incompatible Driver";
                            cells[3].Value = "N/A";

                            cells[0].ToolTipText = "An incompatible driver is installed on this device.";

                            foreach (DataGridViewTextBoxCell cell in cells)
                            {
                                cell.ToolTipText = errorMessage;
                            }

                            newCamera.Cells.AddRange(cells);
                            badCameraList.Add(newCamera);
                        }
                    }
                }
                catch (FC2Exception ex)
                {
                    BasePage.ShowErrorMessageDialog("Error populating camera list.", ex);
                    continue;
                }
            }


            foreach (KeyValuePair <uint, CameraInfo> pair in discoveredCameraInfo)
            {
                try
                {
                    CameraInfo info = pair.Value;

                    m_badCameraInfo.Add(info.serialNumber.ToString(), info);

                    DataGridViewRow newCamera = new DataGridViewRow();

                    newCamera.DefaultCellStyle.BackColor = IP_PROBLEM;
                    DataGridViewTextBoxCell[] cells = new DataGridViewTextBoxCell[4];
                    for (int ci = 0; ci < cells.Length; ci++)
                    {
                        cells[ci] = new DataGridViewTextBoxCell();
                    }

                    cells[0].Value = info.serialNumber.ToString();
                    cells[1].Value = info.modelName;
                    cells[2].Value = "GigE";
                    cells[3].Value = info.ipAddress.Equals(new IPAddress(0)) ? "N/A" : info.ipAddress.ToString();

                    cells[0].ToolTipText = "This camera is discoverable but can not be controlled";

                    foreach (DataGridViewTextBoxCell cell in cells)
                    {
                        if (m_GigEEnumerationIsDisabled)
                        {
                            cell.ToolTipText = "This camera cannot be enumerated by FlyCapture2 because GigE camera enumeration \n" +
                                               "has been disabled)";
                        }
                        else
                        {
                            cell.ToolTipText = "Camera IP settings or local interface is mis-configured. Use \"Force IP\" to \n" +
                                               "correct it";
                        }
                    }

                    newCamera.Cells.AddRange(cells);
                    badCameraList.Add(newCamera);
                }
                catch (InvalidOperationException ex)
                {
                    Debug.WriteLine("Error appending new row to camera list.");
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                    continue;
                }
                catch (ArgumentNullException ex)
                {
                    Debug.WriteLine("The cell in camera list contains null value.");
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                    continue;
                }
            }

            m_cameraDataGridView.Rows.Clear();
            m_cameraListLabel.Text = string.Format("Camera List ({0} cameras detected)", (goodCameraList.Count + badCameraList.Count));
            for (int i = 0; i < goodCameraList.Count; i++)
            {
                try
                {
                    m_cameraDataGridView.Rows.Add(goodCameraList[i]);
                }
                catch (InvalidOperationException ex)
                {
                    Debug.WriteLine("Error adding camera list to the view.");
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                }
                catch (ArgumentNullException ex)
                {
                    Debug.WriteLine("The camera list contains null value.");
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                }
                catch (ArgumentException ex)
                {
                    Debug.WriteLine("The camera list contains invalid value.");
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                }
            }

            for (int i = 0; i < badCameraList.Count; i++)
            {
                try
                {
                    m_cameraDataGridView.Rows.Add(badCameraList[i]);
                }
                catch (InvalidOperationException ex)
                {
                    Debug.WriteLine("Error adding camera list to the view.");
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                }
                catch (ArgumentNullException ex)
                {
                    Debug.WriteLine("The camera list contains null value.");
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                }
                catch (ArgumentException ex)
                {
                    Debug.WriteLine("The camera list contains invalid value.");
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                }
            }

            if (m_cameraDataGridView.Rows.Count > 0)
            {
                // display first camera information
                DisplayCameraInformationFromRowIndex(0);
            }
            else
            {
                // Nothing need to display
                m_cameraInfoPanel.ClearInformation();
            }
        }
Example #30
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(); }*/
        }
Example #31
0
        static void Main(string[] args)
        {
            PrintBuildInfo();

            const Mode        k_fmt7Mode        = Mode.Mode0;
            const PixelFormat k_fmt7PixelFormat = PixelFormat.PixelFormatMono8;
            const int         k_numImages       = 10;

            // Since this application saves images in the current folder
            // we must ensure that we have permission to write to this folder.
            // If we do not have permission, fail right away.
            FileStream fileStream;

            try
            {
                fileStream = new FileStream(@"test.txt", FileMode.Create);
                fileStream.Close();
                File.Delete("test.txt");
            }
            catch
            {
                Console.WriteLine("Failed to create file in current folder.  Please check permissions.\n");
                return;
            }

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

            Console.WriteLine("Number of cameras detected: {0}", numCameras);

            ManagedPGRGuid guid = busMgr.GetCameraFromIndex(0);

            ManagedCamera cam = new ManagedCamera();

            cam.Connect(guid);

            // Get the camera information
            CameraInfo camInfo = cam.GetCameraInfo();

            PrintCameraInfo(camInfo);

            // Query for available Format 7 modes
            bool        supported = false;
            Format7Info fmt7Info  = cam.GetFormat7Info(k_fmt7Mode, ref supported);

            PrintFormat7Capabilities(fmt7Info);

            if ((k_fmt7PixelFormat & (PixelFormat)fmt7Info.pixelFormatBitField) == 0)
            {
                // Pixel format not supported!
                return;
            }

            Format7ImageSettings fmt7ImageSettings = new Format7ImageSettings();

            fmt7ImageSettings.mode        = k_fmt7Mode;
            fmt7ImageSettings.offsetX     = 0;
            fmt7ImageSettings.offsetY     = 0;
            fmt7ImageSettings.width       = fmt7Info.maxWidth;
            fmt7ImageSettings.height      = fmt7Info.maxHeight;
            fmt7ImageSettings.pixelFormat = k_fmt7PixelFormat;

            // Validate the settings to make sure that they are valid
            bool settingsValid = false;
            Format7PacketInfo fmt7PacketInfo = cam.ValidateFormat7Settings(
                fmt7ImageSettings,
                ref settingsValid);

            if (settingsValid != true)
            {
                // Settings are not valid
                return;
            }

            // Set the settings to the camera
            cam.SetFormat7Configuration(
                fmt7ImageSettings,
                fmt7PacketInfo.recommendedBytesPerPacket);

            // Get embedded image info from camera
            EmbeddedImageInfo embeddedInfo = cam.GetEmbeddedImageInfo();

            // Enable timestamp collection
            if (embeddedInfo.timestamp.available == true)
            {
                embeddedInfo.timestamp.onOff = true;
            }

            // Set embedded image info to camera
            cam.SetEmbeddedImageInfo(embeddedInfo);

            // Start capturing images
            cam.StartCapture();

            // Retrieve frame rate property
            CameraProperty frmRate = cam.GetProperty(PropertyType.FrameRate);

            Console.WriteLine("Frame rate is {0:F2} fps", frmRate.absValue);

            Console.WriteLine("Grabbing {0} images", k_numImages);

            ManagedImage rawImage = new ManagedImage();

            for (int imageCnt = 0; imageCnt < k_numImages; imageCnt++)
            {
                // Retrieve an image
                cam.RetrieveBuffer(rawImage);

                // Get the timestamp
                TimeStamp timeStamp = rawImage.timeStamp;

                Console.WriteLine(
                    "Grabbed image {0} - {1} {2} {3}",
                    imageCnt,
                    timeStamp.cycleSeconds,
                    timeStamp.cycleCount,
                    timeStamp.cycleOffset);

                // Create a converted image
                ManagedImage convertedImage = new ManagedImage();

                // Convert the raw image
                rawImage.Convert(PixelFormat.PixelFormatBgr, convertedImage);

                // Create a unique filename
                string filename = String.Format(
                    "CustomImageEx_CSharp-{0}-{1}.bmp",
                    camInfo.serialNumber,
                    imageCnt);

                // Get the Bitmap object. Bitmaps are only valid if the
                // pixel format of the ManagedImage is RGB or RGBU.
                System.Drawing.Bitmap bitmap = convertedImage.bitmap;

                // Save the image
                bitmap.Save(filename);
            }

            // Stop capturing images
            cam.StopCapture();

            // Disconnect the camera
            cam.Disconnect();

            Console.WriteLine("Done! Press any key to exit...");
            Console.ReadKey();
        }
Example #32
0
        static void Main(string[] args)
        {
            PrintBuildInfo();

            const Mode k_fmt7Mode = Mode.Mode0;
            const PixelFormat k_fmt7PixelFormat = PixelFormat.PixelFormatMono8;
            const int k_numImages = 10;

            // Since this application saves images in the current folder
            // we must ensure that we have permission to write to this folder.
            // If we do not have permission, fail right away.
            FileStream fileStream;
            try
            {
                fileStream = new FileStream(@"test.txt", FileMode.Create);
                fileStream.Close();
                File.Delete("test.txt");
            }
            catch
            {
                Console.WriteLine("Failed to create file in current folder.  Please check permissions.\n");
                return;
            }

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

            Console.WriteLine("Number of cameras detected: {0}", numCameras);

            ManagedPGRGuid guid = busMgr.GetCameraFromIndex(0);

            ManagedCamera cam = new ManagedCamera();

            cam.Connect(guid);

            // Get the camera information
            CameraInfo camInfo = cam.GetCameraInfo();

            PrintCameraInfo(camInfo);

            // Query for available Format 7 modes
            bool supported = false;
            Format7Info fmt7Info = cam.GetFormat7Info(k_fmt7Mode, ref supported);

            PrintFormat7Capabilities(fmt7Info);

            if ((k_fmt7PixelFormat & (PixelFormat)fmt7Info.pixelFormatBitField) == 0)
            {
                // Pixel format not supported!
                return;
            }

            Format7ImageSettings fmt7ImageSettings = new Format7ImageSettings();
            fmt7ImageSettings.mode = k_fmt7Mode;
            fmt7ImageSettings.offsetX = 0;
            fmt7ImageSettings.offsetY = 0;
            fmt7ImageSettings.width = fmt7Info.maxWidth;
            fmt7ImageSettings.height = fmt7Info.maxHeight;
            fmt7ImageSettings.pixelFormat = k_fmt7PixelFormat;

            // Validate the settings to make sure that they are valid
            bool settingsValid = false;
            Format7PacketInfo fmt7PacketInfo = cam.ValidateFormat7Settings(
                fmt7ImageSettings,
                ref settingsValid);

            if (settingsValid != true)
            {
                // Settings are not valid
                return;
            }

            // Set the settings to the camera
            cam.SetFormat7Configuration(
               fmt7ImageSettings,
               fmt7PacketInfo.recommendedBytesPerPacket);

            // Get embedded image info from camera
            EmbeddedImageInfo embeddedInfo = cam.GetEmbeddedImageInfo();

            // Enable timestamp collection
            if (embeddedInfo.timestamp.available == true)
            {
                embeddedInfo.timestamp.onOff = true;
            }

            // Set embedded image info to camera
            cam.SetEmbeddedImageInfo(embeddedInfo);

            // Start capturing images
            cam.StartCapture();

            // Retrieve frame rate property
            CameraProperty frmRate = cam.GetProperty(PropertyType.FrameRate);

            Console.WriteLine("Frame rate is {0:F2} fps", frmRate.absValue);

            Console.WriteLine("Grabbing {0} images", k_numImages);

            ManagedImage rawImage = new ManagedImage();
            for (int imageCnt = 0; imageCnt < k_numImages; imageCnt++)
            {
                // Retrieve an image
                cam.RetrieveBuffer(rawImage);

                // Get the timestamp
                TimeStamp timeStamp = rawImage.timeStamp;

                Console.WriteLine(
                   "Grabbed image {0} - {1} {2} {3}",
                   imageCnt,
                   timeStamp.cycleSeconds,
                   timeStamp.cycleCount,
                   timeStamp.cycleOffset);

                // Create a converted image
                ManagedImage convertedImage = new ManagedImage();

                // Convert the raw image
                rawImage.Convert(PixelFormat.PixelFormatBgr, convertedImage);

                // Create a unique filename
                string filename = String.Format(
                   "CustomImageEx_CSharp-{0}-{1}.bmp",
                   camInfo.serialNumber,
                   imageCnt);

                // Get the Bitmap object. Bitmaps are only valid if the
                // pixel format of the ManagedImage is RGB or RGBU.
                System.Drawing.Bitmap bitmap = convertedImage.bitmap;

                // Save the image
                bitmap.Save(filename);
            }

            // Stop capturing images
            cam.StopCapture();

            // Disconnect the camera
            cam.Disconnect();

            Console.WriteLine("Done! Press any key to exit...");
            Console.ReadKey();
        }
        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();
        }
Example #34
0
        public FlyCapture()
        {
            NumBuffers      = 10;
            GrabMode        = GrabMode.BufferFrames;
            ColorProcessing = ColorProcessingAlgorithm.Default;
            source          = Observable.Create <FlyCaptureDataFrame>((observer, cancellationToken) =>
            {
                return(Task.Factory.StartNew(() =>
                {
                    lock (captureLock)
                    {
                        ManagedCamera camera;
                        using (var manager = new ManagedBusManager())
                        {
                            var guid = manager.GetCameraFromIndex((uint)Index);
                            camera = new ManagedCamera();
                            camera.Connect(guid);
                        }

                        var capture = 0;
                        var numBuffers = NumBuffers;
                        var config = camera.GetConfiguration();
                        config.grabMode = GrabMode;
                        config.numBuffers = (uint)NumBuffers;
                        config.highPerformanceRetrieveBuffer = true;
                        camera.SetConfiguration(config);

                        try
                        {
                            var colorProcessing = ColorProcessing;
                            using (var image = new ManagedImage())
                                using (var notification = cancellationToken.Register(() =>
                                {
                                    Interlocked.Exchange(ref capture, 0);
                                    camera.StopCapture();
                                }))
                                {
                                    camera.StartCapture();
                                    Interlocked.Exchange(ref capture, 1);
                                    while (!cancellationToken.IsCancellationRequested)
                                    {
                                        IplImage output;
                                        BayerTileFormat bayerTileFormat;
                                        try { camera.RetrieveBuffer(image); }
                                        catch (FC2Exception)
                                        {
                                            if (capture == 0)
                                            {
                                                break;
                                            }
                                            else
                                            {
                                                throw;
                                            }
                                        }

                                        var raw16 = image.pixelFormat == PixelFormat.PixelFormatRaw16;
                                        if (image.pixelFormat == PixelFormat.PixelFormatMono8 ||
                                            image.pixelFormat == PixelFormat.PixelFormatMono16 ||
                                            ((image.pixelFormat == PixelFormat.PixelFormatRaw8 || raw16) &&
                                             (image.bayerTileFormat == BayerTileFormat.None ||
                                              colorProcessing == ColorProcessingAlgorithm.NoColorProcessing)))
                                        {
                                            unsafe
                                            {
                                                bayerTileFormat = image.bayerTileFormat;
                                                var depth = image.pixelFormat == PixelFormat.PixelFormatMono16 || raw16 ? IplDepth.U16 : IplDepth.U8;
                                                var bitmapHeader = new IplImage(new Size((int)image.cols, (int)image.rows), depth, 1, new IntPtr(image.data));
                                                output = new IplImage(bitmapHeader.Size, bitmapHeader.Depth, bitmapHeader.Channels);
                                                CV.Copy(bitmapHeader, output);
                                            }
                                        }
                                        else
                                        {
                                            unsafe
                                            {
                                                bayerTileFormat = BayerTileFormat.None;
                                                var depth = raw16 ? IplDepth.U16 : IplDepth.U8;
                                                var format = raw16 ? PixelFormat.PixelFormatBgr16 : PixelFormat.PixelFormatBgr;
                                                output = new IplImage(new Size((int)image.cols, (int)image.rows), depth, 3);
                                                using (var convertedImage = new ManagedImage(
                                                           (uint)output.Height,
                                                           (uint)output.Width,
                                                           (uint)output.WidthStep,
                                                           (byte *)output.ImageData.ToPointer(),
                                                           (uint)(output.WidthStep * output.Height),
                                                           format))
                                                {
                                                    convertedImage.colorProcessingAlgorithm = colorProcessing;
                                                    image.Convert(format, convertedImage);
                                                }
                                            }
                                        }

                                        observer.OnNext(new FlyCaptureDataFrame(output, image.imageMetadata, bayerTileFormat));
                                    }
                                }
                        }
                        finally
                        {
                            if (capture != 0)
                            {
                                camera.StopCapture();
                            }
                            camera.Disconnect();
                            camera.Dispose();
                        }
                    }
                },
                                             cancellationToken,
                                             TaskCreationOptions.LongRunning,
                                             TaskScheduler.Default));
            })
                              .PublishReconnectable()
                              .RefCount();
        }
        // calibrator deafult constructor
        public Flea3Calibrator(PictureBox displaybox)
        {
            DisplayBox = displaybox;
             // 1. creating the camera object
            Cam = new ManagedCamera();
            // 2. creating the bus manager in order to handle (potentially)
            // multiple cameras
            BusMgr = new ManagedBusManager();

            // 3. retrieving the List of all camera ids connected to the bus
            CamIDs = new List<ManagedPGRGuid>();
            int camCount = (int)BusMgr.GetNumOfCameras();
            for (int i = 0; i < camCount; i++)
            {
                ManagedPGRGuid guid = BusMgr.GetCameraFromIndex((uint)i);
                CamIDs.Add(guid);
            }

            FrameCount = FRAME_COUNT;
            ChessHorizCount = CHESS_HORIZ_CORNER_COUNT;
            ChessVertCount = CHESS_VERT_CORNER_COUNT;

            RectWidth = RECT_WIDTH;
            RectHeight = RECT_HEIGHT;

            // creatring the imageViewer to display the calibration frame sequence
            //imageViewer = new ImageViewer();

            state = ST_IDLE;
        }
Example #36
0
        static void Main(string[] args)
        {
            PrintBuildInfo();

            const int k_numImages = 10;
            bool useSoftwareTrigger = true;

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

            Console.WriteLine("Number of cameras detected: {0}", numCameras);

            ManagedPGRGuid guid = busMgr.GetCameraFromIndex(0);

            ManagedCamera cam = new ManagedCamera();

            cam.Connect(guid);

            // Get the camera information
            CameraInfo camInfo = cam.GetCameraInfo();

            PrintCameraInfo(camInfo);

            if (!useSoftwareTrigger)
            {
                // Check for external trigger support
                TriggerModeInfo triggerModeInfo = cam.GetTriggerModeInfo();
                if (triggerModeInfo.present != true)
                {
                    Console.WriteLine("Camera does not support external trigger! Exiting...\n");
                    return;
                }
            }

            // Get current trigger settings
            TriggerMode triggerMode = cam.GetTriggerMode();

            // Set camera to trigger mode 0
            // A source of 7 means software trigger
            triggerMode.onOff = true;
            triggerMode.mode = 0;
            triggerMode.parameter = 0;

            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
            cam.SetTriggerMode(triggerMode);

            // Poll to ensure camera is ready
            bool retVal = PollForTriggerReady(cam);
            if (retVal != true)
            {
                return;
            }

            // Get the camera configuration
            FC2Config config = cam.GetConfiguration();

            // Set the grab timeout to 5 seconds
            config.grabTimeout = 5000;

            // Set the camera configuration
            cam.SetConfiguration(config);

            // Camera is ready, start capturing images
            cam.StartCapture();

            if (useSoftwareTrigger)
            {
                if (CheckSoftwareTriggerPresence(cam) == false)
                {
                    Console.WriteLine("SOFT_ASYNC_TRIGGER not implemented on this camera!  Stopping application\n");
                    return;
                }
            }
            else
            {
                Console.WriteLine("Trigger the camera by sending a trigger pulse to GPIO%d.\n",
                  triggerMode.source);
            }

            ManagedImage image = new ManagedImage();
            for (int iImageCount = 0; iImageCount < k_numImages; iImageCount++)
            {
                if (useSoftwareTrigger)
                {

                    // Check that the trigger is ready
                    retVal = PollForTriggerReady(cam);

                    Console.WriteLine("Press the Enter key to initiate a software trigger.\n");
                    Console.ReadLine();

                    // Fire software trigger
                    retVal = FireSoftwareTrigger(cam);
                    if (retVal != true)
                    {
                        Console.WriteLine("Error firing software trigger!");
                        return;
                    }
                }

                // Grab image
                cam.RetrieveBuffer(image);

                Console.WriteLine(".\n");
            }

            Console.WriteLine("Finished grabbing images");

            // Stop capturing images
            cam.StopCapture();

            // Turn off trigger mode
            triggerMode.onOff = false;
            cam.SetTriggerMode(triggerMode);

            // Disconnect the camera
            cam.Disconnect();

            Console.WriteLine("Done! Press any key to exit...");
            Console.ReadKey();
        }
Example #37
0
        static void Main(string[] args)
        {
            PrintBuildInfo();

            const int NumImages = 50;

            Program program = new Program();

            //
            // Initialize BusManager and retrieve number of cameras detected
            //
            ManagedBusManager busMgr = new ManagedBusManager();
            uint numCameras          = busMgr.GetNumOfCameras();

            Console.WriteLine("Number of cameras detected: {0}", numCameras);

            //
            // Check to make sure at least two cameras are connected before
            // running example
            //
            if (numCameras < 2)
            {
                Console.WriteLine("Insufficient number of cameras.");
                Console.WriteLine("Make sure at least two cameras are connected for example to run.");
                Console.WriteLine("Press Enter to exit.");
                Console.ReadLine();
                return;
            }

            //
            // Initialize an array of cameras
            //
            // *** NOTES ***
            // The size of the array is equal to the number of cameras detected.
            // The array of cameras will be used for connecting, configuring,
            // and capturing images.
            //
            ManagedCamera[] cameras = new ManagedCamera[numCameras];

            //
            // Prepare each camera to acquire images
            //
            // *** NOTES ***
            // For pseudo-simultaneous streaming, each camera is prepared as if it
            // were just one, but in a loop. Notice that cameras are selected with
            // an index. We demonstrate pseduo-simultaneous streaming because true
            // simultaneous streaming would require multiple process or threads,
            // which is too complex for an example.
            //
            for (uint i = 0; i < numCameras; i++)
            {
                cameras[i] = new ManagedCamera();

                ManagedPGRGuid guid = busMgr.GetCameraFromIndex(i);

                // Connect to a camera
                cameras[i].Connect(guid);

                // Get the camera information
                CameraInfo camInfo = cameras[i].GetCameraInfo();
                PrintCameraInfo(camInfo);

                try
                {
                    // Turn trigger mode off
                    TriggerMode trigMode = new TriggerMode();
                    trigMode.onOff = false;
                    cameras[i].SetTriggerMode(trigMode);

                    // Turn Timestamp on
                    EmbeddedImageInfo imageInfo = new EmbeddedImageInfo();
                    imageInfo.timestamp.onOff = true;
                    cameras[i].SetEmbeddedImageInfo(imageInfo);
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine("Error configuring camera : {0}", ex.Message);
                    Console.WriteLine("Press any key to exit...");
                    Console.ReadLine();
                    return;
                }

                try
                {
                    // Start streaming on camera
                    cameras[i].StartCapture();
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine("Error starting camera : {0}", ex.Message);
                    Console.WriteLine("Press any key to exit...");
                    Console.ReadLine();
                    return;
                }
            }

            //
            // Retrieve images from all cameras
            //
            // *** NOTES ***
            // In order to work with simultaneous camera streams, nested loops are
            // needed. It is important that the inner loop be the one iterating
            // through the cameras; otherwise, all images will be grabbed from a
            // single camera before grabbing any images from another.
            //
            ManagedImage tempImage = new ManagedImage();

            for (int imageCnt = 0; imageCnt < NumImages; imageCnt++)
            {
                for (int camCount = 0; camCount < numCameras; camCount++)
                {
                    try
                    {
                        // Retrieve an image
                        cameras[camCount].RetrieveBuffer(tempImage);
                    }
                    catch (System.Exception ex)
                    {
                        Console.WriteLine("Error retrieving buffer : {0}", ex.Message);
                        Console.WriteLine("Press any key to exit...");
                        Console.ReadLine();
                        return;
                    }

                    // Display the timestamps of the images grabbed for each camera
                    TimeStamp timeStamp = tempImage.timeStamp;
                    Console.Out.WriteLine("Camera {0} - Frame {1} - TimeStamp {2} {3}", camCount, imageCnt, timeStamp.cycleSeconds, timeStamp.cycleCount);
                }
            }

            //
            // Stop streaming for each camera
            //
            for (uint i = 0; i < numCameras; i++)
            {
                try
                {
                    cameras[i].StopCapture();
                    cameras[i].Disconnect();
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine("Error cleaning up camera : {0}", ex.Message);
                    Console.WriteLine("Press any key to exit...");
                    Console.ReadLine();
                    return;
                }
            }

            Console.WriteLine("Press enter to exit...");
            Console.ReadLine();
        }
        // calibrator constructor#2
        public Flea3Calibrator(int horiz_corner_count, int vert_corner_count, 
                                        float rect_width, float rect_height, int frame_count, PictureBox displaybox)
        {
            DisplayBox = displaybox;
            // 1. creating the camera object
            Cam = new ManagedCamera();
            // 2. creating the bus manager in order to handle (potentially)
            // multiple cameras
            BusMgr = new ManagedBusManager();

            // 3. retrieving the List of all camera ids connected to the bus
            CamIDs = new List<ManagedPGRGuid>();
            int camCount = (int)BusMgr.GetNumOfCameras();
            for (int i = 0; i < camCount; i++)
            {
                ManagedPGRGuid guid = BusMgr.GetCameraFromIndex((uint)i);
                CamIDs.Add(guid);
            }

            FrameCount = frame_count;
            ChessHorizCount = horiz_corner_count;
            ChessVertCount = vert_corner_count;

            RectWidth = rect_width;
            RectHeight = rect_height;

            // creatring the imageViewer to display the calibration frame sequence
            //imageViewer = new ImageViewer();

            state = ST_IDLE;
        }
        // A timer used to sample the IMU during the intervals betweem frame captures
        //private System.Timers.Timer IMUSamplingTimer;
        public Flea3Recorder(GPSReceiver gpsReceiver, IMUCommsDevice imu)
        {
            int i;

            IMUcomms = imu;

            // 1. creating the camera object
            Cam = new ManagedCamera();
            // 2. creating the bus manager in order to handle (potentially)
            // multiple cameras
            BusMgr = new ManagedBusManager();

            // 3. retrieving the List of all camera ids connected to the bus
            CamIDs = new List<ManagedPGRGuid>();
            int camCount = (int)BusMgr.GetNumOfCameras();
            for (i = 0; i < camCount; i++)
            {
                ManagedPGRGuid guid = BusMgr.GetCameraFromIndex((uint)i);
                CamIDs.Add(guid);
            }

            // 4. assigning values to properties
            GpsReceiver = gpsReceiver;

            // 5. init flags
            RecordingThreadActive = false;

            RecordToFile = false;

            OutOfRecordingThread = OutOfDumpingThread = true;

            // 6. Creating the Frame data queue
            FrameQueue = new ManagedImageRollingBuffer(MAX_FRAMEQUEUE_LEN);
        }