# MemoryError on img.find\_rects() API

**URL:** <https://forums.openmv.io/t/memoryerror-on-img-find-rects-api/450>\
**Category:** OpenMV Boards\
**Created:** [October 13, 2017, 4:36pm UTC](https://forums.openmv.io/t/memoryerror-on-img-find-rects-api/450 "2017-10-13T16:36:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JackeyChuang](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@JackeyChuang](https://forums.openmv.io/u/JackeyChuang)\
**Post date:** [October 13, 2017, 4:36pm UTC](https://forums.openmv.io/t/memoryerror-on-img-find-rects-api/450/1 "2017-10-13T16:36:47Z")

</div>

Hi ALL,

I get the IDE error : MemoryError: FB Alloc Collision!!!  
on find\_rects() API but it is not usually on the same code.  
Could you know what is the root cause and how to fix it ? Thanks a lot!

```python
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)

roi_rect = (40, 80, 80, 40)

while(True):
    clock.tick()
    img = sensor.snapshot()

    for r in img.find_rects(roi = roi_rect, threshold = 9000): # sometime get ERROR here 
        img.draw_rectangle(r.rect(), color = (0, 0, 255))

```

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [October 14, 2017, 2:56pm UTC](https://forums.openmv.io/t/memoryerror-on-img-find-rects-api/450/2 "2017-10-14T14:56:43Z")

</div>

Works for me using firmware v2.5.0 with OpenMV IDE v1.7.1
