Skip to content

Instantly share code, notes, and snippets.

@guilhermemauro
Created March 1, 2017 19:42
Show Gist options
  • Save guilhermemauro/257cedef966bb4ce0d7822f0e1d40b2b to your computer and use it in GitHub Desktop.
Save guilhermemauro/257cedef966bb4ce0d7822f0e1d40b2b to your computer and use it in GitHub Desktop.
#cut image staying just the field choosed
def getField(coord, frame):
crop_img = frame[coord[0]:coord[1], coord[2]:coord[3]]
return crop_img
#find X and/or O with color detection in cut image
def getContoursHSV(img):
mask = cv2.inRange(cv2.cvtColor(img, cv2.COLOR_BGR2HSV), CARD_COLOR_LOW, CARD_COLOR_UP)
if len(mask) > 0:
dilation = cv2.dilate(mask,KERNEL,iterations = 2)
cnt = findBiggestContour(dilation)
return cnt
else:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment