Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

indeed, your Mat's have the wrong type.

if you got an array of Points called 'corners', try like this:

// // both must be in the same order / winding ! // MatOfPoint2f src = new MatOfPoint2f( corners[0], // tl corners[1], // tr corners[2], // br corners[3], // bl );

MatOfPoint2f dst = new MatOfPoint2f( new org.opencv.core.Point(0,0), new org.opencv.core.Point(w,0), new org.opencv.core.Point(w.h), new org.opencv.core.Point(0,h) );

Mat pTransform = Imgproc.getPerspectiveTransform(src, dst);

indeed, your Mat's have the wrong type.

if you got an array of Points called 'corners', try like this:

//
// both must be in the same order / winding !
//
MatOfPoint2f src = new MatOfPoint2f(
    corners[0], // tl
    corners[1], // tr
    corners[2], // br
    corners[3], // bl
);

);

MatOfPoint2f dst = new MatOfPoint2f( new org.opencv.core.Point(0,0), new org.opencv.core.Point(w,0), new org.opencv.core.Point(w.h), new org.opencv.core.Point(0,h) );

);

Mat pTransform = Imgproc.getPerspectiveTransform(src, dst);

indeed, your Mat's have the wrong type.

if you got an array of Points called 'corners', try like this:

//
// both must be in the same order / winding !
//
MatOfPoint2f src = new MatOfPoint2f(
    corners[0], // tl
    corners[1], // tr
    corners[2], // br
    corners[3], // bl
);

MatOfPoint2f dst = new MatOfPoint2f(
    new org.opencv.core.Point(0,0),
    new org.opencv.core.Point(w,0),
    new org.opencv.core.Point(w.h),
    new org.opencv.core.Point(0,h)
);

Mat pTransform = Imgproc.getPerspectiveTransform(src, dst);

dst);

indeed, your Mat's have the wrong type.

if you got an array of Points called 'corners', try like this:

//
// both must be in the same order / winding !
//
MatOfPoint2f src = new MatOfPoint2f(
    corners[0], // tl
    corners[1], // tr
    corners[2], // br
    corners[3], // bl
);

MatOfPoint2f dst = new MatOfPoint2f(
    new org.opencv.core.Point(0,0),
org.opencv.core.Point(0,0), // awt has a Point class too, thus the pesky canonical name here
    new org.opencv.core.Point(w,0),
    new org.opencv.core.Point(w.h),
    new org.opencv.core.Point(0,h)
);

Mat pTransform = Imgproc.getPerspectiveTransform(src, dst);

indeed, your Mat's have the wrong type.

if you got an array of Points called 'corners', try like this:

//
// both must be in the same order / winding !
//
MatOfPoint2f src = new MatOfPoint2f(
    corners[0], // tl
    corners[1], // tr
    corners[2], // br
    corners[3], // bl
);

MatOfPoint2f dst = new MatOfPoint2f(
    new org.opencv.core.Point(0,0), // awt has a Point class too, thus the pesky so needs canonical name here
    new org.opencv.core.Point(w,0),
    new org.opencv.core.Point(w.h),
    new org.opencv.core.Point(0,h)
);

Mat pTransform = Imgproc.getPerspectiveTransform(src, dst);