sipeed / MaixPy-v1

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

sensor.set_windowing(roi) not working #191

Open bherbruck opened 4 years ago

bherbruck commented 4 years ago

sensor.set_windowing() does not center when no x, y coords are given, also does not move window to x, y coords. Same image is returned: sensor.set_windowing((50, 0, 224, 224)) sensor.set_windowing((0, 0, 224, 224)) This causes image distortion huge problems with wide angle lenses.

image

I believe the issue is with the dvp libraries, the image just crops to the top-left corner instead of centering.

ted99tw commented 4 years ago

I want this function too, but it seems the dvp lib leaves this as //to do in the source code. I use img.resize(224,224) instead.

bherbruck commented 4 years ago

I haven't been able to get img.resize() working and can't find any documentation for it although it is in py_image.c. I'm also using this for yolo2 and I think sensor.set_windowing also does something with dvp_set_ai_addr() which may affect yolo2. I have no clue though.

ted99tw commented 4 years ago

It seems that yolo2 or mobilenet both refer to dvp_set_ai_addr() and the pix_ai data of the image itself. What I am in need is to resize an image from QVGA to (224,224) for yolo2 or mobilenet by using resize(). Although resize() works fine but the ai data lost after resizing. So I make a #198 pull request to make this happen. I hope it can be accepted so. So we can just use image.resize(224,224) without using something like set_windowing(50,224,224) for kpu task.

Neutree commented 4 years ago

gc0328 has supported, commit here : a3fc950007dffde5fccef65499181e65c18c1ff7 but other sensors need to implement

Neutree commented 4 years ago

and pay attention, the width or height must multiple of 8 bytes