PDA

View Full Version : Cannot set white balance red and blue values



Phil
April 16, 2005, 00:34:49
I'm trying to write some code that will set the red and blue values for white balance, but I get a NULL value when I try to retrieve anything (interface or element) with either the VCDElement_WhiteBalanceRed or the VCDElement_WhiteBalanceBlue identifier. I know it should work, because I have tried using IC Image Capture, and I can adjust those properties in the Properties dialog. I am using version 2.1 of the library with a DFK31F03 camera. Below are the two different methods I tried to set the red and blue values. Any help is appreciated. Thanks.



void
Proprietary::setWhiteBalance( int u, int v )
{
DShowLib::tIVCDPropertyItemsPtr items =
myGrabber->getAvailableVCDProperties();
if ( items == NULL ) return;

DShowLib::tIVCDPropertyInterfacePtr red_interface =
items->findInterface( DShowLib::VCDID_WhiteBalance,
DShowLib::VCDElement_WhiteBalanceRed,
DShowLib::IID_IVCDRangeProperty );
if ( red_interface == NULL ) return;

DShowLib::tIVCDRangePropertyPtr red_range = NULL;
red_interface->QueryInterface( red_range );
if ( red_range == NULL ) return;

red_range->setValue( u );

DShowLib::tIVCDPropertyInterfacePtr blue_interface =
items->findInterface( DShowLib::VCDID_WhiteBalance,
DShowLib::VCDElement_WhiteBalanceBlue,
DShowLib::IID_IVCDRangeProperty );
if ( blue_interface == NULL ) return;

DShowLib::tIVCDRangePropertyPtr blue_range = NULL;
blue_interface->QueryInterface( blue_range );
if ( blue_range == NULL ) return;

blue_range->setValue( v );
}

Alternatively


void
Proprietary::setWhiteBalance( int u, int v )
{
DShowLib::tIVCDPropertyItemsPtr items =
myGrabber->getAvailableVCDProperties();
if ( items == NULL ) return;

DShowLib::tIVCDPropertyItemPtr item =
items->findItem( DShowLib::VCDID_WhiteBalance );
if ( item == NULL ) return;

DShowLib::tIVCDPropertyElementPtr red_value_element =
item->findElement( DShowLib::VCDElement_WhiteBalanceRed );
if ( red_value_element == NULL ) return;

DShowLib::tIVCDRangePropertyPtr red_range;
red_value_element->getInterfacePtr( red_range );
if ( red_range == NULL ) return;

red_range->setValue( u );

DShowLib::tIVCDPropertyElementPtr blue_value_element =
item->findElement( DShowLib::VCDElement_WhiteBalanceBlue );
if ( blue_value_element == NULL ) return;

DShowLib::tIVCDRangePropertyPtr blue_range;
blue_value_element->getInterfacePtr( blue_range );
if ( blue_range == NULL ) return;

blue_range->setValue( v );
}

Stefan Geissler
April 18, 2005, 08:57:48
Hi Phil,

It seems, that the working directory of your application does not contain the “TISDCAM.VDA”. This is an adapter, that provides all properties of the Dxx DCam cameras. If it can not be loaded, e.g. it is missing, the white balance and some other properties can not be set.

Please check the working directory of your debug session. It should point to the “classlib\debug” directory of the IC Imaging Control installation path.

Your code is working properly, i have tested this. You may should disable the automatic for white balance, before you set the values:



DShowLib::tIVCDPropertyElementPtr auto_value_element =
item->findElement( DShowLib::VCDElement_Auto );
if ( auto_value_element != NULL )
{
DShowLib::tIVCDSwitchPropertyPtr white_balance_auto;
auto_value_element->getInterfacePtr( white_balance_auto );
if ( white_balance_auto != NULL )
{
white_balance_auto->setSwitch(false);
}
}

Phil
April 20, 2005, 01:23:47
Thanks for the reply. This works for me. I have added TISDCAM.VDA to our installer, along with vcc_vp.vda, mjpeg.tca, and dvdevice.vda. I assume these other three are also required.

Stefan Geissler
April 20, 2005, 08:56:56
Phil,

You are right. The TCA files are adapters for codecs. The VDA files are adapters for video capture devices and cameras.