PDA

View Full Version : How to Set Exposure



selvanathan
November 24, 2007, 11:58:10
dear sir,
i am using continuous image process. by using grabber how to set
new exposure and false default exposure. plz help me.

thanks in advance

Stefan Geissler
November 26, 2007, 09:38:21
Hello Selvanathan,

which grabber do you use? If you use a grabber for an analogue camera, then you can not set exposure by software. This would only be possible through a special software from the camera producer.

If you use a DCam camera, then you can use the by IC Imaging Control provided methods:
Disable automatic
setProperty( CameraControl_Exposure , false );

Enable automatic
setProperty( CameraControl_Exposure , true);

Set a value:
setProperty( CameraControl_Exposure , -6); // 1/64 seconds

Please refer to:
http://www.imagingcontrol.com/support/documentation/class/meth_descGrabber_setProperty.htm

You can also use the more complex other interfaces of IC Imaging Control, if they are supported by your video capture device.


This sample code demonstrates how to set exposure times with the classlibary of IC Imaging Control. First of all, the interfaces must be declared:



DShowLib::tIVCDMapStringsPropertyPtr m_pExposureRange;
DShowLib::tIVCDSwitchPropertyPtr m_pExposureAuto;



These interfaces will be needed to control exposure. Then the interfaces are to be querried from the current video capture device:



void getExposureInterfaces(DShowlib::Grabber *pGrabber)
{
m_pExposureRange = NULL;
m_pExposureAuto = NULL;

tIVCDPropertyItemsPtr pItems = m_pGrabber->getAvailableVCDProperties();
if( pItems != 0 )
{
// Try to find the exposure item.
tIVCDPropertyItemPtr pExposureItem = pItems->findItem( VCDID_Exposure );
if( pExposureItem != 0 )
{
// Try to find the value and auto elements
tIVCDPropertyElementPtr pExposureValueElement = pExposureItem->findElement( VCDElement_Value );
tIVCDPropertyElementPtr pExposureAutoElement = pExposureItem->findElement( VCDElement_Auto );

// If a value element exists, try to acquire a range interface
if( pExposureValueElement != 0 )
{
pExposureValueElement->getInterfacePtr( m_pExposureRange );
}

// If an auto element exists, try to acquire a switch interface
if( pExposureAutoElement != 0 )
{
pExposureAutoElement->getInterfacePtr( m_pExposureAuto );
}
}
}
}


Now we have the interfaces. The automatic for exposure can be set by using the "setSwitch()" method:


if( m_pExposureAuto != 0 ) m_pExposureAuto->setSwitch( false );


The available exposure values can be retrieved as follows. The code snippet fills a combobox named "m_cExposureCombo" with the exposure values.



if( m_pExposureRange != NULL)
{
IVCDMapStringsProperty::tStringVec ExpStrings = m_pExposureRange->getStrings();
for(int i = 0; i < ExpStrings.size(); i++)
{
m_cExposureCombo.AddString(ExpStrings[i].c_str());
}
}


A new exposure value can be set as follows:



void SetExposure(int iValue)
{
if( m_pExposureRange != NULL)
{
IVCDMapStringsProperty::tStringVec ExpStrings = m_pExposureRange->getStrings();
m_pExposureRange->setString(ExpStrings[iValue]);
}
}


The iValue is an index from the Exposurecombobox. Instead of using a combobox, the possible values can be given in a range with a min and a max value. The values to be set are all numbers between the min and max value.

You can use the "Value" in order to set a new exposure value:

m_pExposureRange->Value=0.001; // 1/1000 sec exposure.

It is a good idea to look into the manuals of the Classlibrary at http://www.imagingcontrol.com/ic/docs/html/class/IVCDPropertyInterface.htm On this page are links to all interface documentations.

I hope, this helps.

selvanathan
December 3, 2007, 09:51:27
Hello,

sorry i now only see u r reply.... its all working fine but

m_pGrabber->setProperty( CameraControl_Exposure , -6);

is not working. i get the following error

error C2668: 'setProperty' : ambiguous call to overloaded function

how to solve this... thanks for u r valuable reply..

Stefan Geissler
December 3, 2007, 10:49:12
Hello,

if the compiler tells "ambiguous call", it usually also tells you the possible parameters. You may try
m_pGrabber->setProperty((tCameraPropertyEnum)CameraControl_Exp osure , (long)-6);
to make all parameter types clear for the compiler.

selvanathan
December 10, 2007, 05:34:58
Hello Stefan,
Thank u for u r reply...

i get by using following lines..

m_pGrabber->setProperty(CameraControl_Exposure , false );
m_pGrabber->setProperty(CameraControl_Exposure , long (-6));

thank u once again..

Stefan Geissler
December 10, 2007, 09:26:36
Hi Selvanathan,

"long(-6)" is no valid type cast. It must be "(long)-6".

selvanathan
December 14, 2007, 14:22:18
Hello Stefan,

Thank u for u r reply...
Sorry i wrongly given... and now i corrected...

and i have following doubt

My Image Source camera model is DFx 31AFo3 - 1024 x 768

i set exposure like following method...

m_pGrabber->setProperty(CameraControl_Exposure , false );
m_pGrabber->setProperty(CameraControl_Exposure , (long) -6);

you already told that -6 is for 1/64 sec but what is the exact value for the exposure 1/1000 sec and 1/2000 sec
and how to calculate this or is there any chart for this....


like the same.... i am using the another model DFK 21Fo4 - 640 x 480
for this model what is the exact value for the exposure 1/1024 sec and 1/2048 sec


Plz send me your valuable reply.....

thanks in advance...

Stefan Geissler
December 14, 2007, 14:32:52
Hi Selvanathan

( Sorry, I was out of office, thus I only saw you tried to reach me through the live ****, but I was too late.)

1/1000 sec and 1/2000 sec can only be set by using the either the range or the absolute values interface of exposure. These are the possible interfaces of exposure:

Register values:
From 4000 to 1, where the exposure time is calculated as 1/n = seconds, e.g. n=30 => 1/30 seconds

Physical values (invented by Microsoft):
-11 to 4, where the exposure time is calucalted as 2^n = seconds, e.g n=-6 =>2^-6 = 1/64 seconds

Absolute values:
This is the interface with the widest range from 0.0001 to 30.0, resp. 0.0001 to 3600.0 for the astronomy cameras. The exposure time is give as float value, e.g 0.3333 = 1/33 seconds.

If you would use the range inteface, then the values to be passed are:
1/1000 = 1000
1/2000 = 2000

Please give me some minutes in order to create a matching function for you.

Stefan Geissler
December 14, 2007, 15:21:55
Hi Selvanathan,

Please copy the following function into your program code:



//////////////////////////////////////////////////////////////////////
// Set exposure using the range interface. For the AF/BF cameras
// the exposure range is 0.00001 to 30.0.
//
// In order to set 1/2000 seconds, call:
// SetExposureAbsolute( pGrabber, 0.002f);
//
bool SetExposureAbsolute( DShowLib::Grabber *pGrabber, float fExposure )
{
bool bOK = false;
DShowLib::tIVCDAbsoluteValuePropertyPtr pExposureRange;
DShowLib::tIVCDSwitchPropertyPtr pExposureAuto;

pExposureRange = NULL;
pExposureAuto = NULL;

tIVCDPropertyItemsPtr pItems = pGrabber->getAvailableVCDProperties();
if( pItems != 0 )
{
// Try to find the exposure item.
tIVCDPropertyItemPtr pExposureItem = pItems->findItem( VCDID_Exposure );
if( pExposureItem != 0 )
{
// Try to find the value and auto elements
tIVCDPropertyElementPtr pExposureValueElement = pExposureItem->findElement( VCDElement_Value );
tIVCDPropertyElementPtr pExposureAutoElement = pExposureItem->findElement( VCDElement_Auto );

// If an auto element exists, try to acquire a switch interface
if( pExposureAutoElement != 0 )
{
pExposureAutoElement->getInterfacePtr( pExposureAuto );
pExposureAuto->setSwitch(false); // Disable auto, otherwise we can not set exposure.
}

// If a value element exists, try to acquire a range interface
if( pExposureValueElement != 0 )
{
pExposureValueElement->getInterfacePtr( pExposureRange );
// Here we set the the exposure value.
pExposureRange->setValue( lExposure);
bOK = true;
}
}
}
return bOK;
}


In order to set the exposure time to 1/2000 second, please call:


SetExposureAbsolute( pGrabber, 0.002f);

Stefan Geissler
December 14, 2007, 16:54:25
Just an addition:
The code above works only with the AF, BF camera series. With the DFK 21F04 it would not work, because this model does not have an Absolute Values interface. This means, you can not set exactly 0.002 second exposure time for this camera model.

selvanathan
December 17, 2007, 05:45:44
Hello Stepan,
Thank u...... thank u very much for your valuable reply... that day actually i tried to post my forums but that time i just try to get live ****.. but its not a problem...its ok...

i under stood how to calculate exposure values

for 1/64 = -6 like that

for 1/1024 = -10 and 1/2048 = -11

so i tried above values and reply u later.. how it works...

bez now i am not able to change camera in future i will buy in that model..

thanks

Stefan Geissler
December 17, 2007, 09:30:19
Hi Selvanathan,

I saw that you tried to reac me through live ****, but I was too late. I was outside my office for a few minutes. Please excuse this.

selvanathan
December 18, 2007, 08:34:09
Hello Stepan,
Its nothing to excuse... i know your service very well... your serviceses are very amazing.... your replys are very fast and accurate... your each and every replys are very much useful for me... so plz dont ask any excuses..... actually i only need to ask u excuse me ...bez.. i distrubing u by asking simple and chilly questions many times...but u reply for that also... i shows your service and genuine...

take care bye...