This is a wrapper around libcamera which makes it a lot easier to establish a callback containing an openCV matrix. This can then be processed by opencv and then displayed with QT.
apt install libopencv-dev libcamera-dev
cmake .
make
sudo make install
-
Include
libcam2opencv.h
and addtarget_link_libraries(yourproj cam2opencv)
to yourCMakeLists.txt
. -
Create your custom callback
struct MyCallback : Libcam2OpenCV::Callback {
Window* window = nullptr;
virtual void hasFrame(const cv::Mat &frame, const libcamera:ControlList &) {
if (nullptr != window) {
window->updateImage(frame);
}
}
};
- Create instances of the the camera and the callback:
Libcam2OpenCV camera;
MyCallback myCallback;
- Register the callback
camera.registerCallback(&myCallback);
- Start the camera delivering frames via the callback
camera.start();
- Stop the camera
camera.stop();
In the subdirectory metadataprinter
is a demo which just prints the sensor
metadata from the callback. This is useful to see what
info is available for example the sensor timestamp to
check the framerate.
The subdirectory qtviewer
contains a simple QT application
which displays the camera on screen and the value of one pixel
as a thermometer with QWT.