FAQ for omegonprocam directshow sdk

NOTICE: This Q&A is only for directshow sdk.

Q01: What's the version of this sdk?

A: 1.0.24718.$WCDATE=%Y%m%d$

Q02: What's in omegonprocam directshow sdk?

A: For normal directshow application development, pure directshow programming is sufficient. For advanced directshow application development (such as camera control GUI customization), COM interfaces in omegonprocam_dshow.h are available. A how-to-use C++ source code sample demodshow is shipped within omegonprocamsdk.zip as well.

Q03: The omegonprocam camera gets found on dshow device enumeration even when it is not connected to PC. If the camera is not connected it should not be enumerated. Is this a bug?

A: No, this is not a bug, it is inherent. If you want to avoid this, please reference Q14 or use the native C API.

Q04: Why the media type is always RGB24 and how to use MONO8/MONO16 or RAW format?

A: The media type of the output pin is fixed to RGB24, but the content of the media sample can be reinterpret.
While the camera filter is not connected, use:

(a) IOmegonprocam::put_Option(OMEGONPROCAM_OPTION_RAW, 1) to enable RAW data mode;
(b) or IOmegonprocam::put_Option(OMEGONPROCAM_OPTION_RGB, 3) to enable MONO8 data mode;
(c) or IOmegonprocam::put_Option(OMEGONPROCAM_OPTION_RGB, 4) to enable MONO16 data mode;
The data is stored into the output buffer as usual, the only difference is that the used data length is less than RGB24 and left the back part of buffer unused & untouched.
NOTE:
(a) It is not supported to change OMEGONPROCAM_OPTION_RAW or OMEGONPROCAM_OPTION_RGB while the camera filter is connected, the function will fail with return value E_UNEXPECTED(0x8000ffff).
(b) OMEGONPROCAM_OPTION_RGB and OMEGONPROCAM_OPTION_RAW are defined in omegonprocam.h

Q05: How about the samples?

A: 1. demodshow: everything about directshow is in dshow.h and dshow.cpp. This sample uses mfc for the UI.

2. amcap: Microsoft sample demonstrates various tasks related to video capture, see https://github.com/microsoft/Windows-classic-samples/tree/main/Samples/Win7Samples/multimedia/directshow/capture/amcap.

Q06: Where can I find the learning materials about DirectShow?

A: Microsoft technical documentation is the most complete reference of DirectShow. You can access it at https://docs.microsoft.com/en-us/windows/win32/directshow/directshow

Q07: Which interfaces does omegonprocam support?

Filter interfaces IBaseFilter
ISpecifyPropertyPages
IAMFilterMiscFlags
IAMVideoControl (Still capture capable models)
IAMVideoProcAmp
IVideoProcAmp
ICameraControl
IAMCameraControl
IOmegonprocam (see omegonprocam_dshow.h)
IOmegonprocamSerialNumber
IOmegonprocamStillImage (Still capture capable models)
IOmegonprocamSerialNumber
IOmegonprocamVersion
IOmegonprocamAdvanced
IOmegonprocamST4
Output pin interfaces
Preview or Still
IPin
IQualityControl
IAMStreamConfig
IKsPropertySet
ISpecifyPropertyPages
IAMVideoProcAmp
IVideoProcAmp
ICameraControl
IAMCameraControl
IOmegonprocam (see omegonprocam_dshow.h)
IOmegonprocamSerialNumber
IOmegonprocamStillImage (Still capture capable models)
IOmegonprocamSerialNumber
IOmegonprocamVersion
IOmegonprocamAdvanced
IOmegonprocamST4
Output Pin Media Types MEDIATYPE_Video
MEDIASUBTYPE_RGB24 (RGB24 or RAW)
FORMAT_VideoInfo

Q08: What are the valid ranges of parameters?

A:

Category Functions Range or function to get the range Default
Video Resolution put_Size
get_Size
put_eSize
get_eSize
get_ResolutionNumber
get_Resolution
model specific
Exposure get_AutoExpoTarget
put_AutoExpoTarget
10~230 120
get_AutoExpoEnable
put_AutoExpoEnable
TRUE or FALSE TRUE
get_ExpoTime
put_ExpoTime
get_ExpTimeRange model specific
get_ExpoAGain
put_ExpoAGain
get_ExpoAGainRange model specific
White Balance get_TempTint
put_TempTint
Temp: 2000~15000
Tint: 200~2500
Temp = 6503
Tint = 1000
Color get_Hue
put_Hue
-180~180 0
get_Saturation
put_Saturation
0~255 128
get_Brightness
put_Brightness
-64~64 0
get_Contrast
put_Contrast
-100~100 0
get_Gamma
put_Gamma
20~180 100
get_LevelRange
put_LevelRange
0~255 Low = 0
High = 255
get_MonoMode S_OK: mono mode
S_FALSE: color mode
model specific
Vignetting get_VignetEnable
put_VignetEnable
TRUE or FALSE FALSE
get_VignetMidPointInt
put_VignetMidPointInt
0~100 50
get_VignetAmountInt
put_VignetAmountInt
-100~100 0
Misc get_VFlip
put_VFlip
TRUE or FALSE FALSE
get_HZ
put_HZ
enum: 0, 1, 2
0 -> 60HZ AC
1 -> 50Hz AC
2 -> DC
DC
get_Chrome
put_Chrome
1(monochromatic) or color(0) 0
get_Speed
put_Speed
get_MaxSpeed model specific
Still Image put_StillSize
get_StillSize
put_eStillSize
get_eStillSize
get_StillResolutionNumber
get_StillResolution
model specific

NOTE: Exposure time unit is microsecond.

Q09: How to know whether the camera supports still capture via SDK?

A: Query the IOmegonprocamStillImage interface.

Q10: How to get the actual frame rate with this SDK?

A: Code example can be found in TDshowContext::get_framerate function in dshow.h and dshow.cpp of the demodshow sample project.

Q11: How to get the camera's unique id?

A: Use the IOmegonprocamSerialNumber interface. Code example can be found in the demodshow sample project.

Q12: Can this SDK used with .net applications?

A: Yes, of course. This SDK is DirectShow based and can be easily integrated into your .net applications. See http://www.aforgenet.com/framework for more details.

Q13: How to use the ROI?

A: There are two cases according to that the camera filter is connected or not connected.
(1) While the camera filter is not connected: firstly, use put_Roi to set the ROI, both the offset and the size can be changed.
(2) While the camera filter is connected: call put_Roi to set the offset can be supported. The width and height can not be changed.

Dshow ROI is supported since 20180824.

Q14: What is DshowMonSvc used for?

A: DshowMonSrc is a service that can monitor the status of the connection of cameras that are connected to PC by directshow driver and report it to Windows, including whether there are cameras connected, how many cameras connected and their model names.
By default, the start type of the DshowMonSvc service is set to "On Demand".

Q15: Does directshow sdk support multiple cameras?

A: Yes, but it's something tricky. The omegonprocam.ax generally open the "first" camera connected to the computer. If you truely want to open multiple cameras simultaneously in directshow, please use one of the following 2 methods:

(a) Run DshowMonSvc automatically, set the service start type to "Auto"

(b) Use DshowEnumCamera and DshowOpenCamera which are defined as below:
/* return value: the number of connected camera */
unsigned __stdcall DshowEnumCamera();

/* return value: camera model name */
const wchar_t* __stdcall DshowGetModelName(unsigned index);

/* return value: the camera directshow COM object, which can be used to QueryInterface(IID_IBaseFilter, ...). When failed, NULL is returned */
/* use DshowOpenCamera(0) to open the first camera, use DshowOpenCamera(1) to open the second camera, etc */
IUnknown* __stdcall DshowOpenCamera(unsigned index);

Please see USE_DSHOWOPENCAMERA in files dshow.h and dshow.cpp of the demodshow sample project. Use InitAxMicro() or InitAxAstro() to get the function pointers.
typedef unsigned  (__stdcall *PFUN_DSHOWENUMCAMERA)();
typedef const wchar_t* (__stdcall *PFUN_DSHOWGETMODELNAME)(unsigned index);
typedef IUnknown* (__stdcall *PFUN_DSHOWOPENCAMERA)(unsigned index);
PFUN_DSHOWENUMCAMERA g_pDshowEnumCamera = NULL;
PFUN_DSHOWGETMODELNAME g_pDshowGetModelName = NULL;
PFUN_DSHOWOPENCAMERA g_pDshowOpenCamera = NULL;
HMODULE g_hModuleAx = NULL;

static void InitAx(const wchar_t* clsid)
{
    if (g_hModuleAx)
        return;
    
    HKEY hKey = NULL;
    wchar_t regPath[MAX_PATH];
    wsprintfW(regPath, L"CLSID\\%s\\InprocServer32", clsid); /* construct regkey path */
    if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CLASSES_ROOT, regPath, 0, KEY_READ, &hKey))
    {
        wchar_t axPath[MAX_PATH + 1] = { 0 };
        DWORD cbData = MAX_PATH * sizeof(wchar_t);
        if (ERROR_SUCCESS == RegQueryValueExW(hKey, NULL, NULL, NULL, (PBYTE)axPath, &cbData)) /* query the full path of omegonprocam.ax */
        {
            g_hModuleAx = LoadLibraryW(axPath);
            if (g_hModuleAx)
            {
                g_pDshowEnumCamera = (PFUN_DSHOWENUMCAMERA)GetProcAddress(g_hModuleAx, "DshowEnumCamera");
                g_pDshowGetModelName = (PFUN_DSHOWGETMODELNAME)GetProcAddress(g_hModuleAx, "DshowGetModelName");
                g_pDshowOpenCamera = (PFUN_DSHOWOPENCAMERA)GetProcAddress(g_hModuleAx, "DshowOpenCamera");
            }
        }
        RegCloseKey(hKey);
    }
}

void InitAxMicro()
{
    /* {EA6387A5-60C7-41D3-B058-8D90580A7BE1} is the clsid of omegonprocam micro dshow object */
    InitAx(L"{EA6387A5-60C7-41D3-B058-8D90580A7BE1}");
}

void InitAxAstro()
{
    /* {B2190DBF-21E3-4580-98B2-0DB1E557A027} is the clsid of omegonprocam astro dshow object */
     InitAx(L"{B2190DBF-21E3-4580-98B2-0DB1E557A027}");
}

After you get the the function pointers, you can use them to open the cameras, such as: g_pDshowOpenCamera(0), g_pDshowOpenCamera(1), g_pDshowOpenCamera(2), etc.