Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] support/testing: add tesseract-ocr test
@ 2024-01-07 12:09 Julien Olivain
  2024-02-05 14:54 ` Peter Korsgaard
  0 siblings, 1 reply; 2+ messages in thread
From: Julien Olivain @ 2024-01-07 12:09 UTC (permalink / raw)
  To: buildroot; +Cc: Julien Olivain, Gilles Talis

Cc: Gilles Talis <gilles.talis@gmail.com>
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
Patch tested on branch master at commit b372495 with commands:

    make check-package
    ...
    0 warnings generated

    support/testing/run-tests \
        -d dl -o output_folder \
        tests.package.test_tesseract_ocr
    ...
    OK
---
 DEVELOPERS                                    |  1 +
 .../tests/package/test_tesseract_ocr.py       | 43 +++++++++++++++++++
 2 files changed, 44 insertions(+)
 create mode 100644 support/testing/tests/package/test_tesseract_ocr.py

diff --git a/DEVELOPERS b/DEVELOPERS
index d7543247f2..73b4a1e2da 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1813,6 +1813,7 @@ F:	support/testing/tests/package/test_screen.py
 F:	support/testing/tests/package/test_stress_ng.py
 F:	support/testing/tests/package/test_tcl.py
 F:	support/testing/tests/package/test_tcl/
+F:	support/testing/tests/package/test_tesseract_ocr.py
 F:	support/testing/tests/package/test_weston.py
 F:	support/testing/tests/package/test_weston/
 F:	support/testing/tests/package/test_xz.py
diff --git a/support/testing/tests/package/test_tesseract_ocr.py b/support/testing/tests/package/test_tesseract_ocr.py
new file mode 100644
index 0000000000..232025bad2
--- /dev/null
+++ b/support/testing/tests/package/test_tesseract_ocr.py
@@ -0,0 +1,43 @@
+import os
+
+import infra.basetest
+
+
+class TestTesseractOcr(infra.basetest.BRTest):
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        """
+        BR2_PACKAGE_FREETYPE=y
+        BR2_PACKAGE_GHOSTSCRIPT_FONTS=y
+        BR2_PACKAGE_GRAPHICSMAGICK=y
+        BR2_PACKAGE_TESSERACT_OCR=y
+        BR2_PACKAGE_TESSERACT_OCR_LANG_ENG=y
+        BR2_TARGET_ROOTFS_CPIO=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """
+
+    def test_run(self):
+        cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
+        self.emulator.boot(arch="armv5",
+                           kernel="builtin",
+                           options=["-initrd", cpio_file])
+        self.emulator.login()
+
+        msg = "Hello from Buildroot runtime test."
+        img_file = "image.pgm"
+        txt_basename = "text"
+        txt_file = f"{txt_basename}.txt"
+
+        # Check the program execute.
+        self.assertRunOk("tesseract --version")
+
+        # Generate an image file including a text message.
+        cmd = f"gm convert -pointsize 16 label:'{msg}' {img_file}"
+        self.assertRunOk(cmd)
+
+        # Perform the character recognition.
+        cmd = f"tesseract {img_file} {txt_basename}"
+        self.assertRunOk(cmd, timeout=30)
+
+        # Check the decoded text matches the original message.
+        cmd = f"grep -F '{msg}' {txt_file}"
+        self.assertRunOk(cmd)
-- 
2.43.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Buildroot] [PATCH 1/1] support/testing: add tesseract-ocr test
  2024-01-07 12:09 [Buildroot] [PATCH 1/1] support/testing: add tesseract-ocr test Julien Olivain
@ 2024-02-05 14:54 ` Peter Korsgaard
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Korsgaard @ 2024-02-05 14:54 UTC (permalink / raw)
  To: Julien Olivain; +Cc: Gilles Talis, buildroot

>>>>> "Julien" == Julien Olivain <ju.o@free.fr> writes:

 > Cc: Gilles Talis <gilles.talis@gmail.com>
 > Signed-off-by: Julien Olivain <ju.o@free.fr>
 > ---
 > Patch tested on branch master at commit b372495 with commands:

 >     make check-package
 >     ...
 >     0 warnings generated

 >     support/testing/run-tests \
 >         -d dl -o output_folder \
 >         tests.package.test_tesseract_ocr
 >     ...
 >     OK

Committed, thanks.

-- 
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-05 14:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-07 12:09 [Buildroot] [PATCH 1/1] support/testing: add tesseract-ocr test Julien Olivain
2024-02-05 14:54 ` Peter Korsgaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox