JeVois
1.20
JeVois Smart Embedded Machine Vision Toolkit
|
Share this page: |
|
|
|
|
|
|
Go to the documentation of this file.
34 #ifdef JEVOIS_PLATFORM
36 #if defined(JEVOIS_A33)
43 #define JEVOIS_CAMERA_DEFAULT "/dev/video0"
46 #define JEVOIS_GADGET_DEFAULT "/dev/video1"
49 #define JEVOIS_SERIAL_DEFAULT "/dev/ttyS0"
52 #define JEVOIS_USBSERIAL_DEFAULT "/dev/ttyGS0"
55 #define JEVOIS_CAMERASENS_DEFAULT CameraSensor::ov9650
58 #define JEVOIS_IMUSPI_DEFAULT ""
60 #elif defined(JEVOIS_PRO)
67 #define JEVOIS_CAMERA_DEFAULT "/dev/video0"
70 #define JEVOIS_GADGET_DEFAULT ""
73 #define JEVOIS_SERIAL_DEFAULT "/dev/ttyS4"
76 #define JEVOIS_USBSERIAL_DEFAULT ""
80 #define JEVOIS_CAMERASENS_DEFAULT CameraSensor::any
83 #define JEVOIS_IMUSPI_DEFAULT "/dev/spidev32766.0"
86 #error "Neither JEVOIS_A33 nor JEVOIS_PRO defined -- ABORT"
89 #else // JEVOIS_PLATFORM
96 #define JEVOIS_CAMERA_DEFAULT "/dev/video0"
99 #define JEVOIS_GADGET_DEFAULT ""
102 #define JEVOIS_SERIAL_DEFAULT "stdio"
105 #define JEVOIS_USBSERIAL_DEFAULT ""
108 #define JEVOIS_IMUSPI_DEFAULT ""
112 #define JEVOIS_CAMERASENS_DEFAULT CameraSensor::imx290
115 #define JEVOIS_CAMERASENS_DEFAULT CameraSensor::ov9650
118 #endif // JEVOIS_PLATFORM
138 "file name (e.g., movie.mpg) or image sequence (e.g., im%02d.jpg, to read frames "
139 "im00.jpg, im01.jpg, etc).",
144 "manually, it is set through boot-time configuration.",
148 "or empty if device does not have an IMU with SPI interface.",
157 "On host hardware, a display window will be used unless gadgetdev is None (useful "
158 "for benchmarking) or is a file stem for a movie file that does not start with /dev/ "
159 "(and which should contain a printf-style directive for a single int argument, "
160 "the movie number).",
169 "Note that this parameter is only available when parsing command-line arguments. "
170 "At runtime, the setmapping command should be used instead.",
175 "or 'stdio' to use the console, or empty for no hardware serial port",
192 "buffer memory. This can accelerate severalfolds access to the captured image data, but "
193 "it may also yield stripe artifacts with some modules, such as PassThrough. The stripes "
194 "are pieces of incorrect data in the cache. You should experiment with each particular "
195 "module. Turbo mode is not recommended for any production-grade application.",
203 SerPort::None, SerPort_Values, ParamCateg);
207 "in the video stream. Only takes effect if streaming video to USB.",
212 SerPort::None, SerPort_Values, ParamCateg);
222 , CPUmode::Performance, CPUmode_Values, ParamCateg);
227 CPUmode::Performance, CPUmode_Values, ParamCateg);
233 ". To enable overclock frequencies above 2208 MHz, you need to first edit "
234 "/boot/env.txt and change max_freq_a73, then reboot. Use with caution!"
238 , 1344, { 120, 240, 312, 408, 480, 504, 600, 648, 720, 816, 912, 1008,
239 1044, 1056, 1080, 1104, 1116, 1152, 1200, 1224, 1248, 1296, 1344 },
243 , 2208, { 500, 667, 1000, 1200, 1398, 1512, 1608, 1704, 1800, 1908, 2016,
244 2100, 2208, 2304, 2400 },
253 "To enable overclock frequencies above 1800 MHz, you need to first edit "
254 "/boot/env.txt and change max_freq_a53, then reboot. Use with caution!",
256 1800, { 500, 667, 1000, 1200, 1398, 1512, 1608, 1704, 1800, 1908, 2016,
263 "reduces the amount of USB bandwidth used by each JeVois camera, from 3kb "
264 "per USB isochronous microframe to 1kb. All 3 JeVois cameras must have this "
265 "option enabled, and the JeVois linux kernel module should also have "
266 "been loaded with multicam on.",
271 "received at the command-line interface. Recommended for advanced users only.",
276 "attempting to load a python module will throw an exception. Disabling python saves "
277 "a lot of memory and may be useful when using C++ modules that run large deep neural "
283 "using sendSerial(), for each video frame, or 0 for no limit. Any message sent by "
284 "the module beyond the first serlimit ones will be dropped. This is useful to avoid "
285 "overloading the serial link, for example in case one is running a ArUco detector and "
286 "a large number of ArUco tags are present in the field of view of JeVois.",
296 "interference, only effective on JeVois-Pro Platform, otherwise ignored. Set conslock "
297 "to false if you are experiencing hard crashes and want to run jevoispro-daemon in gdb.",
302 "is stuck somehow, or 0.0 for no watchdog",
307 "machine vision modules, cycling to the next modules after a number "
308 "of seconds specified by this parameter (or 0.0 for no demo mode).",
388 public Parameter<engine::cameradev, engine::camerasens, engine::cameranbuf, engine::gadgetdev,
389 engine::gadgetnbuf, engine::imudev, engine::videomapping, engine::serialdev,
390 engine::usbserialdev, engine::camreg, engine::imureg, engine::camturbo,
391 engine::serlog, engine::videoerrors, engine::serout, engine::cpumode, engine::cpumax,
392 engine::multicam, engine::quietcmd, engine::python, engine::serlimit
394 , engine::gui, engine::conslock, engine::cpumaxl, engine::cpumodel, engine::watchdog,
401 Engine(std::string
const & instance);
404 Engine(
int argc,
char const* argv[], std::string
const & instance);
418 VideoMapping
const &
findVideoMapping(
unsigned int oformat,
unsigned int owidth,
unsigned int oheight,
419 float oframespersec)
const;
433 size_t getVideoMappingIdx(
unsigned int iformat,
unsigned int iframe,
unsigned int interval)
const;
485 void sendSerial(std::string
const & str,
bool islog =
false);
488 std::shared_ptr<Module>
module()
const;
491 std::shared_ptr<IMU>
imu()
const;
494 std::shared_ptr<Camera>
camera()
const;
539 void runScriptFromFile(std::string
const & filename, std::shared_ptr<UserInterface> ser,
543 void onParamChange(engine::serialdev
const & param, std::string
const & newval)
override;
546 void onParamChange(engine::usbserialdev
const & param, std::string
const & newval)
override;
549 void onParamChange(engine::cpumode
const & param, engine::CPUmode
const & newval)
override;
552 void onParamChange(engine::cpumax
const & param,
unsigned int const & newval)
override;
555 void onParamChange(engine::videoerrors
const & param,
bool const & newval)
override;
559 void onParamChange(engine::gui
const & param,
bool const & newval)
override;
562 void onParamChange(engine::cpumaxl
const & param,
unsigned int const & newval)
override;
565 void onParamChange(engine::cpumodel
const & param, engine::CPUmode
const & newval)
override;
568 void onParamChange(engine::demomode
const & param,
float const & newval)
override;
595 bool parseCommand(std::string
const & str, std::shared_ptr<UserInterface> s, std::string
const & pfx =
"");
598 std::list<std::shared_ptr<UserInterface> > itsSerials;
600 void setFormatInternal(
size_t idx);
601 void setFormatInternal(jevois::VideoMapping
const & m,
bool reload =
false);
604 void foreachCamCtrl(std::function<
void(
struct v4l2_queryctrl & qc, std::set<int> & doneids)> && func);
607 std::string camCtrlHelp(
struct v4l2_queryctrl & qc, std::set<int> & doneids);
610 std::string camCtrlInfo(
struct v4l2_queryctrl & qc, std::set<int> & doneids);
613 void cmdInfo(std::shared_ptr<UserInterface> s,
bool showAll, std::string
const & pfx =
"");
616 void modCmdInfo(std::shared_ptr<UserInterface> s, std::string
const & pfx =
"");
619 std::string camctrlname(
unsigned int id,
char const * longname)
const;
622 unsigned int camctrlid(std::string
const & shortname);
627 void reportErrorInternal(std::string
const & err =
"");
631 bool itsManualStreamon;
632 std::atomic<bool> itsVideoErrors;
634 std::string itsModuleConstructionError;
636 #ifdef JEVOIS_PLATFORM_A33
638 void checkMassStorage();
639 std::future<void> itsCheckMassStorageFut;
640 std::atomic<bool> itsCheckingMassStorage;
641 std::atomic<bool> itsMassStorageMode;
642 void startMassStorageMode();
643 void stopMassStorageMode();
646 std::atomic<size_t> itsNumSerialSent;
647 std::atomic<int> itsRequestedFormat;
650 std::shared_ptr<GUIhelper> itsGUIhelper;
653 void camCtrlGUI(
struct v4l2_queryctrl & qc, std::set<int> & doneids);
655 std::shared_ptr<jevois::Watchdog> itsWatchdog;
657 bool itsDemoReset =
true;
664 std::vector<std::pair<std::string , std::string >> params;
666 std::vector<DemoData> itsDemoData;
667 bool itsNextDemoRequested =
false;
673 std::map<void *, Component *> itsPythonRegistry;
674 mutable std::mutex itsPyRegMtx;
size_t getDefaultVideoMappingIdx() const
Allow access to the default video mapping index.
#define JEVOIS_USBSERIAL_DEFAULT
On platform hardware, device for serial-over-USB port.
void foreachVideoMapping(std::function< void(VideoMapping const &m)> &&func)
Run a function on every video mapping.
void quit()
Terminate the program.
Manager of a hierarchy of Component objects.
#define JEVOIS_CAMERA_DEFAULT
On platform hardware, device for the camera sensor.
std::shared_ptr< Module > itsModule
Our current module.
A component of a model hierarchy.
#define JEVOIS_GADGET_DEFAULT
On platform hardware, device for the USB gadget driver (which sends video frames over USB to a host c...
std::atomic< bool > itsRunning
True when we are running.
std::shared_ptr< Camera > camera() const
Get a pointer to our Camera (may be null, especially if not using a camera but, eg,...
A raw image as coming from a V4L2 Camera and/or being sent out to a USB Gadget.
size_t numVideoMappings() const
Return the number of video mappings.
void unRegisterPythonComponent(Component *comp)
Unregister a component as linked to some python code, used by dynamic params created in python.
A category to which multiple ParameterDef definitions can belong.
void setFormat(size_t idx)
Callback for when the user selects a new output video format.
void reboot()
Request a reboot.
std::shared_ptr< VideoInput > itsCamera
Our camera.
const VideoMapping & getDefaultVideoMapping() const
Allow access to the default video mapping.
std::unique_ptr< DynamicLoader > itsLoader
Our module loader.
void streamOn()
Start streaming on video from camera, processing, and USB.
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(l2grad, bool, "Use more accurate L2 gradient norm if true, L1 if false", false, ParamCateg)
void clearErrors()
Clear all errors currently displayed in the JeVois-Pro GUI.
const VideoMapping & findVideoMapping(unsigned int oformat, unsigned int owidth, unsigned int oheight, float oframespersec) const
Find the VideoMapping that has the given output specs, or throw if not found.
std::timed_mutex itsMtx
Mutex to protect our internals.
JEVOIS_DECLARE_PARAMETER(imudev, std::string, "IMU SPI device name, typically starting with /dev/spidev..., " "or empty if device does not have an IMU with SPI interface.", JEVOIS_IMUSPI_DEFAULT, ParamCateg)
void streamOff()
Stop streaming on video from camera, processing, and USB.
void nextDemo()
When in demo mode, switch to next demo.
void requestSetFormat(int idx)
Use this to request a format change from within process()
JeVois processing engine - gets images from camera sensor, processes them, and sends results over USB...
const VideoMapping & getVideoMapping(size_t idx) const
Allow access to our video mappings which are parsed from file at construction.
void runScriptFromFile(std::string const &filename, std::shared_ptr< UserInterface > ser, bool throw_no_file)
Run a script from file.
void reportError(std::string const &err)
int mainLoop()
Main loop: grab, process, send over USB. Should be called by main application thread.
void onParamChange(engine::serialdev const ¶m, std::string const &newval) override
Parameter callback.
std::shared_ptr< IMU > imu() const
Get a pointer to our IMU (may be null)
std::shared_ptr< IMU > itsIMU
std::vector< VideoMapping > itsMappings
All our mappings from videomappings.cfg.
size_t getVideoMappingIdx(unsigned int iformat, unsigned int iframe, unsigned int interval) const
Get the video mapping index for a given UVC iformat, iframe and interval.
size_t itsDefaultMappingIdx
Index of default mapping.
void preInit() override
Override of Manager::preInit()
#define JEVOIS_CAMERASENS_DEFAULT
Default camera sensor.
std::atomic< bool > itsStreaming
True when we are streaming video.
void registerPythonComponent(Component *comp, void *pyinst)
Register a component as linked to some python code, used by dynamic params created in python.
Component * getPythonComponent(void *pyinst) const
Get the component registered with a given python instance.
void postInit() override
Override of Manager::postInit()
VideoMapping itsCurrentMapping
Current mapping, may not match any in itsMappings if setmapping2 used.
bool parseCommand(std::string const &str, std::shared_ptr< UserInterface > s, std::string const &pfx="")
Parse a user command received over serial port.
void abortDemo()
When in demo mode, abort demo mode.
void sendSerial(std::string const &str, bool islog=false)
Send a string to all serial ports.
JEVOIS_DEFINE_ENUM_CLASS(CameraSensor,(any)(imx290)(os08a10)(ar0234))
Enum for different sensor models.
std::shared_ptr< Module > module() const
Get a pointer to our current module (may be null)
#define JEVOIS_IMUSPI_DEFAULT
Default IMU spi device.
void reloadVideoMappings()
Re-load video mappings from videomappings.cfg.
const VideoMapping & getCurrentVideoMapping() const
Get the current video mapping.
std::atomic< bool > itsStopMainLoop
Flag used to stop the main loop.
void drawCameraGUI()
Draw all camera controls into our GUI.
#define JEVOIS_SERIAL_DEFAULT
On platform hardware, device for the 4-pin hardware serial port.
std::shared_ptr< VideoOutput > itsGadget
Our IMU.