Home Obtain the boundary of the keyboard by open cv

# Obtain the boundary of the keyboard by open cv

user5528
1#
user5528 Published in September 19, 2018, 10:29 am

I'm working on a virtual keyboard in opencv and python. I need to detect the largest contour to obtain the boundary of the keyboard and the coordinates of the corners.

Here is what I actually need:

Here is my code :

import numpy as np
import cv2
import requests

url = 'http://192.168.1.100:8080/shot.jpg'

while (True):

imgResp = requests.get(url)
imgNp = np.array(bytearray(imgResp.content), dtype=np.uint8)
frame = cv2.imdecode(imgNp, -1)

hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
ret1, thresh1 = cv2.threshold(hsv, 100, 255, cv2.THRESH_BINARY)

thresh1, contours, hierarchy = cv2.findContours(thresh1, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)
cv2.drawContours(frame, contours, -1, (0, 255, 0), 3)

cv2.imshow('thresh1', thresh1)
cv2.imshow('frame', frame)

# Q Quit
if cv2.waitKey(1) & 0xFF == ord('q'):
break

cv2.destroyAllWindows()

• have you solved your issue? – Jeru Luke Apr 20 at 19:16