# Revision history [back]

cv::threshold (maybe Otzu), cv::erode/dilate, findContours, cv::moments to check which contours are your circles, solvePNP to get the pose. But as always, an image of your marker could help.

cv::threshold (maybe Otzu), cv::erode/dilate, findContours, cv::moments to check which contours are your circles, solvePNP to get the pose. But as always, an image of your marker could help.

Something to begin with: (I just have to practive my python)

#!/usr/bin/env python
import cv2

im = cv2.cvtColor(im_col,cv2.COLOR_BGR2GRAY)

(threshold,bw) = cv2.threshold(im,150,255,cv2.THRESH_BINARY)
#(threshold,bw) = cv2.threshold(im,150,255,cv2.THRESH_OTSU)

conts, hier = cv2.findContours(bw,cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)

cleaned = []
for c in conts:
a = cv2.contourArea(c)
print a
if a < 50 and a > 5:
cleaned.append(c)

cv2.drawContours(im_col,cleaned,-1,(0,255,0), 3)

cv2.namedWindow("res")
cv2.imshow("res",im_col)

cv2.waitKey()


Otsu will generate many false positives so that you will have to clean up with Ransac or something similar, THRES_BINARY depends stronger on the threshold so that it's not really robust.