Librem5 OpenCV Example?

OpenCV provides V4L/V4L2 interfacing https://github.com/opencv/opencv/blob/master/modules/videoio/src/cap_v4l.cpp so it is compatible at least with low level /dev/video0 and /dev/video2 kernel drivers of Librem 5 integrated cameras. But problem is that these SoC cameras are complex and direct parameters control is complicated and you need to find actual hierarchy of input chip control, its mux and then imx8m video capture interface. So for real control libcamera would be useful, but I am not sure how mature is its interoperability with OpenCV and if Librem 5 camera kernel support is ready enough. The device parameters should be controlled over /dev/mediaW… It seems that original hacks in Millipixels with calling I2C transfer to control parameters has been replaced in January. You can use media-ctl --print-topology to obtain more idea about setup.

It seems that in actual Millipixel source https://source.puri.sm/Librem5/millipixels the exposure and gain are controlled over IOCTLs but focus is controlled with help of media-ctl calls. @dcz can confirm that, I think.

So you can use/reimplement functions found in Millipixels or you can use Millipixels or media-ctl to setup parameters and then use /dev/videoX directly from OpenCV with correctly/matching defined format. You can try to contact Pavel Machek who works on autofocus and other goodies for multiple phones in his spare time right now.

Some more information about media-ctl at http://trac.gateworks.com/wiki/linux/media