I' m trying to deal with opencv in python, and I found some code on the web that are written with the legacy cv lib.
As now, it seems to not be anymore supported, so I'm wondering if one of you had ever seen a kind of translation table,book, recommandation from cv to cv2.
As an example found at : http://ioctl.eu/blog/2009/05/13/opencv_homography
import sys, glob
from opencv.cv import *
from opencv.highgui import *
# load homography
homo = cvGetMat( cvLoad(sys.argv[1]) )
## windows:
file_list = glob.glob(sys.argv[2])
## unix:
# file_list = sys.argv[1:]
# apply
for filename in file_list:
print 'Processing %s...' % (filename)
im = cvLoadImage(filename, 4)
out = cvCloneImage(im)
cvWarpPerspective(im, out, homo)
(base, ext) = filename.rsplit('.')
cvSaveImage(base + '_rect.bmp', out)
I succeed to handle some modification but:
import sys, glob
import cv2
#import cv2.cv as cv
#from opencv.cv import *
#from cv.highgui import *
# load homography
homo = cv2.GetMat( cv2.LoadImage(sys.argv[1]) )
## windows:
file_list = glob.glob(sys.argv[2])
## unix:
# file_list = sys.argv[1:]
# apply
for filename in file_list:
print 'Processing %s...' % (filename)
# im = cv2.cvLoadImage(filename, 4)
im = cv2.imRead(filename, 4)
# out = cvCloneImage(im)
out = cv2.CloneMat(im)
cv2.warpPerspective(im, out, homo)
(base, ext) = filename.rsplit('.')
#cvSaveImage(base + '_rect.bmp', out)
cv2.imWrite(base + '_rect.bmp', out)
But "GetMat" doesn't works...
And I would like to have a more general procedure, or at least advises for this job I will have to do several time, coz many example remains with the old lib.
Cheers,