mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-22 07:31:26 +08:00
Merge pull request #1027 from berak:fix_motempl_py
This commit is contained in:
@@ -37,7 +37,8 @@ if __name__ == '__main__':
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
ret, frame = cam.read()
|
ret, frame = cam.read()
|
||||||
if ret == False:
|
if ret == False:
|
||||||
break
|
print("could not read from " + str(video_src) + " !\n")
|
||||||
|
sys.exit(1)
|
||||||
h, w = frame.shape[:2]
|
h, w = frame.shape[:2]
|
||||||
prev_frame = frame.copy()
|
prev_frame = frame.copy()
|
||||||
motion_history = np.zeros((h, w), np.float32)
|
motion_history = np.zeros((h, w), np.float32)
|
||||||
@@ -45,6 +46,8 @@ if __name__ == '__main__':
|
|||||||
hsv[:,:,1] = 255
|
hsv[:,:,1] = 255
|
||||||
while True:
|
while True:
|
||||||
ret, frame = cam.read()
|
ret, frame = cam.read()
|
||||||
|
if ret == False:
|
||||||
|
break
|
||||||
frame_diff = cv2.absdiff(frame, prev_frame)
|
frame_diff = cv2.absdiff(frame, prev_frame)
|
||||||
gray_diff = cv2.cvtColor(frame_diff, cv2.COLOR_BGR2GRAY)
|
gray_diff = cv2.cvtColor(frame_diff, cv2.COLOR_BGR2GRAY)
|
||||||
thrs = cv2.getTrackbarPos('threshold', 'motempl')
|
thrs = cv2.getTrackbarPos('threshold', 'motempl')
|
||||||
|
Reference in New Issue
Block a user