Demonstrates:
- Initializing camera subsystem
- Capturing frames using libcamera + lccv
- Basic image/video handling
#include <spdlog/spdlog.h>
#include <opencv2/imgcodecs.hpp>
int main()
{
spdlog::info("Initializing camera");
{
cv::Mat frame_rgb;
{
spdlog::error("Camera read buffer failed at capture!");
return -3;
}
cv::imwrite("capture.jpg", frame_rgb);
spdlog::info("Frame saved!");
}
{
spdlog::info("Video window is live! Press ESC to quit!");
cv::namedWindow("Camera", cv::WINDOW_NORMAL);
cv::resizeWindow("Camera", 640, 480);
int time_out_ms = 1500;
int total_frame = 300;
cv::Mat frame;
cv::Mat frame_640x480;
while (total_frame-- > 0)
{
{
cv::resize(frame, frame_640x480, cv::Size(640, 480));
cv::imshow("Camera", frame);
int k = cv::waitKey(1);
if (k == 27) break;
}
else
spdlog::warn("getVideoFrame() timeout/fail");
}
}
return 0;
}
bool capturePhoto(cv::Mat &frame)
Options * options
Definition lccv.hpp:56
bool getVideoFrame(cv::Mat &frame, unsigned int timeout)
Camera helper header (third-party component).