I’m trying to detect if a camera is moving backwards or forwards using OpenCV. From the examples and tutorials i see that OpticalFlow using the Lucas-Kanade algorithm may be my best option. Luckily for me, i do not really need to worry about side to side movement or movement at an angle.
The general idea i was thinking is to use the Lucas-Kanade algo in order to generate sets of points (lines) of objects it locates in the scene. If the objects are moving towards the horizon vanishing point (center) then the camera is moving backwards. If they are moving the opposite direction towards the edges of the scene then the camera is moving forwards.
Another idea was to locate objects in the scene and see if the size of them is growing smaller or bigger. This may be hard though as the length of video i have to work with is in the 5 - 10 seconds in length, the camera may move 10 or so feet and there may be nothing in front of the camera to track.
I have seen little to no topics, discussions, or sites that talk about this. Everything is related to a stationary camera and detecting motion of objects in its FOV.
Anyone have an idea of how this can be accomplished?