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(); }
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(); } }
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(); }
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; } }
private string GenerateToolTipString(ManagedPGRGuid guid) { if (guid.Equals(m_lastTooltipGuid)) { return(m_tooltipString); } m_lastTooltipGuid = guid; if (guid.Equals(m_currCameraGuid)) { StringBuilder tooltipStr = new StringBuilder(); tooltipStr.AppendFormat("Camera: {0} {1} ({2})", m_camInfo.vendorName, m_camInfo.modelName, m_camInfo.serialNumber).AppendLine(); tooltipStr.AppendFormat("Sensor: {0}", m_camInfo.sensorInfo).AppendLine(); tooltipStr.AppendFormat("Firmware: {0} Built: {1}", m_camInfo.firmwareVersion, m_camInfo.firmwareBuildTime).AppendLine(); tooltipStr.AppendFormat("Driver: {0}", m_camInfo.driverName).AppendLine(); m_tooltipString = tooltipStr.ToString(); return(m_tooltipString); } ManagedCameraBase tempCamera = null; if (m_busMgr.GetInterfaceTypeFromGuid(guid) == InterfaceType.GigE) { tempCamera = new ManagedGigECamera(); } else { tempCamera = new ManagedCamera(); } using (tempCamera) { tempCamera.Connect(guid); CameraInfo camInfo = tempCamera.GetCameraInfo(); StringBuilder tooltipStr = new StringBuilder(); tooltipStr.AppendFormat("Camera: {0} {1} ({2})", camInfo.vendorName, camInfo.modelName, camInfo.serialNumber).AppendLine(); tooltipStr.AppendFormat("Sensor: {0}", camInfo.sensorInfo).AppendLine(); tooltipStr.AppendFormat("Firmware: {0} Built: {1}", camInfo.firmwareVersion, camInfo.firmwareBuildTime).AppendLine(); tooltipStr.AppendFormat("Driver: {0}", camInfo.driverName).AppendLine(); m_tooltipString = tooltipStr.ToString(); return(m_tooltipString); } }
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(); }
/// <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); } }
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(); } }
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(); }
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; }
static void Main(string[] args) { ManagedBusManager busMgr = new ManagedBusManager(); uint numCameras = busMgr.GetNumOfCameras(); Console.WriteLine("Number of cameras detected: {0}", numCameras); // Check to make sure enough cameras are connected if (numCameras < 2) { Console.WriteLine("Insufficient number of cameras..."); Console.WriteLine("Please connect at least two 1394 cameras for example to run."); Console.WriteLine("Press Enter to exit..."); Console.ReadLine(); return; } // Check to make sure only 1394 cameras are connected for (uint i = 0; i < numCameras; i++) { ManagedPGRGuid guid = busMgr.GetCameraFromIndex(i); if (busMgr.GetInterfaceTypeFromGuid(guid) != InterfaceType.Ieee1394) { Console.WriteLine("Please make sure ONLY 1394 cameras are connected for example to run."); Console.WriteLine("Press Enter to exit..."); Console.ReadLine(); return; } } Console.Out.WriteLine("Creating ManagedSyncManager Object..."); ManagedSyncManager syncManager = new ManagedSyncManager(); Console.Out.WriteLine("Starting Sync process..."); PGRSyncError syncError; syncError = syncManager.Start(); if (syncError != PGRSyncError.PGRSyncError_OK) { Console.Out.WriteLine("Error in sync start call: {0}", syncError.ToString()); Console.WriteLine("Press Enter to exit..."); Console.ReadLine(); return; } // Grab and check synchonization status uint numChecks = 0; PGRSyncMessage message; do { // Short delay before checking sync status Thread.Sleep(1000); message = syncManager.GetSyncStatus(); Console.WriteLine("Current sync status : {0}", SyncStatusToString(message)); }while (message != PGRSyncMessage.PGRSyncMessage_OK && ++numChecks < 10); Console.Out.WriteLine("\nTiming bus is {0}connected.", syncManager.IsTimingBusConnected() ? "" : "not "); Console.Out.WriteLine("Time since sync started in seconds: {0:F2}.", syncManager.GetTimeSinceSynced()); // Start sync capture and grab images ManagedCamera[] cameras = new ManagedCamera[numCameras]; int grabStatus = StartSyncCaptureAndGrab(ref cameras, numCameras); if (grabStatus != 0) { // Cleanup if start sync capture fails intermittently for (uint i = 0; i < numCameras; i++) { if (cameras[i] != null) { cameras[i].StopCapture(); cameras[i].Disconnect(); } } Console.WriteLine("Press Enter to exit..."); Console.ReadLine(); return; } Console.Out.WriteLine("\nTime since sync started in seconds: {0:F2}.", syncManager.GetTimeSinceSynced()); // Stop sync Console.WriteLine("Stopping Sync Process..."); syncError = syncManager.Stop(); if (syncError != PGRSyncError.PGRSyncError_OK) { Console.Out.WriteLine("Error in sync stop call: {0}", syncError.ToString()); Console.WriteLine("Press Enter to exit..."); Console.ReadLine(); return; } Console.Out.WriteLine("Press any key to exit..."); Console.ReadLine(); }