Community
cancel
Showing results for 
Search instead for 
Did you mean: 
lorrain__claude
Beginner
136 Views

HELP to start OpenVINO, OpenCV, and Movidius NCS on the Raspberry

Hello,

I read  the post of Adrian Rosebrock  (pyimagesearch)

https://www.pyimagesearch.com/2019/04/08/openvino-opencv-and-movidius-ncs-on-the-raspberry-pi/

I launched a file bash from cron  the python code openvino_real_time_object_detection.sh.

Its contents is:

 

#!/bin/bash

source /home/pi/.virtualenvs/openvino/bin/activate

cd /home/pi/openvino-pi-object-detection

python3 openvino_real_time_object_detection.py  --prototxt MobileNetSSD_deploy.prototxt --model MobileNetSSD_deploy.caffemodel

But it doesn't work. Below the log file :

Traceback (most recent call last):

  File "openvino_real_time_object_detection.py", line 2, in <module>

    from imutils.video import VideoStream

  File "/home/pi/.virtualenvs/openvino/lib/python3.5/site-packages/imutils/__init__.py", line 8, in <module>

    from .convenience import translate

  File "/home/pi/.virtualenvs/openvino/lib/python3.5/site-packages/imutils/convenience.py", line 6, in <module>

    import cv2

ImportError: libopencv_ml.so.4.0: cannot open shared object file: No such file or directory

 

I tried to solve this issue, but to no avail.

 

Important :

when I launch this code.sh directly via terminal command  like this :

pi@raspberrypi:~ $ bash -x openvino_real_time_object_detection.sh ;  the software launches and works perfectly

Could you help me to solve this issue in order to launch the  bash file from cron ?

 

Thanks in advance.

0 Kudos
3 Replies
Kulecz__Walter
New Contributor I
136 Views

Not 100% sure but when starting programs from cron job no environment is inherited, i.e. scfripts run from cron jobs need to use things like  /bin/date instead of just date as no path is set.

I suspect the setupvars.sh that is usually sourced in your .bashrc is not being run via the cron job.

You'll likely need to either create the $PYTHONPATH from within your python code, or launch it from a "wrapper" script that sources it before launching the python3 command when started by cron.

 

 

lorrain__claude
Beginner
136 Views

Thanks Walter,

 

Could you please give me a specific example because I do not understand your answer very well ?

 

Tanks in advance

 

 

Kulecz__Walter
New Contributor I
136 Views

Why are you trying to start it from a cron job?

 

 

You will need to add 

source /home/pi/inference_engine_vpu_arm/bin/setupvars.sh

before the line that starts the actual python3 command.

 

A lot of stuff goes on behind the scenes when you log in that doesn't happen when a script is run from a cron job.  Your cronjob script needs to do all the required setup on its own to make your program. run.  For example you may also need the absolute path to the python3 executable.

Adrian sees virtual environments as a necessity.  I see it as a needless complication for a Raspberry Pi that is likely going to be doing a single IOT type of task. 

I needed to use a Virtual Environment to get his openvino code running on an Odroid XU-4 because the Ubuntu-Mate18 it uses has Python3.6 so I had to "sideload" python 3.5 and use a Virtual environment to get Raspbian OpenVINO to run there.  Extra work, but necessary in this case.  But I don't create a virtual environment until I encounter a conflict that forces it.

 

 

 

Reply