Subscribe:

Ads 468x60px

Showing posts with label OpenCV conversion. Show all posts
Showing posts with label OpenCV conversion. Show all posts

Saturday, August 4, 2026

How to convert opencv IplImage to cv::Mat and cv::Mat to IplImage

Hey guys

     This is a tutorial for converting OpenCV image handlers 

*IplImage to cv::Mat
*cv::Mat to IplImage

IplImage to cv::Mat example program

Ipltomat.cpp

 ///Opencv 2.4.2   
 #include "opencv2/highgui/highgui.hpp"  
 #include <iostream>  
 #include <stdio.h>  
 using namespace std;  
 using namespace cv;  
 int main(int argc,  
    char *argv[]  
  )  
 {  
 ///Loading image to IplImage  
 IplImage *img=cvLoadImage(argv[1]);  
 cvShowImage("Ipl",img);  
 ///converting IplImage to cv::Mat  
 Mat image=cvarrToMat(img);  
 imshow("Mat",image);  
 waitKey();  
 return 0;  
 }