Ask Your Question

Revision history [back]

Motion History Image

I would like to create motion history image with Python and OpenCV. I use following function :

cv2.motempl.updateMotionHistory

My video has 6 seconds and 144 frames for examples. I would like to see all motion history in one image for 6 seconds and 144 frames. But somehow, it shows for example, 1 seconds and 24 frames in one image motion history. And then, first ones for motion history disappear and new 1-2 seconds 24-40 frames motion history shown. I cannot see all motion history in one image for 6 seconds and 144 frames.

Is it possible to show all motion history for 6 seconds and 144 frames in one image with updateMotionHistory ? Any sample ?

…… cv2.motempl.updateMotionHistory(motion_mask, motion_history, timestamp, MHI_DURATION) mg_mask, mg_orient = cv2.motempl.calcMotionGradient( motion_history, MAX_TIME_DELTA, MIN_TIME_DELTA, apertureSize=7)#5 ) seg_mask, seg_bounds = cv2.motempl.segmentMotion(motion_history, timestamp, MAX_TIME_DELTA)

    visual_name = visuals[cv2.getTrackbarPos('visual', 'motempl')]
    if visual_name == 'input':
        vis = frame.copy()
    elif visual_name == 'frame_diff':
        vis = frame_diff.copy()
    elif visual_name == 'motion_hist':
        vis = np.uint8(np.clip((motion_history-(timestamp-MHI_DURATION)) / MHI_DURATION, 0, 1)*255)
        vis = cv2.cvtColor(vis, cv2.COLOR_GRAY2BGR)
    elif visual_name == 'grad_orient':
        hsv[:,:,0] = mg_orient/2
        hsv[:,:,2] = mg_mask*255
        vis = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR)

….

click to hide/show revision 2
None

updated 2019-07-04 14:27:46 -0600

berak gravatar image

Motion History Image

I would like to create motion history image with Python and OpenCV. I use following function :

cv2.motempl.updateMotionHistory

My video has 6 seconds and 144 frames for examples. I would like to see all motion history in one image for 6 seconds and 144 frames. But somehow, it shows for example, 1 seconds and 24 frames in one image motion history. And then, first ones for motion history disappear and new 1-2 seconds 24-40 frames motion history shown. I cannot see all motion history in one image for 6 seconds and 144 frames.

Is it possible to show all motion history for 6 seconds and 144 frames in one image with updateMotionHistory ? Any sample ?

……
cv2.motempl.updateMotionHistory(motion_mask, motion_history, timestamp, MHI_DURATION)
mg_mask, mg_orient = cv2.motempl.calcMotionGradient( motion_history, MAX_TIME_DELTA, MIN_TIME_DELTA, apertureSize=7)#5 )
seg_mask, seg_bounds = cv2.motempl.segmentMotion(motion_history, timestamp, MAX_TIME_DELTA)

MAX_TIME_DELTA)
 visual_name = visuals[cv2.getTrackbarPos('visual', 'motempl')]
 if visual_name == 'input':
 vis = frame.copy()
  elif visual_name == 'frame_diff':
 vis = frame_diff.copy()
  elif visual_name == 'motion_hist':
  vis = np.uint8(np.clip((motion_history-(timestamp-MHI_DURATION)) / MHI_DURATION, 0, 1)*255)
 vis = cv2.cvtColor(vis, cv2.COLOR_GRAY2BGR)
 elif visual_name == 'grad_orient':
 hsv[:,:,0] = mg_orient/2
 hsv[:,:,2] = mg_mask*255
  vis = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR)
….

….