Many times we have a stream of video to process without access to camera. Having access to camera matrix would be beneficial for various processing techniques. Is it possible to hack camera calibration without having access to the camera?
I have a stream of video from a single camera mounted on a moving car recording the road (Hence multiple parallel lines on the ground plane, corners from lane markers but no circles). I want to create a top-down view of this but I do not have access to the camera. Is it possible? If so how?
I understand from Learning OpenCV: Computer Vision with the OpenCV Library book that I need the following matrices:
- Intrinsics, and
- Distortion
.. to cv2.undistort()
the image, compute homography cv2.getPerspectiveTransform()
and cv2.warpPerspective()
to finally get the topview.
Question
- How can I compute/approximate/guess Intrinsics or Distortion Matrices/parameters? Are all parameters important?
- Would it be okay to copy parameters from other cameras (like OpenCV source code samples)?
Prior Research:
- OpenCV Python Camera Calibration Tutorial - Requires Access to the Camera
- Camera AutoCalibration - Gives hope "calibration may be obtained if multiple sets of parallel lines or objects with a known shape (e.g. circular) are identified"
- Attempting to understand camera calibration related answers[1][2][3] on SO trying to find answers to my problem.
Any ideas? Appreciate your help in advance!
Update 1: Perspective Transform Experiment
I had attempted using getPerspectiveTransform(pts1,pts2)
and dst = cv2.warpPerspective(img,M,(x,y), flags=flags)
to match four points of input image to get a sort of top-down view. But I am not sure how to handle the distortions:
Selecting Points: First, I zoomed in on the input and tried to precisely select matching exterior points on the lane markers to create the Homography Matrix and previewed the perspective transformed image with warpPerspective
. I saw the lanes were distorted but didn't know how bad. To get an idea I chose points further out by delta (50px) flat on each end. This is what I get:
Can I fix the distortions without having access to the camera? Is there any other way to fix this.
Few input images to play with:
Update 2: Non-Parallel (Scattered) Optical Flow in Top-Down View
Is this due to distortion or something else?: