2012-06-21 101 views
0

我有两个程序,一个接受一个图像作为矩阵,并进行跟踪对象处理使用轮廓检测​​。第二个程序将图像作为数组(IplImage)并计数为no。但我想合并这些程序来计数以及跟踪这些对象。我可以如何合并它们?cvMat转换为IplImage

+1

[重复](http://stackoverflow.com/questions/2468307/how-to-convert-a-mat-variable-type-in​​-an-的IplImage可变型合的OpenCV-2-0?RQ = 1)?这是否回答你的问题? – KobeJohn

+2

[转换cvmat到iplimage]的可能重复(http://stackoverflow.com/questions/11065249/converting-cvmat-to-iplimage) – karlphillip

回答

0

在下面的代码中,左边是CvMat,left1是IplImage。通过这种方式,您可以手动将cvmat转换为IplImage。

for (int y=0;y<height1;y++) 
      { 
        uchar* leftdata=(uchar*)(left->data.ptr+y*left->step); 
        uchar* left1data=(uchar*)(left->imageData+y*left1step); 
       for (int x=0;x<width1;x++) 
        left1data[x]=leftdata[x]; 
      } 

或这里是另一个链路How to convert a Mat variable type in an IplImage variable type in OpenCV 2.0?