21 #include <opencv2/core/core.hpp>
22 #include <opencv2/imgproc/imgproc.hpp>
31 "This is the size of the central image crop that is taken in each frame and fed to the "
32 "deep neural network. If the foa size does not fit within the camera input frame size, "
33 "it will be shrunk to fit. To avoid spending CPU resources on rescaling the selected "
34 "image region, it is best to use here the size that the deep network expects as input.",
35 cv::Size(128, 128), ParamCateg);
155 public jevois::Parameter<foa>
182 cv::Size foasiz = foa::get();
int foaw = foasiz.width, foah = foasiz.height;
183 if (foaw >
w) { foaw =
w; foah = std::min(foah, foaw); }
184 if (foah >
h) { foah =
h; foaw = std::min(foaw, foah); }
187 int const offx = ((
w - foaw) / 2) & (~1);
188 int const offy = ((
h - foah) / 2) & (~1);
191 cv::Mat crop = cvimg(cv::Rect(offx, offy, foaw, foah));
194 cv::Mat rgbroi; cv::cvtColor(crop, rgbroi, cv::COLOR_YUV2RGB_YUYV);
203 int netinw, netinh, netinc;
itsTensorFlow->getInDims(netinw, netinh, netinc);
210 LINFO(
"Predicted in " << ptime <<
"ms");
215 catch (std::logic_error
const & e) { }
232 inimg.
require(
"input",
w,
h, V4L2_PIX_FMT_YUYV);
235 cv::Size foasiz = foa::get();
int foaw = foasiz.width, foah = foasiz.height;
236 if (foaw >
w) { foaw =
w; foah = std::min(foah, foaw); }
237 if (foah >
h) { foah =
h; foaw = std::min(foaw, foah); }
238 int const offx = ((
w - foaw) / 2) & (~1);
239 int const offy = ((
h - foah) / 2) & (~1);
244 outimg = outframe.get();
245 outimg.
require(
"output", outimg.
width,
h + 68, V4L2_PIX_FMT_YUYV);
260 cv::Mat crop = cvimg(cv::Rect(offx, offy, foaw, foah));
263 cv::Mat rgbroi; cv::cvtColor(crop, rgbroi, cv::COLOR_YUV2RGB_YUYV);
266 paste_fut.get(); inframe.done();
272 int netinw, netinh, netinc;
itsTensorFlow->getInDims(netinw, netinh, netinc);
282 w - 7 * 6 - 2,
h + 16, jevois::yuyv::White);
284 w - 7 * 6 - 2,
h + 28, jevois::yuyv::White);
286 w - 7 * 6 - 2,
h + 40, jevois::yuyv::White);
291 catch (std::logic_error
const & e)
304 3, y, jevois::yuyv::White);
309 std::string
const & fpscpu = timer.
stop();