Detecting camera rotation on a Microsoft surface?

Is there a reliable way to determine if the camera is turning on the Microsoft Surface?

Basically, I want to know if a specific camera is built into the device (since it will rotate with the device), is there a way to request this?

My problem is that when the user rotates the device, my camera image is upside down, but I cannot assume that I just need to rotate the captured frames, since the active camera can be an external USB camera.

I read cameras using the Media Foundation API.

+6
source share
1 answer

Basically, I want to know if any camera is built into the device [...], is there any way to request this?

With UWP, you can check the DeviceInformation enclosureLocation camera. panel property:

  • front / back / etc for the integrated camera or
  • unknown for external camera

A complete example is available at CameraStarterKit .


However , if you cannot use UWP, you can still find some basic information. With MF, you must have access to MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK .

It will be something like

 \\?\usb#vid_046d&pid_0843&mi_00#6&2314864d&0&0000#{e5323777-f976-4f5b-9b55-b94699c46e44}\global 

The built-in camera must register its physical location in

 HKLM\SYSTEM\CurrentControlSet\Control\InternalDeviceModification\{GUID} 

If the value of the PLD_Panel key must be a DWORD with values ​​very similar to the panel enumeration mentioned above.

Here 6 means unknown . Therefore, you should be able to check for the presence of this registry key and, if so, to check its value. I suspect this is similar to what UWP does under the hood.

Otherwise, you can crack support by hard-coding some values ​​for the camera vendor and product ID or MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME .

+2
source

Source: https://habr.com/ru/post/1014125/


All Articles