0

How to dump a cv2 object (more preciely a list or a np.array containing these objects), for example keypoints (type: cv2.KeyPoint) or matches (type: cv2.DMatch), to a file on disk in order to import them later rather than re-runing a time consumming (several hours up to days on a low end computer) algorithm on a lot of images (> 50'000)?

It doesn't work with (c)Pickle. Typical errors are:

PicklingError: Can't pickle <type 'cv2.KeyPoint'>: it's not the same object as cv2.KeyPoint

or

PicklingError: Can't pickle <type 'cv2.DMatch'>: it's not the same object as cv2.DMatch

And I can not find any dump or saving/export method on cv2.

The script runs using Python 2.7 on both Ubuntu 16.04 and Windows 7.

4

1 回答 1

0

如果您坚持将关键点保存在文本/pickle 文件中,那么您必须转换 Keypoint 对象以便它可以进行pickle。

使用此处的 SO 答案将对象分解为可腌制的格式并将其加载回您的代码。

于 2017-06-02T19:01:18.330 回答