OpenCv2 study notes (3) Mutual conversion of Mat, CvMat and IplImage

In opencv2.4.9, some functions still have no C++ interface, so CvMat or IplImage are sometimes needed in opencv2, so how to convert these data structures to each other is a problem that needs to be considered. We can read from a required data structure and assign it to a new data structure, which is a deep copy. Usually what we need is the data itself, not the need to make changes to the data, so it is more appropriate to choose the functions that come with opencv, because most of the functions are shallow copies.

1、Mat –> IplImage

 
    
   
 
    
   
 
    
  

2、Mat –> CvMat

 
    
   
 
    
   
 
    
  

3、IplImage –> Mat

 
    
   
 
    
   
 
    
   
 
   

Mat mt2 = cvarrToMat (img,flase); //The second parameter defaults to flase, no data is copied, shallow copy; true deep copy

4、IplImage –> CvMat

 
    
   
 
    
   
 
    
   
 
    
   
 
    
   
 
    
  

5、CvMat –> IplImage

 
    
   
 
    
   
 
    
  

6、CvMat –> Mat

 
    
   
 
    
   
 
    
   
 
    
  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325447313&siteId=291194637