JeVoisBase  1.5
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
JeVoisIntro.C
Go to the documentation of this file.
1 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 //
3 // JeVois Smart Embedded Machine Vision Toolkit - Copyright (C) 2016 by Laurent Itti, the University of Southern
4 // California (USC), and iLab at USC. See http://iLab.usc.edu and http://jevois.org for information about this project.
5 //
6 // This file is part of the JeVois Smart Embedded Machine Vision Toolkit. This program is free software; you can
7 // redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
8 // Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
10 // License for more details. You should have received a copy of the GNU General Public License along with this program;
11 // if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12 //
13 // Contact information: Laurent Itti - 3641 Watt Way, HNB-07A - Los Angeles, CA 90089-2520 - USA.
14 // Tel: +1 213 740 3527 - itti@pollux.usc.edu - http://iLab.usc.edu - http://jevois.org
15 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16 /*! \file */
17 
18 #include <jevois/Core/Module.H>
19 
20 #include <jevois/Debug/Log.H>
21 #include <jevois/Debug/Timer.H>
28 
29 #include <opencv2/core/core.hpp>
30 #include <opencv2/imgproc/imgproc.hpp>
31 #include <linux/videodev2.h> // for v4l2 pixel types
32 //#include <opencv2/highgui/highgui.hpp> // used for debugging only, see imshow below
33 
34 // icon by Freepik in interface at flaticon
35 
36 struct ScriptItem { char const * msg; int blinkx, blinky; };
37 static ScriptItem const TheScript[] = {
38  { "Hello! Welcome to this simple demonstration of JeVois", 0, 0 },
39  { "JeVois = camera sensor + quad-core processor + USB video output", 0, 0 },
40  { "This demo is running on the small processor inside JeVois", 0, 0 },
41  { "Neat, isn't it?", 0, 0 },
42  { "", 0, 0 },
43  { "We will help you discover what you see on this screen", 0, 0 },
44  { "We will use this blinking marker to point at things:", 600, 335 },
45  { "", 0, 0 },
46  { "Now a brief tutorial...", 0, 0 },
47  { "", 0, 0 },
48  { "This demo: Attention + Gist + Faces + Objects", 0, 0 },
49  { "Attention: detect things that catch the human eye", 0, 0 },
50  { "Pink square in video above: most interesting (salient) location", 0, 0 },
51  { "Green circle in video above: smoothed attention trajectory", 0, 0 },
52  { "Try it: wave at JeVois, show it some objects, move it around", 0, 0 },
53  { "", 0, 0 },
54  { "Did you catch the attention of JeVois?", 0, 0 },
55  { "", 0, 0 },
56  { "Attention is guided by color contrast, ...", 40, 270 },
57  { "by luminance (intensity) contrast, ...", 120, 270 },
58  { "by oriented edges, ...", 200, 270 },
59  { "by flickering or blinking lights, ...", 280, 270 },
60  { "and by moving objects.", 360, 270 },
61  { "All these visual cues combine into a measure of saliency", 480, 120 },
62  { "or visual interest for every location in view.", 480, 120 },
63  { "", 0, 0 },
64  { "", 0, 0 },
65  { "Gist: statistical summary of a scene, also based on ...", 440, 270 },
66  { "color, intensity, orientation, flicker and motion features.", 0, 0 },
67  { "Gist can be used to recognize places, such as a kitchen or ...", 0, 0 },
68  { "a bathroom, or a road turning left versus turning right.", 0, 0 },
69  { "Try it: point JeVois to different things and see gist change", 440, 270 },
70  { "", 0, 0 },
71  { "", 0, 0 },
72  { "Face detection finds human faces in the camera's view", 612, 316 },
73  { "Try it: point JeVois towards a face. Adjust distance until ...", 612, 316 },
74  { "the face fits inside the attention pink square. When a face ...", 0, 0 },
75  { "is detected, it will appear in the bottom-right corner.", 612, 316 },
76  { "You may have to move a bit farther than arm's length for ...", 0, 0 },
77  { "your face to fit inside the attention pink square.", 0, 0 },
78  { "", 0, 0 },
79  { "", 0, 0 },
80  { "Objects: Here we recognize handwritten digits using ...", 525, 316 },
81  { "deep neural networks. Try it! Draw a number on paper ...", 0, 0 },
82  { "and point JeVois towards it. Adjust distance until the", 0, 0 },
83  { "number fits in the attention pink square.", 0, 0 },
84  { "", 0, 0 },
85  { "Recognized digits are shown near the detected faces.", 525, 316 },
86  { "", 0, 0 },
87  { "If your number is too small, too big, or not upright ...", 0, 0 },
88  { "keep adjusting the distance and angle of the camera.", 0, 0 },
89  { "", 0, 0 },
90  { "Recognition scores for digits 0 to 9 are shown above.", 464, 310 },
91  { "Sometimes the neural network makes mistakes and thinks it ...", 0, 0 },
92  { "found a digit when actually it is looking at something else.", 0, 0 },
93  { "This is still a research issue", 0, 0 },
94  { "but machine vision is improving fast, so stay tuned!", 0, 0 },
95  { "", 0, 0 },
96  { "With JeVois the future of machine vision is in your hands.", 0, 0 },
97  { "", 0, 0 },
98  { "", 0, 0 },
99  { "", 0, 0 },
100  { "This tutorial is now complete. It will restart.", 0, 0 },
101  { "", 0, 0 },
102  { nullptr, 0, 0 }
103 };
104 
105 //! Simple introduction to JeVois and demo that combines saliency, gist, face detection, and object recognition
106 /*! This module plays an introduction movie, and then launches the equivalent of the \jvmod{DemoSalGistFaceObj} module,
107  but with some added text messages that explain what is going on, on the screen.
108 
109  Try it and follow the instructions on screen!
110 
111  @author Laurent Itti
112 
113  @displayname JeVois Intro
114  @videomapping YUYV 640 360 50.0 YUYV 320 240 50.0 JeVois JeVoisIntro
115  @videomapping YUYV 640 480 50.0 YUYV 320 240 50.0 JeVois JeVoisIntro
116  @email itti\@usc.edu
117  @address University of Southern California, HNB-07A, 3641 Watt Way, Los Angeles, CA 90089-2520, USA
118  @copyright Copyright (C) 2016 by Laurent Itti, iLab and the University of Southern California
119  @mainurl http://jevois.org
120  @supporturl http://jevois.org/doc
121  @otherurl http://iLab.usc.edu
122  @license GPL v3
123  @distribution Unrestricted
124  @restrictions None
125  \ingroup modules */
127 {
128  public:
129  //! Constructor
130  JeVoisIntro(std::string const & instance) : jevois::StdModule(instance), itsScoresStr(" ")
131  {
132  itsSaliency = addSubComponent<Saliency>("saliency");
133  itsFaceDetector = addSubComponent<FaceDetector>("facedetect");
134  itsObjectRecognition = addSubComponent<ObjectRecognitionMNIST>("MNIST");
135  itsKF = addSubComponent<Kalman2D>("kalman");
136  itsVideo = addSubComponent<BufferedVideoReader>("intromovie");
137  }
138 
139  //! Virtual destructor for safe inheritance
140  virtual ~JeVoisIntro() { }
141 
142  //! Initialization once parameters are set:
143  virtual void postInit() override
144  {
145  // Read the banner image and convert to YUYV RawImage:
146  cv::Mat banner_bgr = cv::imread(absolutePath("jevois-banner-notext.png"));
147  itsBanner.width = banner_bgr.cols;
148  itsBanner.height = banner_bgr.rows;
149  itsBanner.fmt = V4L2_PIX_FMT_YUYV;
150  itsBanner.bufindex = 0;
151  itsBanner.buf.reset(new jevois::VideoBuf(-1, itsBanner.bytesize(), 0));
152  jevois::rawimage::convertCvBGRtoRawImage(banner_bgr, itsBanner, 100);
153 
154  // Allow our movie to load a bit:
155  std::this_thread::sleep_for(std::chrono::milliseconds(750));
156  }
157 
158  //! Processing function
159  virtual void process(jevois::InputFrame && inframe, jevois::OutputFrame && outframe) override
160  {
161  static jevois::Timer itsProcessingTimer("Processing");
162  static cv::Mat itsLastFace(60, 60, CV_8UC2, 0x80aa) ; // Note that this one will contain raw YUV pixels
163  static cv::Mat itsLastObject(60, 60, CV_8UC2, 0x80aa) ; // Note that this one will contain raw YUV pixels
164  static std::string itsLastObjectCateg;
165  static bool doobject = false; // alternate between object and face recognition
166  static bool intromode = false; // intro mode plays a video at the beginning, then shows some info messages
167  static bool intromoviedone = false; // turns true when intro movie complete
168  static ScriptItem const * scriptitem = &TheScript[0];
169  static int scriptframe = 0;
170 
171  // Wait for next available camera image:
172  jevois::RawImage inimg = inframe.get();
173 
174  // We only handle one specific input format in this demo:
175  inimg.require("input", 320, 240, V4L2_PIX_FMT_YUYV);
176 
177  itsProcessingTimer.start();
178  int const roihw = 32; // face & object roi half width and height
179 
180  // Compute saliency, in a thread:
181  auto sal_fut = std::async(std::launch::async, [&](){ itsSaliency->process(inimg, true); });
182 
183  // While computing, wait for an image from our gadget driver into which we will put our results:
184  jevois::RawImage outimg = outframe.get();
185  outimg.require("output", 640, outimg.height, V4L2_PIX_FMT_YUYV);
186  switch (outimg.height)
187  {
188  case 312: break; // normal mode
189  case 360:
190  case 480: intromode = true; break; // intro mode
191  default: LFATAL("Incorrect output height: should be 312, 360 or 480");
192  }
193 
194  // Play the intro movie first if requested:
195  if (intromode && intromoviedone == false)
196  {
197  cv::Mat m = itsVideo->get();
198 
199  if (m.empty()) intromoviedone = true;
200  else
201  {
203 
204  // Handle bottom of th eframe: blank or banner
205  if (outimg.height == 480)
206  jevois::rawimage::paste(itsBanner, outimg, 0, 360);
207  else if (outimg.height > 360)
208  jevois::rawimage::drawFilledRect(outimg, 0, 360, outimg.width, outimg.height - 360, 0x8000);
209 
210  // If on a mac with height = 480, need to flip horizontally for photobooth to work (it will flip again):
211  if (outimg.height == 480) jevois::rawimage::hFlipYUYV(outimg);
212 
213  sal_fut.get(); // yes, we are wasting CPU here, just to keep code more readable with the intro stuff added
214  inframe.done();
215  outframe.send();
216  return;
217  }
218  }
219 
220  // Paste the original image to the top-left corner of the display:
221  unsigned short const txtcol = jevois::yuyv::White;
222  jevois::rawimage::paste(inimg, outimg, 0, 0);
223  jevois::rawimage::writeText(outimg, "JeVois Saliency + Gist + Faces + Objects", 3, 3, txtcol);
224 
225  // Wait until saliency computation is complete:
226  sal_fut.get();
227 
228  // find most salient point:
229  int mx, my; intg32 msal;
230  itsSaliency->getSaliencyMax(mx, my, msal);
231 
232  // Scale back to original image coordinates:
233  int const smlev = itsSaliency->smscale::get();
234  int const smadj = smlev > 0 ? (1 << (smlev-1)) : 0; // half a saliency map pixel adjustment
235  int const dmx = (mx << smlev) + smadj;
236  int const dmy = (my << smlev) + smadj;
237 
238  // Compute instantaneous attended ROI (note: coords must be even to avoid flipping U/V when we later paste):
239  int const rx = std::min(int(inimg.width) - roihw, std::max(roihw, dmx));
240  int const ry = std::min(int(inimg.height) - roihw, std::max(roihw, dmy));
241 
242  // Asynchronously launch a bunch of saliency drawings and filter the attended locations
243  auto draw_fut =
244  std::async(std::launch::async, [&]() {
245  // Paste the various saliency results:
246  drawMap(outimg, &itsSaliency->salmap, 320, 0, 16, 20);
247  jevois::rawimage::writeText(outimg, "Saliency Map", 640 - 12*6-4, 3, txtcol);
248 
249  drawMap(outimg, &itsSaliency->color, 0, 240, 4, 18);
250  jevois::rawimage::writeText(outimg, "Color", 3, 243, txtcol);
251 
252  drawMap(outimg, &itsSaliency->intens, 80, 240, 4, 18);
253  jevois::rawimage::writeText(outimg, "Intensity", 83, 243, txtcol);
254 
255  drawMap(outimg, &itsSaliency->ori, 160, 240, 4, 18);
256  jevois::rawimage::writeText(outimg, "Orientation", 163, 243, txtcol);
257 
258  drawMap(outimg, &itsSaliency->flicker, 240, 240, 4, 18);
259  jevois::rawimage::writeText(outimg, "Flicker", 243, 243, txtcol);
260 
261  drawMap(outimg, &itsSaliency->motion, 320, 240, 4, 18);
262  jevois::rawimage::writeText(outimg, "Motion", 323, 243, txtcol);
263 
264  // Draw the gist vector:
265  drawGist(outimg, itsSaliency->gist, itsSaliency->gist_size, 400, 242, 40, 2);
266 
267  // Draw a small square at most salient location in image and in saliency map:
268  jevois::rawimage::drawFilledRect(outimg, mx * 16 + 5, my * 16 + 5, 8, 8, 0xffff);
269  jevois::rawimage::drawFilledRect(outimg, 320 + mx * 16 + 5, my * 16 + 5, 8, 8, 0xffff);
270  jevois::rawimage::drawRect(outimg, rx - roihw, ry - roihw, roihw*2, roihw*2, 0xf0f0);
271  jevois::rawimage::drawRect(outimg, rx - roihw+1, ry - roihw+1, roihw*2-2, roihw*2-2, 0xf0f0);
272 
273  // Blank out free space from 480 to 519 at the bottom, and small space above and below gist vector:
274  jevois::rawimage::drawFilledRect(outimg, 480, 240, 40, 60, 0x8000);
275  jevois::rawimage::drawRect(outimg, 400, 240, 80, 2, 0x80a0);
276  jevois::rawimage::drawRect(outimg, 400, 298, 80, 2, 0x80a0);
277  jevois::rawimage::drawFilledRect(outimg, 0, 300, 640, 12, jevois::yuyv::Black);
278 
279  // If intro mode, blank out rows 312 to bottom:
280  if (outimg.height == 480)
281  {
282  jevois::rawimage::drawFilledRect(outimg, 0, 312, outimg.width, 48, 0x8000);
283  jevois::rawimage::paste(itsBanner, outimg, 0, 360);
284  }
285  else if (outimg.height > 312)
286  jevois::rawimage::drawFilledRect(outimg, 0, 312, outimg.width, outimg.height - 312, 0x8000);
287 
288  // Filter the attended locations:
289  itsKF->set(dmx, dmy, inimg.width, inimg.height);
290  float kfxraw, kfyraw, kfximg, kfyimg;
291  itsKF->get(kfxraw, kfyraw, kfximg, kfyimg, inimg.width, inimg.height, 1.0F, 1.0F);
292 
293  // Draw a circle around the kalman-filtered attended location:
294  jevois::rawimage::drawCircle(outimg, int(kfximg), int(kfyimg), 20, 1, jevois::yuyv::LightGreen);
295 
296  // Send saliency info to serial port (for arduino, etc):
297  sendSerialImg2D(inimg.width, inimg.height, kfximg, kfyimg, roihw * 2, roihw * 2, "salient");
298 
299  // If intro mode, draw some text messages according to our script:
300  if (intromode && intromoviedone)
301  {
302  // Compute fade: we do 1s fade in, 2s full luminance, 1s fade out:
303  int lum = 255;
304  if (scriptframe < 32) lum = scriptframe * 8;
305  else if (scriptframe > 4*30 - 32) lum = std::max(0, (4*30 - scriptframe) * 8);
306 
307  // Display the text with the proper fade:
308  int x = (640 - 10 * strlen(scriptitem->msg)) / 2;
309  jevois::rawimage::writeText(outimg, scriptitem->msg, x, 325, 0x7700 | lum, jevois::rawimage::Font10x20);
310 
311  // Add a blinking marker if specified in the script:
312  if (scriptitem->blinkx)
313  {
314  int phase = scriptframe / 10;
315  if ((phase % 2) == 0) jevois::rawimage::drawDisk(outimg, scriptitem->blinkx, scriptitem->blinky,
316  10, jevois::yuyv::LightTeal);
317  }
318 
319  // Move to next video frame and possibly next script item or loop the script:
320  if (++scriptframe >= 140)
321  {
322  scriptframe = 0; ++scriptitem;
323  if (scriptitem->msg == nullptr) scriptitem = &TheScript[0];
324  }
325  }
326  });
327 
328  // Extract a raw YUYV ROI around attended point:
329  cv::Mat rawimgcv = jevois::rawimage::cvImage(inimg);
330  cv::Mat rawroi = rawimgcv(cv::Rect(rx - roihw, ry - roihw, roihw * 2, roihw * 2));
331 
332  if (doobject)
333  {
334  // #################### Object recognition:
335 
336  // Prepare a color or grayscale ROI for the object recognition module:
337  auto objsz = itsObjectRecognition->insize();
338  cv::Mat objroi;
339  switch (objsz.depth_)
340  {
341  case 1: // grayscale input
342  {
343  // mnist is white letters on black background, so invert the image before we send it for recognition, as we
344  // assume here black letters on white backgrounds. We also need to provide a clean crop around the digit for
345  // the deep network to work well:
346  cv::cvtColor(rawroi, objroi, CV_YUV2GRAY_YUYV);
347 
348  // Find the 10th percentile gray value:
349  size_t const elem = (objroi.cols * objroi.rows * 10) / 100;
350  std::vector<unsigned char> v; v.assign(objroi.datastart, objroi.dataend);
351  std::nth_element(v.begin(), v.begin() + elem, v.end());
352  unsigned char const thresh = std::min((unsigned char)(100), std::max((unsigned char)(30), v[elem]));
353 
354  // Threshold and invert the image:
355  cv::threshold(objroi, objroi, thresh, 255, cv::THRESH_BINARY_INV);
356 
357  // Find the digit and center and crop it:
358  cv::Mat pts; cv::findNonZero(objroi, pts);
359  cv::Rect r = cv::boundingRect(pts);
360  int const cx = r.x + r.width / 2;
361  int const cy = r.y + r.height / 2;
362  int const siz = std::min(roihw * 2, std::max(16, 8 + std::max(r.width, r.height))); // margin of 4 pix
363  int const tlx = std::max(0, std::min(roihw*2 - siz, cx - siz/2));
364  int const tly = std::max(0, std::min(roihw*2 - siz, cy - siz/2));
365  cv::Rect ar(tlx, tly, siz, siz);
366  cv::resize(objroi(ar), objroi, cv::Size(objsz.width_, objsz.height_), 0, 0, cv::INTER_AREA);
367  //cv::imshow("cropped roi", objroi);cv::waitKey(1);
368  }
369  break;
370 
371  case 3: // color input
372  cv::cvtColor(rawroi, objroi, CV_YUV2RGB_YUYV);
373  cv::resize(objroi, objroi, cv::Size(objsz.width_, objsz.height_), 0, 0, cv::INTER_AREA);
374  break;
375 
376  default:
377  LFATAL("Unsupported object detection input depth " << objsz.depth_);
378  }
379 
380  // Launch object recognition on the ROI and get the recognition scores:
381  auto scores = itsObjectRecognition->process(objroi);
382 
383  // Create a string to show all scores:
384  std::ostringstream oss;
385  for (size_t i = 0; i < scores.size(); ++i)
386  oss << itsObjectRecognition->category(i) << ':' << std::fixed << std::setprecision(2) << scores[i] << ' ';
387  itsScoresStr = oss.str();
388 
389  // Check whether the highest score is very high and significantly higher than the second best:
390  float best1 = scores[0], best2 = scores[0]; size_t idx1 = 0, idx2 = 0;
391  for (size_t i = 1; i < scores.size(); ++i)
392  {
393  if (scores[i] > best1) { best2 = best1; idx2 = idx1; best1 = scores[i]; idx1 = i; }
394  else if (scores[i] > best2) { best2 = scores[i]; idx2 = i; }
395  }
396 
397  // Update our display upon each "clean" recognition:
398  if (best1 > 90.0F && best2 < 20.0F)
399  {
400  // Remember this recognized object for future displays:
401  itsLastObjectCateg = itsObjectRecognition->category(idx1);
402  itsLastObject = rawimgcv(cv::Rect(rx - 30, ry - 30, 60, 60)).clone(); // make a deep copy
403 
404  LINFO("Object recognition: best: " << itsLastObjectCateg <<" (" << best1 <<
405  "), second best: " << itsObjectRecognition->category(idx2) << " (" << best2 << ')');
406  }
407  }
408  else
409  {
410  // #################### Face detection:
411 
412  // Prepare a grey ROI from our raw YUYV roi:
413  cv::Mat grayroi; cv::cvtColor(rawroi, grayroi, CV_YUV2GRAY_YUYV);
414  cv::equalizeHist(grayroi, grayroi);
415 
416  // Launch the face detector:
417  std::vector<cv::Rect> faces; std::vector<std::vector<cv::Rect> > eyes;
418  itsFaceDetector->process(grayroi, faces, eyes, false);
419 
420  // Draw the faces and eyes, if any:
421  if (faces.size())
422  {
423  LINFO("detected " << faces.size() << " faces");
424  // Store the attended ROI into our last ROI, fixed size 60x60 for our display:
425  itsLastFace = rawimgcv(cv::Rect(rx - 30, ry - 30, 60, 60)).clone(); // make a deep copy
426  }
427 
428  for (size_t i = 0; i < faces.size(); ++i)
429  {
430  // Draw one face:
431  cv::Rect const & f = faces[i];
432  jevois::rawimage::drawRect(outimg, f.x + rx - roihw, f.y + ry - roihw, f.width, f.height, 0xc0ff);
433 
434  // Draw the corresponding eyes:
435  for (auto const & e : eyes[i])
436  jevois::rawimage::drawRect(outimg, e.x + rx - roihw, e.y + ry - roihw, e.width, e.height, 0x40ff);
437  }
438  }
439 
440  // Let camera know we are done processing the raw YUV input image. NOTE: rawroi is now invalid:
441  inframe.done();
442 
443  // Paste our last attended and recognized face and object (or empty pics):
444  cv::Mat outimgcv(outimg.height, outimg.width, CV_8UC2, outimg.buf->data());
445  itsLastObject.copyTo(outimgcv(cv::Rect(520, 240, 60, 60)));
446  itsLastFace.copyTo(outimgcv(cv::Rect(580, 240, 60, 60)));
447 
448  // Wait until all saliency drawings are complete (since they blank out our object label area):
449  draw_fut.get();
450 
451  // Print all object scores:
452  jevois::rawimage::writeText(outimg, itsScoresStr, 2, 301, txtcol);
453 
454  // Write any positively recognized object category:
455  jevois::rawimage::writeText(outimg, itsLastObjectCateg.c_str(), 517-6*itsLastObjectCateg.length(), 263, txtcol);
456 
457  // FIXME do svm on gist and write resuts here
458 
459  // Show processing fps:
460  std::string const & fpscpu = itsProcessingTimer.stop();
461  jevois::rawimage::writeText(outimg, fpscpu, 3, 240 - 13, jevois::yuyv::White);
462 
463  // If on a mac with height = 480, need to flip horizontally for photobooth to work (it will flip again):
464  if (outimg.height == 480) jevois::rawimage::hFlipYUYV(outimg);
465 
466  // Send the output image with our processing results to the host over USB:
467  outframe.send();
468 
469  // Alternate between face and object recognition:
470  doobject = ! doobject;
471  }
472 
473  protected:
474  std::shared_ptr<Saliency> itsSaliency;
475  std::shared_ptr<FaceDetector> itsFaceDetector;
476  std::shared_ptr<ObjectRecognitionBase> itsObjectRecognition;
477  std::shared_ptr<Kalman2D> itsKF;
478  std::shared_ptr<BufferedVideoReader> itsVideo;
480  std::string itsScoresStr;
481 };
482 
483 // Allow the module to be loaded as a shared object (.so) file:
jevois::RawImage itsBanner
Definition: JeVoisIntro.C:479
std::shared_ptr< FaceDetector > itsFaceDetector
Definition: JeVoisIntro.C:475
cv::Mat cvImage(RawImage const &src)
std::string itsScoresStr
Definition: JeVoisIntro.C:480
void drawCircle(RawImage &img, int x, int y, unsigned int rad, unsigned int thick, unsigned int col)
void writeText(RawImage &img, std::string const &txt, int x, int y, unsigned int col, Font font=Font6x10)
unsigned int height
char const * msg
Definition: JeVoisIntro.C:36
JeVoisIntro(std::string const &instance)
Constructor.
Definition: JeVoisIntro.C:130
std::shared_ptr< BufferedVideoReader > itsVideo
Definition: JeVoisIntro.C:478
void drawGist(jevois::RawImage &img, unsigned char const *gist, size_t gistsize, unsigned int xoff, unsigned int yoff, unsigned int width, unsigned int scale)
Definition: Saliency.C:771
std::shared_ptr< ObjectRecognitionBase > itsObjectRecognition
Definition: JeVoisIntro.C:476
virtual void postInit() override
Initialization once parameters are set:
Definition: JeVoisIntro.C:143
std::shared_ptr< Saliency > itsSaliency
Definition: JeVoisIntro.C:474
void hFlipYUYV(RawImage &img)
void drawMap(jevois::RawImage &img, env_image const *fmap, unsigned int xoff, unsigned int yoff, unsigned int scale)
Definition: Saliency.C:709
Simple introduction to JeVois and demo that combines saliency, gist, face detection, and object recognition.
Definition: JeVoisIntro.C:126
void convertCvBGRtoRawImage(cv::Mat const &src, RawImage &dst, int quality)
std::string const & stop()
std::shared_ptr< Kalman2D > itsKF
Definition: JeVoisIntro.C:477
#define LFATAL(msg)
ENV_INTG32_TYPE intg32
32-bit signed integer
Definition: env_types.h:52
JEVOIS_REGISTER_MODULE(JeVoisIntro)
void drawFilledRect(RawImage &img, int x, int y, unsigned int w, unsigned int h, unsigned int col)
virtual void process(jevois::InputFrame &&inframe, jevois::OutputFrame &&outframe) override
Processing function.
Definition: JeVoisIntro.C:159
virtual ~JeVoisIntro()
Virtual destructor for safe inheritance.
Definition: JeVoisIntro.C:140
#define LINFO(msg)
void drawDisk(RawImage &img, int x, int y, unsigned int rad, unsigned int col)
void drawRect(RawImage &img, int x, int y, unsigned int w, unsigned int h, unsigned int thick, unsigned int col)
unsigned int width
void paste(RawImage const &src, RawImage &dest, int dx, int dy)
void require(char const *info, unsigned int w, unsigned int h, unsigned int f) const