PDA

View Full Version : change exposure value by code



juanlu
April 19, 2013, 12:15:42
Hi,

I would like to change from Code the Exposure of a DMK 72AUC02, there is any sentence to change it instead open the configuration form?

thank you!

Stefan Geissler
April 19, 2013, 13:00:26
Exposure Absolute Values in VB.NET

This sample shows, how it was done with IC 3.0. 3.2 is similar.

This sample shows how to retrieve and handle the Absolute Values interface for exposure in Visual Basic .NET

Now the variables that will hold the interfaces to Absolute Values and Exposure Auto are declared:




Dim AbsoluteValues As ICImagingControl3.VCDAbsoluteValueProperty
Dim ExposureAuto As ICImagingControl3.VCDSwitchProperty


Before the interfaces can be retrieved, a video capture device should be opened. If the device is valid the interfaces can be retrieved as follows:


AbsoluteValues = IcImagingControl1.VCDPropertyItems.FindInterface(V CDIDs.VCDID_Exposure + ":" + _
VCDIDs.VCDElement_Value + ":" + _
VCDIDs.VCDInterface_AbsoluteValue)


ExposureAuto = IcImagingControl1.VCDPropertyItems.FindInterface(V CDIDs.VCDID_Exposure + ":" + _
VCDIDs.VCDElement_Auto + ":" + _
VCDIDs.VCDInterface_Switch)


If the Absolute Values interface is valid, a combo should be filled with some values. Thus we have to "pick" some values that are in the range of this interface:


Dim ExposureMin As Double
Dim ExposureMax As Double
Dim ExposureValue As Double

ExposureMax = AbsoluteValues.RangeMax
ExposureMin = AbsoluteValues.RangeMin

' Generate some values for the exposure combobox.
For ExposureValue = ExposureMin To 0.1 Step 0.001
cboExposureSeconds.Items.Add(Math.Round(ExposureVa lue, 3))
Next

For ExposureValue = 0.0 To 1 Step 0.1
cboExposureSeconds.Items.Add(Math.Round(ExposureVa lue, 2))
Next

For ExposureValue = 1.5 To ExposureMax Step 0.5
cboExposureSeconds.Items.Add(Math.Round(ExposureVa lue, 1))
Next


Setting a value to the Absolute Values interface from the combo box is simple:



Private Sub cboExposureSeconds_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboExposureSeconds.SelectedIndexChanged
AbsoluteValues.Value = System.Convert.ToDouble(cboExposureSeconds.Text)
End Sub


Now the same in C#:




// Please add "using TIS.Imaging;" on top
ICImagingControl3.VCDAbsoluteValueProperty absoluteValues;
ICImagingControl3.VCDSwitchProperty autoExposure;
absoluteValues = (ICImagingControl3.VCDAbsoluteValueProperty)icImag ingControl1.VCDPropertyItems.FindInterface(
VCDIDs.VCDID_Exposure + ":" + VCDIDs.VCDElement_Value + ":" + VCDIDs.VCDInterface_AbsoluteValue);
autoExposure = (ICImagingControl3.VCDSwitchProperty) icImagingControl1.VCDPropertyItems.FindInterface(
VCDIDs.VCDID_Exposure + ":" + VCDIDs.VCDElement_Auto + ":" + VCDIDs.VCDInterface_Switch);


// If autoexposure exosure exist ...
if (autoExposure != null)
{
//... make sure it is disabled.
autoExposure.Switch =false;
}


// If the absolute values interfaces exists...
if (absoluteValues != null)
{
double ExpMin, ExpMax, ExpCurrent;

// ... query the currenty values:
ExpMin = absoluteValues.RangeMin;
ExpMax = absoluteValues.RangeMax;
ExpCurrent = absoluteValues.Value;

//.. set a new value
absoluteValues.Value = 0.001;
}


Also look into the IC documentation at http://www.imagingcontrol.com/en_US/support/documentation/dotnet/tech_VCDProperties.htm

juanlu
April 22, 2013, 15:54:14
wow!

it works like a charm!

thank you so much!