JeVois  1.22
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
Loading...
Searching...
No Matches
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 <sstream>
22#include <iostream>
23#include <memory>
24
25//! Parse videomappings.cfg and output a string to be passed to the jevois kernel module
26/*! This little app was created so that we ensure perfect consistency between the kernel driver and the user code by
27 using exactly the same config file parsing and sorting code (in VideoMapping). */
28int main(int argc, char const * argv[])
29{
30 jevois::logLevel = LOG_CRIT;
31
32 if (argc != 2) LFATAL("USAGE: " << argv[0] << " <sensor>");
33
34 std::unique_ptr<std::istream> iss(new std::istringstream(std::string(argv[1])));
35 jevois::CameraSensor sens; (*iss) >> sens;
36
37 // Parse the videomappings.cfg file and create the mappings:
38 size_t defidx;
39 std::ifstream ifs(JEVOIS_ENGINE_CONFIG_FILE);
40 if (ifs.is_open() == false) LFATAL("Could not open [" << JEVOIS_ENGINE_CONFIG_FILE << ']');
41 std::vector<jevois::VideoMapping> mappings = jevois::videoMappingsFromStream(sens, ifs, defidx, true,
42#ifdef JEVOIS_PRO
43 true
44#else
45 false
46#endif
47 );
48
49 // First, the default index (0-based), but we need to skip over the no-usb mappings:
50 size_t uvcdefidx = 0;
51 for (size_t i = 0; i <= defidx; ++i) if (mappings[i].ofmt != 0) ++uvcdefidx;
52 if (uvcdefidx == 0) LFATAL("No mappings with UVC output?");
53 std::cout << (uvcdefidx - 1); // FIXME: the kernel is actually not using the default index
54
55 // Then each format, grouping by video fcc and framerates:
56 unsigned int ofmt = ~0U, ow = ~0U, oh = ~0u;
57 for (jevois::VideoMapping const & m : mappings)
58 {
59 if (m.ofmt == 0) { ofmt = 0; continue; } // skip over the no-USB mappings
60 if (m.ofmt != ofmt) { std::cout << '/' << m.ofmt; ofmt = m.ofmt; ow = ~0U; oh = ~0U; }
61 if (m.ow != ow || m.oh != oh) { std::cout << '-' << m.ow << 'x' << m.oh; ow = m.ow; oh = m.oh; }
62 std::cout << ':' << jevois::VideoMapping::fpsToUvc(m.ofps);
63 }
64 std::cout << std::endl;
65
66 // Terminate logger:
68
69 return 0;
70}
71
#define JEVOIS_ENGINE_CONFIG_FILE
Location of the engine videomappings.cfg definition file.
Definition Config.H:94
int logLevel
Current log level.
Definition Log.C:29
#define LFATAL(msg)
Convenience macro for users to print out console or syslog messages, FATAL level.
Definition Log.H:230
int main(int argc, char const *argv[])
Parse videomappings.cfg and output a string to be passed to the jevois kernel module.
void logEnd()
Terminate log service.
Definition Log.C:145
Simple struct to hold video mapping definitions for the processing Engine.
static unsigned int fpsToUvc(float fps)
Convert from fps to USB/UVC interval.