Ask Your Question
0

How to select version OpenCV in ROS ?

asked 2018-10-09 03:22:53 -0600

ToanJunifer gravatar image

updated 2018-10-11 04:00:18 -0600

gvdhoorn gravatar image

Hi,

My name is Junifer. I am a student at a university. I am working with ROS and OpenCV. I installed 2 version of OpenCV and Python in my computer.

OpenCV 3.4.3 - Python 3

OpenCV 2.4.8 - Python 2

And I realize that ROS is working with "OpenCV 2.4.8 - Python 2 ".

I want to use "OpenCV 3.4.3 - Python 3 " for ROS. What should i do now ?

Help me...Thank you so much !


Edit: Hi @l4ncelot, I tried but it's not working.

Question 1: Before run this code:

export PYTHONPATH=$PYTHONPATH:/opt/ros/indigo/lib/python3.5/dist-packages

Do i need to copy python3.4/dis-package folder to /opt/ros/indigo/lib/ ?

Case 1: I just run this code with without moving any file. Fisrt line is okay. Second line give an error:

sed: -e expression #1, char 12: unknown option to `s'

Case 2: I try to copy dist-package from python 3.4 folder (I using python 3.4). But i realized that content of python3.4/dist-package is different with python2.7/dist-package.

Particularly, python2.7/dist-package have files of ROS but python3.4/dist-package haven't them. Can you explain for me ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-10-09 04:26:20 -0600

l4ncelot gravatar image

updated 2018-10-11 05:01:23 -0600

Edit: Sorry, I've overlooked somehow you're using python instead of c++. I'm not familiar with python in ROS that much, but here might be answer for you. It seems like you need to remove /opt/ros/indigo/lib/python2.7/dist-packages from your PYTHONPATH environment variable and replace it with the path to your python3 package (this should be something similar to /opt/ros/indigo/lib/python3.5/dist-packages depending on where your python is installed).

You can do it by adding these lines in the end of your .bashrc file at home directory:

export PYTHONPATH=$PYTHONPATH:/opt/ros/indigo/lib/python3.5/dist-packages
export PYTHONPATH=$(echo $PYTHONPATH | sed -e 's/\/opt\/ros\/indigo\/lib\/python2.7\/dist-packages//g')

The first line adds your python3 path to your PYTHONPATH system variable (again, this is just example of the path, yours path to the python3 can be different). The second line removes your old python2 path.

c++ version: You can find the correct version through your CMakeLists.txt file in yoru ROS package:

find_package(OpenCV 3.4.3 REQUIRED)

Look here for documentation of find_package.

edit flag offensive delete link more

Comments

Hi C4ncelot,

Thank you so much for your support. I so glad, and I going to try this way to solve it.

And, do you know the most advantages of Ros? I am know not clearly about it.

I hope you will response me and discuss about it.

Thank you again!

ToanJunifer gravatar imageToanJunifer ( 2018-10-09 13:27:54 -0600 )edit
1

@ToanJunifer, glad to help. I'm not the right one to explain full advantages of ROS in detail. Try to look at q#200423 for some basics. ROS is basically set of libraries, tools, communication layer etc...

l4ncelot gravatar imagel4ncelot ( 2018-10-10 01:33:50 -0600 )edit
1

... everything you need to build some robots. Image if ROS wouldn't exist. How would you e.g. program some mobile robot to navigate through unknown environment? What would you need to code except for your main algorithms? What about communication between your code? What about architecture? ...

l4ncelot gravatar imagel4ncelot ( 2018-10-10 01:36:55 -0600 )edit
1

... what about hardware drivers, debug tools etc.? Before ROS robotic research was primarily done at universities and not many universities were collaborating with each other. And when they did, each collaboration group had their own solution to the problem described above...

l4ncelot gravatar imagel4ncelot ( 2018-10-10 01:40:15 -0600 )edit
1

... There wasn't one solid approach everybody would use and improve. Now with ROS you basically don't need to solve above problems. Learning ROS is not easy, but it's a lot easier than solving everything on your own. Collaboration between the community is great advantage of ROS thanks to the...

l4ncelot gravatar imagel4ncelot ( 2018-10-10 01:43:52 -0600 )edit
1

... modularity of ROS packages. If you want to use package e.g. for obstacle avoidance using laser range finder you basically download it, look at the documentation about that particular package, find out input/output topics and connect it to your packages with subscribers/publishers of your own.

l4ncelot gravatar imagel4ncelot ( 2018-10-10 01:47:16 -0600 )edit

Hi @l4ncelot, Do i need to copy python3.4/dis-package folder to /opt/ros/indigo/lib/ before run first line?

ToanJunifer gravatar imageToanJunifer ( 2018-10-11 04:26:20 -0600 )edit
1

@ToanJunifer, Q1: No, just use the path you're working with. My path was just example, you need to replace it with yours. Q2: Sorry, I forgot about the escape characters. I've updated the syntax.

l4ncelot gravatar imagel4ncelot ( 2018-10-11 04:59:33 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2018-10-09 03:22:53 -0600

Seen: 560 times

Last updated: Oct 11 '18