Skip to content

Development using LCCV

kbarni edited this page Jan 28, 2022 · 2 revisions

LCCV is a simple C++ wrapper which allows to grab photos or videos from a camera handled by the libcamera library.

The grabbed frames are in OpenCV Mat format for easy post-processing.

General setup

Projects using the LCCV library should be compiled using C++-17 standard and linked against OpenCV, libcamera and lccv.

A CMake project can be found in the examples folder.

Grabbing a photo

This is the main point of the LCCV library, as the V4L2 library cannot handle still camera configuration (thus high resolution images).

First you need to declare a PiCamera variable and set the parameters, like image size, ROI, exposure etc. The parameters can be accessed from PiCamera::options.

Then, grab a photo using the PiCamera::captureFrame(cv::Mat &image) function.

As camera startup takes a few seconds, you can start the camera before grabbing using the startPhoto() function. In this case, you have to call stopPhoto() after the acquisitions were made.

The takephoto example demonstrates how to do this.

Grabbing a video

Declaring and configuring cameras is similar to grabbing a photo.

To start the camera in video mode, call the PiCamera::startVideo() function.

Then, you can capture frames using PiCamera::getVideoFrame(cv::Mat &frame, unsigned int timeout) function, where timeout is the time in milliseconds how long will it wait for the next frame.

Finally stop the camera using the PiCamera::stopVideo() function.

The takevideo example demonstrates how to do this.

Clone this wiki locally