esp32-cam-micropython-2022 icon indicating copy to clipboard operation
esp32-cam-micropython-2022 copied to clipboard

camera.capture() , does not capture newest frame. It captures one previous frame.

Open h4hassanali opened this issue 2 years ago • 1 comments

When I capture image using camera.capture() and saved it, the previous frame is captured instead of fresh, latest frame.

h4hassanali avatar Nov 05 '23 09:11 h4hassanali

I noticed the same thing. You can modify site.py and add an extra camera.capture() before the "real" one to clear the buffer.

For example:

@route('/foto')
def foto(cs,v): # still photo
    try:
       buf=camera.capture()
       #ln=len(buf)
       cs.setblocking(True)
       cs.write(b'%s\r\n\r\n' % hdr['pic'])
       cs.write(camera.capture())
       cs.write(b'\r\n')  # send and flush the send buffer
       #nc=cs.write(b'%s\r\n\r\n' % (hdr['pix']%ln)+buf)
    except Exception as e:
       print(f"EX:{e}")
       clean_up(cs)

dave0003 avatar Aug 03 '24 14:08 dave0003