0

Is there a definitive set of instructions to implement OpenCV trackers with OpenVINO and the now-obsolete NCS2 on a RPi 4b - Buster?

My understanding that the last OpenVINO to support the NCS2 was v2020.3.

I attempted to cross-compile using:

https://github.com/opencv/opencv/wiki/Intel-OpenVINO-backend#raspbian-buster

After installing opencv/opencv-contrib 4.5.5 from source:

$ python3

Python 3.7.3 (default, Oct 31 2022, 14:04:00) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.5.5'
>>> tracker = cv2.TrackerCSRT_create()
>>> 

However, in a test.py script I have:

...

import cv2

net = cv2.dnn.readNetFromCaffe(_weights, _model)
net.setPreferableTarget(cv2.dnn.DNN_TARGET_MYRIAD)
...
detections = net.forward()

I get the error relating to DNN_TARGET_MYRIAD:

cv2.error: OpenCV(4.5.5) /home/pi/opencv/modules/dnn/src/dnn.cpp:1414: error: (-215:Assertion failed) preferableBackend != DNN_BACKEND_OPENCV || preferableTarget == DNN_TARGET_CPU || preferableTarget == DNN_TARGET_OPENCL || preferableTarget == DNN_TARGET_OPENCL_FP16 in function 'setUpNet'

I then used this to install OpenVINO:

https://docs.openvino.ai/latest/openvino_docs_install_guides_installing_openvino_raspbian.html

but using this version of OpenVINO (as the last to support the NCS2):

https://storage.openvinotoolkit.org/repositories/openvino/packages/2020.3/l_openvino_toolkit_runtime...

I exported the paths to the new post cross-compiled opencv_install directory:

$ export PYTHONPATH=/home/pi/Desktop/opencv_install/lib/python2.7/dist-packages/:$PYTHONPATH

$ export PYTHONPATH=/home/pi/Desktop/opencv_install/lib/python3.7/site-packages/:$PYTHONPATH

$ export LD_LIBRARY_PATH=/home/pi/Desktop/opencv_install/lib/:$LD_LIBRARY_PATH

I set up the NCS2 with no errors :

$ sudo usermod -a -G users "$(whoami)"

$ sh /opt/intel/openvino_2020.3/install_dependencies/install_NCS_udev_rules.sh

then:

$ source /opt/intel/openvino_2020.3/bin/setupvars.sh

 

and then checked:

$ python3

Python 3.7.3 (default, Oct 31 2022, 14:04:00) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.3.0-openvino-2020.3.0'
>>> tracker = cv2.TrackerCSRT_create()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'cv2' has no attribute 'TrackerCSRT_create'
>>>

If I open a new terminal and $ source /opt/intel/openvino_2020.3/bin/setupvars.sh

then run a test.py script:

...

import cv2
net = cv2.dnn.readNetFromCaffe(_weights, _model)
net.setPreferableTarget(cv2.dnn.DNN_TARGET_MYRIAD)
...
detections = net.forward()
...

I get a segmentation fault error.

So far I have not edited any of the setup scripts.

Thanks for any help! I'd like to put this NCS2 to work.

user773881
  • 845
  • 1
  • 8
  • 10
  • outdated versions. opencv v4.3 is very old. I don't even know if these trackers existed back then, or what they were called (probably lived in contrib). I'd recommend updating everything. – Christoph Rackwitz Jan 18 '23 at 10:22

1 Answers1

0

Generally, if you are able to run some OpenVINO demo with NCS2 after following this installation guide, then you should be able to use that OpenCV functionality (ensured that you had installed the correct OpenCV).

It's recommended to use the recent OpenVINO and OpenCV version.

As indicated in this OpenVINO System Requirements, the current recommended OpenCV version is 4.5.

Iffa_Intel
  • 106
  • 3
  • Per: https://docs.openvino.ai/latest/openvino_docs_OV_UG_supported_plugins_Supported_Devices.html ... "With OpenVINO™ 2020.4 release, Intel® Movidius™ Neural Compute Stick support has been cancelled."', so I used OpenVino 2020.3. I can install OpenCV 4.5.5 from source and current OpenVINO and achieve NCS2 support but without cv2 trackers (even cross-compiling). The noted instructions specifies OpenVINO 2022 which apparently does not support the NCS2. Also, those instructions are for Raspberian but under System Requirements only Ubuntu (not Rasbarian or Debian) is supported. This is confusing? – user773881 Jan 24 '23 at 19:04
  • If you look at that installation guide carefully(the one that I shared), the version being instructed is 2022.3 which is the latest right now. This installation guide is meant for Raspberry Pi running on Raspbian OS. Step 5 is compulsory to enable NCS2 on this setup. Make sure you followed 32bit/64bit download links accordingly. – Iffa_Intel Jan 25 '23 at 01:34
  • Intel® Movidius™ Neural Compute Stick is the first generation of NCS, based on Movidius Myriad 2 VPU and last release supporting this device is 2020.3. The Intel Neural Compute Stick 2 is based on Movidius Myriad X VPU which is still currently supported by OpenVINO. – avitial Feb 16 '23 at 00:42