Memory Allocation Failed Error

Discussion related to "under the hood" OpenMV topics.
susamsokagi
Posts: 12
Joined: Fri Nov 15, 2019 9:21 am

Memory Allocation Failed Error

Postby susamsokagi » Tue Feb 25, 2020 9:42 am

Hello,

I am trying to get pixels of a grayscale image and save it to my array, but I am having memory allocation failed error as you can see in the picture. Why? Sorry for asking a dumb question, I am new to both OpenMV cam and Python.

Image
User avatar
iabdalkader
Posts: 1193
Joined: Sun May 24, 2015 3:53 pm

Re: Memory Allocation Failed Error

Postby iabdalkader » Tue Feb 25, 2020 9:49 am

You're just running out of memory, the camera doesn't have a lot of memory, the heap is only ~230KBs, there's no fix for this. I'm not sure why you're making a copy of the image, but if you must, try setting a smaller resolution/window.
susamsokagi
Posts: 12
Joined: Fri Nov 15, 2019 9:21 am

Re: Memory Allocation Failed Error

Postby susamsokagi » Tue Feb 25, 2020 10:01 am

Hello,

Thank you for your fast answer. I am trying to calculate the trash level in the trash bin. So, I am trying to get amount of non-black pixels (because trash bin has a black trash bin inside) in the image to all four sides starting from the center. I added a visual for better understanding.

Image


So, I am trying to calculate x1,x2,y1, and y2 levels by subtracting black parts of the image. Any ideas how can I do this in camera? I implemented same stuff on MATLAB but its a different thing of course.
User avatar
iabdalkader
Posts: 1193
Joined: Sun May 24, 2015 3:53 pm

Re: Memory Allocation Failed Error

Postby iabdalkader » Tue Feb 25, 2020 10:20 am

susamsokagi wrote: I am trying to get amount of non-black pixels
You can use find_blobs and search for a black (or white) blob, then call blob.pixels() to get the number of pixels in that blob, you may also want to check the get_statistics function.
susamsokagi
Posts: 12
Joined: Fri Nov 15, 2019 9:21 am

Re: Memory Allocation Failed Error

Postby susamsokagi » Tue Feb 25, 2020 10:27 am

iabdalkader wrote:
Tue Feb 25, 2020 10:20 am
susamsokagi wrote: I am trying to get amount of non-black pixels
You can use find_blobs and search for a black (or white) blob, then call blob.pixels() to get the number of pixels in that blob, you may also want to check the get_statistics function.
Again thank you for your answer. One more question, is it possible to use background subtraction method in this case? Is OpenMV H7 able for background sub?
User avatar
iabdalkader
Posts: 1193
Joined: Sun May 24, 2015 3:53 pm

Re: Memory Allocation Failed Error

Postby iabdalkader » Tue Feb 25, 2020 11:13 am

Yes you can subtract a background image, see the examples.

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 24 guests