Had some spare time over the long weekend to knock out AX-VideoCapture, which borrows a lot from my AX-MediaPlayer block, but for hardware accelerated webcam capture on windows.
It (ab)uses WGL_NV_DX_interop2 to share DirectX textures with OpenGL on the GPU side, which saves a round trip down to the CPU and back up again, which is important as 4k video streams become more prevalent.
If you need access to the pixel data on the CPU side there’s a non-accelerated path that will allow you to grab a ci::SurfaceRef out to do with as you please, otherwise frames exist on the GPU only and can be extracted via the FrameLease
concept I used for AX-MediaPlayer to handle the locking and synchronisation and whatnot behind the scenes.
There’s a SimpleCapture
sample provided that basically covers the entire API, so hopefully you shouldn’t need much more than that to get going. I also added rudimentary device events (i.e inserted/unplugged etc) as well as some of the CameraControl
api, so if your device exposes certain parameters via KSPROPERTY_CAMERACONTROL_*
I will detect them and provide a way to read and write those values: Brightness, exposure, zoom etc being some of the common ones.
Hopefully it might come in useful for somebody
A