I warpAffine license plate before segmentation but cannot correct incline character.
opencv_core.RotatedRect rr = opencv_imgproc.minAreaRect(currentPlate.countor); opencv_core.Point[] pt = ImageOpenCvUtils.getVerticesPoint(rr); for (int k = 0; k < 4; k++) { opencv_imgproc.line(input, pt[k], pt[(k + 1) % 4], opencv_core.Scalar.RED); } double angle = rr.angle(); if (angle < -45) { angle += 90; }
opencv_core.Mat rot_mat = opencv_imgproc.getRotationMatrix2D(rr.center(), angle, 1);
opencv_core.Mat rotated = new opencv_core.Mat();
opencv_imgproc.warpAffine(clone, rotated, rot_mat, input.size());
opencv_core.Size size = null;
if (rr.angle() < -45) {
size = new opencv_core.Size(Math.round(rr.size().height()), Math.round(rr.size().width()));
} else {
size = new opencv_core.Size((int) rr.size().width(), (int) rr.size().height());
}
opencv_imgproc.rectangle(clone, rr.boundingRect(), opencv_core.Scalar.BLUE);
opencv_core.Mat subImage = new opencv_core.Mat();
opencv_imgproc.getRectSubPix(rotated, size, rr.center(), subImage);
Can you help me? Thanks