yaml python 3.0

asked 2016-09-20 08:03:07 -0600

paolo.rota gravatar image

I have to read a YAML file in python using opencv 3.0 . I have found this solution in one of the previous questions but it is not applicable for version 3.0:

yaml_data = numpy.asarray(cv2.cv.Load("my_file.yaml"))

It seems that cv2.cv has been removed, can anyone tell me where is it now?

edit retag flag offensive close merge delete

Comments

cv2.cv is gone entirely.

what are you trying to load ?

berak gravatar imageberak ( 2016-09-20 08:43:27 -0600 )edit

Indeed. A colleague of mine has produced some YML using opencv, I have to read them.

paolo.rota gravatar imagepaolo.rota ( 2016-09-21 03:10:50 -0600 )edit

any chance, you can remove the yaml headers, and read it in as csv or such ?

sad as it is, you need some gross hack here...

berak gravatar imageberak ( 2016-09-21 03:17:32 -0600 )edit

I was hoping not to read this answer... :(

paolo.rota gravatar imagepaolo.rota ( 2016-09-21 03:24:08 -0600 )edit

Apparently there is this function:

fs = cv2.FileStorage("my_file.yml", 0)

However it is not clear how to use it: the code I have found here: https://github.com/opencv/opencv/pull/6482 does not work on my system, it keep saying FileStorage has no attribute 'getNode'

paolo.rota gravatar imagepaolo.rota ( 2016-09-21 06:19:07 -0600 )edit

indeed then, if you want to use cv2.FileStorage properly, you'd need a version later than the merge date(31 May)

berak gravatar imageberak ( 2016-09-21 07:53:13 -0600 )edit

Allright, I am using the release 3.1... Will try with beeding edge version. Thanks

paolo.rota gravatar imagepaolo.rota ( 2016-09-21 08:20:19 -0600 )edit