- Note
- DirectShow can only be used in combination with the Microsoft Windows operating system.
-
Since Windows Vista, Movie Maker does not support capturing from a device registered for DirectShow anymore.
This is the documentation of the Balluff DirectShow_acquire interface. A Balluff specific property interface based on the IKsPropertySet has been added. All other features are related to standard DirectShow programming.
Supported Interfaces
- IAMCameraControl
- IAMDroppedFrames
- IAMStreamConfig
- IAMVideoProcAmp
- ISpecifyPropertyPages
- IKsPropertySet (for further information please refer to the Microsoft DirectX 9.0 Programmer's Reference). Supported property set GUID's:
- AMPROPERTY_PIN_CATEGORY
- DIRECT_SHOW_ACQUIRE_PROPERTYSET
C++ Example Code Using the IKsPropertySet Interface
This section provides a small C++ code snippet showing how the DirectShow interface could be used e.g. to query all properties from a device or how to set the value of a certain property
#include <DSImpactAcquire/Include/DirectShowAcquire.h>
#define _WRITE_STRING_PROPERTY(iksprop,prop,str)\
if( prop != 0 )\
{\
prop->value.s = str;\
hr = iksprop->Set(DIRECT_SHOW_ACQUIRE_PROPERTYSET, MVPropIDWrite, NULL, 0, prop, sizeof(MVProperty));\
}
#define _WRITE_FLOAT_PROPERTY(iksprop,prop,fval)\
if( prop != 0 )\
{\
prop->value.f = fval;\
hr = iksprop->Set(DIRECT_SHOW_ACQUIRE_PROPERTYSET, MVPropIDWrite, NULL, 0, prop, sizeof(MVProperty));\
}
#define _DELETE_POINTER_ARRAY(prop_array,cnt)\
for( unsigned long pr = 0; pr < cnt; pr++ )\
{\
if( prop_array[pr].stringArraySize > 0 )\
delete [] prop_array[pr].stringArray;\
}
MVProperty* GetProperty( MVProperty* props, unsigned int property_count, char* property_name )
{
for( unsigned int pr = 0; pr < property_count && props != 0; pr++ )
{
if( strcmp( props[pr].propertyName, property_name ) == 0 )
{
return &props[pr];
}
}
return 0;
}
unsigned long ScanAllProperties( IAMStreamConfig* pvsc, MVProperty* props, unsigned int property_count )
{
IKsPropertySet* ksProp;
unsigned long propCnt = 0;
HRESULT hr = pvsc->QueryInterface( IID_IKsPropertySet, ( void** )&ksProp );
if( SUCCEEDED( hr ) )
{
DWORD cbReturned;
ZeroMemory( props, property_count * sizeof( MVProperty ) );
hr = ksProp->Get( DIRECT_SHOW_ACQUIRE_PROPERTYSET, MVPropIDReadProperties, NULL, 0,
props, property_count * sizeof( MVProperty ), &cbReturned );
propCnt = cbReturned / sizeof( MVProperty );
for( DWORD pr = 0; pr < propCnt; pr++ )
{
hr = ksProp->Get( DIRECT_SHOW_ACQUIRE_PROPERTYSET, MVPropIDRead, NULL, 0, &props[pr], sizeof( props[pr] ), &cbReturned );
if( props[pr].stringArraySize > 0 )
{
props[pr].stringArray = new const char* [props[pr].stringArraySize];
hr = ksProp->Get( DIRECT_SHOW_ACQUIRE_PROPERTYSET, MVPropIDReadStringArray, NULL, 0, &props[pr], sizeof( props[pr] ), &cbReturned );
}
}
ksProp->Release();
}
return propCnt;
}
unsigned long functionXY( ..., bool bBayerOFF, double gain )
{
IKsPropertySet* ks_prop;
hr = gcap.pVSC->QueryInterface( IID_IKsPropertySet, ( void** )&ks_prop );
if( SUCCEEDED( hr ) )
{
const int max_prop = 500;
MVProperty props[max_prop];
unsigned int propCnt = ScanAllProperties( gcap.pVSC, props, max_prop );
MVProperty* gain_prop = GetProperty( props, propCnt, "ImagingSubsystem/Setting/Base/Camera/Gain_dB" );
_WRITE_FLOAT_PROPERTY( ks_prop, gain_prop, gain );
MVProperty* bayer_prop = GetProperty( props, propCnt, "ImagingSubsystem/Setting/Base/ImageProcessing/ColorProcessing" );
_WRITE_STRING_PROPERTY( ks_prop, bayer_prop, bBayerOFF ? "Raw" : "Auto" );
_DELETE_POINTER_ARRAY( props, propCnt );
ks_prop->Release();
}
}
Logging
The DirectShow_acquire logging procedure is equal to the logging of the Balluff products which uses Impact Acquire. The log output itself is based on XML.
If you want more information about the logging please have a look at the Logging chapter of the respective Impact Acquire API manual or read on how to configure the log-output using DeviceConfigure in the "Impact Acquire GUI Applications" manual.
Setting up Devices For DirectShow Usage
In order to be able to access a device through the Impact Acquire software stack from an application through DirectShow a registration procedure is needed. This can either be done using DeviceConfigure or by a command-line tool that is part of the Windows operating system.
- Note
- Please be sure to register the device for DirectShow with a matching version of DeviceConfigure. I.e. if you have installed the 32-bit version of the VLC Media Player, Virtual Dub, etc., you have to register devices with the 32-bit version of DeviceConfigure ("C:/Program Files/Balluff/Impact Acquire/bin", the 64-bit version resides in "C:/Program Files/Balluff/Impact Acquire/bin/x64")!
Registering Devices
Using DeviceConfigure
To register all devices currently recognized by the Impact Acquire software stack for access with DirectShow the following registration procedure is needed:
-
DeviceConfigure needs to be started (with elevated rights).
If no device has been registered the application will more or less (depending on the installed devices) look like this.
DeviceConfigure - After Start
-
To register every installed device for DirectShow access click on the menu item "DirectShow" → "Register All Devices".
DeviceConfigure - Register All Devices
-
After a successful registration the column "Registered For DirectShow" will display "yes" for every device and the devices will be registered with a default DirectShow friendly name which is displayed in the "DirectShow Friendly Name" column.
DeviceConfigure - All Devices Registered For DirectShow Access
Using regsvr32
To register all devices currently recognized by the Impact Acquire software stack with auto-assigned names, the Windows tool "regsvr32"
can be used from an elevated command shell.
The following command-line options are available and can be passed during the silent registration:
EXAMPLES:
Register ALL devices that are recognized by Impact Acquire (this will only register devices for which the corresponding support libraries are installed) without any user interaction:
regsvr32 <path>\DirectShow_acquire.ax /s
Unregister ALL devices that have been registered before without any user interaction:
regsvr32 <path>\DirectShow_acquire.ax /u /s
Renaming Devices
To modify the DirectShow friendly name of a device:
-
DeviceConfigure needs to be started (with elevated rights).
-
right-click on the device to rename and select "Set DirectShow Friendly Name":
DeviceConfigure - Set DirectShow Friendly Name
-
Then, a dialog will appear. Please enter the new name and confirm it with "OK".
DeviceConfigure - Dialog For New Name
-
Afterwards the column "DirectShow friendly name" will display the newly assigned friendly name.
DeviceConfigure - Renamed Device
- Note
- Please do not select the same friendly name for two different devices. In theory this is possible, however the DeviceConfigure GUI will not allow this to avoid confusion.
DirectShow-based Applications
Applications like the VLC Media Player or VirtualDub can be used to capture images via DirectShow. VirtualDub is a good choice if you want full control over the camera, while VLC Media Player decides some of the DirectShow configuration under the hood, which may lead to undesirable results. (See Wrong Colors in the VLC Media Player)
- Note
- Some Windows tools like Teams and Outlook also try to get hold of available DirectShow video capture devices. Keep this in mind if you experience strange behavior of any DirectShow device.