在Iplimage或Mat上失败

时间:2013-03-03 18:01:03

标签: xcode opencv

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

  

OpenCV错误:断言失败(src.type()== dst.type()&& src.rows   == dst.cols&& cvInvert中的src.cols == dst.rows),文件/opt/local/var/macports/build/_opt_mports_dports_graphics_opencv/opencv/work/OpenCV-2.4.3/modules/core/src/lapack.cpp,line 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有错误吗?

谢谢。

2 个答案:

答案 0 :(得分:1)

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

从您的代码中可以清楚地看到,Mat_imgMatinvert

的Mat类型不同

答案 1 :(得分:0)

您确定要反转方阵吗? 我有一个类似的错误,因为我试图反转一个M-N矩阵。

相关问题