Advertisement
jack06215

[OpenCV] meshgrid

Jul 8th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. //     meshgridTest(cv::Range(1,3), cv::Range(10, 14), X, Y);
  2. std::pair<cv::Mat1i, cv::Mat1i> meshgrid(const cv::Range &xgv, const cv::Range &ygv)
  3. {
  4.     struct meshgrid_test
  5.     {
  6.         static void meshgrid_test1(const cv::Mat &xgv, const cv::Mat &ygv,
  7.             cv::Mat1i &X, cv::Mat1i &Y)
  8.         {
  9.             cv::repeat(xgv.reshape(1, 1), ygv.total(), 1, X);
  10.             cv::repeat(ygv.reshape(1, 1).t(), 1, xgv.total(), Y);
  11.         }
  12.     };
  13.  
  14.     std::pair<cv::Mat1i, cv::Mat1i> mesh_pair;
  15.     std::vector<int> t_x, t_y;
  16.     for (int i = xgv.start; i <= xgv.end; i++) t_x.push_back(i);
  17.     for (int i = ygv.start; i <= ygv.end; i++) t_y.push_back(i);
  18.     meshgrid_test::meshgrid_test1(cv::Mat(t_x), cv::Mat(t_y), mesh_pair.first, mesh_pair.second);
  19.  
  20.     return mesh_pair;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement