remibert / pycameresp

Motion detection with image notification for Esp32CAM and Esp32 flasher with GUI based on esptool.py.
Other
71 stars 20 forks source link

post error during camera opening #8

Closed Vinter7 closed 1 year ago

Vinter7 commented 1 year ago

Hello, I've installed the firm for esp32cam, when I try to do this:

# connect wifi
camera.init()

res = urequests.post(theUrl,json=data).json()
print(res)

camera.deinit()

I get the error: OSError: [Errno 12] ENOMEM

If I run camera.deinit() before post request, it will be ok.

So I guess the error is due to camera opening.

remibert commented 1 year ago

Hello,

if you receive the ENOMEM message, it means that Micropython didn't have enough memory to allocate the request. If the request is an image, you should try adjusting the resolution or quality to reduce the required amount of memory. Another parameter to consider is that if this message occurs after a few minutes of usage, it may be due to memory fragmentation. In that case, you need to periodically call the garbage collector to eliminate this issue. Please note that I don't use urequests for streaming in pycamerep because it will inevitably trigger reallocation of the image in memory. Instead, since I handle the HTTP protocol layer, I send the image directly, but you need to add the necessary HTTP headers and footers.

Le 7 mai 2023 à 11:19, 高枕枕 @.***> a écrit :

Hello, I've installed the firm for esp32cam, when I try to do this:

connect wifi

camera.init()

res = urequests.post(theUrl,json=data).json() print(res)

camera.deinit() I get the error: OSError: [Errno 12] ENOMEM

If I run camera.deinit() before post request, it will be ok.

So I guess the error is due to camera opening.

— Reply to this email directly, view it on GitHub https://github.com/remibert/pycameresp/issues/8, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP3HE2CTXO62IRBWQZ2WZ2LXE5SI7ANCNFSM6AAAAAAXYXSKAY. You are receiving this because you are subscribed to this thread.