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

OSError: Camera Init Failed #76

Open
wildernessfamily opened this issue Dec 15, 2022 · 13 comments
Open

OSError: Camera Init Failed #76

wildernessfamily opened this issue Dec 15, 2022 · 13 comments

Comments

@wildernessfamily
Copy link

There have been many comments and posts relating to OSError: Camera Init Failed error when trying to initialize the camera. I have reviewed every post, which the most recent was over a half a year a go, and all have gone unanswered.
Steps that I have taken on my MacBookPro:

  1. I have a 3 brand new AIThinker ESP32-CAM microcontrollers.
  2. Downloaded micropython_camera_feeeb5ea3_esp32_idf4_4.bin (commit it 905c798 on February 2, 2022)
  3. Created a python virtual environment in a new folder (Python version 3.10.7).
mkdir -p sandboxESP32CAM
cd sandboxESP32CAM
python -m venv .venv
source .venv/bin/activate
  1. Installed ESPTools pip install esptool
  2. Performed the erase flash python -m esptool --chip esp32 --port /dev/cu.usb1440 erase_flash
  3. Installed the firmware above. python esptool --chip esp32 --port /dev/cu.usb1440 write_flash -z 0x1000 micropython_camera_feeeb5ea3_esp32_idf4_4.bin
    Everything was a success.
  4. Opened VSCode code .
  5. Installed PyMakr extension
  6. Restarted VSCode
  7. Created a PyMakr project
  8. Copied over the code. I tried all three projects, webcam, webserver (both picoweb & MicroWebServer), and timelapse.
    They all failed with the same error: OSError: Camera Init Failed
    I tried with all three ESP32-CAM controllers.
    I'm at a loss on what else I can try.
@magixyu
Copy link

magixyu commented Mar 3, 2023

I have the same issue. Could you please help to take a look?

>>> %Run -c $EDITOR_CONTENT
Traceback (most recent call last):
  File "<stdin>", line 11, in <module>
  File "webserver.py", line 48, in run
OSError: Camera Init Failed

@PsuFan
Copy link

PsuFan commented Jul 12, 2023

Make sure you execute your code after a hard reset and check to make sure the camera ribbon cable is fully inserted. I get this error only after a soft reset and am still looking for a solution. Works fine for me on first power up.

@shillehbean
Copy link

I am also having this issue, so we have to hard reset every time we want to use the camera? Then that removes the use of practical use case unless I am missing something

@PsuFan
Copy link

PsuFan commented Nov 25, 2023

I was able to deinit before init to solve the issue on soft reset.

@kdschlosser
Copy link

I know this is old but a soft reset only clears the RAM. It doesn't clear out any hardware settings. so if you do a soft reset and attempt to restart the camera it will fail. only a hard reset will clear the hardware states.

The same problem exists with SPI as well.

@PsuFan
Copy link

PsuFan commented Nov 20, 2024

IMO init should do this automatically, not hope that the developer finds the issue and figures out how to fix it…

@kdschlosser
Copy link

Micropyhton doesn't have anything build into it to let anything know that a soft reset is occurring. This is why most libraries do have a deinit function or are bound to __del__ so when you delete the object it will do it's cleanup and release the hardware parts. The user knows when a soft reset is going to occur and is able to perform the cleanup that is needed bu using the deinit or deleting the object that holds any hardware resources.

I believe that there should be some way to register a callback function so that application or library C code can be notified and cleanup can be done that way. But that is not available so it's up to the user to do.

@PsuFan
Copy link

PsuFan commented Nov 20, 2024

Not sure what the implications of not cleaning up are or am really talking about that. Init can and should do the cleanup aka work every time.

@kdschlosser
Copy link

doesn't work that way. the init method has no clue whether or not it should clean up after settings that don't exist anymore. Remember the memory has been cleared. How is it supposed to know what pins were used last time?

@PsuFan
Copy link

PsuFan commented Nov 21, 2024

It’s the only way I know of to get it to reliably start every time. Deinit doesn’t crash if run first at boot and presumably does nothing.

@kdschlosser
Copy link

I can tell you that part of the problem is there is no "instance" or class for a camera that gets made. No way to to really keep track of it. I am working on writing the driver over again so it will compile properly with MicroPython 1.22 and to expose more of the esp32-camera feature set and hopefully correct the deinit issue.

@PsuFan
Copy link

PsuFan commented Nov 21, 2024

FYI I also have to take the picture twice and throw out the first one. The first picture is from BEFORE I requested it lol…

@kdschlosser
Copy link

I will do my best to streamline buffers. I have a pretty good way of handling frame buffers in the display and GUI framework module I wrote for MicroPython so I am very familiar with how to handle them and to make the C allocated frame buffers accessible to the Python side of things.

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

5 participants