PDA

View Full Version : How can I set the gain and exposure?



lxr5109
March 24, 2011, 04:06:04
In the samples, the programs use property page to set gain and exposure.
But I'd like to set them in the code in advance and never allow others to change them, how can I do ? Thank you very much.

Best regards,
lxr5109

Stefan Geissler
March 24, 2011, 12:26:53
Hello,

The general concept is documented at http://www.imagingcontrol.com/en_US/support/documentation/class/tech_VCDProperties.htm

A simple copy and paste function for your source code, that sets exposure:

//////////////////////////////////////////////////////////////////////
// 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.002);
//
bool SetExposureAbsolute( DShowLib::Grabber *pGrabber, double dExposure )
{
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 );

double min = pExposureRange->getRangeMin();
double max = pExposureRange->getRangeMax();

if ( dExposure < min )
{
dExposure = min;
}
else if( dExposure > max )
{
dExposure = max;
}

// Here we set the the exposure value.
pExposureRange->setValue( dExposure);
bOK = true;
}
}
}
return bOK;
}

Setting gain is similar. you use "VCDID_Gain" instead of "VCDID_Exposure"

lxr5109
March 27, 2011, 08:56:51
Thank you very much. I'll try it.