SokratG / Surround-View

MIT License
149 stars 48 forks source link

Image Perspective Transformation #13

Closed hanrui234 closed 1 year ago

hanrui234 commented 1 year ago

Sorry to bother you again, I saw that you have performed perspective transformation on the stitched image. Is the purpose of the perspective transformation to map with the bowl model? If so, why are the four coordinate points in the configuration file a very strange one? shape, thank you The following code comes from SVStitcher.cpp

    WPTSfout["tl"] >> tl; WPTSfout["tr"] >> tr;
          WPTSfout["bl"] >> bl; WPTSfout["br"] >> br;
          WPTSfout["res_size"] >> resSize;
          const auto width_ = resSize.width;
          const auto height_ = resSize.height;

          std::vector<cv::Point_<float>> src {tl, tr, bl, br};
          std::vector<cv::Point_<float>> dst {cv::Point(0, 0), cv::Point(width_, 0),
                                              cv::Point(0, height_), cv::Point(width_, height_)};
          cv::Mat transformM = cv::getPerspectiveTransform(src, dst);

          cv::cuda::buildWarpPerspectiveMaps(transformM, false, resSize, warpXmap, warpYmap);

          row_range = cv::Range(tl.y, height_);
          col_range = cv::Range(0,  width_);
    }
SokratG commented 1 year ago

Hi! The idea is the following - tripod-mounted cameras have uneven heights(different heights). That mean I don't have pure rotation(it's strange because they don't have only rotation anyway, even if they are set at the same height), therefore I get much more offset of frames when I place them in one coordinate system(after calibration) and stitch.

Figure 1 (below) is an explanation of what this code does. I'm trying to find(automatically) 4 angle points of a stitched image (code here) and then I make perspective transform(warping) on full size of panorama figure 2. This is just texture preparing for pass to OpenGL and render on bowl mesh.

figure 1

figure 2

hanrui234 commented 1 year ago

Thanks for your answer, I got it