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.
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.