1

我需要使用 CvInvert,但我有这个问题:

OpenCV 错误:在 cvInvert、文件 /opt/local/var/macports/ 中断言失败 (src.type() == dst.type() && src.rows == dst.cols && src.cols == dst.rows) build/_opt_mports_dports_graphics_opencv/opencv/work/OpenCV-2.4.3/modules/core/src/lapack.cpp,第 1738 行 libc++abi.dylib:终止调用抛出异常

这是代码:

#include <iostream>
#include <opencv/cv.h>
#include <stdio.h>

#include <opencv2/highgui/highgui_c.h>
#include <opencv2/imgproc/imgproc_c.h>
#include <opencv2/core/core_c.h>
#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

int main(int argc, const char * argv[])
{
    CvCapture* capture=cvCreateCameraCapture(0);
    IplImage* originalImg;
    cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);
    cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);
    cvNamedWindow("Imagen");

    while (true) {
        originalImg=cvQueryFrame(capture);
        cvFlip(originalImg,originalImg,3);
        IplImage* Gray=cvCreateImage(cvGetSize(originalImg), IPL_DEPTH_8U, 1);
        cvCvtColor(originalImg, Gray, CV_RGB2GRAY);

        CvMat* Mat_tipo=cvCreateMat(originalImg->height, originalImg->width, CV_32F);
        CvMat* Mat_img=cvGetMat(Gray,Mat_tipo);

        CvMat* Matinvenrt=cvCreateMat(Mat_img->rows, Mat_img->cols, CV_32F);
        cvInvert(Mat_img, Matinvenrt,CV_LU);





        cvShowImage("Imagen", Mat_img);
//        imshow("imagen", img);
        cvReleaseMat(&Mat_img);

        int  id=cvWaitKey(27);
        if (id==27) break;       
    }


}

发生了什么??,Cvinvert 有错误吗?

谢谢你。

4

2 回答 2

1
Assertion failed (src.type() == dst.type() 

从您的代码中可以清楚地看到,Mat 类型对于Mat_imgMatinvert

于 2013-03-04T06:13:26.643 回答
0

Are you sure you are inverting a square matrix? I had a similar error and was because I was trying to invert a M-N matrix.

于 2013-05-24T15:02:28.313 回答