Hello @JietChoo ,
Your code can infer the right, but i find that the color detection always detect N/A. And you set the default color is (255, 255, 255) which cause the you write white text and white box on white background. Try to change the default as black, (0, 0, 0).
Another problem, the boundary of box is too thin and the text is too small. You can change those parameter to change them.
font = ImageFont.truetype("./data/simfang.ttf", 20) # ImageFont.truetype(font type, font size)
draw.rectangle((left, top, right, bottom), outline=color, width=2) # change width bigger
Hi Louis,
Alright, let me try again later.
By the way, i need to use the newly converted .so file as well right?
Hello @JietChoo ,
Have better use the new, if you change the convert parameter.
Hi Louis,
I’m still unable to detect my + images. Below are the images that i cannot detect (But able to detect in Windows PaddleOCR)
Hello @JietChoo ,
Have you check the log on VIM4? Is it without any output?
Hmmmm let me check it later. Are you able to detect these two images?
Hmmm… I’m not sure where went wrong Louis 
Should i factory reset my VIM 4 and try again?
Hello @JietChoo ,
Check log on VIM4 first. You code has some print after inference. Make sure the VIM4 whether infer right result.
Hi Louis, where’s the log file? Is there a log file generated?
If i print to console, no result is printed out.
My print console during inferencing
one. inference time: 0.10247921943664551
cmos_inttime_calc_table_imx415[150]: cmos_inttime_calc_table: 14065664, 14065664, 14065664, 14065664
Done. inference time: 0.09801483154296875
cmos_inttime_calc_table_imx415[150]: cmos_inttime_calc_table: 14061568, 14061568, 14061568, 14061568
Done. inference time: 0.10322380065917969
cmos_inttime_calc_table_imx415[150]: cmos_inttime_calc_table: 14057472, 14057472, 14057472, 14057472
Done. inference time: 0.09907698631286621
cmos_inttime_calc_table_imx415[150]: cmos_inttime_calc_table: 14053376, 14053376, 14053376, 14053376
Done. inference time: 0.1038827896118164
Done. inference time: 0.1021425724029541
Done. inference time: 0.10213494300842285
Done. inference time: 0.1014554500579834
Done. inference time: 0.10411214828491211
Done. inference time: 0.09951543807983398
Done. inference time: 0.10544204711914062
Done. inference time: 0.1110844612121582
Done. inference time: 0.10393905639648438
Done. inference time: 0.10538744926452637
Done. inference time: 0.10002803802490234
Done. inference time: 0.10471224784851074
Done. inference time: 0.09997153282165527
Done. inference time: 0.10509371757507324
Done. inference time: 0.099517822265625
Done. inference time: 0.10456562042236328
Done. inference time: 0.1018972396850586
Done. inference time: 0.09889507293701172
Done. inference time: 0.09929871559143066
Done. inference time: 0.10040569305419922
Done. inference time: 0.09557104110717773
Done. inference time: 0.0979149341583252
Done. inference time: 0.09669804573059082
Done. inference time: 0.09620189666748047
Done. inference time: 0.10226964950561523
Done. inference time: 0.09920144081115723
Done. inference time: 0.09735918045043945
Done. inference time: 0.10196208953857422
Done. inference time: 0.10615944862365723
Done. inference time: 0.10459637641906738
Done. inference time: 0.10514307022094727
Done. inference time: 0.10267972946166992
Done. inference time: 0.09970211982727051
Done. inference time: 0.0964348316192627
Done. inference time: 0.09870743751525879
Done. inference time: 0.09792637825012207
Done. inference time: 0.09905695915222168
Done. inference time: 0.09527134895324707
Done. inference time: 0.0921785831451416
Done. inference time: 0.09507536888122559
Done. inference time: 0.09616303443908691
Done. inference time: 0.09603571891784668
Done. inference time: 0.09973883628845215
Done. inference time: 0.10135889053344727
Done. inference time: 0.10193824768066406
Done. inference time: 0.104461669921875
Done. inference time: 0.10779857635498047
Done. inference time: 0.10988283157348633
Done. inference time: 0.10669994354248047
Done. inference time: 0.10449361801147461
Done. inference time: 0.10425496101379395
Done. inference time: 0.10508966445922852
Done. inference time: 0.10052299499511719
Done. inference time: 0.10741615295410156
Done. inference time: 0.09975075721740723
Done. inference time: 0.09558272361755371
Done. inference time: 0.09618592262268066
Done. inference time: 0.09716153144836426
Done. inference time: 0.10628843307495117
Done. inference time: 0.11103224754333496
Done. inference time: 0.1037299633026123
Done. inference time: 0.10235404968261719
Done. inference time: 0.10057783126831055
Done. inference time: 0.10391449928283691
Done. inference time: 0.1075129508972168
Done. inference time: 0.10071921348571777
Done. inference time: 0.09887528419494629
Done. inference time: 0.1008765697479248
Done. inference time: 0.11258959770202637
Done. inference time: 0.10083580017089844
Done. inference time: 0.1079702377319336
Done. inference time: 0.10836625099182129
Done. inference time: 0.1089012622833252
Done. inference time: 0.11134862899780273
Done. inference time: 0.10428810119628906
Done. inference time: 0.10957694053649902
Done. inference time: 0.10997533798217773
Done. inference time: 0.09678411483764648
Done. inference time: 0.10137200355529785
Done. inference time: 0.10990142822265625
Done. inference time: 0.10029792785644531
Done. inference time: 0.1099553108215332
Done. inference time: 0.09885072708129883
Done. inference time: 0.10451889038085938
Done. inference time: 0.10025358200073242
Done. inference time: 0.10404586791992188
Done. inference time: 0.11451077461242676
Done. inference time: 0.10430216789245605
Done. inference time: 0.09859633445739746
Done. inference time: 0.10100340843200684
Done. inference time: 0.10014748573303223
Done. inference time: 0.11329531669616699
Done. inference time: 0.10394883155822754
Done. inference time: 0.10673737525939941
Done. inference time: 0.10988140106201172
Done. inference time: 0.1020653247833252
Done. inference time: 0.09836649894714355
Done. inference time: 0.10039854049682617
Done. inference time: 0.110107421875
Done. inference time: 0.10535407066345215
Done. inference time: 0.09709382057189941
Done. inference time: 0.09582209587097168
Done. inference time: 0.09298300743103027
Done. inference time: 0.09809565544128418
Done. inference time: 0.10451555252075195
Done. inference time: 0.10464739799499512
Done. inference time: 0.09789228439331055
Done. inference time: 0.09876084327697754
Done. inference time: 0.09854793548583984
Done. inference time: 0.09673094749450684
Done. inference time: 0.09152770042419434
Done. inference time: 0.09822797775268555
qDone. inference time: 0.09500312805175781
Done. inference time: 0.09441995620727539
Done. inference time: 0.09558558464050293
Done. inference time: 0.09762716293334961
Done. inference time: 0.0935983657836914
Done. inference time: 0.1034841537475586
Done. inference time: 0.09829020500183105
Done. inference time: 0.09776186943054199
Done. inference time: 0.10141587257385254
Done. inference time: 0.09814095497131348
Done. inference time: 0.09857606887817383
Done. inference time: 0.09438323974609375
Done. inference time: 0.09688568115234375
Done. inference time: 0.09655523300170898
Done. inference time: 0.09738588333129883
One of an image snapshot during inferencing
Are you running in a virtual environment?
Could it be the conversion from ppocr models (pdiparams and files) to adla files went wrong?
For conversion i follow this
Hello @JietChoo ,
So confusing!
We package our test demo based by your code. Try to run on your VIM4. Whether it can get right result.
https://dl.khadas.com/.test/ppocr_test.zip
Unzip and push folder ppocr_test in ksnn-vim4/example. Change the usb camera into mipi camera in test.py and then run follow command.
$ python3 test.py
Recently, another discover that OpenCV different version cause model detecting nothing. If still cannot detect, try to uninstall OpenCV and then use pip3 install ksnn package. The package will install compatible OpenCV version.
Another thing, i find that in color_detection.py has a loading camera code. It will occupy usb camera. But i am not sure if it will affect mipi camera.

Hi Louis, I have tried with your code. Same, i cannot detect any + signs
Console prints also don’t have anything.
Should i factory reset my VIM4?
Hello @JietChoo ,
Have you try reinstall OpenCV by KSNN package? If still detect nothing, factory reset is the last way.
I did not run it in virtual environment. Should I?
I need to follow the installation in this link right
https://docs.khadas.com/products/sbc/vim4/npu/ksnn/demo/ppocr
$ sudo apt update
$ sudo apt install python3-venv
$ python3 -m venv myenv
$ source myenv/bin/activate
$ cd ksnn-vim4/ksnn
$ sudo apt update
$ sudo apt install python3-pip
$ pip3 install ksnn_vim4-1.4.1-py3-none-any.whl
$ pip3 install shapely pyclipper Pillow
Follow all these? Or is there any other way?
Hello @JietChoo ,
Yes, follow this doc.
Using virtual environment is to deal with the problem Ubuntu 24.04 cannot use pip-install. Suggest you have a try running in virtual environment.
And what VIM4 firmware do you use?
We are using emmc ubuntu24.04 gnome on Nov 2024
I followed this installation
$ sudo apt update
$ sudo apt install python3-venv
$ python3 -m venv myenv
$ source myenv/bin/activate
$ cd ksnn-vim4/ksnn
$ sudo apt update
$ sudo apt install python3-pip
$ pip3 install ksnn_vim4-1.4.1-py3-none-any.whl
$ pip3 install shapely pyclipper Pillow
then ran
python3 test.py
on the zip file you sent
I got this error when i run in virtual environment
|---+ KSNN Version: v1.4.1 +---|
Start init neural network ...
adla usr space 1.4.0.2
adla usr space 1.4.0.2
Done.
False
Traceback (most recent call last):
File "/home/khadas/ppocr_test/test.py", line 96, in <module>
det_img = cv.resize(orig_img, (det_input_size[1], det_input_size[0])).astype(np.float32)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cv2.error: OpenCV(4.11.0) /io/opencv/modules/imgproc/src/resize.cpp:4208: error: (-215:Assertion failed) !ssize.empty() in function 'resize'
Hello @JietChoo ,
The error is OpenCV calling camera fail. Make sure the camera is available and camera index is right. And check the if this line is commented in color_detection.py.
