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