21 #include <opencv2/core/core.hpp>
22 #include <opencv2/imgproc/imgproc.hpp>
130 itsDarknet = addSubComponent<Darknet>(
"darknet");
157 int netw, neth, netc;
158 try {
itsDarknet->getInDims(netw, neth, netc); }
159 catch (std::logic_error
const & e) { inframe.done();
return; }
161 if (netw >
w) netw =
w;
162 if (neth >
h) neth =
h;
165 int const offx = ((
w - netw) / 2) & (~1);
166 int const offy = ((
h - neth) / 2) & (~1);
169 cv::Mat crop = cvimg(cv::Rect(offx, offy, netw, neth));
172 cv::cvtColor(crop,
itsCvImg, cv::COLOR_YUV2RGB_YUYV);
179 LINFO(
"Predicted in " << ptime <<
"ms");
199 inimg.
require(
"input",
w,
h, V4L2_PIX_FMT_YUYV);
204 outimg = outframe.get();
217 jevois::rawimage::drawFilledRect(outimg, w, 0, outimg.width - w, h, jevois::yuyv::Black);
218 jevois::rawimage::writeText(outimg,
"Loading network -", w + 3, 3, jevois::yuyv::White);
219 jevois::rawimage::writeText(outimg,
"please wait...", w + 3, 15, jevois::yuyv::White);
228 if (
itsPredictFut.wait_for(std::chrono::milliseconds(5)) == std::future_status::ready)
232 bool success =
true;
float ptime = 0.0F;
236 paste_fut.get(); inframe.done();
249 int y = neth + 3;
if (y +
int(
itsDarknet->top::get()) * 12 >
h - 21) y = 3;
254 w + 3, y, jevois::yuyv::White);
263 w + 3,
h - 11, jevois::yuyv::White);
275 paste_fut.get(); inframe.done();
284 if (outimg.
width < inimg.
width)
LFATAL(
"USB output image must be larger than camera input");
286 int const neth = netw;
289 if (netw >
w || neth >
h)
LFATAL(
"Network input window must fit within camera frame");
292 int const offx = ((
w - netw) / 2) & (~1);
293 int const offy = ((
h - neth) / 2) & (~1);
295 cv::Mat crop = cvimg(cv::Rect(offx, offy, netw, neth));
298 cv::cvtColor(crop,
itsCvImg, cv::COLOR_YUV2RGB_YUYV);
309 int netinw, netinh, netinc;
itsDarknet->getInDims(netinw, netinh, netinc);
316 std::string
const & fpscpu = timer.
stop();