Ask Your Question

simpleCV to openCV

asked 2012-10-17 03:24:58 -0500

harsha_fractal gravatar image

Hi, I ve got a simplecv Image on which I drew a colour rectangle on the source image only.(not on any layer) Now I want to take this colour image and turn it into a cvMat (8UC3) so that I can use it with some openCV functions. How do i do that?

edit retag flag offensive close merge delete


Can you post your code here? That would be really helpful.

jayrambhia gravatar imagejayrambhia ( 2012-10-17 04:54:40 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2012-10-17 09:51:25 -0500

xamox gravatar image

We don't have anything built-in, but we can return an IPLImage and then use OpenCV to convert it for us:

from SimpleCV import *

img = Image('simplecv.png')
iplimg = img.getBitmap()
cvmat = cv.GetMat(iplimg)
edit flag offensive delete link more

answered 2012-10-17 09:31:14 -0500

kscottz gravatar image

Try the getMatrix() method.

SimpleCV:3> img = Image("lenna")
SimpleCV:4> img.drawRectangle(10,10,100,100,color=Color.RED)
SimpleCV:5> img = img.applyLayers()
SimpleCV:6> mat = img.getMatrix() #OpenCV matrix
SimpleCV:7> img2 = Image(mat)

See the documentation here

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2012-10-17 03:24:58 -0500

Seen: 1,382 times

Last updated: Oct 17 '12