Hi, thanks for your help.
I'm now able to recognize the display, or at least the marker with its white border.
I'll take this region as mask for feature extraction, or is it more efficient to extract the region of interest?
Here is my code:
small = frame.img[::4, ::4]
gray = cv2.cvtColor(small, cv2.COLOR_RGB2GRAY)
#blur = cv2.medianBlur(gray, 5)
blur = cv2.blur(gray, (5,5))
#threshold, binary = cv2.threshold(blur, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
threshold, binary = cv2.threshold(blur, 150, 255, cv2.THRESH_BINARY)
contours, hierarchy = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
mask = np.zeros(small.shape, np.uint8)
count = 0
for h,cnt in enumerate(contours):
arclength = cv2.arcLength(cnt, True)
if arclength > self._max_rect:
self.max_rect = arclength
approx = cv2.approxPolyDP(cnt, 0.1*arclength, True)
if arclength > 0.6 * self._max_rect and len(approx) == 4:
cv2.drawContours(mask, [cnt], 0, (255, 255, 255), -1)
count = count + 1
#cv2.fillConvexPoly(mask, approx, (255, 255, 255))
mask = cv2.split(mask)[0]
Kind regards,
Michael