Ask Your Question

Revision history [back]

Trying to migrate python opencv application

We have a python application that was originally written and working under Ubuntu 10.10 and we're trying to migrate the application to Ubuntu 12.4. I am not familure with opencv or image processing, I am just trying to make the migration and keep it running the same way it was previously.

The program reads a barcode from a camera and pass the image to reconize the bar code.

Originally it had the following code fragments:

import opencv from opencv import highgui

This is in the initialization routine...I suspect it is checking if a camera is present or not: for index in range(3, -1,-1): self.camera = highgui.cvCreateCameraCapture(index) if self.camera: break

And finally this is performed periodically (captures image and processes it) if self.camera: cv_img = highgui.cvQueryFrame(self.camera) cv_img = opencv.cvGetMat(cv_img) py_img = opencv.adaptors.Ipl2PIL(cv_img) w,h = py_img.size

So I have read that the highgui has been combined into opencv....so I have made the following changes so far:

import cv

self.camera = cv.CreateCameraCapture(-1) (Not sure what the parameter to CreateCameraCapture does by the way.) The goal is if self.camera is null, then no camera is detected

Perodically: cv_img = cv.QueryFrame(self.camera) cv_img = cv.GetMat(cv_img) py_img = cv.adaptors.Ipl2PIL(cv_img) This does not work.....adaptors not known type [Use to work as opencv.adaptors.Ipl2PIL(cv_img)] What is correct syntax now?

Then from here py_img is used.

Can you assist me in getting this working under ubuntu 12.4.

Thanks for your help, Robert