简体   繁体   中英

Matrix conversions for opencv2 in python

The lack of documentation on the opencv 2 is a bit hard to work with. I am trying to use kalman filter to track moving objects. I looked here for an example, but it uses a version before 2.x:

https://projects.developer.nokia.com/opencv/browser/opencv/opencv-2.3.1/samples/python/kalman.py

I know that the python bindings for opencv 2 uses numpy matrix. How does this translate from the old implementation? For example, in the link, a matrix is created this way:

state = cv.CreateMat(2, 1, cv.CV_32FC1)

But in numpy this doesn't seem correct:

state = numpy.zeros(shape=(2,1))

There are examples where one could create a cv Matrix by converting it from numpy, but I wish to use only functions provided by cv2.

Also, I cannot find the equivalent of some functions in opencv 2:

cv.RandArr(...)

Is there an equivalent function for RandArr in cv2? I don't quite understand how it works, so implementing it myself would take some time.

I am also facing the same problem. I am unable to use cv2.Kalman() properly. But as cv2 and cv are quite compatible, I worked my way around using cv.CreateKalman() . I think this might be useful. http://jayrambhia.wordpress.com/2012/07/26/kalman-filter/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM