use of br.edu.ifspsaocarlos.sdm.kifurecorder.processing.cornerDetector.Ponto in project kifu-recorder by leonardost.
the class ImageUtils method generateOrthogonalBoardImage.
public static Mat generateOrthogonalBoardImage(Mat image, Corner[] corners) {
Mat orthogonalBoardImage = new Mat(ORTHOGONAL_BOARD_IMAGE_SIZE, ORTHOGONAL_BOARD_IMAGE_SIZE, image.type());
Mat orthogonalImageCorners = new Mat(4, 1, CvType.CV_32FC2);
orthogonalImageCorners.put(0, 0, 0, 0, ORTHOGONAL_BOARD_IMAGE_SIZE, 0, ORTHOGONAL_BOARD_IMAGE_SIZE, ORTHOGONAL_BOARD_IMAGE_SIZE, 0, ORTHOGONAL_BOARD_IMAGE_SIZE);
Point[] realCornerPositions = new Point[4];
for (int i = 0; i < 4; i++) {
Ponto realCornerPosition = corners[i].getRealCornerPosition();
realCornerPositions[i] = new Point(realCornerPosition.x, realCornerPosition.y);
}
Mat boardPositionInImage = new Mat(4, 1, CvType.CV_32FC2);
boardPositionInImage.put(0, 0, realCornerPositions[0].x, realCornerPositions[0].y, realCornerPositions[1].x, realCornerPositions[1].y, realCornerPositions[2].x, realCornerPositions[2].y, realCornerPositions[3].x, realCornerPositions[3].y);
Mat transformationMatrix = Imgproc.getPerspectiveTransform(boardPositionInImage, orthogonalImageCorners);
Imgproc.warpPerspective(image, orthogonalBoardImage, transformationMatrix, orthogonalBoardImage.size());
return orthogonalBoardImage;
}
use of br.edu.ifspsaocarlos.sdm.kifurecorder.processing.cornerDetector.Ponto in project kifu-recorder by leonardost.
the class RecordGameActivity method processBoardCorners.
private void processBoardCorners() {
Point[] cornerPoints = new Point[4];
for (int i = 0; i < 4; i++) {
Ponto ponto = boardCorners[i].getRealCornerPosition();
cornerPoints[i] = new Point(ponto.x, ponto.y);
}
boardPositionInImage = new Mat(4, 1, CvType.CV_32FC2);
boardPositionInImage.put(0, 0, cornerPoints[0].x, cornerPoints[0].y, cornerPoints[1].x, cornerPoints[1].y, cornerPoints[2].x, cornerPoints[2].y, cornerPoints[3].x, cornerPoints[3].y);
boardContour = new MatOfPoint(cornerPoints);
}
Aggregations