gpt4 book ai didi

xcode - 在 Iplimage 或 Mat 上失败 cvinvert

转载 作者:太空宇宙 更新时间:2023-11-03 23:02:03 25 4
gpt4 key购买 nike

我需要使用 CvInvert,但我遇到了这个问题:

OpenCV Error: Assertion failed (src.type() == dst.type() && src.rows == dst.cols && src.cols == dst.rows) in cvInvert, file /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: terminate called throwing an exception

这是代码:

#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 有错误吗??

谢谢。

最佳答案

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

从您的代码中可以清楚地看到 Mat_imgMatinvert 的 Mat 类型不同

关于xcode - 在 Iplimage 或 Mat 上失败 cvinvert,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15188837/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com