PDA

View Full Version : Exposure value



Alexander
January 24, 2013, 09:37:52
Hello
I need to take pictures with different exposure.
Version with different XML files is not suitable.
How can I set the value of exposure from the program on the VC + +.

Stefan Geissler
January 24, 2013, 09:55:33
Hi

Some documentation about using camera properties can be found at:
http://www.imagingcontrol.com/en_US/support/documentation/class/tech_VCDProperties.htm

Simply copy & paste function:




//////////////////////////////////////////////////////////////////////
// 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;
}

(It is C++ code, I use "PHP" tags only for syntax highlighting in the forum.)

Alexander
January 24, 2013, 14:37:40
Thank you,

Everything works.

ahmed.mlj
March 31, 2014, 15:08:05
Hi,
I am trying to generate different frames with different exposure values.
I applied this function and called it in a while loop:

while(run)

if( pSinkL->getFrameCount()>0)
{
SetExposureAbsolute(m_pGrabberLeft,exposure_value_ 0);
pBufferL= pSinkL->getLastAcqMemBuffer();
memcpy( (unsigned char *)mFrameLeft.data,pBufferL->getPtr(),h*w*3 ); //4 =32 ,3=24

warpAffine( mFrameLeft, mFrameLeft, mRot, mFrameLeft.size() );
cv::flip(mFrameLeft,mFrameLeft,1);
imshow("image0",mFrameLeft);

SetExposureAbsolute(m_pGrabberLeft,exposure_value_ 1);
pBuffer1= pSinkL->getLastAcqMemBuffer();
memcpy( (unsigned char *)mFrame1.data,pBuffer1->getPtr(),h*w*3 ); //4 =32 ,3=24

warpAffine( mFrame1, mFrame1, mRot, mFrame1.size() );
cv::flip(mFrame1,mFrame1,1);
imshow("image1",mFrame1);

c =waitKey(1);// for real-time
// c = waitKey(1000); // for testing
if( c == 27 || c == 'q' || c == 'Q' ) run =0;
}

}

But I am not seeing any difference between the 2 images. It seems that is more compliacated than defining different buffers
to get getLastAcqMemBuffer.
Any idea please?
An other question, who we can set the exposure interface back to default values once we finish processing.