Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esp32-cam failing to init camera #9356

Open
aguaviva opened this issue Jun 20, 2024 · 3 comments
Open

esp32-cam failing to init camera #9356

aguaviva opened this issue Jun 20, 2024 · 3 comments
Labels
board New board or update to a single board bug espressif applies to multiple Espressif chips
Milestone

Comments

@aguaviva
Copy link

CircuitPython version

CircuitPython 9.1.0-beta.3 (https://circuitpython.org/board/ai-thinker-esp32-cam/)

Code/REPL

import espcamera
import board

cam = espcamera.Camera(
    data_pins=board.CAMERA_DATA,
    external_clock_pin=board.CAMERA_XCLK,
    pixel_clock_pin=board.CAMERA_PCLK,
    vsync_pin=board.CAMERA_VSYNC,
    href_pin=board.CAMERA_HREF,
    pixel_format=espcamera.PixelFormat.JPEG,
    frame_size=espcamera.FrameSize.SVGA,
    i2c=board.I2C(),
    external_clock_frequency=20_000_000,
    grab_mode=espcamera.GrabMode.WHEN_EMPTY)

f = cam.take()

print(len(f))

Behavior

Traceback (most recent call last):
  File "<stdin>", line 14, in <module>
espidf.IDFError: Requested resource not found

Description

I am trying to take a picture but fails

Additional information

  • I haven't found any sample code to take a picture on a ESP32-CAM
  • I just switched from Micropython
@aguaviva aguaviva added the bug label Jun 20, 2024
@aguaviva
Copy link
Author

aguaviva commented Jun 20, 2024

it turns out it was documented in the PR (#9231), I'd be nice if this could make it in the official documentation and have a unit test for this board.

@tannewt tannewt added espressif applies to multiple Espressif chips board New board or update to a single board labels Jun 21, 2024
@tannewt tannewt added this to the Long term milestone Jun 21, 2024
@aguaviva
Copy link
Author

aguaviva commented Jun 22, 2024

This works like a charm:

import socketpool
import wifi
from adafruit_httpserver import Server, Request, Response

import board
import espcamera

cam = espcamera.Camera(
    data_pins=board.CAMERA_DATA,
    external_clock_pin=board.CAMERA_XCLK,
    pixel_clock_pin=board.CAMERA_PCLK,
    vsync_pin=board.CAMERA_VSYNC,
    href_pin=board.CAMERA_HREF,
    powerdown_pin=board.CAMERA_PWDN,
    reset_pin=None,
    i2c=board.I2C(),
    external_clock_frequency=20_000_000,
    pixel_format=espcamera.PixelFormat.JPEG,
    frame_size=espcamera.FrameSize.SVGA,
    # jpeg_quality=0,
    # framebuffer_count=0,
    # grab_mode=espcamera.GrabMode.WHEN_EMPTYi
    )

from adafruit_httpserver import Server, Request, ChunkedResponse

pool = socketpool.SocketPool(wifi.radio)
server = Server(pool, debug=True)

@server.route("/pic")
def chunked(request: Request):
    frame = cam.take(1)
    return Response(request, content_type="image/jpeg", body=frame)

server.serve_forever(str(wifi.radio.ipv4_address))

Now trying to get multipart working...

@aguaviva
Copy link
Author

Update: the HTTPServer is getting updated to support streaming, see: adafruit/Adafruit_CircuitPython_HTTPServer#95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
board New board or update to a single board bug espressif applies to multiple Espressif chips
Projects
None yet
Development

No branches or pull requests

2 participants