Assembly: Cognex.VisionPro.Core (in Cognex.VisionPro.Core.dll) Version: 87.0.0.0
Property Value
Type: Double| Event Type | Reason |
|---|---|
| ICogChangedEvent Changed | Fires when the contrast is changed. The following state flag may be affected: |
| Exception | Condition |
|---|---|
| NotImplementedException | The attached hardware is an L4000 or an L38. Note that this behavior is different from most other cameras which do not provide contrast support. Those cameras will return a null ICogAcqContrast interface. Your code should be prepared to handle both scenarios. |
| ArgumentException | Value is less than 0 or Value is greater than 1.0. |
Sets or gets the contrast level. This value ranges from 0.0 (least contrast) to 1.0 (most contrast).
Not all FIFOs support this property. Check whether the FIFO supports it, as in the example, before using this property.
The contrast and brightness values control how different light levels are mapped to pixel values. Assume that you are working with an 8-bit image. All the light levels entering the camera must be mapped to a pixel value from 0 to 255.
Contrast determines how the light levels are mapped to the 256 light levels. A low value closer to 0.0 maps more light values to the pixel value range.
A high value closer to 1.0 maps fewer light values to the pixel value range. Light values that are below or above the contrast threshold are mapped to the lowest and highest pixel values, respectively.
For multichannel FIFOs, Contrast sets the contrast of all channels to the same value. To set the contrast of individual channels, use ICogAcqContrastMultiChannel.SetContrastMultiChannel(Int32, Double).
Default Value: CDC-50 camera: 0.15 CDC-100 camera: 0.66 CDC-200 camera: 0.45 All other cameras: 0.35
using Cognex.VisionPro; private CogFrameGrabbers myFrameGrabbers; private ICogFrameGrabber myFrameGrabber; private ICogAcqFifo myAcqFifo; private void InitializeFifo() { const string VIDEO_FORMAT = "Sony XC75 640x480"; ICogAcqContrast contrastParams; myFrameGrabbers = new CogFrameGrabbers(); myFrameGrabber = myFrameGrabbers[0]; myAcqFifo = myFrameGrabber.CreateAcqFifo(VIDEO_FORMAT, Cognex.VisionPro.CogAcqFifoPixelFormatConstants.Format8Grey, 0, false); contrastParams = myAcqFifo.OwnedContrastParams; if (contrastParams != null) contrastParams.Contrast = .8; }
Imports Cognex.VisionPro
Private myFrameGrabbers As CogFrameGrabbers
Private myFrameGrabber As Cognex.VisionPro.ICogFrameGrabber
Private myAcqFifo As Cognex.VisionPro.ICogAcqFifo
Private Sub InitializeFifo()
Const VIDEO_FORMAT = "Sony XC75 640x480"
Dim contrastParams As Cognex.VisionPro.ICogAcqContrast
myFrameGrabbers = New CogFrameGrabbers
myFrameGrabber = myFrameGrabbers.Item(0)
myAcqFifo = myFrameGrabber.CreateAcqFifo(VIDEO_FORMAT, CogAcqFifoPixelFormatConstants.Format8Grey, 0, False)
contrastParams = myAcqFifo.OwnedContrastParams
If Not contrastParams Is Nothing Then
contrastParams.Contrast = 0.8
End If
End Sub