0
$\begingroup$

Rosanswers logo

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);

Originally posted by Markus on ROS Answers with karma: 311 on 2017-10-12

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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/272390/compile-with-different-opencv/#272442. You can look either at the accepted answer there or at my answer.


Originally posted by TTDM with karma: 267 on 2017-10-12

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$
0
$\begingroup$

Rosanswers logo

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)

Originally posted by Markus with karma: 311 on 2017-10-12

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by aaditya_saraiya on 2017-10-17:
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 ??

Comment by aaditya_saraiya on 2017-10-17:
Nvm. I added it some place randomly and it worked. Thank you anyways

Comment by VAVROS on 2017-11-14:
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.

Comment by aaditya_saraiya on 2017-11-14:
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()

Comment by VAVROS on 2017-11-14:
Did you place it in the CMakeLists.txt of your package or in a CMakeLists somewhere in the tracking module?

Comment by aaditya_saraiya on 2017-11-14:
No. CmakeLists.txt of my package.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.