Doly C++ SDK v1.00
Loading...
Searching...
No Matches
lccv.hpp
Go to the documentation of this file.
1#pragma once
2
3
22
23 // LCCV is a simple C++ wrapper that allows capturing photos or video from a camera
24 // handled by the libcamera library. Captured frames are provided as OpenCV cv::Mat
25 // objects for easy post-processing.
26
27 /* SPDX-License-Identifier: BSD-2-Clause */
28 /*
29 * Copyright (C) 2020-2021 Raspberry Pi (Trading) Ltd.
30 *
31 * libcamera_app.hpp - Base class for libcamera apps.
32 * options.hpp - Common program options.
33 */
34
35 /*
36 * Based on LCCV (BSD 2-Clause License)
37 * Original Copyright (c) 2023 <https://github.com/kbarni/LCCV>
38 *
39 * Modifications Copyright (c) 2025 Levent
40 */
41
42
43#include <mutex>
44#include <atomic>
45#include <pthread.h>
46#include <opencv2/opencv.hpp>
47
48#include "libcamera_app.hpp"
49#include "libcamera_app_options.hpp"
50
51class PiCamera {
52public:
55
56 Options* options;
57
58 //Photo mode
59 bool startPhoto();
60 bool capturePhoto(cv::Mat& frame);
61 bool stopPhoto();
62
63 //Video mode
64 bool startVideo();
65 bool getVideoFrame(cv::Mat& frame, unsigned int timeout);
66 void stopVideo();
67
68 //Applies new zoom options. Before invoking this func modify options->roi.
70
71 // custom settings
72 void SetExposure(const float& value);
73 void SetAwbEnable(const bool& enable);
74
75protected:
76 LibcameraApp* app;
77 void getImage(cv::Mat& frame, CompletedRequestPtr& payload);
78 static void* videoThreadFunc(void* p);
79 pthread_t videothread;
80 unsigned int still_flags;
81 unsigned int vw, vh, vstr;
82 std::atomic<bool> running, frameready;
83 uint8_t* framebuffer;
84 std::mutex mtx;
86};
87
bool startPhoto()
bool capturePhoto(cv::Mat &frame)
pthread_t videothread
Definition lccv.hpp:79
bool stopPhoto()
void getImage(cv::Mat &frame, CompletedRequestPtr &payload)
void stopVideo()
void ApplyZoomOptions()
std::atomic< bool > frameready
Definition lccv.hpp:82
static void * videoThreadFunc(void *p)
std::mutex mtx
Definition lccv.hpp:84
uint8_t * framebuffer
Definition lccv.hpp:83
void SetAwbEnable(const bool &enable)
LibcameraApp * app
Definition lccv.hpp:76
unsigned int vw
Definition lccv.hpp:81
void SetExposure(const float &value)
bool camerastarted
Definition lccv.hpp:85
unsigned int still_flags
Definition lccv.hpp:80
Options * options
Definition lccv.hpp:56
bool startVideo()
bool getVideoFrame(cv::Mat &frame, unsigned int timeout)
unsigned int vstr
Definition lccv.hpp:81
std::atomic< bool > running
Definition lccv.hpp:82
unsigned int vh
Definition lccv.hpp:81