简体   繁体   English

在opencv中将Mat转换为iplimage *

[英]converting Mat to iplimage* in opencv

I am new in opencv and c++. 我是opencv和c ++的新手。 what is the difference between iplimage and iplimage*? iplimage和iplimage *有什么区别? I used cvHaarDetectObjects that need iplimage* in arg[1]. 我在arg [1]中使用了需要iplimage *的cvHaarDetectObjects。 I have a frame in the format of Mat. 我有一个Mat格式的框架。 how could I convert Mt to iplimage*? 如何将Mt转换为iplimage *? (I found a way to convert mat to iplimage but not to iplimage*). (我找到了一种将mat转换为iplimage而不是iplimage *的方法)。

the true one is : 真正的一个是:

iplimage* frame=cvLoadImage("1.jpg");
objects = cvHaarDetectObjects( frame, face_cascade, storage, scale_factor, 1 );

but I want to use: 但我想使用:

Mat frame;
//some functions are performed on frame
objects = cvHaarDetectObjects( frame, face_cascade, storage, scale_factor, 1 );

IplImage* is a pointer to the image data structure IplImage. IplImage *是图像数据结构IplImage的指针。 It is used in C API of opencv. 它在opencv的C API中使用。

After opencv 2.0, C++ API is introduced, and "Mat" structure replaced IplImage. 在opencv 2.0之后,引入了C ++ API,“ Mat”结构取代了IplImage。

C API functions accept IplImage* instead of IplImage, and C++ API functions accept Mat. C API函数接受IplImage *而不是IplImage,而C ++ API函数接受Mat。

Two solutions: 两种解决方案:

Mat frame;
// apply pre-processing functions
IplImage* frame2 = cvCloneImage(&(IplImage)frame);
objects = cvHaarDetectObjects(frame2, face_cascade, storage, scale_factor, 1 );

OR 要么

use C++ API function accepting &frame, doing same job with haardetectobjects. 使用接受&frame的C ++ API函数 ,对haardetectobjects做同样的工作。

If you already have the image in Mat format you should try this function call 如果您已经具有Mat格式的图像,则应尝试此函数调用

void CascadeClassifier::detectMultiScale(const Mat& image, vector<Rect>& objects, double scaleFactor=1.1, int minNeighbors=3, int flags=0, Size minSize=Size(), Size maxSize=Size());

from the link in Canberk's answer 从Canberk的答案中的链接

or try this 或尝试这个

IplImage iplframe = IplImage( frame );
objects = cvHaarDetectObjects( &iplframe, face_cascade, storage, scale_factor, 1 );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM