I'm trying to write a program with C++ and OpenCV that calculates the remaining time (frames) until a collision with an object. As a sample video I have a camera moving towards a blackboard.
My approach on this is the following:
- detect features to track (tried goodFeaturesToTrack() or setting points "by hand")
- calculate optical flow via calcOpticalFlowPyrLK()
- calculate fundamental matrix of the previous and current found features via findFundamentalMat()
- check if fundamental matrix is correct
- calculate epipolar lines and epipole - the focus of expansion in the video
Finally, I'd planned to use the time to contact method to calculate the remaining frames till collision.
Up until now, my biggest problem is to find the correct fundamental matrix and thus the epipole. The calculated matrix seems to be wrong as are the epipolar lines. Would my planned approach be correct? Does anyone have a working example of getting a FoE from a video or any kind of walkthrough on what I have to do?
I'd be very happy about any help at all!
Thank you!