Skip to content

Commit

Permalink
Adapt to new OpenCV version.
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestmc committed Feb 19, 2018
1 parent 6529ebd commit 8593bfc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions optical_tracker/src/blob_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def detect_blob(self, image):
if blob is not None:
center = (int(blob.pt[0]), int(blob.pt[1]))
radius = int(blob.size / 2.0)
cv2.circle(pimage, center, radius, (255, 255, 255), 3)
cv2.circle(pimage, center, radius, (128, 128, 128), 3)
im_with_keypoints = pimage
cv2.imshow(self.MASK_WINDOW, im_with_keypoints)
if blob is None:
Expand All @@ -113,7 +113,14 @@ def create_detector(self):
# Filter by Inertia
params.filterByInertia = False
params.minInertiaRatio = 0.01
return cv2.SimpleBlobDetector(params)
## check opencv version and construct the detector
is_cv3 = cv2.__version__.startswith("3.")
if is_cv3:
detector = cv2.SimpleBlobDetector_create(params)
else:
detector = cv2.SimpleBlobDetecto(params)

return detector

def publish_position(self, x, y, z):
self.publisher.publish(Point(x, y, z))
Expand Down

0 comments on commit 8593bfc

Please sign in to comment.