Ask Your Question
0

Development environment and process for small devices like Pi Zero W

asked 2020-02-11 01:57:11 -0600

R0B gravatar image

I'm just starting with OpenCV using the go-cv wrapper and I would like to ask you for some general advice on how you would layout your development environment and processes. My goal is to write a program that detects different states of an industrial device by "watching" its control panel, some old school metal panel with red and green lights etc.

I have a powerful workstation on my desk with Linux and an attached USB camera. Go-cv and thereby OpenCV 4 is installed on both the workstation and the Pi Zero W with the Pi Camera version 2, I can successfully create a "Hello world" on the workstation that simply shows a video capture window, build it for the Pi and run it there (or compile it on the Pi).

Now there's this fact that the workstation is of course many orders of magnitudes more powerful than the little Pi. When I now start developing on the workstation, I will hardly ever run into some hardware-based limitations, but as the software is supposed to be run on the Pi in the end, this won't help much, I think. On the other hand, I do not want to start X on the pi and have the development take place there. Besides that, I would have to either use VNC or really use the Pi as a development machine with attached monitor, mouse and keyboard (which seems strange in a way).

In the end, as far as I understand, all the windows that you show (like the face detection in the demos) are not really neccessary and are just handy for optimizing and tweaking the program until it does what it should, is that correct? I think, showing a live camera feed alone will also take a away a significant amount of cpu power from the Pi.

What would be a good setup to use the best of both worlds? Thanks for sharing your thoughts and recommendations.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2020-02-11 05:07:39 -0600

kbarni gravatar image

Yes, the Raspberry Pi is much slower than a desktop computer. So you'll need to optimize the code as much as possible.

Note that the Zero is by far the weakest Raspberry Pi; I would rather choose another model with better performances (like the Pi 4).

I would develop the software on the desktop computer, it's much faster. Then, if you take out the UI part (imshow, etc.) you can run it without the X server. You can recompile and run this on the Pi in headless mode (without attached screen). Anyway, you won't use a screen in the final product.

For testing, I would use a verbose output to see (over SSH) if everything works without a graphical display. Something like:

Opening camera...OK
Beginning capture...
Frame 1 captured. Frame1 processed in 100ms.
    --> Red LED detected. Red LED OFF.
    --> Blue LED detected. Blue LED ON.
Frame2....
edit flag offensive delete link more

Comments

1

You're right, a Nvidia Jetson Nano or Pi 4 would be way more powerful, but from what I read the Zero should be sufficient for our use case. The main reason is its really low price, considering that I'm looking for a solution that will be running in about 3500 locations across the country this is really important.

Yes, I want to run the Zero headless without any UI or similar. My question was aiming towards the actual development process: so you are writing and testing the code on your desktop (with another camera), then push it onto the Pi Zero and see if it works? Or is there a better way, something more direct? Working "somehow" from your desktop system right on the Pi Zero, so that you can use the actual Pi Cam and get a feel for the performance?

R0B gravatar imageR0B ( 2020-02-11 05:42:33 -0600 )edit
1

Yes, if you design your code with modules or objects in mind, then you will have a camera and whoever uses the image in your application (the core). If you do so, you can deploy it and test the core on a desktop PC and then test it on your embedded device. The camera as it should communicate with the driver you will have to test it directly on your device. This type of application needs a lot of optimization, but as a recommendation, leave it for the last.

juanmamdp gravatar imagejuanmamdp ( 2020-02-11 06:35:40 -0600 )edit

Ok, thank you for that clarification. So the way to go is write/optimize on PC --> deploy to Pi --> test on Pi --> next iteration.

R0B gravatar imageR0B ( 2020-02-11 06:57:43 -0600 )edit

Working "somehow" from your desktop system right on the Pi Zero, so that you can use the actual Pi Cam and get a feel for the performance?

You can connect from the desktop to the Pi over SSH (over network or via serial port) and run the algorithm. Run alongside htop to check the CPU and memory usage (for example using a split terminal window using tmux).

kbarni gravatar imagekbarni ( 2020-02-12 04:25:33 -0600 )edit

Yes, I think I'll try that. I'm already thinking of a little script as a build tool that sends the source to the "big" machine, cross-compiles (which is extremely easy to do in Golang) and sends back the binary. Compiling on the Pi takes quite some time, so that would probably speed things up.

R0B gravatar imageR0B ( 2020-02-12 05:59:43 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-02-11 01:57:11 -0600

Seen: 412 times

Last updated: Feb 11 '20