Title: conversion of cvMat to IplImage
Tags: opencv;contour;iplimage
Question: I have two programs, one which accepts an Image as a matrix and does the processing like tracking objects using contour detection.The second program takes image as an array(IplImage) and counting no. of objects.But I want to merge these programs to count as well as track these objects.How can I merge them ?
Comment: possible duplicate of [converting cvmat to iplimage](http://stackoverflow.com/questions/11065249/converting-cvmat-to-iplimage)

Comment: [duplicate](http://stackoverflow.com/questions/2468307/how-to-convert-a-mat-variable-type-in-an-iplimage-variable-type-in-opencv-2-0?rq=1)? Does that answer your question?


Here is another answer: In the following code left is CvMat, left1 is IplImage. In this way you can manually convert cvmat to IplImage.
for (int y=0;y<height1;y++)
{
uchar* leftdata=(uchar*)(left-&gt;data.ptr+y*left-&gt;step);
uchar* left1data=(uchar* )(left-&gt;imageData+y*left1step);
for (int x=0;x<width1;x++)
left1data[x]=leftdata[x];
}
or here is another link  How to convert a Mat variable type in an IplImage variable type in OpenCV 2.0?

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2012:00:06/21/12', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<opencv><contour><iplimage>', 'Title': 'conversion of cvMat to IplImage', 'ViewCount': 462, 'id': 11136740, 'user_AboutMe': None, 'user_AccountId': 1476085.0, 'user_DisplayName': 'user1386438', 'user_Reputation': 51.0, 'user_Views': 28.0, 'user_id': 1386438.0}}