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

Install opencv_contrib Tracking package

asked 2017-10-12 04:12:34 -0500

Markus gravatar image

updated 2017-10-12 04:27:15 -0500

Hey there I simply want to use the tracking package of the opencv3 contrib package in my ros kinetic.

I figured already out that in particular the tracking package is not contained in one of the following:

[STATUS]OpenCV_LIBRARIES [STATUS]opencv_calib3dopencv_coreopencv_features2dopencv_flannopencv_highguiopencv_imgcodecsopencv_imgprocopencv_mlopencv_objdetectopencv_photoopencv_shapeopencv_stitchingopencv_superresopencv_videoopencv_videoioopencv_videostabopencv_vizopencv_arucoopencv_bgsegmopencv_bioinspiredopencv_ccalibopencv_cvvopencv_datasetsopencv_dpmopencv_faceopencv_fuzzyopencv_hdfopencv_line_descriptoropencv_optflowopencv_phase_unwrappingopencv_plotopencv_regopencv_rgbdopencv_saliencyopencv_stereoopencv_structured_lightopencv_surface_matchingopencv_textopencv_xfeatures2dopencv_ximgprocopencv_xobjdetectopencv_xphoto [STATUS]OpenCV_LIB_COMPONENTS [STATUS]opencv_calib3dopencv_coreopencv_features2dopencv_flannopencv_highguiopencv_imgcodecsopencv_imgprocopencv_mlopencv_objdetectopencv_photoopencv_shapeopencv_stitchingopencv_superresopencv_videoopencv_videoioopencv_videostabopencv_vizopencv_arucoopencv_bgsegmopencv_bioinspiredopencv_ccalibopencv_cvvopencv_datasetsopencv_dpmopencv_faceopencv_fuzzyopencv_hdfopencv_line_descriptoropencv_optflowopencv_phase_unwrappingopencv_plotopencv_regopencv_rgbdopencv_saliencyopencv_stereoopencv_structured_lightopencv_surface_matchingopencv_textopencv_xfeatures2dopencv_ximgprocopencv_xobjdetectopencv_xphoto [STATUS]OpenCV_INCLUDE_DIRS [STATUS]/opt/ros/kinetic/include/opencv-3.2.0-dev/opt/ros/kinetic/include/opencv-3.2.0-dev/opencv

So I guess I have to install the tracking package myself but how do I do that?

I have installed sudo apt-get install ros-kinetic-opencv*

Well actually my main problem is: That I have the following code (tracker.cpp):

#include <opencv2/opencv.hpp>
// selectROI is part of tracking API
#include <opencv2/tracking.hpp>

using namespace std;
using namespace cv;


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

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

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

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

    return 0;
}

And when I run:

g++ -M tracker.cpp

I even get:

....
 /usr/local/include/opencv2/tracking.hpp \
 /usr/local/include/opencv2/tracking/tracker.hpp \
 /usr/local/include/opencv2/tracking/feature.hpp \
 /usr/local/include/opencv2/tracking/onlineMIL.hpp \
 /usr/local/include/opencv2/tracking/onlineBoosting.hpp \
 /usr/local/include/opencv2/tracking/tldDataset.hpp

Building my package leads to the following error:

error: ‘selectROI’ was not declared in this scope
     Rect2d r = selectROI(im);
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2017-10-12 09:03:46 -0500

Markus gravatar image

The solution for me was a linking problem I just did the following:

Linking to Traking lib:

LINK_DIRECTORIES(/usr/local/lib)

add_executable(tracker src/tracker.cpp)
target_link_libraries(tracker ${catkin_LIBRARIES} /usr/local/lib/libopencv_tracking.so)
edit flag offensive delete link more

Comments

Hey Markus,

Actually I was running into a similar problem. I wanted to use Tracking API as well with ROS and wanted to create a ROS Publisher to publish some information data from the tracking process.

Where does the LINK_DIRECTORIES(/usr/local/lib) need to be placed in the CMakeLists.txt ??

aaditya_saraiya gravatar image aaditya_saraiya  ( 2017-10-17 00:22:13 -0500 )edit

Nvm. I added it some place randomly and it worked. Thank you anyways

aaditya_saraiya gravatar image aaditya_saraiya  ( 2017-10-17 00:29:26 -0500 )edit

Did you just put that somewhere in your CMakeLists.txt? Because i've got the same problem with the "selectROI" but i can create trackers without errors. Seems like some parts of the tracking module are working while others are not.

VAVROS gravatar image VAVROS  ( 2017-11-14 00:44:32 -0500 )edit

Hey! Yes I placed it inside CMakeLists.txt. Had an OpenCV + OpenCV_contrib built from source and I added it to CMakeLists.txt with the command I mentioned before. I have tried for selectROI()

aaditya_saraiya gravatar image aaditya_saraiya  ( 2017-11-14 01:44:43 -0500 )edit

Did you place it in the CMakeLists.txt of your package or in a CMakeLists somewhere in the tracking module?

VAVROS gravatar image VAVROS  ( 2017-11-14 02:28:38 -0500 )edit
1

No. CmakeLists.txt of my package.

aaditya_saraiya gravatar image aaditya_saraiya  ( 2017-11-14 03:31:04 -0500 )edit
1

answered 2017-10-12 06:46:25 -0500

TTDM gravatar image

updated 2017-10-12 06:54:35 -0500

1/ Have you sucessfully run this code in a non catkin environment ? if no this is an openCV question.

2/ If yes then have you correctly linked a suitable openCV version to ROS ? If no, see for exemple : https://answers.ros.org/question/2723... . You can look either at the accepted answer there or at my answer.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-10-12 04:12:34 -0500

Seen: 3,252 times

Last updated: Oct 12 '17