python-2.7opencvraspberry-pi3projectionautonomy

OpenCV, projection on 3d surface


I'm currently working on a school project with an "autonomous" car, I need to project the image from my camera (which is situated on the car and slightly tilted), onto a 2d surface representing a road (i assume the road is perfectly flat), given the FOV, position and angle of my camera relative to the surface, how would I project it in OpenCV? What i need excatly is for the projection to be as if I had filmed the road from above at a 90° angle. Thanks in advance for help...


Solution

  • use opencv function to do it

    C++: void reprojectImageTo3D(InputArray disparity, OutputArray _3dImage, InputArray Q, bool handleMissingValues=false, int ddepth=-1 )
    

    The Q matrix is inverse of projection matrix K which contains camera center and fx fy

    enter image description here

    You can artificially create a disparity say a gradient map to represent the depth of the flat surface.

    Then pass Q, disparty, and output3Dmat you want

    The program will gives you what you want