Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Adding templates to linemod fails

Hello all,

I'm attempting to implement opencv linemod, however I've come upon an issue that I can't seem to solve. Essentially whenever I run the addTemplate function on a detector class it simply fails to add (returns -1, and numTemplates is 0). Does anybody have any ideas what might be causing this behaviour?

#include <iostream>                                                                                                                                                                                          
#include <opencv2/core/core.hpp>
#include <opencv2/core/utility.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/rgbd.hpp>
#include <opencv2/objdetect/objdetect.hpp>

using namespace std;
int main() {
//Instantiate detector
cv::Ptr<cv::linemod::Detector> detector;
detector = cv::linemod::getDefaultLINEMOD();

//load ims 
cv::Mat rgb_im;
cv::Mat depth_im;
rgb_im = cv::imread("/home/pete/work/data/train/15/rgb/0300.png", CV_LOAD_IMAGE_COLOR);
depth_im = cv::imread("/home/pete/work/data/train/15/depth/0300.png", CV_LOAD_IMAGE_ANYDEPTH);
vector<cv::Mat> sources= {rgb_im,depth_im}; //load to vector for template adding
cv::Mat mask(rgb_im.size(), CV_8UC1, cv::Scalar::all(255));
string class_id="testclass";
//cv::Rect bb;

int Templ_ID =detector->addTemplate(sources, class_id, mask);
cout<<"Templ_ID: "<<Templ_ID<<endl;
return 0;
}

A few weird quirks- using the empty intialiser will add templates just fine, however this seems to be designed for loading pre-stored detectors from file, and fails to match holding some pretty wild and seemingly random parameter values.

Another unexpected thing is that despite failing to load the template the detector somehow updates that it has a class loaded into it.

The mask I've currently just put as all white but all sorts of mask variations get the same results. Bounding box or not doesn't seem to affect results either.

Thanks everyone!

Adding templates to linemod fails

Hello all,

I'm attempting to implement opencv linemod, however I've come upon an issue that I can't seem to solve. Essentially whenever I run the addTemplate function on a detector class it simply fails to add (returns -1, and numTemplates is 0). Does anybody have any ideas what might be causing this behaviour?

#include <iostream>                                                                                                                                                                                  
#include <opencv2/core/core.hpp>
#include <opencv2/core/utility.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/rgbd.hpp>
#include <opencv2/objdetect/objdetect.hpp>

using namespace std;
int main() {
//Instantiate detector
cv::Ptr<cv::linemod::Detector> detector;
detector = cv::linemod::getDefaultLINEMOD();

//load ims 
cv::Mat rgb_im;
cv::Mat depth_im;
rgb_im = cv::imread("/home/pete/work/data/train/15/rgb/0300.png", CV_LOAD_IMAGE_COLOR);
depth_im = cv::imread("/home/pete/work/data/train/15/depth/0300.png", CV_LOAD_IMAGE_ANYDEPTH);
vector<cv::Mat> sources= {rgb_im,depth_im}; //load to vector for template adding
cv::Mat mask(rgb_im.size(), CV_8UC1, cv::Scalar::all(255));
string class_id="testclass";
//cv::Rect bb;

int Templ_ID =detector->addTemplate(sources, class_id, mask);
cout<<"Templ_ID: "<<Templ_ID<<endl;
return 0;
}

A few weird quirks- using the empty intialiser will add templates just fine, however this seems to be designed for loading pre-stored detectors from file, and fails to match holding some pretty wild and seemingly random parameter values.

Another unexpected thing is that despite failing to load the template the detector somehow updates that it has a class loaded into it.

The mask I've currently just put as all white but all sorts of mask variations get the same results. Bounding box or not doesn't seem to affect results either.

Thanks everyone!