Error in running the Prespective transform in Fedora [closed]

asked 2015-02-25 00:37:54 -0600

jamesnzt gravatar image

When i run the following program it is working but when i run it in fedora it shows the error message

OpenCV Error: Assertion failed (k == STD_VECTOR_MAT) in getMat, file /builddir/build/BUILD/OpenCV-2.3.1/modules/core/src/matrix.cpp, line 918
terminate called after throwing an instance of 'cv::Exception'
  what():  /builddir/build/BUILD/OpenCV-2.3.1/modules/core/src/matrix.cpp:918: error: (-215) k == STD_VECTOR_MAT in function getMat

Mainly this error is thrown when the getPerspectiveTransform(P,Q); is included.

the code is

#include "opencv2/opencv.hpp"   
using namespace cv;

int main() 
{
    Mat ocv = imread("chess.png");

    vector<Point2f> P,Q;
   P.push_back(Point2f(118,128));
    Q.push_back(Point2f(10,10)); // 10 pixel border on all sides

    P.push_back(Point2f(753,19));
    Q.push_back(Point2f(210,10));

    P.push_back(Point2f(625,328));
    Q.push_back(Point2f(210,210));

    P.push_back(Point2f(18,542));
    Q.push_back(Point2f(10,210));

    Mat rot = cv::getPerspectiveTransform(P,Q);

    Mat result;
    cv::warpPerspective(ocv, result, rot, Size(220,220));

    imshow("result",result);
    waitKey();
    return 0;
}

Why this error occoured?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by jamesnzt
close date 2015-02-26 04:55:57.938658

Comments

just saying, opencv2.3.1 is pretty outdated, and should no more be used.

berak gravatar imageberak ( 2015-02-25 02:15:32 -0600 )edit

I tried updating it using yum install opencv. but it says already installed and upto date.

jamesnzt gravatar imagejamesnzt ( 2015-02-25 02:38:31 -0600 )edit
1

that probably only means, that yum can't install something more recent than 2.3.1 (bummer)

remember, that current stable version is 2.4.10 (or 11?), so, for that system you probably will have to build from src.

berak gravatar imageberak ( 2015-02-25 04:29:05 -0600 )edit

You are correct @berak searched for opencv package in rpmfind.net. I am using fedora 17 which supports upto opencv 2.3.1. only.

jamesnzt gravatar imagejamesnzt ( 2015-02-26 04:55:36 -0600 )edit