Using opencv tracking with ROS kinetic
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!
Not a complete answer, but:
and
No, this would be a compiler error: it cannot find the declaration of the symbol
selectROI
. Are you including the correct headers?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
Well it's still a compiler error.
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.
I sympathise, but I can't help you with that. I just wanted to let you know it's not a linker error.
Btw: OpenCV has its own forum:
answers.opencv.org
. You might want to ask this over there.Thanks for that, it helps to find a solution :)
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?
Yeah i included the contribs and i'm using the newest version of OpenCv which should normally include the necessary functions. I'm trying to figure out a work around to write the function myself.
Kinetic ships its own version of OpenCV. You'll have to make sure which version of OpenCV you're actually compiling against.
Oh ok, i didn't know that. How can i check if im'm compiling against the right OpenCV Version?
If you're using the CMake snippet as shown on wiki/vision_opencv, then you're most likely using the version shipped with Kinetic.
For using a different version I suggest you search ROS Answers.
Thank you very much!! I managed to compile against the stand alone version of OpenCV and it worked. The correct answer from here did the trick
You changed the name of the dir in
/opt/ros
? Please don't do that.You should be able to override where CMake looks or OpenCV using the regular approach: setting
OpenCV_DIR
before callingfind_package(OpenCV)
. Be aware of the pitfalls when building against a custom OpenCV version.I'm looking for a better solution, but for checking if thats the right way to compile i changed the name in the dir
Did u find any solution ? I have the same problem
I renamed the folder
opencv-3.2.0-dev
in my ros/kinetic/include compiled afterwards, the only package giving an error then wascv_bridge
. Therefore i editet the filecv_bridgeConfig.cmake
inros/kinetic/share/cv_bridge
and changed the path to (in my case)/opt/opencv/
(line 94&96)