public bool SetSequencerConfigurationMode(bool enable) { bool result = false; try { IEnum iSequencerConfigurationMode = nodeMap.GetNode <IEnum>("SequencerConfigurationMode"); if (iSequencerConfigurationMode == null || !iSequencerConfigurationMode.IsWritable) { throw new Exception("node - SequencerConfigurationMode"); } if (enable) { // // Turn configuration mode on // // *** NOTES *** // Once sequencer mode is off, enabling sequencer configuration // mode allows for the setting of individual sequences. // // *** LATER *** // Before sequencer mode is turned back on, sequencer // configuration mode must be turned off. // IEnumEntry iSequencerConfigurationModeOn = iSequencerConfigurationMode.GetEntryByName("On"); if (iSequencerConfigurationModeOn == null || !iSequencerConfigurationModeOn.IsReadable) { throw new Exception("entry - SequencerConfigurationMode 'On'"); } iSequencerConfigurationMode.Value = iSequencerConfigurationModeOn.Value; } else { // // Turn configuration mode off // // *** NOTES *** // Once all desired states have been set, turn sequencer // configuration mode off in order to turn sequencer mode on. // IEnumEntry iSequencerConfigurationModeOff = iSequencerConfigurationMode.GetEntryByName("Off"); if (iSequencerConfigurationModeOff == null || !iSequencerConfigurationModeOff.IsReadable) { throw new Exception("entry - SequencerConfigurationMode 'Off'"); } iSequencerConfigurationMode.Value = iSequencerConfigurationModeOff.Value; } result = true; } catch (Exception ex) { result = false; } return(result); }
/// <summary> /// AcquisitionMode: Continuous/SingleFrame/MutipleFrame /// </summary> /// <param name="strMode"></param> public override bool SetAcquisitionMode(string strMode) { bool ret = false; try { IEnum iAcquisitionMode = m_NodeMap.GetNode <IEnum>("AcquisitionMode"); if (iAcquisitionMode == null || !iAcquisitionMode.IsWritable) { return(ret); } IEnumEntry iAcquisitionModeContinuous; switch (strMode) { case "Continuous": // Retrieve entry node from enumeration node iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName("Continuous"); if (iAcquisitionModeContinuous == null || !iAcquisitionMode.IsReadable) { return(ret); } break; case "SingleFrame": iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName("SingleFrame"); if (iAcquisitionModeContinuous == null || !iAcquisitionMode.IsReadable) { return(ret); } break; case "MutipleFrame": iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName("MutipleFrame"); if (iAcquisitionModeContinuous == null || !iAcquisitionMode.IsReadable) { return(ret); } break; default: return(ret); } // Set symbolic from entry node as new value for enumeration node iAcquisitionMode.Value = iAcquisitionModeContinuous.Symbolic; ret = true; } catch (Exception ex) { LogHelper.AppLoger.Error(ex); } return(ret); }
public void StartVideo(bool isContinue = true) { try { if (managedCamera != null && _videoMode == false) { if (isContinue) { // Set acquisition mode to continuous IEnum iAcquisitionMode = nodeMap.GetNode <IEnum>("AcquisitionMode"); IEnumEntry iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName("Continuous"); iAcquisitionMode.Value = iAcquisitionModeContinuous.Symbolic; } // Configure image events imageEventListener = new ImageEventListener(imageQueue); managedCamera.RegisterEvent(imageEventListener); // Begin acquiring images managedCamera.BeginAcquisition(); _videoMode = true; } } catch (SpinnakerException ex) { Debug.WriteLine("Error: {0}", ex.Message); } }
/// <summary> /// OldestFirst = 0, /// OldestFirstOverwrite = 1, /// NewestFirst = 2, /// NewestFirstOverwrite = 3, /// NUMSTREAMBUFFERHANDLINGMODE = 4 /// </summary> /// <param name="strMode"></param> public override bool SetStreamBufferHandlingMode(string strMode) { bool ret = false; try { INodeMap sNodeMap = m_Camera.GetTLStreamNodeMap(); IEnum iStreamBufferHandlingMode = sNodeMap.GetNode <IEnum>("StreamBufferHandlingMode"); if (iStreamBufferHandlingMode == null || !iStreamBufferHandlingMode.IsWritable) { return(false); } IEnumEntry iMode = iStreamBufferHandlingMode.GetEntryByName(strMode); if (iMode == null || !iMode.IsReadable) { return(false); } iStreamBufferHandlingMode.Value = iMode.Symbolic; ret = true; } catch (Exception ex) { LogHelper.AppLoger.Error(ex); } return(ret); }
public bool SetStreamBufferCount(long count) { try { // set to manual INodeMap sNodeMap = managedCamera.GetTLStreamNodeMap(); IEnum sBufferCountSelector = sNodeMap.GetNode <IEnum>("StreamBufferCountMode"); if (sBufferCountSelector == null || !sBufferCountSelector.IsWritable) { return(false); } IEnumEntry iBufferCountManual = sBufferCountSelector.GetEntryByName("Manual"); if (iBufferCountManual == null || !iBufferCountManual.IsReadable) { return(false); } sBufferCountSelector.Value = iBufferCountManual.Symbolic; // set the value IInteger streamNode = sNodeMap.GetNode <IInteger>("StreamDefaultBufferCount"); if (streamNode == null || !streamNode.IsWritable) { return(false); } streamNode.Value = count; } catch { return(false); } return(true); }
// 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 bool SetVideoMode(int mode) { try { IEnum iVideoMode = nodeMap.GetNode <IEnum>("VideoMode"); if (iVideoMode == null || !iVideoMode.IsWritable) { return(false); } IEnumEntry iVideoMode0 = iVideoMode.GetEntryByName("Mode0"); if (iVideoMode0 == null || !iVideoMode0.IsReadable) { return(false); } IEnumEntry iVideoMode1 = iVideoMode.GetEntryByName("Mode1"); if (iVideoMode1 == null || !iVideoMode1.IsReadable) { return(false); } if (mode == 0) { iVideoMode.Value = iVideoMode0.Symbolic; } else if (mode == 1) { iVideoMode.Value = iVideoMode1.Symbolic; } else { return(false); } return(true); } catch { return(false); } }
public override bool SetBalanceRatio(float fRoG, float fBoG) { bool ret = false; try { IEnum iBalanceWhiteAuto = m_NodeMap.GetNode <IEnum>("BalanceWhiteAuto"); if (iBalanceWhiteAuto == null || !iBalanceWhiteAuto.IsWritable) { LogHelper.AppLoger.Error("Unable to disable automatic balance (enum retrieval). Aborting..."); return(ret); } IEnumEntry iBalanceAutoOff = iBalanceWhiteAuto.GetEntryByName("Off"); if (iBalanceAutoOff == null || !iBalanceAutoOff.IsReadable) { LogHelper.AppLoger.Error("Unable to disable automatic balance (entry retrieval). Aborting..."); return(ret); } iBalanceWhiteAuto.Value = iBalanceAutoOff.Value; LogHelper.AppLoger.Debug("Automatic balance disabled..."); IEnum iBalanceSelector = m_NodeMap.GetNode <IEnum>("BalanceRatioSelector"); IEnumEntry iBlueChannel = iBalanceSelector.GetEntryByName("Blue"); iBalanceSelector.Value = iBlueChannel.Value; IFloat iBalanceRatio = m_NodeMap.GetNode <IFloat>("BalanceRatio"); iBalanceRatio.Value = fBoG; LogHelper.AppLoger.DebugFormat("BalanceRatio B channel set to {0}...", iBalanceRatio.Value); IEnumEntry iRedChannel = iBalanceSelector.GetEntryByName("Red"); iBalanceSelector.Value = iRedChannel.Value; iBalanceRatio.Value = fRoG; LogHelper.AppLoger.DebugFormat("BalanceRatio R channel set to {0}...", iBalanceRatio.Value); ret = true; } catch (Exception ex) { LogHelper.AppLoger.Error(ex); } return(ret); }
bool RestoreDefaultSettings() { bool result = false; try { for (int i = 0; i < 3; i++) { try { managedCamera.UserSetSelector.Value = UserSetSelectorEnums.Default.ToString(); managedCamera.UserSetLoad.Execute(); result = true; break; } catch (SpinnakerException s) { managedCamera.AcquisitionMode.Value = AcquisitionModeEnums.Continuous.ToString(); managedCamera.BeginAcquisition(); System.Threading.Thread.Sleep(500); managedCamera.EndAcquisition(); } } //TODO: stream buffer default count mode to manual // Set stream buffer Count Mode to manual // Retrieve Stream Parameters device nodemap INodeMap sNodeMap = managedCamera.GetTLStreamNodeMap(); IEnum streamBufferCountMode = sNodeMap.GetNode <IEnum>("StreamBufferCountMode"); if (streamBufferCountMode == null || !streamBufferCountMode.IsWritable) { return(false); } IEnumEntry streamBufferCountModeManual = streamBufferCountMode.GetEntryByName("Manual"); if (streamBufferCountModeManual == null || !streamBufferCountModeManual.IsReadable) { return(false); } streamBufferCountMode.Value = streamBufferCountModeManual.Value; } catch (Exception ex) { result = false; } return(result); }
protected override void setNodeValue(IEnum node, TEnum value) { IEnumEntry entry = node.GetEntryByName(value.ToString()); if (entry == null) { throw new SpinnakerException("Could not find entry '" + value.ToString() + "' for the node '" + value + "'."); } if (!entry.IsReadable) { throw new SpinnakerException("The entry '" + value.ToString() + "' for the node '" + value + "' is not readable."); } node.Value = entry.Value; }
public void SetCameraVideoModeAndFrameRate(double newFrameRate) { bool restartCapture = true; try { StopCapture(); } catch (SpinnakerException) { throw; } try { //camera.SetVideoModeAndFrameRate(newVideoMode, newFrameRate); // 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"); restartCapture = false; } IEnumEntry iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName("Continuous"); if (iAcquisitionModeContinuous == null || !iAcquisitionMode.IsReadable) { Console.WriteLine("Unable to set acquisition mode to continuous (enum entry retrieval). Aborting...\n"); restartCapture = false; } iAcquisitionMode.Value = iAcquisitionModeContinuous.Symbolic; } catch (SpinnakerException /*ex*/) { throw; } if (!SetFrameRate(newFrameRate)) { restartCapture = false; } if (restartCapture) { StartCapture(); } }
private void frameRateManualDisable() { IEnum iAcquisitionFrameRateAuto = cam.GetNodeMap().GetNode <IEnum>("AcquisitionFrameRateAuto"); if (iAcquisitionFrameRateAuto == null || !iAcquisitionFrameRateAuto.IsWritable) { Console.WriteLine("无法设置帧率模式\n"); return; } IEnumEntry iAcquisitionFrameRateAutoOff = iAcquisitionFrameRateAuto.GetEntryByName("Continuous"); if (iAcquisitionFrameRateAutoOff == null || !iAcquisitionFrameRateAutoOff.IsReadable) { Console.WriteLine("无法设置启用帧率自动模式\n"); return; } // Set symbolic from entry node as new value for enumeration node iAcquisitionFrameRateAuto.Value = iAcquisitionFrameRateAutoOff.Symbolic; }
void SetCameraVideoModeAndFrameRate() { bool restartCapture = _capturingImage; StopCapture(); try { //camera.SetVideoModeAndFrameRate(newVideoMode, newFrameRate); // 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"); restartCapture = false; } IEnumEntry iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName("Continuous"); if (iAcquisitionModeContinuous == null || !iAcquisitionMode.IsReadable) { Console.WriteLine("Unable to set acquisition mode to continuous (enum entry retrieval). Aborting...\n"); restartCapture = false; } iAcquisitionMode.Value = iAcquisitionModeContinuous.Symbolic; // set framerate 30 SetProprtyEnabledSetting("FrameRate", true); //SetProprtyAutomaticSetting("FrameRate", false); SetAbsolutePropertyValue("FrameRate", "25"); } catch (SpinnakerException ex) { throw ex; } if (restartCapture) { StartCapture(); } }
bool RestoreDefaultSettings() { bool result = false; try { #region default_settings IEnum iUserSetSelector = nodeMap.GetNode <IEnum>("UserSetSelector"); if (iUserSetSelector == null || !iUserSetSelector.IsWritable) { return(false); } IEnumEntry iUserSetSelectorDefault = iUserSetSelector.GetEntryByName("Default"); if (iUserSetSelectorDefault == null || !iUserSetSelectorDefault.IsReadable) { return(false); } iUserSetSelector.Value = iUserSetSelectorDefault.Symbolic; ICommand iUserSetLoad = nodeMap.GetNode <ICommand>("UserSetLoad"); if (iUserSetLoad == null || !iUserSetLoad.IsWritable) { return(false); } iUserSetLoad.Execute(); #endregion result = true; } catch (Exception ex) { result = false; Console.WriteLine("PtGreyCamera exception: " + ex.Message); } return(result); }
private int SetNodeMapItem(INodeMap nodeMap, String nodeName, String entryName) { try { // Retrieve enumeration node from nodemap IEnum iAcquisitionMode = nodeMap.GetNode <IEnum>(nodeName); if (iAcquisitionMode == null || !iAcquisitionMode.IsWritable) { writeLog(String.Format( "Unable to set {0} to {1} (node retrieval). Aborting...\n\n", nodeName, entryName)); return(-1); } // Retrieve entry node from enumeration node IEnumEntry iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName(entryName); if (iAcquisitionModeContinuous == null || !iAcquisitionMode.IsReadable) { writeLog(String.Format( "Unable to set {0} to {1} (enum entry retrieval). Aborting...\n\n", nodeName, entryName)); return(-1); } // Set symbolic from entry node as new value for enumeration node iAcquisitionMode.Value = iAcquisitionModeContinuous.Symbolic; } catch (SpinnakerException ex) { writeLog(String.Format("Error: {0}\n", ex.Message)); return(-1); } writeLog(String.Format("{0} set to {1}...\n", nodeName, entryName)); return(0); }
// 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); }
//void SetProprtyAutomaticSetting(PropertyType property, bool automatic) //{ // CameraProperty camProp = camera.GetProperty(property); // if (camProp.autoManualMode != automatic) // { // camProp.autoManualMode = automatic; // camera.SetProperty(camProp); // } //} public void SetProprtyAutomaticSetting(string property, bool automatic) { try { if (property == "Gain") { IEnum gainAuto = nodeMap.GetNode <IEnum>("GainAuto"); if (automatic) { // TODO: may have other selection such as "Once" gainAuto.Value = "Continuous"; } else { gainAuto.Value = "Off"; } } else if (property == "Shutter") { IEnum exposureAuto = nodeMap.GetNode <IEnum>("ExposureAuto"); if (automatic) { // TODO: may have other selection such as "Once" exposureAuto.Value = "Continuous"; } else { exposureAuto.Value = "Off"; } } else if (property == "Sharpness") { IEnum sharpnessAuto = nodeMap.GetNode <IEnum>("SharpnessAuto"); if (automatic) { // TODO: may have other selection such as "Once" sharpnessAuto.Value = "Continuous"; } else { sharpnessAuto.Value = "Off"; } } else if (property == "FrameRate") { IEnum framerateAuto = nodeMap.GetNode <IEnum>("AcquisitionFrameRateAuto"); if (automatic) { // TODO: may have other selection such as "Once" framerateAuto.Value = "Continuous"; } else { framerateAuto.Value = "Off"; } } else if (property == "Saturation") { IEnum saturationAuto = nodeMap.GetNode <IEnum>("SaturationAuto"); if (automatic) { // TODO: may have other selection such as "Once" saturationAuto.Value = "Continuous"; } else { saturationAuto.Value = "Off"; } } else if (property == "WhiteBalance") { IEnum whiteBalanceAuto = nodeMap.GetNode <IEnum>("BalanceWhiteAuto"); if (automatic) { // TODO: may have other selection such as "Once" IEnumEntry iBalanceWhiteAutoModeContinuous = whiteBalanceAuto.GetEntryByName("Continuous"); if (iBalanceWhiteAutoModeContinuous?.IsReadable == true) { whiteBalanceAuto.Value = iBalanceWhiteAutoModeContinuous.Symbolic; } } else { whiteBalanceAuto.Value = "Off"; } } else if (property == "ExposureCompensationAuto") { IEnum expoCompAuto = nodeMap.GetNode <IEnum>("pgrExposureCompensationAuto"); if (automatic) { // TODO: may have other selection such as "Once" IEnumEntry iExpoCompAutoModeContinuous = expoCompAuto.GetEntryByName("Continuous"); if (iExpoCompAutoModeContinuous?.IsReadable == true) { expoCompAuto.Value = iExpoCompAutoModeContinuous.Symbolic; } } else { expoCompAuto.Value = "Off"; } } else { Debug.WriteLine("Error: SetPropertyAutomaticSetting for " + property + " not implemented."); } } catch (SpinnakerException e) { Debug.WriteLine("Error: SetPropertyAutomaticSetting for " + property + " exceptoin: " + e.Message); } }
//void SetCameraVideoModeAndFrameRate(VideoMode newVideoMode, FrameRate newFrameRate) //{ // bool restartCapture = true; // try // { // camera.StopCapture(); // } // catch (FC2Exception ex) // { // if (ex.Type != ErrorType.IsochNotStarted) // { // throw; // } // else // restartCapture = false; // } // try // { // camera.SetVideoModeAndFrameRate(newVideoMode, newFrameRate); // } // catch (FC2Exception /*ex*/) // { // throw; // } // if (restartCapture) // { // camera.StartCapture(); // } //} //void SetAbsolutePropertyValue(PropertyType property, float newValue) //{ // CameraProperty camProp = camera.GetProperty(property); // CameraPropertyInfo propInfo = camera.GetPropertyInfo(property); // if (!camProp.autoManualMode && propInfo.manualSupported && propInfo.absValSupported) // { // float difference = camProp.absValue - newValue; // if (difference != 0) // { // // The brightness abs register sometimes starts drifting // // due to a rounding error between the camera and the // // actual value being held by the adjustment. To prevent // // this, only apply the change to the camera if the // // difference is greater than a specified amount. // // Check if the difference is greater than 0.005f. // if (property != PropertyType.Brightness || // Math.Abs(difference) > 0.005f) // { // camProp.absControl = true; // camProp.absValue = newValue; // camera.SetProperty(camProp); // } // } // } // else // { // throw new ApplicationException("Trying to set a property that cannot be adjusted"); // } //} public void SetAbsolutePropertyValue(string property, string newValue) { try { if (property == "Hue") { IFloat hue = nodeMap.GetNode <IFloat>("Hue"); hue.Value = Convert.ToDouble(newValue); } else if (property == "Gamma") { IFloat gamma = nodeMap.GetNode <IFloat>("Gamma"); gamma.Value = Convert.ToDouble(newValue); } else if (property == "Width") { IInteger width = nodeMap.GetNode <IInteger>("Width"); width.Value = Convert.ToInt32(newValue); } else if (property == "Height") { IInteger height = nodeMap.GetNode <IInteger>("Height"); height.Value = Convert.ToInt32(newValue); } else if (property == "Gain") { IEnum gainAuto = nodeMap.GetNode <IEnum>("GainAuto"); gainAuto.Value = "Off"; IFloat gainValue = nodeMap.GetNode <IFloat>("Gain"); gainValue.Value = Convert.ToDouble(newValue); } else if (property == "Saturation") { IEnum saturationAuto = nodeMap.GetNode <IEnum>("SaturationAuto"); saturationAuto.Value = "Off"; IFloat saturationValue = nodeMap.GetNode <IFloat>("Saturation"); saturationValue.Value = Convert.ToDouble(newValue); } else if (property == "Binning") { IInteger binningValue = nodeMap.GetNode <IInteger>("BinningVertical"); binningValue.Value = Convert.ToInt32(newValue); } else if (property == "FrameRate") { IEnum frameRateAuto = nodeMap.GetNode <IEnum>("AcquisitionFrameRateAuto"); frameRateAuto.Value = "Off"; IFloat frameRateValue = nodeMap.GetNode <IFloat>("AcquisitionFrameRate"); frameRateValue.Value = Convert.ToDouble(newValue); } else if (property == "PixelFormat") { IEnum pixelFormat = nodeMap.GetNode <IEnum>("PixelFormat"); IEnumEntry pixelFormatItem = pixelFormat.GetEntryByName(newValue); if (pixelFormatItem?.IsReadable == true) { pixelFormat.Value = pixelFormatItem.Symbolic; } } else if (property == "VideoMode") { IEnum acquisitionMode = nodeMap.GetNode <IEnum>("AcquisitionMode"); if (acquisitionMode?.IsWritable == true) { IEnumEntry acquisitionModeItem = acquisitionMode.GetEntryByName(newValue); if (acquisitionModeItem?.IsReadable == true) { acquisitionMode.Value = acquisitionModeItem.Symbolic; } else { Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property); } } else { Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property); } } else if (property == "ShutterMode") { IEnum exposureMode = nodeMap.GetNode <IEnum>("ExposureMode"); if (exposureMode?.IsWritable == true) { IEnumEntry exposureModeItem = exposureMode.GetEntryByName(newValue); if (exposureModeItem?.IsReadable == true) { exposureMode.Value = exposureModeItem.Symbolic; } else { Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property); } } else { Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property); } } else if (property == "StreamBufferMode") { INodeMap nodeMapStream = camera.GetTLStreamNodeMap(); IEnum bufferMode = nodeMapStream.GetNode <IEnum>("StreamBufferHandlingMode"); if (bufferMode?.IsWritable == true) { IEnumEntry bufferModeItem = bufferMode.GetEntryByName(newValue); if (bufferModeItem?.IsReadable == true) { bufferMode.Value = bufferModeItem.Symbolic; } else { Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property); } } else { Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property); } } else if (property == "ExposureCompensation") { IFloat expoCompensation = nodeMap.GetNode <IFloat>("pgrExposureCompensation"); expoCompensation.Value = Convert.ToDouble(newValue); } else { Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property + " not implemented."); } } catch (SpinnakerException e) { Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property + " exceptoin: " + e.Message); } }
private void SetSetting(Util.SettingInfo item) { string settingName = item._SettingName.ToString(); Util.NodeType nodeType = item._NodeType; Util.NodeMap nodeMap = item._NodeMap; string value = item._Value; if (nodeType == Util.NodeType.String) { IString iNode = null; if (nodeMap == Util.NodeMap.GenICam) { iNode = cam.nodeMap.GetNode <IString>(settingName); } else if (nodeMap == Util.NodeMap.TLDevice) { iNode = cam.nodeMapTLDevice.GetNode <IString>(settingName); } else if (nodeMap == Util.NodeMap.TLStream) { iNode = cam.nodeMapTLStream.GetNode <IString>(settingName); } string currentValue = string.Copy(iNode.Value.ToString()); iNode.Value = value; string newValue = string.Copy(iNode.Value.ToString()); printSettingChangeInfo(currentValue, newValue); } else if (nodeType == Util.NodeType.Integer) { IInteger iNode = null; if (nodeMap == Util.NodeMap.GenICam) { iNode = cam.nodeMap.GetNode <IInteger>(settingName); } else if (nodeMap == Util.NodeMap.TLDevice) { iNode = cam.nodeMapTLDevice.GetNode <IInteger>(settingName); } else if (nodeMap == Util.NodeMap.TLStream) { iNode = cam.nodeMapTLStream.GetNode <IInteger>(settingName); } string currentValue = string.Copy(iNode.Value.ToString()); iNode.Value = int.Parse(value); string newValue = string.Copy(iNode.Value.ToString()); printSettingChangeInfo(currentValue, newValue); } else if (nodeType == Util.NodeType.Float) { IFloat iNode = null; if (nodeMap == Util.NodeMap.GenICam) { iNode = cam.nodeMap.GetNode <IFloat>(settingName); } else if (nodeMap == Util.NodeMap.TLDevice) { iNode = cam.nodeMapTLDevice.GetNode <IFloat>(settingName); } else if (nodeMap == Util.NodeMap.TLStream) { iNode = cam.nodeMapTLStream.GetNode <IFloat>(settingName); } string currentValue = string.Copy(iNode.Value.ToString()); iNode.Value = float.Parse(value, CultureInfo.InvariantCulture.NumberFormat); string newValue = string.Copy(iNode.Value.ToString()); printSettingChangeInfo(currentValue, newValue); } else if (nodeType == Util.NodeType.Bool) { IBool iNode = null; if (nodeMap == Util.NodeMap.GenICam) { iNode = cam.nodeMap.GetNode <IBool>(settingName); } else if (nodeMap == Util.NodeMap.TLDevice) { iNode = cam.nodeMapTLDevice.GetNode <IBool>(settingName); } else if (nodeMap == Util.NodeMap.TLStream) { iNode = cam.nodeMapTLStream.GetNode <IBool>(settingName); } string currentValue = string.Copy(iNode.Value.ToString()); iNode.Value = bool.Parse(value); string newValue = string.Copy(iNode.Value.ToString()); printSettingChangeInfo(currentValue, newValue); } else if (nodeType == Util.NodeType.Command) { ICommand iNode = null; if (nodeMap == Util.NodeMap.GenICam) { iNode = cam.nodeMap.GetNode <ICommand>(settingName); } else if (nodeMap == Util.NodeMap.TLDevice) { iNode = cam.nodeMapTLDevice.GetNode <ICommand>(settingName); } else if (nodeMap == Util.NodeMap.TLStream) { iNode = cam.nodeMapTLStream.GetNode <ICommand>(settingName); } Console.WriteLine("Command to be executed: {0}: ", settingName); iNode.Execute(); } else if (nodeType == Util.NodeType.Enumeration) { IEnum iNode = null; if (nodeMap == Util.NodeMap.GenICam) { iNode = cam.nodeMap.GetNode <IEnum>(settingName); } else if (nodeMap == Util.NodeMap.TLDevice) { iNode = cam.nodeMapTLDevice.GetNode <IEnum>(settingName); } else if (nodeMap == Util.NodeMap.TLStream) { iNode = cam.nodeMapTLStream.GetNode <IEnum>(settingName); } string currentValue = string.Copy(iNode.Value); IEnumEntry iEntry = iNode.GetEntryByName(value); iNode.Value = iEntry.Symbolic; string newValue = string.Copy(iEntry.Symbolic); printSettingChangeInfo(currentValue, newValue); } void printSettingChangeInfo(string _currentValue, string _newValue, bool suppress = true) { if (!suppress) { Console.WriteLine("{0} ({1}) changed from {2} to {3}", settingName, nodeType, _currentValue, _newValue); } } }
public bool SetSingleSequence(int sequenceNumber, int finalSequenceNumber, double gain, double exposureTimeToSet) { bool result = false; try { // // Select the current sequence // // *** NOTES *** // Select the index of the sequence to be set. // // *** LATER *** // The next state - i.e. the state to be linked to - // also needs to be set before saving the current state. // IInteger iSequencerSetSelector = nodeMap.GetNode <IInteger>("SequencerSetSelector"); if (iSequencerSetSelector == null || !iSequencerSetSelector.IsWritable) { throw new Exception("Unable to select state. Aborting...\n"); } iSequencerSetSelector.Value = sequenceNumber; // // Set desired settings for the current state // // Set exposure time; exposure time recorded in microseconds IFloat iExposureTime = nodeMap.GetNode <IFloat>("ExposureTime"); if (iExposureTime == null || !iExposureTime.IsWritable) { throw new Exception("Unable to set exposure time. Aborting...\n"); } iExposureTime.Value = exposureTimeToSet; // TODO: set gain // Set gain; gain recorded in decibels IFloat iGain = nodeMap.GetNode <IFloat>("Gain"); if (iGain == null || !iGain.IsWritable) { throw new Exception("Unable to set gain. Aborting...\n"); } iGain.Value = gain; // // Set the trigger type for the current state // // *** NOTES *** // It is a requirement of every state to have its trigger // source set. The trigger source refers to the moment when the // sequencer changes from one state to the next. // IEnum iSequencerTriggerSource = nodeMap.GetNode <IEnum>("SequencerTriggerSource"); if (iSequencerTriggerSource == null || !iSequencerTriggerSource.IsWritable) { throw new Exception("Unable to set trigger source (enum retrieval). Aborting...\n"); } IEnumEntry iSequencerTriggerSourceFrameStart = iSequencerTriggerSource.GetEntryByName("FrameStart"); if (iSequencerTriggerSourceFrameStart == null || iSequencerTriggerSourceFrameStart.IsWritable) { throw new Exception("Unable to set trigger source (entry retrieval). Aborting...\n"); } iSequencerTriggerSource.Value = iSequencerTriggerSourceFrameStart.Value; // // Set the next state in the sequence // IInteger iSequencerSetNext = nodeMap.GetNode <IInteger>("SequencerSetNext"); if (iSequencerSetNext == null || !iSequencerSetNext.IsWritable) { throw new Exception("Unable to set next state. Aborting...\n"); } if (sequenceNumber == finalSequenceNumber) { iSequencerSetNext.Value = 0; } else { iSequencerSetNext.Value = sequenceNumber + 1; } // // Save current state // // *** NOTES *** // Once all appropriate settings have been configured, make // sure to save the state to the sequence. Notice that these // settings will be lost when the camera is power-cycled. // ICommand iSequencerSetSave = nodeMap.GetNode <ICommand>("SequencerSetSave"); if (iSequencerSetSave == null || !iSequencerSetSave.IsWritable) { throw new Exception("Unable to save state. Aborting...\n"); } iSequencerSetSave.Execute(); result = true; } catch (Exception ex) { result = false; } return(result); }
public bool SetSequencerMode(bool enable) { bool result = false; try { IEnum iSequencerMode = nodeMap.GetNode <IEnum>("SequencerMode"); IEnumEntry iSequencerModeOn = iSequencerMode.GetEntryByName("On"); IEnumEntry iSequencerModeOff = iSequencerMode.GetEntryByName("Off"); if (enable) { // // Turn sequencer mode on // // *** NOTES *** // After sequencer mode has been turned on, the camera will // begin using the saved states in the order that they were set. // // *** LATER *** // Once all images have been captured, disable the sequencer // in order to restore the camera to its initial state. // if (iSequencerMode.Value.Int != iSequencerModeOn.Value) { if (!iSequencerMode.IsWritable) { throw new Exception("entry - SequencerMode 'On'"); } iSequencerMode.Value = iSequencerModeOn.Value; } } else { // // Turn sequencer mode back off // // *** NOTES *** // Between uses, it is best to disable the sequencer until it // is once again required. // if (iSequencerMode.Value.Int != iSequencerModeOff.Value) { if (!iSequencerMode.IsWritable) { throw new Exception("entry - SequencerMode 'Off'"); } iSequencerMode.Value = iSequencerModeOff.Value; } } result = true; } catch (Exception ex) { result = false; } return(result); }
bool EnableChunkData() { bool result = true; try { IBool iChunkModeActive = nodeMap.GetNode <IBool>("ChunkModeActive"); if (iChunkModeActive == null || !iChunkModeActive.IsWritable) { Console.WriteLine("Cannot active chunk mode. Aborting..."); return(false); } iChunkModeActive.Value = true; IEnum iChunkSelector = nodeMap.GetNode <IEnum>("ChunkSelector"); if (iChunkSelector == null || !iChunkSelector.IsReadable) { Console.WriteLine("Chunk selector not available. Aborting..."); return(false); } IEnumEntry frameIDEntry = iChunkSelector.GetEntryByName("FrameCounter");//iChunkSelector.Entries[2]; if (!frameIDEntry.IsAvailable || !frameIDEntry.IsReadable) { } else { iChunkSelector.Value = frameIDEntry.Value; IBool iChunkEnable = nodeMap.GetNode <IBool>("ChunkEnable"); if (iChunkEnable?.IsWritable == true) { iChunkEnable.Value = true; } } IEnumEntry timeStampEntry = iChunkSelector.GetEntryByName("Timestamp"); if (!timeStampEntry.IsAvailable || !timeStampEntry.IsReadable) { } else { iChunkSelector.Value = timeStampEntry.Value; IBool iChunkEnable = nodeMap.GetNode <IBool>("ChunkEnable"); if (iChunkEnable?.IsWritable == true) { iChunkEnable.Value = true; } } IEnumEntry exposureTimeEntry = iChunkSelector.GetEntryByName("ExposureTime"); if (!exposureTimeEntry.IsAvailable || !exposureTimeEntry.IsReadable) { } else { iChunkSelector.Value = exposureTimeEntry.Value; IBool iChunkEnable = nodeMap.GetNode <IBool>("ChunkEnable"); if (iChunkEnable?.IsWritable == true) { iChunkEnable.Value = true; } } } catch (SpinnakerException ex) { Debug.WriteLine("Error: " + ex.Message); result = false; } return(result); }
public override bool SetTriggerMode(bool extTrigger, TriggerType chosenTrigger) { bool rect = false; try { // // Ensure trigger mode off // // *** NOTES *** // The trigger must be disabled in order to configure whether // the source is software or hardware. // IEnum iTriggerMode = m_NodeMap.GetNode <IEnum>("TriggerMode"); if (iTriggerMode == null || !iTriggerMode.IsWritable) { LogHelper.AppLoger.Error("Unable to disable trigger mode (enum retrieval). Aborting..."); return(rect); } IEnumEntry iTriggerModeOff = iTriggerMode.GetEntryByName("Off"); if (iTriggerModeOff == null || !iTriggerModeOff.IsReadable) { LogHelper.AppLoger.Error("Unable to disable trigger mode (entry retrieval). Aborting..."); return(rect); } iTriggerMode.Value = iTriggerModeOff.Value; LogHelper.AppLoger.Debug("Trigger mode disabled..."); // // Select trigger source // // *** NOTES *** // The trigger source must be set to hardware or software while // trigger mode is off. // IEnum iTriggerSource = m_NodeMap.GetNode <IEnum>("TriggerSource"); if (iTriggerSource == null || !iTriggerSource.IsWritable) { LogHelper.AppLoger.Error("Unable to set trigger mode (enum retrieval). Aborting..."); return(rect); } if (chosenTrigger == TriggerType.Software) { // Set trigger mode to software IEnumEntry iTriggerSourceSoftware = iTriggerSource.GetEntryByName("Software"); if (iTriggerSourceSoftware == null || !iTriggerSourceSoftware.IsReadable) { LogHelper.AppLoger.Error("Unable to set software trigger mode (entry retrieval). Aborting..."); return(rect); } iTriggerSource.Value = iTriggerSourceSoftware.Value; LogHelper.AppLoger.Debug("Trigger source set to software..."); } else if (chosenTrigger == TriggerType.Hardware) { // Set trigger mode to hardware ('Line0') IEnumEntry iTriggerSourceHardware = iTriggerSource.GetEntryByName("Line0"); if (iTriggerSourceHardware == null || !iTriggerSourceHardware.IsReadable) { LogHelper.AppLoger.Error("Unable to set hardware trigger mode (entry retrieval). Aborting..."); return(rect); } iTriggerSource.Value = iTriggerSourceHardware.Value; LogHelper.AppLoger.Debug("Trigger source set to hardware(Line0)... "); } // // Turn trigger mode on // // *** LATER *** // Once the appropriate trigger source has been set, turn // trigger mode on in order to retrieve images using the // trigger. // IEnumEntry iTriggerModeOn = iTriggerMode.GetEntryByName("On"); if (extTrigger) { iTriggerModeOn = iTriggerMode.GetEntryByName("On"); } else { iTriggerModeOn = iTriggerMode.GetEntryByName("Off"); } if (iTriggerModeOn == null || !iTriggerModeOn.IsReadable) { LogHelper.AppLoger.Error("Unable to enable trigger mode (entry retrieval). Aborting..."); return(rect); } iTriggerMode.Value = iTriggerModeOn.Value; // TODO: Blackfly and Flea3 GEV cameras need 1 second delay after trigger mode is turned on LogHelper.AppLoger.Debug("Trigger mode enabled..."); rect = true; } catch (Exception ex) { LogHelper.AppLoger.Error(ex); } return(rect); }
public bool DefaultSettings() { bool result = false; try { StopVideo(); if (RestoreDefaultSettings()) { if (!SetStreamBufferCount(1)) { return(false); } //mode 0 and pixel format raw8/bayer rg 8 if (!SetVideoMode(0)) { return(false); } //managedCamera.PixelFormat.Value = PixelFormatEnums.BayerGB8.ToString(); managedCamera.PixelFormat.Value = PixelFormatEnums.RGB8.ToString(); //shutter, gain, wb and frame rate auto off #region exposure_auto_compensation_off IEnum iExposure = nodeMap.GetNode <IEnum>("pgrExposureCompensationAuto"); if (iExposure == null || !iExposure.IsWritable) { return(false); } IEnumEntry iExposureOff = iExposure.GetEntryByName("Off"); if (iExposureOff == null || !iExposureOff.IsReadable) { return(false); } iExposure.Value = iExposureOff.Symbolic; #endregion managedCamera.ExposureAuto.Value = ExposureAutoEnums.Off.ToString(); managedCamera.ExposureMode.Value = ExposureModeEnums.Timed.ToString(); managedCamera.GainAuto.Value = GainAutoEnums.Off.ToString(); #region frame_rate_off IEnum iFrameRate = nodeMap.GetNode <IEnum>("AcquisitionFrameRateAuto"); if (iFrameRate == null || !iFrameRate.IsWritable) { return(false); } IEnumEntry iFrameRateOff = iFrameRate.GetEntryByName("Off"); if (iFrameRateOff == null || !iFrameRateOff.IsReadable) { return(false); } iFrameRate.Value = iFrameRateOff.Symbolic; IBool iFrameRateEnabled = nodeMap.GetNode <IBool>("AcquisitionFrameRateEnabled"); if (iFrameRateEnabled == null || !iFrameRateEnabled.IsWritable) { return(false); } iFrameRateEnabled.Value = false; #endregion // saturation enable off { IBool iSaturationEnabled = nodeMap.GetNode <IBool>("SaturationEnabled"); if (iSaturationEnabled == null || !iSaturationEnabled.IsWritable) { return(false); } iSaturationEnabled.Value = false; } managedCamera.BalanceWhiteAuto.Value = BalanceWhiteAutoEnums.Off.ToString(); result = true; } //result = EnableChunkData(); } catch (Exception ex) { result = false; } return(result); }
public override bool SetExposureTime(float exposureTime) { bool rect = false; try { // // Turn off automatic exposure mode // // *** NOTES *** // Automatic exposure prevents the manual configuration of // exposure time and needs to be turned off. // // *** LATER *** // Exposure time can be set automatically or manually as needed. // This example turns automatic exposure off to set it manually // and back on in order to return the camera to its default // state. // IEnum iExposureAuto = m_NodeMap.GetNode <IEnum>("ExposureAuto"); if (iExposureAuto == null || !iExposureAuto.IsWritable) { LogHelper.AppLoger.Error("Unable to disable automatic exposure (enum retrieval). Aborting..."); return(rect); } IEnumEntry iExposureAutoOff = iExposureAuto.GetEntryByName("Off"); if (iExposureAutoOff == null || !iExposureAutoOff.IsReadable) { LogHelper.AppLoger.Error("Unable to disable automatic exposure (entry retrieval). Aborting..."); return(rect); } iExposureAuto.Value = iExposureAutoOff.Value; LogHelper.AppLoger.Debug("Automatic exposure disabled..."); // // Set exposure time manually; exposure time recorded in microseconds // // *** NOTES *** // The node is checked for availability and writability prior // to the setting of the node. Further, it is ensured that the // desired exposure time does not exceed the maximum. Exposure // time is counted in microseconds. This information can be // found out either by retrieving the unit with the GetUnit() // method or by checking SpinView. // IFloat iExposureTime = m_NodeMap.GetNode <IFloat>("ExposureTime"); if (iExposureTime == null || !iExposureTime.IsWritable) { LogHelper.AppLoger.Error("Unable to set exposure time. Aborting..."); return(rect); } // Ensure desired exposure time does not exceed the maximum iExposureTime.Value = (exposureTime > iExposureTime.Max ? iExposureTime.Max : exposureTime); LogHelper.AppLoger.DebugFormat("Exposure time set to {0} us...", iExposureTime.Value); rect = true; } catch (Exception ex) { LogHelper.AppLoger.Error(ex); } return(rect); }
bool configTrigger(TriggerMode triggerMode, TriggerType triggerType, uint count = 1) { bool result = false; if (triggerMode == TriggerMode.Off) { IEnum triMode = nodeMap.GetNode <IEnum>("TriggerMode"); if (triMode == null || !triMode.IsWritable) { Console.WriteLine("configTrigger: Unable to disable trigger mode (enum retrieval). Aborting..."); return(false); } IEnumEntry iTriggerModeOff = triMode.GetEntryByName("Off"); if (iTriggerModeOff == null || !iTriggerModeOff.IsReadable) { Console.WriteLine("configTrigger: Unable to disable trigger mode (entry retrieval). Aborting..."); return(false); } triMode.Value = iTriggerModeOff.Value; result = true; } else if (triggerMode == TriggerMode.On) { IEnum triMode = nodeMap.GetNode <IEnum>("TriggerMode"); if (triMode == null || !triMode.IsWritable) { Console.WriteLine("configTrigger: Unable to enable trigger mode (enum retrieval). Aborting..."); return(false); } IEnumEntry iTriggerModeOn = triMode.GetEntryByName("On"); if (iTriggerModeOn == null || !iTriggerModeOn.IsReadable) { Console.WriteLine("configTrigger: Unable to enable trigger mode (entry retrieval). Aborting..."); return(false); } triMode.Value = iTriggerModeOn.Value; IEnum triggerSource = nodeMap.GetNode <IEnum>("TriggerSource"); if (triggerType == TriggerType.Software) { // Set trigger mode to software IEnumEntry iTriggerSourceSoftware = triggerSource.GetEntryByName("Software"); if (iTriggerSourceSoftware == null || !iTriggerSourceSoftware.IsReadable) { Console.WriteLine("configTrigger: Unable to set software trigger mode (entry retrieval). Aborting..."); return(false); } triggerSource.Value = iTriggerSourceSoftware.Value; Console.WriteLine("configTrigger: Trigger source set to software..."); } else if (triggerType == TriggerType.Hardware) { // Set trigger mode to hardware ('Line0') IEnumEntry iTriggerSourceHardware = triggerSource.GetEntryByName("Line0"); if (iTriggerSourceHardware == null || !iTriggerSourceHardware.IsReadable) { Console.WriteLine("configTrigger: Unable to set hardware trigger mode (entry retrieval). Aborting..."); return(false); } triggerSource.Value = iTriggerSourceHardware.Value; Console.WriteLine("configTrigger: Trigger source set to hardware..."); } else { Console.WriteLine("configTrigger: Trigger source Unknown"); return(false); } { IEnum triggerSelector = nodeMap.GetNode <IEnum>("TriggerSelector"); IEnumEntry iTriggerSelector = triggerSelector.GetEntryByName("FrameStart"); if (iTriggerSelector == null || !iTriggerSelector.IsReadable) { Console.WriteLine("configTrigger: Unable to set trigger selector (entry retrieval). Aborting..."); return(false); } triggerSelector.Value = iTriggerSelector.Value; } { IEnum triggerActivation = nodeMap.GetNode <IEnum>("TriggerActivation"); triggerActivation.Value = "RisingEdge"; IEnumEntry iTriggerActivation = triggerActivation.GetEntryByName("RisingEdge"); if (iTriggerActivation == null || !iTriggerActivation.IsReadable) { Console.WriteLine("configTrigger: Unable to set trigger activation (entry retrieval). Aborting..."); return(false); } triggerActivation.Value = iTriggerActivation.Value; } // multi frame if (count >= 1) { IEnum iAcquisitionMode = nodeMap.GetNode <IEnum>("AcquisitionMode"); IEnumEntry iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName("MultiFrame"); iAcquisitionMode.Value = iAcquisitionModeContinuous.Symbolic; IInteger acquCount = nodeMap.GetNode <IInteger>("AcquisitionFrameCount"); acquCount.Value = count; //single frame acquisition mode set to triggered { IEnum iSingleFrameAcquisitionMode = nodeMap.GetNode <IEnum>("SingleFrameAcquisitionMode"); IEnumEntry iSingleAcquisitionMode = iSingleFrameAcquisitionMode.GetEntryByName("Triggered"); iSingleFrameAcquisitionMode.Value = iSingleAcquisitionMode.Symbolic; } } else { IEnum iAcquisitionMode = nodeMap.GetNode <IEnum>("AcquisitionMode"); IEnumEntry iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName("Continuous"); iAcquisitionMode.Value = iAcquisitionModeContinuous.Symbolic; } result = true; } return(result); }
// 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); }