ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Using opencv tracking with ROS kinetic

asked 2017-11-14 01:30:36 -0600

VAVROS gravatar image

Hey, i want to use the tracking packageof opencv3 contrib in my ROS package.

The tracking packagee seems to be installed correctly, i can find the tracker.cpp in my opencv folder and also use other functions like

Ptr<tracker> tracker = TrackerMIL::create();

But when i want to use "selectROI" is get an error:

error: ‘selectROI’ was not declared in this scope
 Rect2d r = selectROI(im);

I tried the solution from here but that didn't work for me.

In my opinion i got a linking error like the OP from the link, but what i don't understand is how i can create a Tracker but when i want to use the "selectROI" function its not declared.

Thats the Code i'm trying to compile:

#include <opencv2/opencv.hpp>
#include <opencv2/video/tracking.hpp>
#include "opencv2/highgui/highgui.hpp"

using namespace std;
using namespace cv;


 int main (int argc, char **arv)
{
// Read image
Mat im = imread("~/catkin_ws/Bild.jpg");

// Select ROI
Rect2d r;
r = selectROI(im);

// Crop image
Mat imCrop = im(r);

// Display Cropped Image
imshow("Image", imCrop);
waitKey(0);

return 0;
}

Thanks in advance!

edit retag flag offensive close merge delete

Comments

Not a complete answer, but:

error: ‘selectROI’ was not declared in this scope

and

In my opinion i got a linking error [..]

No, this would be a compiler error: it cannot find the declaration of the symbol selectROI. Are you including the correct headers?

gvdhoorn gravatar image gvdhoorn  ( 2017-11-14 02:06:40 -0600 )edit

I think i do, got the test code from here and just strg+C it to be able to better trace back the source of the problem. My complete code is more, but as the "selectROI" seems to be the problem i broke it down

VAVROS gravatar image VAVROS  ( 2017-11-14 02:21:29 -0600 )edit

Well it's still a compiler error.

gvdhoorn gravatar image gvdhoorn  ( 2017-11-14 02:28:28 -0600 )edit

But i don't get why everyone can use the function with the same headers, but when i try it can't compile. While other function of the tracking API are working just fine.

VAVROS gravatar image VAVROS  ( 2017-11-14 02:48:59 -0600 )edit

I sympathise, but I can't help you with that. I just wanted to let you know it's not a linker error.

gvdhoorn gravatar image gvdhoorn  ( 2017-11-14 02:53:13 -0600 )edit

Btw: OpenCV has its own forum: answers.opencv.org. You might want to ask this over there.

gvdhoorn gravatar image gvdhoorn  ( 2017-11-14 02:54:35 -0600 )edit

Thanks for that, it helps to find a solution :)

VAVROS gravatar image VAVROS  ( 2017-11-14 02:54:47 -0600 )edit

And OpenCV: Can't find modules from contrib repository (Tracker, selectROI) seems to suggest that perhaps the OpenCV version you are using doesn't include the necessary functionality. I'm not an OpenCV expert, but is the contribs stuff included?

gvdhoorn gravatar image gvdhoorn  ( 2017-11-14 02:55:55 -0600 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2017-11-21 06:37:34 -0600

ZainMehdi gravatar image

updated 2017-11-22 02:46:10 -0600

Edit : Work around not a solution

For anyone still having the same issue I found another way of solving it. I assume that you have installed opencv from source in /usr/local 1) Locate ROS version of opencv files in /opt/ros/kinetic/include/opencv-3.2.0-dev and /opt/ros/kinetic/lib. 2) Copy and paste all files from /usr/local/include/opencv2 to /opt/ros/kinetic/include/opencv-3.2.0-dev/opencv2 3) Do the same for /user/local/lib and /opt/ros/kinetic/lib. (Copy only opencv related lib files)

Assuming that you carried out above steps properly your code involving packages from contrib module including the one mentioned above (selectROI case) should compile fine now without the need of tweaking with cmake files at all.

edit flag offensive delete link more

Comments

3

I found another way of solving it

please clearly emphasise that this is a work-around, not a solution. Renaming package manager / system installed directories and editing files like this is not recommended and very brittle: updated pkgs will overwrite / undo your changes.

gvdhoorn gravatar image gvdhoorn  ( 2017-11-22 02:43:57 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2017-11-14 01:30:36 -0600

Seen: 999 times

Last updated: Nov 22 '17