Ask Your Question
0

Converting openCV image to simpleCV image

asked 2013-04-26 06:55:59 -0600

KOB gravatar image

Hi. I am using an Odroid-u2 to do some image processing. I have a problem with capturing frames from my webcamera in simpleCV, so instead i use cv2 module to capture the frames. I still want to use simpleCV to process the image, but when I create a simpleCV Image from an openCV image the width becomes the height and height become the width in the new Image.

The code looks like this.

cam = cv2.VideoCapture(0)
var, img = cam.read()
simpleCVimg = Image(img).rotate(270).flipHorizontal()

When i print the size of both images i get 640X360(openCV) and 360X640(simpleCV) Does anyone have a clue how to fix this?

edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted
1

answered 2014-01-08 11:23:55 -0600

Alan Johnstone gravatar image

updated 2014-01-08 11:26:25 -0600

I am afraid that the answer given by jayrambia does not work. It should, but if you look at the code of the Image Class it stupidly does the transform TWICE effectively doing nothing. so you have to do the following

transImg=img.transpose(1,0,2) # transpose the rows and columns

transColImg=transImg[:,:,::-1] # change from BGR to RGB

simpleCVImg=Image(transColImg)

note all the above van be done on one line as

simpleCVImg=Image(img.transpose(1,0,2)[:,:,::-1])

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

Stats

Asked: 2013-04-26 06:55:59 -0600

Seen: 2,006 times

Last updated: Jan 08 '14