Ask Your Question
0

Trying to migrate python opencv application

asked 2013-01-23 17:59:32 -0500

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-05-03 03:09:54 -0500

edunham gravatar image

Robert,

The easiest solution in your case will probably be to figure out exactly what version of OpenCV you were running on the 10.10 system, and try to install it on the 12.04 machine. This would not be a good idea if you were continuing to develop the software and adding new features, but it sounds like you just want it to work the way it did before.

I'd recommend installing the version you want from source, basically following the instructions here except downloading the correct old version from here instead of following the section on "Getting the latest stable OpenCV version".

If you'd like to update your code to work with newer versions of the OpenCV bindings, you can find a lot of good Python examples along with the source.

Sorry for the late answer -- hopefully you or others will find it useful.

edit flag offensive delete link more

Comments

I do not agree on your approach. I would always suggest people to upgrade their entire software when migrating to a newer OpenCV version, even if you want exact functionality. Tons of bugs, memory leaks, wrong closures, ... have been fixed in the latest stable release. Also, if your program works in previous versions, basically all bindings should still work if you use a newer openCV version, since they always stay backwards compatible.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-05-03 03:33:57 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-01-23 17:59:32 -0500

Seen: 526 times

Last updated: May 03 '13