package org.genericsystem.layout;

import org.genericsystem.cv.Img;
import org.genericsystem.cv.Zone;
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.core.Size;
import org.testng.annotations.Test;

public class LayoutsTransformationTest {

	static {
		System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
	}

	public static void main(String[] args) {
		new LayoutsTransformationTest().testScale();
	}

	@Test
	public void testScale() {
		Img binary1 = new Img(new Mat(new Size(800, 600), CvType.CV_8U, new Scalar(255)), false);
		new Zone(0, new Rect(new Point(200, 200), new Point(300, 300))).draw(binary1, new Scalar(0), -1);
		new Zone(0, new Rect(new Point(400, 400), new Point(500, 500))).draw(binary1, new Scalar(0), -1);

		Layout layout1 = binary1.buildLayout(new Size(0.04, 0.008), 8);
		System.out.println(layout1.recursiveToString());

		Img binary2 = new Img(new Mat(new Size(800, 600), CvType.CV_8U, new Scalar(255)), false);
		new Zone(0, new Rect(new Point(250, 200), new Point(350, 300))).draw(binary2, new Scalar(0), -1);
		new Zone(0, new Rect(new Point(450, 400), new Point(550, 500))).draw(binary2, new Scalar(0), -1);

		Layout layout2 = binary2.buildLayout(new Size(0.04, 0.008), 8);
		System.out.println(layout2.recursiveToString());

		Img binary3 = new Img(new Mat(new Size(160, 120), CvType.CV_8U, new Scalar(255)), false);
		new Zone(0, new Rect(new Point(40, 40), new Point(60, 60))).draw(binary3, new Scalar(0), -1);
		new Zone(0, new Rect(new Point(80, 80), new Point(100, 100))).draw(binary3, new Scalar(0), -1);

		Layout layout3 = binary3.buildLayout(new Size(0.04, 0.02), 8);
		System.out.println(layout3.recursiveToString());

		// // Close the images
		// binary1.close();
		// binary2.close();
		// binary3.close();
	}
}

@@ -720,16 +720,16 @@
 int(
-300, 300
+299, 299
 ))).
@@ -820,16 +820,16 @@
 int(
-500, 500
+499, 499
 ))).
@@ -1132,15 +1132,15 @@
 nt(3
-50, 300
+49, 299
 ))).
@@ -1232,15 +1232,15 @@
 nt(5
-50, 500
+49, 499
 ))).
@@ -1540,14 +1540,14 @@
 int(
-60, 60
+59, 59
 ))).
@@ -1636,16 +1636,14 @@
 int(
-100, 100
+99, 99
 ))).

Fix values in test of transformations