Realtime Text Recognition with VIM4 and IMX415 MIPI Camera

Hello @JietChoo ,

Sorry, now we have not ready text detection model.

Will there be one soon?

Hi Louis, any updates on text detection model?

Hello @JietChoo

About the new demo we need time to finish, we will update you once we finished.

Thank you, just wondering expected how long will it be done?

Hi, any updates on this?

Hello, good day, any update on this?

Hello Good day, any updates?

Hello @JietChoo ,

Sorry for late reply. We meet many problem when convert PPOCR model and infer on VIM4. Now the latest firmware which supports PPOCR is undergoing final testing. The firmware and KSNN Text Recognition will be released next week.

2 Likes

Hi Louis, Hooray! Thank you for the update! Looking forward to it!

Hello @JietChoo ,

The latest KSNN Demo has updated. Please use the latest firmware and refer this doc to run PPOCR Demo.
PPOCR KSNN Demo - 10 [Khadas Docs]

1 Like

Hooray! Thank you Louis! Will look into it!

Hi it seems that the URL Link cant be found

Hello @JietChoo ,

Sorry, the link is error. Now corrected and try again.

Hi Louis, i ran the follow code

python3 ppocr-cap.py --det_model ./models/VIM4/ppocr_det_int8.adla --det_library ./libs/libnn_ppocr_det.so --rec_model ./models/VIM4/ppocr_rec_int16.adla --rec_library ./libs/libnn_ppocr_rec.so --device 63

And got this result

|---+ KSNN Version: v1.4 +---| 
Start init neural network ...
adla usr space 1.2.0.5
Segmentation fault

Source code

Another thing,

When i try installing python3-env

sudo apt install python3-venv

I go this error

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  python3.12-venv
The following NEW packages will be installed:
  python3-venv python3.12-venv
0 upgraded, 2 newly installed, 0 to remove and 114 not upgraded.
Need to get 5,678 B/6,712 B of archives.
After this operation, 34.8 kB of additional disk space will be used.
Do you want to continue? [Y/n] 
Ign:1 http://ports.ubuntu.com noble-security/universe arm64 python3.12-venv arm64 3.12.3-1ubuntu0.2
Err:1 http://ports.ubuntu.com noble-security/universe arm64 python3.12-venv arm64 3.12.3-1ubuntu0.2
  404  Not Found [IP: 185.125.190.39 80]
E: Failed to fetch http://ports.ubuntu.com/pool/universe/p/python3.12/python3.12-venv_3.12.3-1ubuntu0.2_arm64.deb  404  Not Found [IP: 185.125.190.39 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Hello @JietChoo ๏ผŒ

Only the latest firmware supports this demo. The latest firmware will print adla usr space 1.4.0.5.
https://dl.khadas.com/products/vim4/firmware/ubuntu/emmc/ubuntu-24.04/vim4-ubuntu-24.04-server-linux-5.15-fenix-1.7.3-241129-emmc.img.xz

And before run install python3-venv, have you run sudo apt update?

Hi Louis,

I have erased the OS Image from VIM4, reinstall the latest gnome version. And follow the setup again. I have also downloaded the ksnn ppocr demo, ran a virtual environment, pip3 install necessary pacakges and run it with

python3 ppocr-cap.py --det_model ./models/VIM4/ppocr_det_int8.adla --det_library ./libs/libnn_ppocr_det.so --rec_model ./models/VIM4/ppocr_rec_int16.adla --rec_library ./libs/libnn_ppocr_rec.so --device 63

And got the result as below.

 |---+ KSNN Version: v1.4.1 +---| 
Start init neural network ...
adla usr space 1.4.0.2
adla usr space 1.4.0.2
Done.
Traceback (most recent call last):
  File "/home/khadas/ksnn-vim4/examples/ppocr/ppocr-cap.py", line 104, in <module>
    det_img = cv.resize(orig_img, (736, 736)).astype(np.float32)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cv2.error: OpenCV(4.10.0) /io/opencv/modules/imgproc/src/resize.cpp:4152: error: (-215:Assertion failed) !ssize.empty() in function 'resize'

Not sure whether if the device number --device 63. In the previous version it was 63. I have not try it with cv.VideoCapture(โ€œ{pipeline}โ€,cv.CAP_GSTREAMER) yet

Hello @JietChoo ,

Try again after deleting the two lines.

    cap.set(3,1920)
    cap.set(4,1080)

And please make sure your camera device is still 63.

Hi Louis,

I have tried commenting the two lines out, and run it with device 63, but still have the same error.

[ERROR:0@0.184] global obsensor_uvc_stream_channel.cpp:158 getStreamChannelGroup Camera index out of range
Traceback (most recent call last):
  File "/home/khadas/ksnn-vim4/examples/ppocr/ppocr-cap.py", line 103, in <module>
    det_img = cv.resize(orig_img, (736, 736)).astype(np.float32)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cv2.error: OpenCV(4.10.0) /io/opencv/modules/imgproc/src/resize.cpp:4152: error: (-215:Assertion failed) !ssize.empty() in function 'resize'

GStreamer not working as the GSTREAMER Video I/O in cv.getBuildInformation() has a NO value.

General configuration for OpenCV 4.10.0 =====================================
  Version control:               4.10.0-dirty

  Platform:
    Timestamp:                   2024-06-17T18:00:16Z
    Host:                        Linux 5.3.0-28-generic aarch64
    CMake:                       3.29.5
    CMake generator:             Unix Makefiles
    CMake build tool:            /bin/gmake
    Configuration:               Release

  CPU/HW features:
    Baseline:                    NEON FP16
    Dispatched code generation:  NEON_DOTPROD NEON_FP16 NEON_BF16
      requested:                 NEON_FP16 NEON_BF16 NEON_DOTPROD
      NEON_DOTPROD (1 files):    + NEON_DOTPROD
      NEON_FP16 (2 files):       + NEON_FP16
      NEON_BF16 (0 files):       + NEON_BF16

  C/C++:
    Built as dynamic libs?:      NO
    C++ standard:                11
    C++ Compiler:                /opt/rh/devtoolset-10/root/usr/bin/c++  (ver 10.2.1)
    C++ flags (Release):         -Wl,-strip-all   -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -Wl,-strip-all   -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /opt/rh/devtoolset-10/root/usr/bin/cc
    C flags (Release):           -Wl,-strip-all   -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -Wl,-strip-all   -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      -L/ffmpeg_build/lib  -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined  
    Linker flags (Debug):        -L/ffmpeg_build/lib  -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined  
    ccache:                      YES
    Precompiled headers:         NO
    Extra dependencies:          /lib64/libopenblas.so Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Test Qt5::Concurrent /usr/local/lib/libpng.so /lib64/libz.so dl m pthread rt
    3rdparty dependencies:       libprotobuf ade ittnotify libjpeg-turbo libwebp libtiff libopenjp2 IlmImf tegra_hal

  OpenCV modules:
    To be built:                 calib3d core dnn features2d flann gapi highgui imgcodecs imgproc ml objdetect photo python3 stitching video videoio
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 java python2 ts
    Applications:                -
    Documentation:               NO
    Non-free algorithms:         NO

  GUI:                           QT5
    QT:                          YES (ver 5.15.13 )
      QT OpenGL support:         NO
    GTK+:                        NO
    VTK support:                 NO

  Media I/O: 
    ZLib:                        /lib64/libz.so (ver 1.2.7)
    JPEG:                        build-libjpeg-turbo (ver 3.0.3-70)
      SIMD Support Request:      YES
      SIMD Support:              YES
    WEBP:                        build (ver encoder: 0x020f)
    PNG:                         /usr/local/lib/libpng.so (ver 1.6.43)
    TIFF:                        build (ver 42 - 4.6.0)
    JPEG 2000:                   build (ver 2.5.0)
    OpenEXR:                     build (ver 2.3.0)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES
    PFM:                         YES

  Video I/O:
    DC1394:                      NO
    FFMPEG:                      YES
      avcodec:                   YES (59.37.100)
      avformat:                  YES (59.27.100)
      avutil:                    YES (57.28.100)
      swscale:                   YES (6.7.100)
      avresample:                NO
    GStreamer:                   NO
    v4l/v4l2:                    YES (linux/videodev2.h)

  Parallel framework:            pthreads

  Trace:                         YES (with Intel ITT)

  Other third-party libraries:
    Lapack:                      YES (/lib64/libopenblas.so)
    Eigen:                       NO
    Custom HAL:                  YES (carotene (ver 0.0.1, Auto detected))
    Protobuf:                    build (3.19.1)
    Flatbuffers:                 builtin/3rdparty (23.5.9)

  OpenCL:                        YES (no extra features)
    Include path:                /io/opencv/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python 3:
    Interpreter:                 /opt/python/cp39-cp39/bin/python3.9 (ver 3.9.19)
    Libraries:                   libpython3.9m.a (ver 3.9.19)
    Limited API:                 YES (ver 0x03060000)
    numpy:                       /home/ci/.local/lib/python3.9/site-packages/numpy/_core/include (ver 2.0.0)
    install path:                python/cv2/python-3

  Python (for build):            /opt/python/cp39-cp39/bin/python3.9

  Java:                          
    ant:                         NO
    Java:                        NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Install to:                    /io/_skbuild/linux-aarch64-3.9/cmake-install
-----------------------------------------------------------------