Reputation: 85
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:
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
Upvotes: 1
Views: 1398
Reputation: 11
the mask is not intersect with template image. even though the image is filtered by gausian, the sobel magnitude in mask area is lower than the threshold(default is 55). so it can't be successful. You can lower the threshold or just not give mask.
Upvotes: 1