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

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()
share|improve this question
  • have you solved your issue? – Jeru Luke Apr 20 at 19:16

2 Answers 2

active oldest votes
up vote 0 down vote
You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO