Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

opencv 3.3.1 python linemod: how to add templates

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()
print(len(lineModDetector.getModalities()))

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

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

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?!

Best,

Manuel