JeVois  1.22
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
Loading...
Searching...
No Matches
JeVois-Pro: Cloning and compiling C++ modules on device

JeVois-Pro: Starting with JeVois v1.20.0, you can edit and compile C++ modules on a running camera. It is quite slow, but it works quite well. This is useful mainly to get a module started and for small debugging edits. For more extensive C++ code writing, we recommend using the JeVois-Pro SDK on a powerful Linux desktop, testing your module in host mode first, and then cross-compiling it to run on the camera. See Programmer guide for more info.

Step 1: Clone an existing module to provide a working starting point

In the System tab of the GUI, click "Create new machine vision module..."

Step 2: Select which module to clone

Click on the "..." menu at top and select a module to clone.

Here we are going to clone the PassThrough module, with 1920x1080 video for display purposes, and 512x288 greyscale video for processing purposes:

A new module will be created with vendor name Testing and module name MyPassThrough (if you clone the same module several time, you will get MyPassThrough2, MyPassThrough3, etc). The source code will be saved in /jevoispro/modules/Testing/MyPassThrough/ and you should back it up often in case your microSD card gets corrupt somehow. Feel free to edit those names if you do not like them. Then click the Create button.

Step 3: Initial compilation of the clone

Once it is copied, a new window will open, and we will attempt to compile the clone right away. Please be patient, this takes a while (several minutes).

Once compilation is complete (which should always work on fresh clones), you will be asked whether you want to run the module. Click Yes to run it.

Step 4: Edit code

Once the clone is loaded and running, you can access its source code in the Code tab of the GUI.

Note that both the C++ source and the associated CMakeLists.txt are available in the code editor. Most users will not have to modify CMakeLists.txt unless they want to link against extra libraries or compile additional source files.

Let's try an edit. In PassThrough, at some point we draw a green circle around the mouse pointer. This is to demo the ability to draw things on top of rendered windows, using an ImGui foreground draw list. Let's change the radius of that green circle from 20 to 120 pixels.

Note
Remember to edit the correct process() function. If your module is running in JeVois-Pro GUI mode, then you want to edit the function with this signature: virtual void process(jevois::InputFrame && inframe, jevois::GUIhelper & helper) override

Click Save to save the modified code (or hit CTRL-S):

This will trigger a recompilation.

Once compiled, you can run the module:

Yep, that green circle around the mouse pointer is larger now!

Step 5: Dealing with errors

If any step in the build process fails, you will see an error message. Here let's add some buggy C++ code to see what happens:

That will trigger a compilation error:

If you scroll back up to the top of the compilation window, you can use the buttons to edit the offending source code or CMakeLists.txt:

Step 6: Dealing hard crashes

If you modify a module in such a way that it hard crashes the whole JeVois framework (e.g., segmentation fault by accessing memory past the end of an array), then you will not be able to load and run that module anymore, which means that you cannot easily change its source code anymore.

The way to handle this is as follows: load any other working module. Then in the Code editor, select "Browse / Create file..." at the end of the standard files. Then navigate to the C++ source code of your file, for example /jevoispro/modules/Testing/MyX.C and open that file.

Fix the code and save. This will recompile the module. Because the source file was selected manually, we do not know which videomapping (camera resolution, etc) you want to run on that code. Hence, after compiling, it will fail to load with an internal error. That is ok, just ignore the error, and from the pull-down list of available modules you can now manually select your module.