sipeed / MaixPy-v1

MicroPython for K210 RISC-V, let's play with edge AI easier
https://wiki.sipeed.com/maixpy
Other
1.68k stars 439 forks source link

error loading cascade files #185

Open Feiko opened 5 years ago

Feiko commented 5 years ago

I've build a Haar Cascade and converted the cascade to a .cascade file using cascade_convert.py. When I try to load the cascade from sd or flash I get a core dump. I tried the default haarcascade_frontalface_default.xml. I get the same problem. The default script where the haarcascade is loaded from memory does work image.HaarCascade("frontalface", stages=25) I can't find any prebuild .cascade file for testing.

I'm using the following firmware version MicroPython v0.4.0-82-gc3327b5 on 2019-10-25; Sipeed_M1 with kendryte-k210

import image image.HaarCascade('/sd/face.cascade') core dump: misaligned load Cause 0x0000000000000004, EPC 0x00000000800010c2 reg00 = 0x0000000000000056, reg01 = 0x000000008000023e reg02 = 0x000000008019c140, reg03 = 0x000000008018d390 reg04 = 0x0000000000000000, reg05 = 0x0000001000000000 reg06 = 0x00000000800010ac, reg07 = 0x000000000000007d reg08 = 0x000000008000f0de, reg09 = 0x0000000000000001 reg10 = 0x0000000000000004, reg11 = 0x000000008000f0de reg12 = 0x000000008019c360, reg13 = 0x000000008019c460 reg14 = 0x0000000000000020, reg15 = 0x0000000000000003 reg16 = 0x0000000000000061, reg17 = 0x0000000000000000 reg18 = 0x000000008019c648, reg19 = 0x0000000000000000 reg20 = 0x00000000000000c0, reg21 = 0x00000000000000b0 reg22 = 0x00000000800e0f90, reg23 = 0x00000000802f3f1b reg24 = 0x00000000800d3e98, reg25 = 0x00000000800d3e90 reg26 = 0x00000000800d3e88, reg27 = 0x00000000800d3e80 reg28 = 0x0000000000000020, reg29 = 0x0000000000000003 reg30 = 0x0000000000000004, reg31 = 0x0000000000000000 freg00 = 0x0000000000000000(), freg[00]() = 0x00000000800d17b0() freg02 = 0x0000000000000000(), freg[00]() = 0x00000000800d17c0() freg04 = 0x0000000000000000(), freg[00]() = 0x00000000800d17d0() freg06 = 0x0000000000000000(), freg[00]() = 0x00000000800d17e0() freg08 = 0x0000000000000000(), freg[00]() = 0x00000000800d1808() freg10 = 0x0000000043028000(), freg[00]() = 0x00000000800d1838() freg12 = 0x0000000000000000(), freg[00]() = 0x00000000800d1860() freg14 = 0x0000000043020000(), freg[00]() = 0x00000000800d1870() freg16 = 0x0000000000000000(), freg[00]() = 0x00000000800d1880() freg18 = 0x0000000000000000(), freg[00]() = 0x00000000800d18a8() freg20 = 0x0000000000000000(), freg[00]() = 0x00000000800d18b8() freg22 = 0x0000000000000000(), freg[00]() = 0x00000000800d18c8() freg24 = 0x0000000000000000(), freg[00]() = 0x00000000800d18d8() freg26 = 0x0000000000000000(), freg[00]() = 0x00000000800d18e8() freg28 = 0x0000000000000000(), freg[00]() = 0x00000000800d1910() freg30 = 0x0000000000000000(), freg[00]() = 0x00000000800d1920() W (21964026773) SYSCALL: sys_exit called by core 0 with 0x539`

Feiko commented 5 years ago

I just tried loading the original frontal.cascade file from flash. image.HaarCascade('/flash/frontalface.cascade') throws the same core dump. So the issue is not the cascade file.

Neutree commented 4 years ago

actually this func is not full tested, it's better to use model to find face https://github.com/sipeed/MaixPy_scripts/blob/master/machine_vision/demo_find_face.py

Feiko commented 4 years ago

I agree, for finding faces using the KPU would make more sense. However my haarcascade can identify license plates and I don't have a suitable license plate database to train a new kmodel. Also I want to use the KPU to read the license plate. Hopefully this bug will be resolved soon, this project has been on hold for more than 6 months.

shanejohnpaul commented 4 years ago

I'm facing the same issue. Any updates on this?

Feiko commented 4 years ago

Any updates on when we can expect a fix? It would be very nice if we could use the Haarcascade.

cHemingway commented 3 years ago

I am facing the same issue as well, on the M5StickV.

Firmware version M5StickV_v5.1.2 Micropython prompt: MicroPython v0.5.0-98-g7ec09ea22-dirty on 2020-07-21; Sipeed_M1 with kendryte-k210

However, loading a built-in model does work, so the issue is only if I want to use my own HaarCascade.

>>> import image
>>> image.HaarCascade("eye")
{"width":20, "height":20, "n_stages":24, "n_features":1066, "n_rectangles":2299}
>>> image.HaarCascade("flash/haarcascade_eye.cascade")
V (13037270160) SYSCALL: misaligned load recovered at 8000f474. len:08,addr:736163726161682f,reg:06,data:0000000000000000,signed:1,float:0
core dump: illegal instruction
Cause 0x0000000000000002, EPC 0x0000000000000000