-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcam.py
36 lines (34 loc) · 1003 Bytes
/
cam.py
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
#PYTHON CAMERA MODEL
import cv2
import numpy as np
i=0
def capturing(event,x,y,flags,param):
global i
if event==cv2.EVENT_LBUTTONUP:
name="photo_"+str(i)+".png"
wname="CAPTURED IMAGE"
cv2.imwrite(name,frame)
h=cv2.imread(name)
cv2.namedWindow(wname)
cv2.imshow(wname,h)
cv2.moveWindow(wname,700,50)
i+=1
cv2.waitKey(1000)
cv2.destroyWindow(wname)
cap=cv2.VideoCapture(0)
while True:
ret,frame = cap.read()
win="CAPTURE"
cv2.imshow("CAMERA",frame)
cv2.moveWindow("CAMERA",50,50)
cv2.namedWindow(win)
img=np.zeros((150,150,3))
cv2.putText(img,"CLICK",(35,65),cv2.FONT_HERSHEY_SIMPLEX,0.85,(255,255,255),2,cv2.LINE_AA)
cv2.putText(img,"HERE",(35,90),cv2.FONT_HERSHEY_SIMPLEX,0.85,(255,255,255),2,cv2.LINE_AA)
cv2.imshow(win,img)
cv2.moveWindow(win,250,560)
cv2.setMouseCallback(win,capturing)
if cv2.waitKey(1)==13:
break
cap.release()
cv2.destroyAllWindows()