1
0
mirror of https://github.com/opencv/opencv_contrib.git synced 2025-10-19 11:21:39 +08:00

Merge pull request #1027 from berak:fix_motempl_py

This commit is contained in:
Maksim Shabunin
2017-02-28 09:54:37 +00:00

View File

@@ -37,7 +37,8 @@ if __name__ == '__main__':
sys.exit(1)
ret, frame = cam.read()
if ret == False:
break
print("could not read from " + str(video_src) + " !\n")
sys.exit(1)
h, w = frame.shape[:2]
prev_frame = frame.copy()
motion_history = np.zeros((h, w), np.float32)
@@ -45,6 +46,8 @@ if __name__ == '__main__':
hsv[:,:,1] = 255
while True:
ret, frame = cam.read()
if ret == False:
break
frame_diff = cv2.absdiff(frame, prev_frame)
gray_diff = cv2.cvtColor(frame_diff, cv2.COLOR_BGR2GRAY)
thrs = cv2.getTrackbarPos('threshold', 'motempl')