1

I am trying to implement a win32 console application using C++ that takes an ON/OFF input for a specific camera which determines the state its torchlight. The camera is integrated to my laptop and the device description states its a USB Video Camera.

In my first attempts I tried researching the DirectShow and Media Foundation frameworks if they support such functionality, but from what I found - they do not.

I came to the conclusion that I must use DeviceIOControl to send a specific IOCTL control code to the device driver, indicating it to turn the light of the camera. The camera uses some common drivers like ksthunk.sys and usbvideo.sys but I am unable to find such control codes and from what I understood the only solution is to refer to the specific device documentation or contact the manufacturers for answers.

Yet this raises a question: How does .NET know which control code to send to the device?

The UWP class VideoDeviceController can turn the light of a camera using TorchControl and FlashControl and from what I researched this functionality does use DeviceIoControl.

Is there any other way to determine the control codes or my solution for the task is wrong?

Valio Raltchev
  • 113
  • 2
  • 13
  • 1
    There may be a way to do this using OpenCV. https://opencv.org/ – James Smith May 20 '23 at 16:28
  • Not really sure, but this post might help:https://stackoverflow.com/questions/63405367/opencv-camera-capture-no-light#63405473 – James Smith May 20 '23 at 16:33
  • Use API hooker/logger and see what it sends. eg. [API Monitor](http://www.rohitab.com/apimonitor) – jtxkopt May 20 '23 at 17:10
  • The [`VideoDeviceController`](https://learn.microsoft.com/en-us/uwp/api/windows.media.devices.videodevicecontroller) isn't part of the UWP. It's just your average Windows Runtime type. .NET has **nothing** to do with any of this. You can use it from your standard Win32 console or desktop application. – IInspectable May 20 '23 at 17:31
  • @JamesSmith Looking into their documentation VideoCaptureProperties do not include any torchlight control, so I assume they do not support it as well, will keep digging. Also thank you for the suggestion, but I specifically need the camera light. – Valio Raltchev May 21 '23 at 09:28
  • @jtxkopt is this application legit, seems a bit shady? – Valio Raltchev May 21 '23 at 09:31
  • @IInspectable the link you sent me is part of the UWP documentation and I also doubt I can use VideoDeviceController in a c++ application, or am I wrong? – Valio Raltchev May 21 '23 at 09:31
  • 1
    `VideoDeviceController` is implemented in C++, and C++ is the most natural way to access the type as well. [C++/WinRT](https://aka.ms/cppwinrt) provides the library and tooling to do so, if you don't want or need to interface at a lower level. The WinRT types are listed under UWP in the documentation for historic reasons only. At one point, the UWP was the only user of the Windows Runtime, and while the UWP is dead, the historic baggage has survived. – IInspectable May 21 '23 at 09:38

0 Answers0