Welcome new user! You can search existing questions and answers without registering, but please register to post new questions and receive answers.
Welcome to JeVois Tech Zone, where you can ask questions and receive answers from other members of the community.

Updating Parameters in a Python Module via Serial

0 votes
I am working on a module that would track lines and send the information to an Arduino (eg for a line tracking robot). I have basically just modified the PythonOpenCV.py example to use HoughLinesP to find the lines. However, getting the parameters tuned is time consuming if you have to change a value, restart camera, test, and repeat. I would like to be able to change the parameters via serial - either through a terminal or at the top of my Arduino script. Is there a standardized way of implementing this on the Python side? If so, an example would be great!

Along those same lines, what standardized serial message would be appropriate for this? I was picturing sending an array similar to [x1 y1 x2 y2] , [x1 y1 x2 y2], ... Should this be sent as a series of N2s? Again, an example you be appreciated.

asked Jul 6 in User questions by matthew (160 points)

1 Answer

0 votes
Best answer

JeVois parameters and components are not yet supported on the python side. It is unclear whether they will since they rely on constructs that may not be easy to translate into python (multiple inheritance over a variadic template chain). We will look into it but it will take some time. For now I would recommend implementing a custom command instead, which is already supported by the python bindings. See for example the PythonTest module:


you implement 2 functions: parseSerial() (takes a command string in, returns a string with results or throws if anything went wrong), and supportedCommands() (returns a \n separated list of commands, for the help message). In your case you could just implement commands like

thresh1 <val>

and so on. The parseSerial() and supportedCommands() functions for python are documented here:



http://jevois.org/doc/ModulePythonTutorial.html (last tutorial)

For standardized serial messages, those are kind of specific to sending location info about a target. So I would say just create your own messages for now since you are sending quite different information. You just need to agree between what JeVois sends and what your Arduino expects. A series of N2 messages might be confusing if people then try to use your module with a standard pan/tilt head but the head would not know what to do with a bunch of lines coming in. Using the conversions to standardized coordinates system might still be useful so your arduino code does not have to be dependent on video resolution, see 


answered Jul 6 by JeVois (10,590 points)
selected Jul 6 by matthew
I forgot to add: parseSerial() and process() are guaranted to not be called concurrently. So no need to worry about locking mechanisms around the settings that parseSerial() will modify and process() will use.