Home Obtain the boundary of the keyboard by open cv
Reply: 0

Obtain the boundary of the keyboard by open cv

user942
1#
user942 Published in July 20, 2018, 1:19 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()
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.302011 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO