C# EmguCV 이미지 투시 변환

using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;

public void ImagePerspectiveTransformation()
{
    // 이미지 로딩
    Image<Bgr, byte> image = new Image<Bgr, byte>("image.jpg");

    // 원근 변환을 위한 좌표 설정
    PointF[] sourcePoints = new PointF[]
    {
        new PointF(100, 100),
        new PointF(200, 100),
        new PointF(200, 200),
        new PointF(100, 200)
    };

    PointF[] destinationPoints = new PointF[]
    {
        new PointF(0, 0),
        new PointF(300, 0),
        new PointF(300, 300),
        new PointF(0, 300)
    };

    // 투시 변환 행렬 계산
    Mat transformationMatrix = CvInvoke.GetPerspectiveTransform(sourcePoints, destinationPoints);

    // 이미지 투시 변환
    Image<Bgr, byte> transformedImage = image.WarpPerspective(transformationMatrix, image.Size);

    // 결과 이미지 표시
    ImageViewer viewer = new ImageViewer(transformedImage, "Perspective Transformation");
    viewer.ShowDialog();


}

+ Recent posts