What is the best way to detect motions of objects on video (exclude ego motion of camera) when the my camera moves?
I have real-time 50 FPS fullHD 1920x1080 video-stream. Camera has ego motion.
I.e. I must do:
- estimate motion of my camera between 1st and 2nd frames (translation, scale and rotation)
- compensate this movement of my camera - reversed move 2-nd frame
- use
gpu::MOG2_GPU
to detect motions of objects - the difference between the two frames
What is the best way (the fastest and the best quality) to compensate movement of the my camera?
phaseCorrelate()
- get only translation and very slowcv::videostab
- class designed to eliminate jitter and video stabilization- for each frame calculate (
gpu::SURF_GPU
orgoodFeaturesToTrack()
) andestimateRigidTransform()
- get affine transformation (translation, scale and rotation) but is very slow for HD real-time video - for every 50 th frame (1 times per 1 sec) calculate (
gpu::SURF_GPU
orgoodFeaturesToTrack()
) andestimateRigidTransform()
- use approach 4, but with custom implementation of
estimateRigidTransform()
- use (calcOpticalFlowSF()
orcalcOpticalFlowFarneback()
orDenseOpticalFlow::calc
) instead ofcalcOpticalFlowPyrLK()
: https://github.com/Itseez/opencv/blob/3942b1f36261b196a264eb35c996222848fe3c93/modules/video/src/lkpyramid.cpp#L1439
What is the best of these 5 approaches, and if this is 4, then what is the best of OpticalFlow-functions: