22 #include <linux/videodev2.h>
25 #ifndef JEVOIS_PLATFORM_A33
26 #include <opencv2/core/core.hpp>
27 #include <opencv2/highgui/highgui.hpp>
28 #include <opencv2/imgproc/imgproc.hpp>
32 jevois::VideoOutput(), itsImageQueue(std::max(size_t(2), nbufs)), itsName(displayname)
35 cv::namedWindow(itsName, cv::WINDOW_AUTOSIZE);
44 itsImageQueue.clear();
45 size_t const nbufs = itsImageQueue.size();
48 unsigned int imsize = m.osize();
50 for (
size_t i = 0; i < nbufs; ++i)
52 itsBuffers.push_back(std::make_shared<jevois::VideoBuf>(-1, imsize, 0, -1));
59 img.
buf = itsBuffers[i];
63 itsImageQueue.push(img);
66 LDEBUG(
"Allocated " << nbufs <<
" buffers");
69 cv::namedWindow(itsName, cv::WINDOW_AUTOSIZE);
76 for (
auto & b : itsBuffers)
78 if (b.use_count() > 1)
LERROR(
"Ref count non zero when attempting to free VideoBuf");
87 cv::destroyWindow(itsName);
95 img = itsImageQueue.pop();
96 LDEBUG(
"Empty image " << img.
bufindex <<
" handed over to application code for filling");
108 case V4L2_PIX_FMT_YUYV:
111 cv::cvtColor(imgcv, imgbgr, cv::COLOR_YUV2BGR_YUYV);
115 case V4L2_PIX_FMT_GREY:
118 cv::cvtColor(imgcv, imgbgr, cv::COLOR_GRAY2BGR);
122 case V4L2_PIX_FMT_SRGGB8:
125 cv::cvtColor(imgcv, imgbgr, cv::COLOR_BayerBG2BGR);
129 case V4L2_PIX_FMT_RGB565:
132 cv::cvtColor(imgcv, imgbgr, cv::COLOR_BGR5652BGR);
136 default:
LFATAL(
"Unsupported video format");
140 cv::imshow(itsName, imgbgr);
147 itsImageQueue.push(img);
148 LDEBUG(
"Empty image " << img.
bufindex <<
" ready for filling in by application code");
163 #else // JEVOIS_PLATFORM_A33
168 itsImageQueue(nbufs), itsName(displayname)
169 {
LFATAL(
"VideoDisplay is not supported on JeVois hardware platform"); }
172 {
LERROR(
"VideoDisplay is not supported on JeVois hardware platform"); }
175 {
LFATAL(
"VideoDisplay is not supported on JeVois hardware platform"); }
178 {
LFATAL(
"VideoDisplay is not supported on JeVois hardware platform"); }
181 {
LFATAL(
"VideoDisplay is not supported on JeVois hardware platform"); }
184 {
LFATAL(
"VideoDisplay is not supported on JeVois hardware platform"); }
187 {
LFATAL(
"VideoDisplay is not supported on JeVois hardware platform"); }
190 {
LFATAL(
"VideoDisplay is not supported on JeVois hardware platform"); }
192 #endif // JEVOIS_PLATFORM_A33