プロパティ情報の取得

ここでは選択したデバイスがサポートするプロパティ情報の取得の仕方について説明します。

このプログラムはディレクトリ%TOPLEVEL%\Samples\VC\SimplePropertyにあります。
プログラムを実行するため、ディレクトリ内のソリューションファイルSimpleProperty.slnを開き、メニューからビルド -> ビルド SimplePropertyと選択します。
そこからデバッグ -> スタートと選択することでプログラムを実行することができます。

プログラムがGrabber::showDevicePageクラスライブラリリファレンス>クラス>Grabber>Grabber::showDevicePage Methodを使ってユーザーにデバイスを選択させます。
デバイスプロパティにアクセスするためにGrabber::getVCDPropertyInterfaceクラスライブラリリファレンス>クラス>Grabber>Grabber::getVCDPropertyInterface Methodが使われます。

tIVCDPropertyItemPtr exposure = grabber.getVCDPropertyItem( VCDID_Exposure );
if( exposure == NULL )
{
  std::cout << "Exposure property not available" << std::endl;
    return;
}
tIVCDSwitchPropertyPtr exposure_auto = grabber.getVCDPropertyInterface<IVCSwitchProperty>( VCDID_Exposure, VCDElement_Auto );
if( exposure_auto == NULL )
{
    std::cout << "Exposure property has no auto" << std::endl;
}
else
{
    std::cout << "Exposure auto enabled=" << exposure_auto->getSwitch() << std::endl;
}
tIVCDRangePropertyPtr exsposure_range = grabber.getVCDPropertyInterface<IVCSwitchProperty>(VCDID_Exposure, VCDElement_Value );
if( exposure_range == NULL )
{
    std::cout << "Exposure property has no range interface" << std::endl;
}
else
{
    std::cout << "Current Exposure range value: " << exposure_range->getValue() << std::endl;
    std::cout << "Exposure range range: [" << exposure_range->getRangeMin() << ".." << exposure_range->getRangeMax() << "]" << std::endl
}
tIVCDAvsoluteValuePropertyPtr exposure_absolute = grabber.getVCDPropertyInterface<IVCDAbsoluteValueProperty>( VCDID_Exposure, VCDElement_Value );
if( exposure_absolute == NULL )
{
    std::cout << "Exposure property has no absolute value interface" << std::endl;
}
else
{
    std::cout << "Current Exposure absolute value: " << std::fixed << exposure_absolute->getValue() << " " << exposure_absolute->getDimType() << std::endl;
    std::cout << "Exposure absolute range: [" << exposure_absolute->getRangeMin() << ".." << exposure_absolute->getRangeMax() << "]" << std::endl;
}

Grabber::getVCDPropertyItemクラスライブラリリファレンス>クラス>Grabber>Grabber::getVCDPropertyItem MethodをパラメータVCDID_Exposureでコールすることで、ビデオキャプチャデバイスがexposureプロパティをサポートするかどうかをチェックします。サポートされている場合はautoインターフェースを取得するために、Grabber::getVCDPropertyInterfaceクラスライブラリリファレンス>クラス>Grabber>Grabber::getVCDPropertyInterface Methodがコールされます。これによりデバイスがexposure autoに対応しているかをチェックします。

その後、Grabber::getVCDPropertyInterfaceクラスライブラリリファレンス>クラス>Grabber>Grabber::getVCDPropertyInterface Methodが露光時間設定のabsolute valueをサポートしているかを チェックします。サポートしている場合、現在の値と単位、設定可能な値の範囲を表示します。

インターフェースはデバイスによっては対応していないものもあります。有効性を確認してから使用することをお勧めします。