JeVois  1.0
JeVois Smart Embedded Machine Vision Toolkit
jevois-module-param.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/Debug/Log.H>
20 #include <fstream>
21 #include <iostream>
22 
23 //! Parse videomappings.cfg and output a string to be passed to the jevois kernel module
24 /*! This little app was created so that we ensure perfect consistency between the kernel driver and the user code by
25  using exactly the same config file parsing and sorting code (in VideoMapping). */
26 int main()
27 {
28  jevois::logLevel = LOG_CRIT;
29 
30  // Parse the videomappings.cfg file and create the mappings:
31  size_t defidx;
32  std::ifstream ifs(JEVOIS_ENGINE_CONFIG_FILE);
33  if (ifs.is_open() == false) LFATAL("Could not open [" << JEVOIS_ENGINE_CONFIG_FILE << ']');
34  std::vector<jevois::VideoMapping> mappings = jevois::videoMappingsFromStream(ifs, defidx);
35 
36  // First, the default index (0-based), but we need to skip over the no-usb mappings:
37  size_t uvcdefidx = 0;
38  for (size_t i = 0; i <= defidx; ++i) if (mappings[i].ofmt != 0) ++uvcdefidx;
39  if (uvcdefidx == 0) LFATAL("No mappings with UVC output?");
40  std::cout << (uvcdefidx - 1); // FIXME: the kernel is actually not using the default index
41 
42  // Then each format, grouping by video fcc and framerates:
43  unsigned int ofmt = ~0U, ow = ~0U, oh = ~0u;
44  for (jevois::VideoMapping const & m : mappings)
45  {
46  if (m.ofmt == 0) { ofmt = 0; continue; } // skip over the no-USB mappings
47  if (m.ofmt != ofmt) { std::cout << '/' << m.ofmt; ofmt = m.ofmt; ow = ~0U; oh = ~0U; }
48  if (m.ow != ow || m.oh != oh) { std::cout << '-' << m.ow << 'x' << m.oh; ow = m.ow; oh = m.oh; }
49  std::cout << ':' << jevois::VideoMapping::fpsToUvc(m.ofps);
50  }
51  std::cout << std::endl;
52 
53  return 0;
54 }
55 
Simple struct to hold video mapping definitions for the processing Engine.
Definition: VideoMapping.H:41
int logLevel
Current log level.
Definition: Log.C:26
#define LFATAL(msg)
Convenience macro for users to print out console or syslog messages, FATAL level. ...
Definition: Log.H:205
int main()
Parse videomappings.cfg and output a string to be passed to the jevois kernel module.
static unsigned int fpsToUvc(float fps)
Convert from fps to USB/UVC interval.
Definition: VideoMapping.C:66