# Trying to record whiteboard in lecture

Hey I'm trying to record whiteboard in a lecture. I tried to extract background to ignore lecturer but if the lecturer moves slowly or spends some time on the board it will blur the image and lecturer will block the notes on the board. Now I'm trying different approach. If a lecturer is looking at the camera I will not update background image. If the lecturer is writing on the board I will update board picture. My question is how can i get the image of the board only and not the lecturer?

Here's how i will decide if lecturer is writing or not:

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while 1:
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

for (x, y, w, h) in faces:
cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
roi_gray = gray[y:y + h, x:x + w]
roi_color = img[y:y + h, x:x + w]

for (ex, ey, ew, eh) in bodies:
cv2.rectangle(roi_color, (ex, ey), (ex + ew, ey + eh), (0, 255, 0), 2)

cv2.imshow('img', img)
k = cv2.waitKey(30) & 0xff
if k == 27:
break

cap.release()
cv2.destroyAllWindows()

If I can detect face he is not writing if not he is.

And here is the function i use to blur moving objects:
import cv2
import numpy as np

# Initalize webacam and store first frame
cap = cv2.VideoCapture(0)

# Create a flaot numpy array with frame values
average = np.float32(frame)

while True:
# Get webcam frmae

# 0.01 is the weight of image, play around to see how it changes
cv2.accumulateWeighted(frame, average, 0.01)

# Scales, calculates absolute values, and converts the result to 8-bit
background = cv2.convertScaleAbs(average)
canny = cv2.Canny(background, 100, 200)
cv2.imshow('Input', frame)
cv2.imshow('Disapearing Background', background)
cv2.imshow('Canny Disappearing', canny)
if cv2.waitKey(1) == 13:  # 13 is the Enter Key
break

cv2.destroyAllWindows()
cap.release()


But I couldn't find a way to update the rest of the board where the lecturer isn't blocking.

edit retag close merge delete