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 usage #1

Open
e135193 opened this issue Jul 7, 2022 · 1 comment
Open

ESP32-Cam usage #1

e135193 opened this issue Jul 7, 2022 · 1 comment

Comments

@e135193
Copy link

e135193 commented Jul 7, 2022

Hi I wish to use it in my esp32-cam project.

The camera driver does not work properly so I can not get raw data. Therefore I want to use the camera in JPEG mode.

I will have a buf array. In this library we have R G B data separately. How could be the usage in my case ?

spi = SPI(baudrate=40000000, polarity=0, phase=0, sck=Pin(14), mosi=Pin(13), miso=Pin(12))
display = Display(spi, dc=Pin(2), cs=Pin(15), rst=Pin(0))

state = camera.init(0, format=camera.RGB565, fb_location=camera.PSRAM)
#state = camera.init(0, format=camera.JPEG, fb_location=camera.PSRAM)
print("Camera State: ",state)
camera.framesize(camera.FRAME_96X96)

while True:
    buf = bytearray(2 * 96 * 96)
    buf = camera.capture()
    display.block(0,0,96,96,buf)
@daniel-falk
Copy link
Owner

Hi,

I am not familiar with the esp32-cam. The separation of the R, G and B channels are in the decoded output, not the jpeg encoded data. I suspect you can make it work by using the jpeg_decode_from_buffer() function and pointing the raw_image struct to your jpeg encoded buffer. When you want to display the image you might have to shuffle around the order of the pixels to get the format your display requires. If you require an RGB565 image you need to recalculate the values too, the output from the library is 8-bit depth per channel, RGB565 has 5-bit for R and B and 6-bit for G. This can be done as a for-loop over all the pixels, copying from the output buffer to an RGB565 buffer.

If you want to debug while developing the code, I recommend to dump the decoded frame over serial port or some other means to get it to the computer, there you can put it into a ppm file and verify that it looks OK. That way you can isolate any issue to either the decoder or the raw color space conversion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants