opencv cv::linemod throwing runtime errors

asked 2013-07-24 06:22:02 -0500

alykhantejani gravatar image

I am using opencv-2.4.6 and trying to run a simple program to use the cv::linemod functionality.

Here is my code:

    #include <opencv2/core/core.hpp>
    #include <opencv2/imgproc/imgproc_c.h> 
    #include <opencv2/imgproc/imgproc.hpp>
    #include <opencv2/objdetect/objdetect.hpp>
    #include <opencv2/highgui/highgui.hpp>

int main(int argc, char **argv) {

    cv::Ptr<cv::linemod::Detector> detector;
    detector = cv::linemod::getDefaultLINEMOD();

    Mat depth = imread("input/duck/duck_650_depth2.png", CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH);
    Mat color = imread("input/duck/duck_650_rgb2.png", CV_LOAD_IMAGE_ANYCOLOR);

    Mat object_mask = Mat(depth.rows, depth.cols, CV_32S);

    for (int x = 0; x < depth.cols; x++) {
        for (int y = 0; y < depth.rows; y++) {
            if (<int16_t>(y, x) > 0) {
      <int>(y, x) = 1;
            } else {
      <int>(y, x) = 0;

    vector<Mat> sources;
    std::string class_id = cv::format("class%d", 1);
    Mat display = color.clone();
    Rect bb;

    int template_id = detector->addTemplate(sources, class_id, object_mask, &bb);
    if (template_id != -1) {
        cout << " added template " << endl;
    return 0;

Which compiles fine, however at runtime I get this error:

OpenCV Error: The function/feature is not implemented (Unsupported data type (=4)) in getMorphologyRowFilter, file /home/aly/libs/opencv-, line 894
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/aly/libs/opencv- error: (-213) Unsupported data type (=4) in function getMorphologyRowFilter

I don't really understand what it means? I am using the latest opencv version

edit retag flag offensive close merge delete


A first guess at the errors meaning is that the input data you are supplying to the getMorphologyRowFilter() function doesn't follow the rules that it needs to follow. Check on this link that all your arguments have right format.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-07-24 08:12:53 -0500 )edit