是否有一套明确的指令来实现OpenCV跟踪器与OpenVINO和现在过时的NCS2上的RPi 4b-Buster?
据我所知,最后一个支持NCS2的OpenVINO是v2020.3。
我尝试使用以下代码进行交叉编译:
https://github.com/opencv/opencv/wiki/Intel-OpenVINO-backend#raspbian-buster
从源代码安装opencv/opencv-contrib 4.5.5后:
$ 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()
>>>
但是,在www.example.com脚本中,我有:test.py script I have:
...
import cv2
net = cv2.dnn.readNetFromCaffe(_weights, _model)
net.setPreferableTarget(cv2.dnn.DNN_TARGET_MYRIAD)
...
detections = net.forward()
我收到与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'
然后我用这个来安装OpenVINO:
https://docs.openvino.ai/latest/openvino_docs_install_guides_installing_openvino_raspbian.html
但使用此版本的OpenVINO(作为最后一个支持NCS2的版本):
https://storage.openvinotoolkit.org/repositories/openvino/packages/2020.3/l_openvino_toolkit_runtime...
我将路径导出到新的交叉编译后的opencv_install目录:
$ 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
我设置了NCS2,没有出现任何错误:
$ sudo usermod -a -G users "$(whoami)"
$ sh /opt/intel/openvino_2020.3/install_dependencies/install_NCS_udev_rules.sh
然后:
$ source /opt/intel/openvino_2020.3/bin/setupvars.sh
然后检查:
$ 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'
>>>
如果我打开一个新的终端,并使用$source/opt/intel/openvino_2020.3/bin/www.example.comsetupvars.sh
然后运行www.example.com脚本:test.py script:
...
import cv2
net = cv2.dnn.readNetFromCaffe(_weights, _model)
net.setPreferableTarget(cv2.dnn.DNN_TARGET_MYRIAD)
...
detections = net.forward()
...
我得到一个分段错误。
到目前为止,我还没有编辑任何安装脚本。
感谢您的帮助!我想让NCS2工作。
1条答案
按热度按时间s3fp2yjn1#
一般来说,如果您能够在遵循此installation guide之后使用NCS2运行一些OpenVINO演示,那么您应该能够使用OpenCV功能(确保您安装了正确的OpenCV)。
建议使用最新的OpenVINO和OpenCV版本。
如本OpenVINO System Requirements所示,当前推荐的OpenCV版本为4.5。