If you call the homography matrix H, the camera matrix K (necessary for conversion to pixels) will be something like this, depending on your resolution.
Mat K= Mat::zeros(3,3,CV_32FC1); K.at<float>(0,0)=500.0f; K.at<float>(0,2)=320.0f; // width/2 K.at<float>(1,1)=500.0f; K.at<float>(1,2)=240.0f; // height/2 K.at<float>(2,2)=1.0f;
If your marker points are 2D vector points:
vector<Point2f> marker_point;
then the projection will be like this: with the result, there will be a 3D point in pixel coordinates.
Mat point(3,1,CV_32FC1); point.at<float>(0) = marker_point.x; point.at<float>(1) = marker_point.y; point.at<float>(2) = 1.0f; point = H* point; point = point/point.at<float>(2);
source share