opencv 3.3.1 python linemod: how to add templates

asked 2018-05-27 15:34:59 -0500

mondi gravatar image

0 down vote favorite

today it try to use the linemod algorithm which is part of OpenCV. In an earlier C++ project I already use linemod and it works like it is described in the documentation, but this time I try to use the Python API.

Here my approach:

import cv2

template = cv2.imread('path_to_template')

lineModDetector = cv2.linemod.getDefaultLINE()

mask = cv2.bitwise_not(template)[:,:,1]

ret, boundingBox = lineModDetector.addTemplate([template], "circle", mask)

The template image:

image description

But when I try to add a template it always fails. Has someone an idea how to make it work as expected? I already had a look into the C++ source code but everything seems to be fine. I guess the wrapper code could be the problem?!



edit retag flag offensive close merge delete