OpenCV: 4 Camera Bird Eye view?

I have a lot of problems thinking about how to make a four-camera view with a bird's eye view similar to that seen in luxury cars . Here is the original that I will use as an example for this question ... enter image description here

Right now, I have the image distorted using .getPerspectiveTransform , but this is just for a single image.

enter image description here

I obviously need four, and I don't know how to stitch these images together. I also do not know how the images look. Here is the code I have:

 import cv2 as cv import numpy as np img1 = cv.imread("testBird.jpg", cv.IMREAD_COLOR) image = np.zeros((700, 700, 3), np.uint8) src = np.array([[0,200],[480,200],[480,360],[0,360]],np.float32) dst = np.array([[0,0],[480,0],[300,360],[180,360]],np.float32) M = cv.getPerspectiveTransform(src, dst) warp = cv.warpPerspective(img1.copy(), M, (480, 360)) cv.imshow('transform', warp) cv.waitKey(0) cv.destroyAllWindows() 

and here is the final image that I would like to get (Friend, compiled using Photoshop) ...

enter image description here

+8
python opencv computer-vision perspectivecamera
source share
1 answer

To implement the conversion, you need to call the getPerspectiveTransform function. It is required:

  • src: The coordinates of the quadrangles in the original image.
  • dst: The coordinates of the corresponding quadrangles in the target image.

    I think it is not easy to define "src" and "dst". He needs some calculations based on real data and cannot be solved on their own, just by looking at the photos.


So, for me, the key idea is to make a plan of the desired scene (how it should look). It should use real data such as:

  • distance between cameras
  • camera viewing angle
  • rectangle size between cameras (gray and white mesh)

enter image description here

Then you can find a good value for the EF distance depending on the size of your bird’s bird’s viewport. After that, your work is almost complete.


The dst parameter is just a scaled version of the JLK rectangle (for the top camera). Depending on the size in pixel of the output image.

The src parameter should be a rectangle in your photo. Its width fills the whole picture . The height should be calculated from the distance EF desired .

enter image description here

These are two ways to calculate the height of a red rectangle. Either you place β€œmarkers” on the real scene (or try to detect some) to automatically find a horizontal line. Or you can try to calculate it as a complex function of the elevation angle of your camera (but I want to advise you, I think it seems rather complicated).

Here is how I would solve this problem. Hope this helps :)

+4
source share

All Articles