At the moment I am trying to work with yolov3 in OpenCV in Ros Kinetic. Only yolov3 is supported from OpenCV 3.4.2 and up. Kinetic is natively on 3.3.1-dev.
Is there a way to either upgrade to a newer version of OpenCV in ROS? or is there an other way to get this to work?
A way to work with yolov3 configs and weights in OpenCV 3.3.1 is fine too!
If there is something unclear, please let me know
Have you tried this?
Let me know if it works for you or if there are any steps unclear!
I see Rick has already answered your question
In addition to his answer I would like to ask: Why use Yolo through OpenCV? I would suggest installing Darknet directly and if you prefer working in python: the python wrapper.
So you can use Yolo without depending on a specific OpenCV version.
A more simple approach would be to use available pre-trained networks through a mature library like Keras. Which includes mobilenets which are optimized for low computational expense.
If you really want go the single shot multibox detection route, you could also look into Retinanet. Which has pretty clear steps for installation.
For an overview and comparison of modern neural net object detectors check out this article.
The reason is that we are most used to working with OpenCV for further or prior image processing.
We have to make two pictures with a camera using ROS, in this case a KinectV1. One depth image and a color image. We want to use object detection using OpenCV because when you know the coordinates of one picture, we know immediately how to use that information to get the depth of that pixel in the depth image(and maybe surrounding pixels to not get false info due to noise).
The python wrapper might be interesting though! Then we can still use OpenCV for image processing, because its only the neural network part of OpenCV that is outdated for us.
I have no idea if and how to make ROS work with it yet, but it seems like a good alternative too!
I’m definitely going to try the arbitrary version install first, because it almost seems like you can easily substitute that for any other library that isn’t natively in Kinetic.
I’ll keep you updated!
I have fixed it by forcing ros to use python3 by using #/usr/bin/env python3 instead of just python (python2.7). Then it gave an error that in the python3 environment that it didn’t know OpenCV yet.
I ran: $pip3 install --user opencv-python for a python3 opencv library.
After that it still gave an error:
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type
After days of troubleshooting I came across a workaround that basicly softlinks the cv2.so in kinetic/lib/python2.7/dist-packages/ with a different cv2.so. One of the version 3.4.4 in my case
I ran: $sudo ln -sf /home/yournamehere/anaconda3/lib/python3.7/site-packages/cv2.so /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so
From what I understand this let’s the OS point the import of python to another package. Even outside of ROS. I don’t really understand everything about this yet, but it did make it possible to use OpenCV’s dnn module and YOLOv3 inside a ROS node!
The only thing I can imagine not working now is when you try to import cv2 in python 2.7. If that turns out to be it there’s no downside for me. I prefer python3 anyway.
Does anyone know what I might run into when I softlink files? So far everything still seems to be working!