PDA

View Full Version : Controlling exposure and gain (cam DMM 41BF02)



imamares
March 16, 2010, 10:41:41
Hi,

I have problems to control gain and exposure of a cam DMM 41BF02. Here it is the VC++ 8.0 code that I have programmed:

"
bool CameraAdapter::setFeatureValue( GUID feature, double dValue )
{
bool bOK = false;
DShowLib::tIVCDAbsoluteValuePropertyPtr pValueAbs;
DShowLib::tIVCDRangePropertyPtr pValueRange;
DShowLib::tIVCDSwitchPropertyPtr pValueAuto;

pValueAbs = NULL;
pValueRange = NULL;
pValueAuto = NULL;

tIVCDPropertyItemsPtr pItems = this->grabber->getAvailableVCDProperties();
if( pItems != 0 )
{
tIVCDPropertyItemPtr pValueItem = pItems->findItem( feature );
if( pValueItem != 0 )
{
// Try to find the value and auto elements
tIVCDPropertyElementPtr pValueValueElement = pValueItem->findElement( VCDElement_Value );
tIVCDPropertyElementPtr pValueAutoElement = pValueItem->findElement( VCDElement_Auto );

// If an auto element exists, try to acquire a switch interface
if( pValueAutoElement != 0 )
{
pValueAutoElement->getInterfacePtr( pValueAuto );
pValueAuto->setSwitch(false); // Disable auto
}

// If a value element exists, try to acquire an absolute interface
if( pValueValueElement != 0 )
{
if (pValueValueElement->getInterfacePtr(pValueAbs) != 0){
if (pValueAbs->getAvailable()) {
pValueAbs->setValue(dValue);
bOK = true;
}
}
if (pItems->findInterfacePtr(feature,VCDElement_Value,pValueRa nge)!=0){
if (pValueRange->getAvailable()) {
pValueRange->setValue((long)dValue);
bOK = true;
}
}
}
else {
bOK = false;
}
"

Therefore, when setting the exposure by means of 'setFeatureValue( VCDID_Exposure, exposure)', there is no possible to get the absolute interface because pValueValueElement->getInterfacePtr(pValueAbs) is NULL. I do not why, because with the VCD Property Inspector I am able to change the absolute value for exposure (absolute interface is avaliable).
In the abovementioned code, the interface of exposure is only find as a Range interface. How can I get the absolute interface and then set an absolute value for exposure?

In regard to the gain, there is even more misterious, because when calling to 'setFeatureValue(VCDIC_Gain, gain)' the VCDID_Gain is not recognized as a property of the camera because pValueValueElement->getInterfacePtr(pValueAbs) is NULL. But again throughout the VCD Property Inspector I am able to adjust the Gain. What is the problem?

Thanks in advance for the help. Kind regards.

Stefan Geissler
March 17, 2010, 11:49:53
Hello,

I checked your code on my own, and I found it is working fine. I only change a little thing:


// If a value element exists, try to acquire an absolute interface
if( pValueValueElement != 0 )
{
if (pValueValueElement->getInterfacePtr(pValueAbs) != 0)
{
if (pValueAbs->getAvailable())
{
pValueAbs->setValue(dValue);
bOK = true;
}
}
if( bOK == false ) // Success at abs val, so do not set again as range value!
{
if (pItems->findInterfacePtr(feature,VCDElement_Value,pValueRa nge)!=0)
{
if (pValueRange->getAvailable())
{
pValueRange->setValue((long)dValue);
bOK = true;
}
}
}
}


However, since you can set all properties using the VCP Property Inspector, I think, you use an own working directory and copy the TIS*.DLLs into it, buit forgot the "*.VDA" files, thus you have only some standard DirectShow properties. I suggest to copy these VDA files also in your working directory.

imamares
March 17, 2010, 17:27:20
Thanks Stefan for the support. You are right, I just forgot to include the *.vda files in the working directory. It is working fine now!.