Python CVMat


we have some problems with our OpenCV2-implementation or library (we aren't so sure). We want our pictures to be exported as cvMat but at the moment we have no access to anything with cv2.anyFunction, so we get our pictures as IplImage. 

We want to continue with image procession with this format with cv2-functions in Python, that's why we need it.

Any suggestions how to get this started or even if it's possible to get it started?

Thanks in advance :) 

kwatters's picture

example script

Hello InMoov HDA, 

  What is it that you're trying to do with the image as a CvMat ?  We have a lot of filters already implemented, perhaps you can use one of those , or maybe it'd be easier / better if you did your OpenCV stuff in Java? 


  OpenCV is exposed via the JavaCV bindings and MRL exposes those via the python service.  Normally we are passing around an IplImage, but you can convert from IplImage to a cvMat.  

In javacv there is a method called  "cvGetMat()"

you should be able to pass that the image and your cvMat.  It should copy the bytes from the image into the cvmat.  you could try something like the following :


from org.bytedeco.javacpp.opencv_core import cvGetMat
from org.bytedeco.javacpp.opencv_core import CvMat
from org.bytedeco.javacpp.opencv_core import IplImage;
image = IplImage()
mat = CvMat()
cvGetMat(image, mat)


Hope this helps!




InMoov HDA's picture

Re: Example script


sorry for our late response and thank you for your fast reply. 

We are actually not completely sure if it's what we need. We will discuss it within our team this week and if we can try it  we will give you feedback :) 

Thanks a lot for your help!