AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

VideoCapabilities issue with camera as User Interface Periph

Forum to discuss AForge.NET Framework, its features, API, how-tos, etc.

VideoCapabilities issue with camera as User Interface Periph

Postby Ammo » Tue May 23, 2017 8:11 am

Hi,
I am making an application that runs on Windows 8 & 10 with WPF and .Net 4.0 and AForge 2.2.5.
It lets the user to take pictures using tablets having front and rear integrated cameras. The user can chose the camera then one of its resolutions.

The problem I am facing is when the cameras are exposed as User Interface Peripherals in Windows peripherals manager. VideoCapabilities obtained are sames for both of the two cameras, they are a shorter list of the real capabilities and not all of them are working for bot of the cameras.

Code exemple :
Code: Select all
FilterInfoCollection videoSources = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach (FilterInfo vs in videoSources)
{
    System.Console.WriteLine(String.Format("Caméra : {0}", vs.Name));
    System.Console.WriteLine(String.Format("Moniker : {0}", vs.MonikerString));

    VideoCapabilitiesWrappers resolutions = new VideoCapabilitiesWrappers(new VideoCaptureDevice(vs.MonikerString).VideoCapabilities);

    Console.WriteLine(string.Format("{0} résolutions : ", resolutions.Count));

    IOrderedEnumerable<VideoCapabilitiesWrapper> sortedResolutions = resolutions.OrderBy<VideoCapabilitiesWrapper, int>(f => { return (f.FrameSize.Height * f.FrameSize.Width); });

    foreach (VideoCapabilitiesWrapper res in sortedResolutions)
    {
        System.Console.WriteLine(String.Format("{0}", res.ToString()));
    }

    System.Console.WriteLine("[FIN]");
}


Result is :
Caméra : IMX175
Moniker : @device:pnp:\\?\display#int0f38#4&17cd1ff8&0&uid134968#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\{d5b24b01-ff44-4f5d-92ea-622a44c3566a}
5 résolutions :
Résolution : 448x252. Capacité : 0.1 Mp. Taux : 29 ips. Format : 16:9.
Résolution : 640x360. Capacité : 0.2 Mp. Taux : 29 ips. Format : 16:9.
Résolution : 640x480. Capacité : 0.3 Mp. Taux : 29 ips. Format : 4:3.
Résolution : 960x540. Capacité : 0.5 Mp. Taux : 29 ips. Format : 16:9.
Résolution : 1280x720. Capacité : 0.9 Mp. Taux : 30 ips. Format : 16:9.
[FIN]

Caméra : OV2722
Moniker : @device:pnp:\\?\display#int0f38#4&17cd1ff8&0&uid134968#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\{7bced037-bf28-4c43-a060-53e57b08c5cc}
5 résolutions :
Résolution : 448x252. Capacité : 0.1 Mp. Taux : 29 ips. Format : 16:9.
Résolution : 640x360. Capacité : 0.2 Mp. Taux : 29 ips. Format : 16:9.
Résolution : 640x480. Capacité : 0.3 Mp. Taux : 29 ips. Format : 4:3.
Résolution : 960x540. Capacité : 0.5 Mp. Taux : 29 ips. Format : 16:9.
Résolution : 1280x720. Capacité : 0.9 Mp. Taux : 30 ips. Format : 16:9.
[FIN]


But in fact both of the camera are having many more capabilities and not all of the 5 returned capabilities are fitting both cameras.

When the cameras are exposed as Image Acquisition Peripherals in the Windows Peripherals Manager there is no problem : I get distincts and rigths lists of capabilities.
It does not depend on Windows 8 or 10. On W8 I get a tablet with cameras as User Interface : OK - and another model with cameras as Image Acquisition : problem.

Here is a result exract of call of DirectShowCaptureCapabilities-Win32.exe (full file attached) :

# API

Version information (file version):

* quartz.dll: Product 6.6.9600.18154, File 6.6.9600.18154
* mfcore.dll: Product 12.0.9600.18154, File 12.0.9600.18154
* mfplat.dll: Product 12.0.9600.17489, File 12.0.9600.17489

# Video

* OV2722
* IMX175

## Device: OV2722

* Moniker Display Name: @device:pnp:\\?\display#int0f38#4&17cd1ff8&0&uid134968#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\{7bced037-bf28-4c43-a060-53e57b08c5cc}

Interfaces:

* `ISpecifyPropertyPages`
* `IKsPropertySet`
* `IAMCameraControl`
* `IAMDeviceRemoval`
* `IAMFilterMiscFlags`
* `IAMVideoControl`
* `IAMVideoProcAmp`

[...........]

## Device: IMX175

* Moniker Display Name: @device:pnp:\\?\display#int0f38#4&17cd1ff8&0&uid134968#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\{d5b24b01-ff44-4f5d-92ea-622a44c3566a}

Interfaces:

* `ISpecifyPropertyPages`
* `IKsPropertySet`
* `IAMCameraControl`
* `IAMDeviceRemoval`
* `IAMFilterMiscFlags`
* `IAMVideoControl`
* `IAMVideoProcAmp`



Does someone can help me please?
Ammo
Attachments
directShowResult.zip
(10.48 KiB) Downloaded 824 times
Ammo
 
Posts: 5
Joined: Tue May 23, 2017 7:15 am

Re: VideoCapabilities issue with camera as User Interface Pe

Postby Ammo » Thu Jun 01, 2017 3:57 pm

Hi,
at last the problem seems to be due or assimilable to the VideoCapabilites.BitCount restriction : if BitCount value is <= 12 the capabilitie is rejected (not retained).
Any progress or idea with this problem?
Thanks,
Ammo
Ammo
 
Posts: 5
Joined: Tue May 23, 2017 7:15 am

Re: VideoCapabilities issue with camera as User Interface Pe

Postby Ammo » Fri Jun 02, 2017 3:48 pm

Hi,
what I have found now is that the problem is more on the Bitmap planes than on the Bitmap bitcount :

if camera has a
* `BITMAPINFOHEADER`:
* `.biSize`: `40`
* `.biWidth`: `1920`
* `.biHeight`: `1080`
* `.biPlanes`: `1`
* `.biBitCount`: `12`

* `.biCompression`: `842094158` `NV12`
* `.biSizeImage`: `3,110,400`
it works fine. On a Windows 8.

But this one doesn't work :
* `BITMAPINFOHEADER`:
* `.biSize`: `40`
* `.biWidth`: `1920`
* `.biHeight`: `1080`
* `.biPlanes`: `3`
* `.biBitCount`: `12`

* `.biCompression`: `842094158` `NV12`
* `.biSizeImage`: `3,110,400`

The YUV presentation is not the same when Planes is 3. The copy of the frame into the bitmap by the Grabber object fails in something.
Ammo
Ammo
 
Posts: 5
Joined: Tue May 23, 2017 7:15 am

Re: VideoCapabilities issue with camera as User Interface Pe

Postby Ammo » Tue Jun 13, 2017 11:59 am

Still searching for a solution... I understand more things now :
the Grabber already get a pointer on the image buffer wich is a RGB 24 bits representation of the image. The source image can be 24 or 16 bits it doesn't matter it is given as a 3 bytes values per pixel (RGB) (values are limited when format is 16 bits instead of 24). So it seems not the right place to operate.

The WorkerThread method seems to be where decoding is done : mediaType.SubType = MediaSubType.RGB24; is set.
MediaSubType.YUYV with 4:2:2 is available but doesn't work.
In my problem the image source is a NV12 format 4:2:0 (12 bits with a Y plane and UV interleaved plane, 4 Y bytes according to 2 U+V bytes ).
I do not find the way to add a format and where the camera memory is accessed or decoded.

Any help?
Thanks,
Ammo
Ammo
 
Posts: 5
Joined: Tue May 23, 2017 7:15 am




Return to AForge.NET Framework