Question

I have a point cloud created from multiple images. I extracted a plane from it, it is also in 3d co-ordinate system, this implies I have the plane equation of that plane. But in none of the original images the plane has ortho-normal view, that is the plane is not parallel to the viewing plane. But, as I have the plane's 3d cloud, I want to project it in XY plane, that is I want to make the plane parallel to the viewing plane and create an image from it. What is the algorithm or function to do it in C++/OpenCV?

Était-ce utile?

La solution

I'm not sure to understand exactly what you want to do, but these may help you, I did this with a chessboard:

std::vector<cv::Point2f> not_a_rect_shape;  // In this vector you should save the x,y coordinates of your 3D rect  

// the not_a_rect_shapecoordinates are from you source frame 



// Define the destination image
            quad = cv::Mat::zeros(300, 220, CV_8UC3);  // the size is important, it depends on your application, I have to say that 300x220 isn't always the right one. you have to give more infomations!! 


// these will be the parallel plane vector of point 
quad_pts.push_back(cv::Point2f(0, 0));
            quad_pts.push_back(cv::Point2f(quad.cols, 0));
            quad_pts.push_back(cv::Point2f(quad.cols, quad.rows));
            quad_pts.push_back(cv::Point2f(0,quad.rows));


transformationMatrix= cv::getPerspectiveTransform(not_a_rect_shape, quad_pts);// this is you transformation matirx 

cv::warpPerspective(src, quad, transformationMatrix,quad.size(),CV_INTER_LINEAR,cv::BORDER_ISOLATED); // the flags could change 

now quad frame should be that what you're looking for! I hope it helps

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top