-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcanvas_temp.py
49 lines (32 loc) · 1 KB
/
canvas_temp.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
37
38
39
40
41
42
43
44
45
46
47
48
49
import cv2
import numpy as np
import time
load_from_disk = True
if load_from_disk:
penval = np.load('penval.npy')
cap = cv2.VideoCapture(0)
cap.set(3,1280)
cap.set(4,720)
pen_img = cv2.resize(cv2.imread('pen.png',1), (100, 100))
eraser_img = cv2.resize(cv2.imread('eraser.jpg',1), (100, 100))
kernel= np.ones((5,5),np.uint8)
cv2.namedWindow('image', cv2.WINDOW_NORMAL)
canvas = None
#removing the shadow
backgroundobject = cv2.createBackgroundSubtractorMOG2( detectShadows = False )
# This threshold determines the amount of disruption in background.
background_threshold = 600
# A variable which tells you if you're using a pen or an eraser.
switch = 'Pen'
last_switch = time.time()
x1,y1=0,0
noiseth = 800
wiper_thresh = 40000
clear = False
while(1):
_, frame = cap.read()
frame = cv2.flip(frame, 1 )
if canvas is None:
canvas = np.zeros_like(frame)
top_left = frame[0: 100, 0: 100]
fgmask = backgroundobject.apply(top_left)