1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

added truetype font support into OpenCV, based on STB_truetype

This commit is contained in:
Vadim Pisarevsky
2020-11-11 22:17:05 +03:00
parent 1088d95c50
commit d42665d9e2
26 changed files with 7786 additions and 3720 deletions
@@ -1814,13 +1814,14 @@ public class ImgprocTest extends OpenCVTestCase {
double fontScale = 2;
int thickness = 3;
int baseLine[] = new int[1];
double EPS=5.0;
Imgproc.getTextSize(text, Imgproc.FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale, thickness, null);
Size res = Imgproc.getTextSize(text, Imgproc.FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale, thickness, baseLine);
assertEquals(543.0, res.width);
assertEquals(44.0, res.height);
assertEquals(20, baseLine[0]);
assertEquals(494.0, res.width, EPS);
assertEquals(51.0, res.height, EPS);
assertEquals(10, baseLine[0], 2.0);
}
public void testCircleMatPointIntScalar() {
@@ -2032,7 +2033,7 @@ public class ImgprocTest extends OpenCVTestCase {
public void testPutTextMatStringPointIntDoubleScalar() {
String text = "Hello World";
Size labelSize = new Size(175, 22);
Size labelSize = new Size(170, 23);
Mat img = new Mat(20 + (int) labelSize.height, 20 + (int) labelSize.width, CvType.CV_8U, colorBlack);
Point origin = new Point(10, labelSize.height + 10);
@@ -2040,13 +2041,13 @@ public class ImgprocTest extends OpenCVTestCase {
assertTrue(Core.countNonZero(img) > 0);
// check that border is not corrupted
Imgproc.rectangle(img, new Point(11, 11), new Point(labelSize.width + 10, labelSize.height + 10), colorBlack, Imgproc.FILLED);
Imgproc.rectangle(img, new Point(10, 10), new Point(labelSize.width + 10, labelSize.height + 10), colorBlack, Imgproc.FILLED);
assertEquals(0, Core.countNonZero(img));
}
public void testPutTextMatStringPointIntDoubleScalarInt() {
String text = "Hello World";
Size labelSize = new Size(176, 22);
Size labelSize = new Size(170, 23);
Mat img = new Mat(20 + (int) labelSize.height, 20 + (int) labelSize.width, CvType.CV_8U, colorBlack);
Point origin = new Point(10, labelSize.height + 10);
@@ -2060,7 +2061,7 @@ public class ImgprocTest extends OpenCVTestCase {
public void testPutTextMatStringPointIntDoubleScalarIntIntBoolean() {
String text = "Hello World";
Size labelSize = new Size(175, 22);
Size labelSize = new Size(170, 23);
Mat img = new Mat(20 + (int) labelSize.height, 20 + (int) labelSize.width, CvType.CV_8U, colorBlack);
Point origin = new Point(10, 10);
@@ -2069,7 +2070,7 @@ public class ImgprocTest extends OpenCVTestCase {
assertTrue(Core.countNonZero(img) > 0);
// check that border is not corrupted
Imgproc.rectangle(img, new Point(10, 10), new Point(labelSize.width + 9, labelSize.height + 9), colorBlack, Imgproc.FILLED);
Imgproc.rectangle(img, new Point(10, 10), new Point(labelSize.width + 10, labelSize.height + 10), colorBlack, Imgproc.FILLED);
assertEquals(0, Core.countNonZero(img));
}
}