3

sourceImageから抽出された4つのコーナーがあります:

src_vertices[0] = corners[upperLeft];
src_vertices[1] = corners[upperRight];   
src_vertices[2] = corners[downLeft];
src_vertices[3] = corners[downRight];

これらの4つのコーナーは、次のようにdestinationImageにワープされます。

dst_vertices[0] = Point(0,0);
dst_vertices[1] = Point(width, 0); 
dst_vertices[2] = Point(0, height);
dst_vertices[3] = Point(width, height);

Mat warpPerspectiveMatrix = getPerspectiveTransform(src_vertices, dst_vertices);
cv::Size size_d =  Size(width, height);
cv::Mat DestinationImage(width,height,CV_8UC3);
warpPerspective(sourceImage, destinationImage, warpPerspectiveMatrix, size_d, INTER_LINEAR, BORDER_CONSTANT);

今私の質問は:

destinationImageから取得したポイントp(x、y)があります。元のsourceImageでこのポイントの座標を取得するにはどうすればよいですか。

つまり、warpPerspectiveMatrixを使用して、getPerspectiveTransformの反対の作業を実行したいと思います。

4

1 に答える 1

6

逆遠近法変換が必要です。元の変換がS->S'の場合、変換行列S'->Sが必要です。

Mat InversewarpPerspectiveMatrix = getPerspectiveTransform(dst_vertices, src_vertices);

次に、スパース行列を作成します

Mat PerspectiveCoordinates containing the vector x,y.

最後にあなたは電話したい

PerspectiveTransform(PerspectiveCoordinates,OriginalCoordinates,InversewarpPerspectiveMatrix)
于 2013-01-15T20:20:45.143 に答える