public FlirProperties(string spinnakerLibraryVersion, IManagedCamera camera) { SpinnakerLibraryVersion = spinnakerLibraryVersion; PixelFormat = new EnumNode <PixelFormatEnums>(camera, nameof(camera.PixelFormat)); AcquisitionMode = new EnumNode <AcquisitionModeEnums>(camera, nameof(camera.AcquisitionMode)); TestPattern = new EnumNode <TestPatternEnums>(camera, nameof(camera.TestPattern)); TestPatternGeneratorSelector = new EnumNode <TestPatternGeneratorSelectorEnums>(camera, nameof(camera.TestPatternGeneratorSelector)); GainSelector = new EnumNode <GainSelectorEnums>(camera, nameof(camera.GainSelector)); GainAuto = new EnumNode <GainAutoEnums>(camera, nameof(camera.GainAuto)); AutoGainUpperLimit = new FloatNode(camera, "AutoGainUpperLimit"); //todo nameof AutoGainLowerLimit = new FloatNode(camera, "AutoGainLowerLimit"); //todo nameof Gain = new FloatNode(camera, nameof(camera.Gain)); ExposureMode = new EnumNode <ExposureModeEnums>(camera, nameof(camera.ExposureMode)); ExposureAuto = new EnumNode <ExposureAutoEnums>(camera, nameof(camera.ExposureAuto)); ExposureAutoUpperLimit = new FloatNode(camera, nameof(camera.AutoExposureExposureTimeUpperLimit)); ExposureAutoLowerLimit = new FloatNode(camera, nameof(camera.AutoExposureExposureTimeLowerLimit)); ExposureTime = new FloatNode(camera, nameof(camera.ExposureTime)); ExposureTimeAbs = new FloatNode(camera, "ExposureTimeAbs"); //todo abs DeviceVendorName = new Flir.Nodes.StringNode(camera, nameof(camera.DeviceVendorName)); DeviceModelName = new Flir.Nodes.StringNode(camera, nameof(camera.DeviceModelName)); DeviceVersion = new Flir.Nodes.StringNode(camera, nameof(camera.DeviceVersion)); DeviceSerialNumber = new Flir.Nodes.StringNode(camera, nameof(camera.DeviceSerialNumber)); DeviceID = new Flir.Nodes.StringNode(camera, nameof(camera.DeviceID)); DeviceUserID = new Flir.Nodes.StringNode(camera, nameof(camera.DeviceUserID)); DeviceGenCpVersionMajor = new Flir.Nodes.StringNode(camera, nameof(camera.DeviceGenCPVersionMajor)); DeviceGenCPVersionMinor = new Flir.Nodes.StringNode(camera, nameof(camera.DeviceGenCPVersionMinor)); DeviceFamilyName = new Flir.Nodes.StringNode(camera, nameof(camera.DeviceFamilyName)); DeviceTemperatureSelector = new EnumNode <DeviceTemperatureSelectorEnums>(camera, nameof(camera.DeviceTemperatureSelector)); DeviceTemperature = new FloatNode(camera, nameof(camera.DeviceTemperature)); Width = new IntegerNode(camera, nameof(camera.Width)); Height = new IntegerNode(camera, nameof(camera.Height)); FPS = new FloatNode(camera, nameof(camera.AcquisitionFrameRate)); }
private void Init() { ManagedSystem system = new ManagedSystem(); cam = system.GetCameras()[0]; cam.Init(); }
public static void CloseOryxCamera(IManagedCamera managedCamera, INodeMap nodeMap, int camNumber, CloseCameraMethod closeMethod) { if (!managedCamera.IsInitialized()) { Console.WriteLine("Camera number {0} not initialized. Cannot execute DeviceReset or FactoryReset command", camNumber.ToString()); return; } if (managedCamera.IsStreaming()) { managedCamera.EndAcquisition(); Console.WriteLine("EndAcquisition executed from CloseOryxCamera block on camera {0}", camNumber.ToString()); } if (closeMethod == CloseCameraMethod.DeInit) { managedCamera.DeInit(); Console.WriteLine("Camera number {0} deinitialized.", camNumber.ToString()); } else if (closeMethod == CloseCameraMethod.DeInitAndDeviceReset) { nodeMap.GetNode <ICommand>("DeviceReset").Execute(); Console.WriteLine("DeviceReset command executed on camera number {0}.", camNumber.ToString()); } else if (closeMethod == CloseCameraMethod.DeInitAndFactoryReset) { nodeMap.GetNode <ICommand>("FactoryReset").Execute(); Console.WriteLine("FactoryReset command executed on camera number {0}.", camNumber.ToString()); } }
// This function acts as the body of the example; please see // NodeMapInfo_CSharp example for more in-depth comments on setting up // cameras. public int RunSingleCamera(IManagedCamera cam) { int result = 0; try { // Retrieve TL device nodemap and print device information INodeMap nodeMapTLDevice = cam.GetTLDeviceNodeMap(); result = PrintDeviceInfo(nodeMapTLDevice); // Initialize camera cam.Init(); // Retrieve GenICam nodemap INodeMap nodeMap = cam.GetNodeMap(); // Acquire images result = result | AcquireImages(cam, nodeMap, nodeMapTLDevice); // Deinitialize camera cam.DeInit(); } catch (SpinnakerException ex) { writeLog(String.Format("Error: {0}\n", ex.Message)); result = -1; } return(result); }
protected override void Configure(IManagedCamera camera) { Rect imageRoi; base.Configure(camera); var widthMax = (int)camera.WidthMax; var heightMax = (int)camera.HeightMax; if (AutoCrop) { imageRoi = processor.GetBoundingRegion(widthMax, heightMax); imageRoi.Width = (int)Math.Min(camera.WidthMax, SafeIncrement(imageRoi.Width, camera.Width.Min, camera.Width.Increment)); imageRoi.Height = (int)Math.Min(camera.HeightMax, SafeIncrement(imageRoi.Height, camera.Height.Min, camera.Height.Increment)); imageRoi.X = (int)Math.Max(0, imageRoi.X - imageRoi.X % camera.OffsetX.Increment); imageRoi.Y = (int)Math.Max(0, imageRoi.Y - imageRoi.Y % camera.OffsetY.Increment); } else { imageRoi = new Rect(0, 0, widthMax, heightMax); } processor.RegionOffset = new Rect(imageRoi.X, imageRoi.Y, widthMax, heightMax); camera.OffsetX.Value = 0; camera.OffsetY.Value = 0; camera.Width.Value = imageRoi.Width; camera.Height.Value = imageRoi.Height; camera.OffsetX.Value = imageRoi.X; camera.OffsetY.Value = imageRoi.Y; }
// Disables heartbeat on GEV cameras so debugging does not incur timeout errors static int DisableHeartbeat(IManagedCamera cam, INodeMap nodeMap, INodeMap nodeMapTLDevice) { Console.WriteLine("Checking device type to see if we need to disable the camera's heartbeat...\n\n"); // // Write to boolean node controlling the camera's heartbeat // // *** NOTES *** // This applies only to GEV cameras and only applies when in DEBUG mode. // GEV cameras have a heartbeat built in, but when debugging applications the // camera may time out due to its heartbeat. Disabling the heartbeat prevents // this timeout from occurring, enabling us to continue with any necessary debugging. // This procedure does not affect other types of cameras and will prematurely exit // if it determines the device in question is not a GEV camera. // // *** LATER *** // Since we only disable the heartbeat on GEV cameras during debug mode, it is better // to power cycle the camera after debugging. A power cycle will reset the camera // to its default settings. // IEnum iDeviceType = nodeMapTLDevice.GetNode <IEnum>("DeviceType"); IEnumEntry iDeviceTypeGEV = iDeviceType.GetEntryByName("GigEVision"); // We first need to confirm that we're working with a GEV camera if (iDeviceType != null && iDeviceType.IsReadable) { if (iDeviceType.Value == iDeviceTypeGEV.Value) { Console.WriteLine( "Working with a GigE camera. Attempting to disable heartbeat before continuing...\n\n"); IBool iGEVHeartbeatDisable = nodeMap.GetNode <IBool>("GevGVCPHeartbeatDisable"); if (iGEVHeartbeatDisable == null || !iGEVHeartbeatDisable.IsWritable) { Console.WriteLine( "Unable to disable heartbeat on camera. Continuing with execution as this may be non-fatal..."); } else { iGEVHeartbeatDisable.Value = true; Console.WriteLine("WARNING: Heartbeat on GigE camera disabled for the rest of Debug Mode."); Console.WriteLine( " Power cycle camera when done debugging to re-enable the heartbeat..."); } } else { Console.WriteLine("Camera does not use GigE interface. Resuming normal execution...\n\n"); } } else { Console.WriteLine("Unable to access TL device nodemap. Aborting..."); return(-1); } return(0); }
public CameraSettings(IManagedCamera cam) { InitializeComponent(); gridControl = new PropertyGridControl(); Grid.SetRow(gridControl, 1); LayoutLeft.Children.Add(gridControl); SetCamera(cam); }
public override bool Connect() { bool result = false; try { system = new ManagedSystem(); IList <IManagedCamera> camList = system.GetCameras(); if (camList.Count != 1) { int count = camList.Count; foreach (IManagedCamera mc in camList) { mc.Dispose(); } // Clear camera list before releasing system camList.Clear(); // Release system system.Dispose(); throw new Exception("Only one camera should be connected, but found " + count); } camera = camList[0]; // Initialize camera camera.Init(); SerialNumber = Convert.ToUInt32(camera.DeviceSerialNumber); FirmwareVersion = camera.DeviceFirmwareVersion; // Retrieve GenICam nodemap nodeMap = camera.GetNodeMap(); //initialise settings DefaultSettings(); ImageWidth = camera.Width; ImageHeight = camera.Height; result = true; } catch (Exception /*ex*/) { //App.LogEntry.AddEntry("Failed to Connect to Point Grey Camera : " + ex.Message); result = false; } return(result); }
protected override void Configure(IManagedCamera camera) { base.Configure(camera); camera.PixelFormat.Value = PixelFormatEnums.Mono16.ToString(); camera.TriggerSource.Value = TriggerSourceEnums.Line0.ToString(); camera.TriggerMode.Value = TriggerModeEnums.On.ToString(); camera.TriggerOverlap.Value = TriggerOverlapEnums.ReadOut.ToString(); camera.TriggerActivation.Value = TriggerActivationEnums.RisingEdge.ToString(); camera.ExposureAuto.Value = ExposureAutoEnums.Off.ToString(); camera.ExposureMode.Value = ExposureModeEnums.Timed.ToString(); camera.ExposureTime.Value = ExposureTime * 1000; camera.GainAuto.Value = GainAutoEnums.Off.ToString(); camera.Gain.Value = 0; }
public override bool Init(int index = 0) { bool ret = false; try { // Retrieve singleton reference to system object ManagedSystem system = new ManagedSystem(); // Retrieve list of cameras from the system IList <IManagedCamera> camList = system.GetCameras(); LogHelper.AppLoger.DebugFormat("Number of cameras detected: {0}", camList.Count); if (camList.Count == 0) { LogHelper.AppLoger.Error("没有发现相机!"); return(ret); } m_Camera = camList[index]; // Retrieve TL device nodemap and print device information INodeMap nodeMapTLDevice = m_Camera.GetTLDeviceNodeMap(); // Initialize camera m_Camera.Init(); // Retrieve GenICam nodemap m_NodeMap = m_Camera.GetNodeMap(); //if (!m_camera.DeviceConnectionStatus.IsRegister) //{ // Dialogs.Show("连接相机失败!"); // return ret; //} //CameraInfo camInfo = m_camera.GetCameraInfo(); IString iDeviceSerialNumber = nodeMapTLDevice.GetNode <IString>("DeviceSerialNumber"); LogHelper.AppLoger.DebugFormat("camera serial number:{0}", iDeviceSerialNumber); //Set embedded timestamp to on //EmbeddedImageInfo embeddedInfo = m_camera.GetEmbeddedImageInfo(); //embeddedInfo.timestamp.onOff = true; //m_camera.SetEmbeddedImageInfo(embeddedInfo); SetAcquisitionMode("Continuous"); ret = true; } catch (Exception ex) { LogHelper.AppLoger.Error(ex); } return(ret); }
public OryxCamera(int camNumber, IManagedCamera managedCamera, CamStreamManager manager, Util.OryxSetupInfo setupInfo) { this.camNumber = camNumber; this.managedCamera = managedCamera; this.manager = manager; this.setupInfo = setupInfo; messageQueue = this.manager.messageQueue; sessionPath = this.manager.sessionPath; GetNodeMapsAndInitialize(); LoadCameraSettings(); StreamController.BasicStreamController controller = new StreamController.BasicStreamController(oryxCamera: this); Console.WriteLine("BasicStreamController set to Run"); controller.Run(); }
protected virtual void Configure(IManagedCamera camera) { var nodeMap = camera.GetNodeMap(); var chunkMode = nodeMap.GetNode <IBool>("ChunkModeActive"); if (chunkMode != null && chunkMode.IsWritable) { chunkMode.Value = true; var chunkSelector = nodeMap.GetNode <IEnum>("ChunkSelector"); if (chunkSelector != null && chunkSelector.IsReadable) { var entries = chunkSelector.Entries; for (int i = 0; i < entries.Length; i++) { var chunkSelectorEntry = entries[i]; if (!chunkSelectorEntry.IsAvailable || !chunkSelectorEntry.IsReadable) { continue; } chunkSelector.Value = chunkSelectorEntry.Value; var chunkEnable = nodeMap.GetNode <IBool>("ChunkEnable"); if (chunkEnable == null || chunkEnable.Value || !chunkEnable.IsWritable) { continue; } chunkEnable.Value = true; } } } var acquisitionMode = nodeMap.GetNode <IEnum>("AcquisitionMode"); if (acquisitionMode == null || !acquisitionMode.IsWritable) { throw new InvalidOperationException("Unable to set acquisition mode to continuous."); } var continuousAcquisitionMode = acquisitionMode.GetEntryByName("Continuous"); if (continuousAcquisitionMode == null || !continuousAcquisitionMode.IsReadable) { throw new InvalidOperationException("Unable to set acquisition mode to continuous."); } acquisitionMode.Value = continuousAcquisitionMode.Symbolic; }
/// <summary> /// Connect ImageDrawingControl and PropertyGridControl with IManagedCamera /// </summary> /// <param name="cam"></param> void SetCamera(IManagedCamera cam, bool startStreaming = false) { try { Mouse.OverrideCursor = Cursors.Wait; //cam.Init(); gridControl.Connect(cam); } catch (Exception ex) { MessageBox.Show(string.Format("There was a problem connecting to IManagedCamera.\n{0}", ex.Message)); } finally { Mouse.OverrideCursor = null; } }
public OryxCamera(int camNumber, IManagedCamera managedCamera, ConcurrentQueue <ButtonCommands> camControlMessageQueue, ConcurrentQueue <RawMat> streamOutputQueue, Util.OryxSetupInfo setupInfo, string sessionPath) { this.camNumber = camNumber; this.managedCamera = managedCamera; this.camControlMessageQueue = camControlMessageQueue; this.streamOutputQueue = streamOutputQueue; this.setupInfo = setupInfo; this.sessionPath = sessionPath; settingsFileName = this.sessionPath + @"\" + "cam" + this.camNumber.ToString() + @"_cameraSettings.txt"; encodePipeName = "ffpipe" + camNumber.ToString(); frameSize = new Size(width: setupInfo.maxFramesize.Width, height: setupInfo.maxFramesize.Height); streamFrameSize = this.setupInfo.streamFramesize; streamEnqueueDutyCycle = 2; GetNodeMapsAndInitialize(); LoadCameraSettings(); DisplayLoop(); }
protected override void Configure(IManagedCamera camera) { camera.BinningSelector.Value = BinningSelectorEnums.All.ToString(); camera.BinningHorizontalMode.Value = BinningHorizontalModeEnums.Sum.ToString(); camera.BinningVerticalMode.Value = BinningVerticalModeEnums.Sum.ToString(); camera.BinningHorizontal.Value = 2; camera.BinningVertical.Value = 2; base.Configure(camera); camera.V3_3Enable.Value = true; camera.GammaEnable.Value = false; camera.AcquisitionFrameRateEnable.Value = false; camera.DeviceLinkThroughputLimit.Value = camera.DeviceLinkThroughputLimit.Max; camera.PixelFormat.Value = PixelFormatEnums.Mono8.ToString(); camera.TriggerSelector.Value = TriggerSelectorEnums.FrameStart.ToString(); camera.TriggerSource.Value = TriggerSourceEnums.Line0.ToString(); camera.TriggerMode.Value = TriggerModeEnums.On.ToString(); camera.TriggerOverlap.Value = TriggerOverlapEnums.ReadOut.ToString(); camera.TriggerActivation.Value = TriggerActivationEnums.RisingEdge.ToString(); camera.LineSelector.Value = LineSelectorEnums.Line1.ToString(); camera.LineMode.Value = LineModeEnums.Output.ToString(); camera.LineSource.Value = LineSourceEnums.ExposureActive.ToString(); camera.ExposureAuto.Value = ExposureAutoEnums.Off.ToString(); camera.ExposureMode.Value = ExposureModeEnums.Timed.ToString(); camera.ExposureTime.Value = ExposureTime; camera.GainAuto.Value = GainAutoEnums.Off.ToString(); camera.Gain.Value = 0; var maxFrameRate = camera.AcquisitionFrameRate.Value; var minTriggerPeriod = 1e6 / maxFrameRate; if (TriggerPeriod < minTriggerPeriod) { var errorMessage = string.Concat( "The current maximum acquisition rate (", maxFrameRate.ToString("F2"), " Hz) cannot match the requested trigger frequency (", (1e6 / TriggerPeriod).ToString("F2"), " Hz). Please make sure the system is connected to a USB 3.0 port using the Neurophotometrics cable.", " Otherwise, make sure ROIs are defined as small as possible and AutoCrop is enabled."); throw new InvalidOperationException(errorMessage); } }
// This function acts as the body of the example; please see // NodeMapInfo_CSharp example for more in-depth comments on setting up // cameras. int RunSingleCamera(IManagedCamera cam) { int result = 0; int err = 0; try { // Retrieve TL device nodemap and print device information INodeMap nodeMapTLDevice = cam.GetTLDeviceNodeMap(); result = PrintDeviceInfo(nodeMapTLDevice); // Initialize camera cam.Init(); // Retrieve GenICam nodemap INodeMap nodeMap = cam.GetNodeMap(); // Acquire images List <IManagedImage> images = new List <IManagedImage>(); err = result | AcquireImages(cam, nodeMap, ref images); if (err < 0) { return(err); } // Create video result = result | SaveListToVideo(nodeMap, nodeMapTLDevice, ref images); // Deinitialize camera cam.DeInit(); } catch (SpinnakerException ex) { Console.WriteLine("Error: {0}", ex.Message); result = -1; } return(result); }
public MainWindow() { InitializeComponent(); ManagedSystem ms = new ManagedSystem(); IList <IManagedCamera> camList = ms.GetCameras(); IManagedCamera cam = camList[0]; GUIFactory AcquisitionGUI = new GUIFactory(); cam.Init(); //AcquisitionGUI.ConnectGUILibrary(cam); ImageDrawingWindow AcquisitionDrawing = AcquisitionGUI.GetImageDrawingWindow(); //AcquisitionDrawing.Connect(cam); //AcquisitionDrawing.Start(); //AcquisitionDrawing.Stop(); AcquisitionDrawing.ShowModal(); }
// Code below is directly copied from example_acquisition // This function acquires and saves 10 images from a device. public int AcquireImages(IManagedCamera cam, INodeMap nodeMap, INodeMap nodeMapTLDevice) { int result = 0; writeLog(String.Format("\n*** IMAGE ACQUISITION ***\n\n")); try { // // Set acquisition mode to continuous // // *** NOTES *** // Because the example acquires and saves 10 images, setting // acquisition mode to continuous lets the example finish. If // set to single frame or multiframe (at a lower number of // images), the example would just hang. This is because the // example has been written to acquire 10 images while the // camera would have been programmed to retrieve less than that. // // Setting the value of an enumeration node is slightly more // complicated than other node types. Two nodes are required: // first, the enumeration node is retrieved from the nodemap and // second, the entry node is retrieved from the enumeration node. // The symbolic of the entry node is then set as the new value // of the enumeration node. // // Notice that both the enumeration and entry nodes are checked // for availability and readability/writability. Enumeration // nodes are generally readable and writable whereas entry // nodes are only ever readable. // // Retrieve enumeration node from nodemap IEnum iAcquisitionMode = nodeMap.GetNode <IEnum>("AcquisitionMode"); if (iAcquisitionMode == null || !iAcquisitionMode.IsWritable) { writeLog(String.Format( "Unable to set acquisition mode to continuous (node retrieval). Aborting...\n\n")); return(-1); } // Retrieve entry node from enumeration node IEnumEntry iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName("Continuous"); if (iAcquisitionModeContinuous == null || !iAcquisitionMode.IsReadable) { writeLog(String.Format( "Unable to set acquisition mode to continuous (enum entry retrieval). Aborting...\n\n")); return(-1); } // Set symbolic from entry node as new value for enumeration node iAcquisitionMode.Value = iAcquisitionModeContinuous.Symbolic; writeLog(String.Format("Acquisition mode set to continuous...\n")); // // Begin acquiring images // // *** NOTES *** // What happens when the camera begins acquiring images depends // on which acquisition mode has been set. Single frame captures // only a single image, multi frame catures a set number of // images, and continuous captures a continuous stream of images. // Because the example calls for the retrieval of 10 images, // continuous mode has been set for the example. // // *** LATER *** // Image acquisition must be ended when no more images are needed. // cam.BeginAcquisition(); writeLog(String.Format("Acquiring images...\n")); // // Retrieve device serial number for filename // // *** NOTES *** // The device serial number is retrieved in order to keep // different cameras from overwriting each other's images. // Grabbing image IDs and frame IDs make good alternatives for // this purpose. // String deviceSerialNumber = ""; IString iDeviceSerialNumber = nodeMapTLDevice.GetNode <IString>("DeviceSerialNumber"); if (iDeviceSerialNumber != null && iDeviceSerialNumber.IsReadable) { deviceSerialNumber = iDeviceSerialNumber.Value; writeLog(String.Format( "Device serial number retrieved as {0}...\n", deviceSerialNumber)); } writeLog(String.Format("\n")); // Retrieve, convert, and save images const int NumImages = 10; for (int imageCnt = 0; imageCnt < NumImages; imageCnt++) { try { // // Retrieve next received image // // *** NOTES *** // Capturing an image houses images on the camera buffer. // Trying to capture an image that does not exist will // hang the camera. // // Using-statements help ensure that images are released. // If too many images remain unreleased, the buffer will // fill, causing the camera to hang. Images can also be // released manually by calling Release(). // using (IManagedImage rawImage = cam.GetNextImage()) { // // Ensure image completion // // *** NOTES *** // Images can easily be checked for completion. This // should be done whenever a complete image is // expected or required. Alternatively, check image // status for a little more insight into what // happened. // if (rawImage.IsIncomplete) { writeLog(String.Format( "Image incomplete with image status {0}...\n", rawImage.ImageStatus)); } else { // // Print image information; width and height // recorded in pixels // // *** NOTES *** // Images have quite a bit of available metadata // including CRC, image status, and offset // values to name a few. // uint width = rawImage.Width; uint height = rawImage.Height; writeLog(String.Format( "Grabbed image {0}, width = {1}, height = {1}\n", imageCnt, width, height)); writeLog(String.Format( "Pixel format is {0}\n", rawImage.PixelFormatName)); // // Convert image to mono 8 // // *** NOTES *** // Images can be converted between pixel formats // by using the appropriate enumeration value. // Unlike the original image, the converted one // does not need to be released as it does not // affect the camera buffer. // // Using statements are a great way to ensure code // stays clean and avoids memory leaks. // leaks. // using (IManagedImage convertedImage = rawImage.Convert(PixelFormatEnums.Mono8)) { // Create a unique filename String filename = "Acquisition-CSharp-"; if (deviceSerialNumber != "") { filename = filename + deviceSerialNumber + "-"; } filename = filename + imageCnt + ".jpg"; // // Save image // // *** NOTES *** // The standard practice of the examples is // to use device serial numbers to keep // images of one device from overwriting // those of another. // convertedImage.Save(filename); writeLog(String.Format("Image saved at {0}\n\n", filename)); } } } } catch (SpinnakerException ex) { writeLog(String.Format("Error: {0}\n", ex.Message)); result = -1; } } // // End acquisition // // *** NOTES *** // Ending acquisition appropriately helps ensure that devices // clean up properly and do not need to be power-cycled to // maintain integrity. // cam.EndAcquisition(); } catch (SpinnakerException ex) { writeLog(String.Format("Error: {0}\n", ex.Message)); result = -1; } return(result); }
public NumericalNode(IManagedCamera cam, string nodeName) : base(cam, nodeName) { }
public override bool Connect() { bool result = false; //try //{ // CameraSelectionDialog m_selDlg = new CameraSelectionDialog(); // if (m_selDlg.ShowModal()) // { // ManagedPGRGuid[] guids = m_selDlg.GetSelectedCameraGuids(); // if (guids.Length == 0) // { // //MessageBox.Show("Please select a camera", "No camera selected"); // return false; // } // camera = new ManagedCamera(); // m_ctldlg = new CameraControlDialog(); // camera.Connect(guids[0]); // //initialise settings // InitializeSettings(); // InitializeSettingsWB(); // CameraInfo ci = camera.GetCameraInfo(); // SerialNumber = ci.serialNumber; // result = true; // } //} //catch (Exception /*ex*/) //{ // //App.LogEntry.AddEntry("Failed to Connect to Point Grey Camera : " + ex.Message); // result = false; //} system = new ManagedSystem(); IList <IManagedCamera> camList = system.GetCameras(); if (camList.Count != 1) { int count = camList.Count; foreach (IManagedCamera mc in camList) { mc.Dispose(); } // Clear camera list before releasing system camList.Clear(); // Release system system.Dispose(); throw new Exception("Only one camera should be connected, but found " + count); } camera = camList[0]; // Initialize camera camera.Init(); // Retrieve GenICam nodemap nodeMap = camera.GetNodeMap(); SerialNumber = Convert.ToUInt32(camera.DeviceSerialNumber); //initialise settings try { InitializeSettings(); InitializeSettingsWB(); result = true; } catch (SpinnakerException ex) { result = false; Debug.WriteLine("PtGrey connect failed: " + ex.Message); } return(result); }
public IntegerNode(IManagedCamera cam, string nodeName) : base(cam, nodeName) { }
public PtGreyCamera(IManagedCamera cam, CameraType camType) { camera = cam; cameraType = camType; nodeMap = camera.GetNodeMap(); }
public FloatNode(IManagedCamera cam, string nodeName) : base(cam, nodeName) { }
// This function acquires and saves 10 images from a device; please see // Acquisition_CSharp example for more in-depth comments on the // acquisition of images. int AcquireImages(IManagedCamera cam, INodeMap nodeMap, ref List <IManagedImage> images) { int result = 0; Console.WriteLine("\n*** IMAGE ACQUISITION ***\n"); try { // Set acquisition mode to continuous IEnum iAcquisitionMode = nodeMap.GetNode <IEnum>("AcquisitionMode"); if (iAcquisitionMode == null || !iAcquisitionMode.IsWritable) { Console.WriteLine("Unable to set acquisition mode to continuous (node retrieval). Aborting...\n"); return(-1); } IEnumEntry iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName("Continuous"); if (iAcquisitionModeContinuous == null || !iAcquisitionMode.IsReadable) { Console.WriteLine("Unable to set acquisition mode to continuous (entry retrieval). Aborting...\n"); return(-1); } iAcquisitionMode.Value = iAcquisitionModeContinuous.Value; Console.WriteLine("Acquisition mode set to continuous..."); // Begin acquiring images cam.BeginAcquisition(); Console.WriteLine("Acquiring images...\n"); // Retrieve and convert images const int NumImages = 10; for (int imageCnt = 0; imageCnt < NumImages; imageCnt++) { // Retrieve the next received images using (IManagedImage rawImage = cam.GetNextImage()) { try { if (rawImage.IsIncomplete) { Console.WriteLine("Image incomplete with image status {0}...\n", rawImage.ImageStatus); } else { // Print image information Console.WriteLine("Grabbed image {0}, width = {1}, height {2}", imageCnt, rawImage.Width, rawImage.Height); // Deep copy image into list images.Add(rawImage.Convert(PixelFormatEnums.BayerBG8)); } } catch (SpinnakerException ex) { Console.WriteLine("Error: {0}", ex.Message); result = -1; } } } cam.EndAcquisition(); } catch (SpinnakerException ex) { Console.WriteLine("Error: {0}", ex.Message); result = -1; } return(result); }
// This function queries an interface for its cameras and then prints // out device information. int QueryInterface(IManagedInterface managedInterface) { int result = 0; try { // // Retrieve TL nodemap from interface // // *** NOTES *** // Each interface has a nodemap that can be retrieved in order // to access information about the interface itself, any devices // connected, or addressing information if applicable. // INodeMap nodeMapInterface = managedInterface.GetTLNodeMap(); // // Print interface display name // // *** NOTES *** // Grabbing node information requires first retrieving the node // and then retrieving its information. There are two things to // keep in mind. First, a node is distinguished by type, which // is related to its value's data type. Second, nodes should be // checked for availability and readability/writability prior to // making an attempt to read from or write to them. // IString iInterfaceDisplayName = nodeMapInterface.GetNode <IString>("InterfaceDisplayName"); if (iInterfaceDisplayName != null && iInterfaceDisplayName.IsReadable) { string interfaceDisplayName = iInterfaceDisplayName.Value; Console.WriteLine("{0}", interfaceDisplayName); } else { Console.WriteLine("Interface display name not readable"); } // // Update list of cameras on the interface // // *** NOTES *** // Updating the cameras on each interface is especially important // if there has been any device arrivals or removals since the // last time UpdateCameras() was called. // managedInterface.UpdateCameras(); // // Retrieve list of cameras from the interface // // *** NOTES *** // Camera lists can be retrieved from an interface or the system // object. Camera lists retrieved from an interface, such as this // one, only return cameras attached on that specific interface // while camera lists retrieved from system returns all cameras // on all interfaces. // // *** LATER *** // Camera lists must be cleared manually. This must be done // prior to releasing the system and while the camera list is // still in scope. // List <IManagedCamera> camList = managedInterface.GetCameras(); // Return if no cameras detected if (camList.Count == 0) { Console.WriteLine("\tNo devices detected.\n"); return(0); } // Print device vendor and model name for each camera on the // interface for (int i = 0; i < camList.Count; i++) { // // Select camera // // *** NOTES *** // Each camera is retrieved from a camera list with an index. // If the index is out of range, an exception is thrown. // IManagedCamera cam = camList[i]; // Retrieve TL device nodemap; please see NodeMapInfo_CSharp // example for additional information on TL device nodemaps INodeMap nodeMapTLDevice = cam.GetTLDeviceNodeMap(); Console.Write("\tDevice {0} ", i); // Print device vendor name and device model name IString iDeviceVendorName = nodeMapTLDevice.GetNode <IString>("DeviceVendorName"); if (iDeviceVendorName != null && iDeviceVendorName.IsReadable) { String deviceVendorName = iDeviceVendorName.Value; Console.Write("{0} ", deviceVendorName); } IString iDeviceModelName = nodeMapTLDevice.GetNode <IString>("DeviceModelName"); if (iDeviceModelName != null && iDeviceModelName.IsReadable) { String deviceModelName = iDeviceModelName.Value; Console.WriteLine("{0}\n", deviceModelName); } // Dispose of managed camera cam.Dispose(); // // Clear camera list before losing scope // // *** NOTES *** // If a camera list (or an interface list) is not cleaned up // manually, the system will do so when the system is // released. // camList.Clear(); } } catch (SpinnakerException ex) { Console.WriteLine("Error " + ex.Message); result = -1; } return(result); }
public EnumNode(IManagedCamera cam, string nodeName) : base(cam, nodeName) { }
public BaseNode(IManagedCamera camera, string nodeName) { this.camera = camera; this.NodeName = nodeName; }
public bool Open(ConcurrentQueue <PtGreyCameraImage> imageQ, out string message, out long width, out long height) { bool result = false; message = ""; width = height = 0; system = new ManagedSystem(); // Retrieve list of cameras from the system camList = system.GetCameras(); // Finish if there are no cameras if (camList.Count != 1) { foreach (IManagedCamera mc in camList) { mc.Dispose(); } // Clear camera list before releasing system camList.Clear(); // Release system system.Dispose(); message = "Camera count is " + camList.Count; } else { try { #region FlyCaptureAPI FlyCapture2Managed.ManagedBusManager busMgr = new FlyCapture2Managed.ManagedBusManager(); var guid = busMgr.GetCameraFromIndex(0); flycapManagedCamera = new FlyCapture2Managed.ManagedCamera(); flycapManagedCamera.Connect(guid); #endregion managedCamera = camList[0]; if (managedCamera.TLDevice.DeviceDisplayName != null && managedCamera.TLDevice.DeviceDisplayName.IsReadable) { message = managedCamera.TLDevice.DeviceDisplayName.ToString(); } // Initialize camera managedCamera.Init(); width = managedCamera.Width.Value; height = managedCamera.Height.Value; // Retrieve GenICam nodemap nodeMap = managedCamera.GetNodeMap(); imageQueue = imageQ; result = true; } catch (SpinnakerException ex) { Debug.WriteLine("Error: {0}", ex.Message); message = ex.Message; result = false;; } catch (Exception ex) { message = ex.Message; result = false; } } return(result); }
public IManagedImage RetrieveMonoImage() { IManagedImage imgResult = null; // Retrieve singleton reference to system object ManagedSystem system = new ManagedSystem(); // Retrieve list of cameras from the system IList <IManagedCamera> camList = system.GetCameras(); if (camList.Count < 1) { writeLog(String.Format("No camera detected. Aborted.\n\n")); return(null); } else { writeLog(String.Format("Number of cameras detected: {0}\n\n", camList.Count)); } // Use the first camera using (camList[0]) { writeLog(String.Format("Running example for the 1st camera...\n")); IManagedCamera cam = camList[0]; try { // Run for a camera // Retrieve TL device nodemap and print device information INodeMap nodeMapTLDevice = cam.GetTLDeviceNodeMap(); PrintDeviceInfo(nodeMapTLDevice); // Initialize camera cam.Init(); // Retrieve GenICam nodemap INodeMap nodeMap = cam.GetNodeMap(); /***** Acquire single BW image from the camera *****/ writeLog(String.Format("\n*** BW IMAGE ACQUISITION ***\n\n")); SetNodeMapItem(nodeMap, "AcquisitionMode", "Continuous"); cam.BeginAcquisition(); using (IManagedImage rawImage = cam.GetNextImage()) { if (rawImage.IsIncomplete) { writeLog(String.Format( "Image incomplete with image status {0}...\n", rawImage.ImageStatus)); imgResult = null; } else { // TODO: Need to return the acquired rawImage here. //IManagedImage monoImage = rawImage.Convert( // PixelFormatEnums.Mono16, ColorProcessingAlgorithm.EDGE_SENSING); IManagedImage monoImage = rawImage.Convert(PixelFormatEnums.Mono8); imgResult = monoImage; } } cam.EndAcquisition(); /***** Acquiring Complete *****/ // Deinitialize camera cam.DeInit(); } catch (SpinnakerException ex) { writeLog(String.Format("Error: {0}\n", ex.Message)); imgResult = null; } writeLog(String.Format("Camera example complete...\n")); } // Clear camera list before releasing system camList.Clear(); // Release system system.Dispose(); writeLog(String.Format("Done!\n")); return(imgResult); }
public bool Open(ConcurrentQueue <PtGreyCameraImage> imageQ, out string message) { bool result = false; message = ""; system = new ManagedSystem(); // Retrieve list of cameras from the system camList = system.GetCameras(); // Finish if there are no cameras if (camList.Count != 1) { foreach (IManagedCamera mc in camList) { mc.Dispose(); } // Clear camera list before releasing system camList.Clear(); // Release system system.Dispose(); message = "Camera count is " + camList.Count; } else { try { managedCamera = camList[0]; if (managedCamera.TLDevice.DeviceDisplayName != null && managedCamera.TLDevice.DeviceDisplayName.IsReadable) { message = managedCamera.TLDevice.DeviceDisplayName.ToString(); } // Initialize camera managedCamera.Init(); // Retrieve GenICam nodemap nodeMap = managedCamera.GetNodeMap(); imageQueue = imageQ; result = true; } catch (SpinnakerException ex) { Debug.WriteLine("Error: {0}", ex.Message); message = ex.Message; result = false;; } catch (Exception ex) { message = ex.Message; result = false; } } return(result); }