-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcornerdetection.py
More file actions
40 lines (36 loc) · 1.09 KB
/
cornerdetection.py
File metadata and controls
40 lines (36 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import cv2
import numpy as np
def cordet():
img=cv2.imread('./venv/imgs/10.jpg')
gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
corner=cv2.goodFeaturesToTrack(gray,100,0.01,10)
corner=np.int0(corner)
for c in corner:
x,y=c.ravel()
cv2.circle(img,(x,y),3,(0,255,0),-1)
cv2.imshow("img",img)
cv2.waitKey(0)
cv2.destroyAllWindows()
def nothing():
pass
def cordetliv():
cap=cv2.VideoCapture(0)
cv2.namedWindow("frame")
cv2.createTrackbar("quality","frame",1,100,nothing)
while True:
_,frame=cap.read()
value=cv2.getTrackbarPos("quality","frame")
value=value/100 if value>0 else 0.01
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
corner = cv2.goodFeaturesToTrack(gray, 100, value, 20)
if corner is not None:
corner = np.int0(corner)
for c in corner:
x, y = c.ravel()
cv2.circle(frame, (x, y), 3, (0, 0,255), -1)
cv2.imshow("frame",frame)
key=cv2.waitKey(1)
if key==27:
break
cap.release()
cv2.destroyAllWindows()