uPyCam icon indicating copy to clipboard operation
uPyCam copied to clipboard

MicroWebSrv handler exception: [Errno 2] ENOENT

Open tiwanacote opened this issue 5 years ago • 13 comments

Hi , I'm trying to make running uPyCam over ESP32CAM but I getting this error when trying to connect via browser with http://<<IP-device>>

MicroWebSrv handler exception: In route GET / [Errno 2] ENOENT

I'm not an experimented user, maybe you can help me... It is an exception into def _processRequest(self) : function

'except Exception as ex : print('MicroWebSrv handler exception:\r\n - In route %s %s\r\n - %s' % (self._method, self._resPath, ex)) raise ex`'

Thank you!

tiwanacote avatar Oct 04 '20 02:10 tiwanacote

Try to erase the flash, flash the firmware again and upload the code. Keep me updated!

lemariva avatar Oct 18 '20 20:10 lemariva

Hello, i get the same error as above and I already tried erasing and flashing again, is there any other solution? Also with http://<<board-ip>>/?stream=true will I get a stream fast enough to reach something like at least 10fps for robot control or it's just gonna be enough for time lapses?

a message I always get when initializing the camera is E (49289) gpio: gpio_install_isr_service(411): GPIO isr service already installed (in red) but it doesn't seem to stop the camera from taking pictures, with a script of mine and using camera.capture(1) (without argument it throws an exception) I get to save one picture every 500ms in different jpgs

TizioMaurizio avatar Dec 14 '20 00:12 TizioMaurizio

Thanks @lemariva for this project. I'm hoping to be able to have a camera webserver running with micropython using a basic ESP32 Cam.

My setup was the following:

  • Erased flash, then flashed with lemariva/micropython-camera-driver/firmware/micropython_b7883ce_esp32_idf4.x_ble_camera.bin
  • Setup webrepl and connected to wifi network
  • Edited config.py.sample and renamed to config.py
  • Used webrepl file transfer to manually copy each file over

Then when I run main.py, I get the same error as @tiwanacote and @TizioMaurizio

Any advice would be appreciated!

maurera avatar Feb 15 '21 21:02 maurera

Thanks @lemariva for this project. I'm hoping to be able to have a camera webserver running with micropython using a basic ESP32 Cam.

My setup was the following:

  • Erased flash, then flashed with lemariva/micropython-camera-driver/firmware/micropython_b7883ce_esp32_idf4.x_ble_camera.bin
  • Setup webrepl and connected to wifi network
  • Edited config.py.sample and renamed to config.py
  • Used webrepl file transfer to manually copy each file over

Then when I run main.py, I get the same error as @tiwanacote and @TizioMaurizio

Any advice would be appreciated!

Since I just needed a video stream for first person view on Lan I managed to get it to work by using UDP socket and gave up on the webserver, if you need the same I'll send you some scripts, still up for getting the webserver to work since I also could use it in the future :D

TizioMaurizio avatar Feb 16 '21 00:02 TizioMaurizio

Sure, that would be great if you have something working. You're using the esp 32 cam or a different module?

I was close to abandoning using micropython on the esp32 cam and just reverting to an Arduino sketch

maurera avatar Feb 16 '21 00:02 maurera

@maurera Yes I use esp32 cam, once I found out how quick it is to program with micropython I couldn't go back to the sketches, I managed to stream the video at like 15fps with QVGA resolution and by upscaling the image it's acceptable. I have a script on ESP32 that goes like:

import camera
import socket
import _thread
import utime

host = ''
port = 5555
RECEIVER = socket.getaddrinfo('RECEIVING_DEVICE', 80)[0][-1][0] #resolve pc hostname
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((host, port))

def stream():
    begin = utime.ticks_ms()
    time = utime.ticks_ms()
    prev = time
    while True:
        time = utime.ticks_ms()
        if (time-prev>=50):
            s.sendto(camera.capture(), (RECEIVER, 5555))
            prev = utime.ticks_ms()

camera.init(1)
camera.framesize(camera.FRAME_QVGA)
# The options are the following:
# FRAME_96X96 FRAME_QQVGA FRAME_QCIF FRAME_HQVGA FRAME_240X240
# FRAME_QVGA FRAME_CIF FRAME_HVGA FRAME_VGA FRAME_SVGA
# FRAME_XGA FRAME_HD FRAME_SXGA FRAME_UXGA FRAME_FHD
# FRAME_P_HD FRAME_P_3MP FRAME_QXGA FRAME_QHD FRAME_WQXGA
# FRAME_P_FHD FRAME_QSXGA
# Check this link for more information: https://bit.ly/2YOzizz
camera.quality(10)
_thread.start_new_thread(stream, ())

camera.capture() inside stream is what gets one frame from the camera, i suggest avoiding the use of threads and putting it inside the for loop of what you are doing in order to speed up everything

Then there is the code on my pc that uses opencv-python to show the stream:

import cv2
import numpy as np
import time
import socket
import traceback

host = ''
port = 5555
RECTIME = 20
RECSIZE = 32768 #images are bigger than default udp packet size
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((host, port))
#start udp camera stream on ESP32 Camera and this script will show the camera stream
def receive():
  global message
  message2, address = s.recvfrom(RECSIZE)
  message = bytearray(message2)
  nparr = np.frombuffer(message, np.uint8)
  img = cv2.imdecode(nparr, cv2.IMREAD_UNCHANGED)
  return img

def show():
  prevTime = time.time()
  i = 0
  while True:
    try:
      image = receive()
      scale_percent = 200  # percent of original size
      width = int(image.shape[1] * scale_percent / 100)
      height = int(image.shape[0] * scale_percent / 100)
      dim = (width, height)
      # resize image
      resized = cv2.resize(image, dim, interpolation=cv2.INTER_AREA)
      cv2.imshow("Res", resized)
      cv2.waitKey(1)
    except:
      traceback.print_exc()

show()

It's very raw but for now it works :D

PS remember that esp32 camera consumes a lot with wifi and camera enabled and can easily brownout if not powered enough PPS i suggest this buggy but very useful gui to use the terminal and send files to esp32 through wifi https://github.com/BetaRavener/uPyLoader

TizioMaurizio avatar Feb 17 '21 15:02 TizioMaurizio

@lemariva I have downloaded your project and flashed the ESP32. However I get the error below. I have even tried stream mode. Nothing changed. Is there any further improvement in the project ?

MicroWebSrv handler exception:

  • In route GET /
  • [Errno 2] ENOENT

e135193 avatar Jun 09 '21 15:06 e135193

you should copy files under www to the board

idiotstone avatar Apr 15 '22 13:04 idiotstone

I have flashed the latest firmware however the module restarts itself with the error below @lemariva

connecting to network...
network config: ('192.168.0.26', '255.255.255.0', '192.168.0.1', 'X.X.X.X')
E (17435) gpio: gpio_install_isr_service(460): GPIO isr service already installed
MicroPython v1.14-122-g9fef1c0bd-dirty on 2021-03-30; Camera Module (i2s) with ESP32
Type "help()" for more information.

e135193 avatar Jun 07 '22 22:06 e135193

and when I run main.py I get error below

Traceback (most recent call last):
  File "<stdin>", line 12, in <module>
  File "webserver.py", line 48, in run
OSError: Camera Init Failed

e135193 avatar Jun 07 '22 23:06 e135193

I've tried several different ways of initializing the camera and nothing seems to work. I also continue to receive OSError: Camera Init Failed. The last post has been over a half a year a go. Has there been any solution to this problem?

wildernessfamily avatar Dec 15 '22 20:12 wildernessfamily

I don't use the webserver in question but my camera successfully starts by excecuting these instructions, mind that there could be some exposed pins that will be used by the camera so you can't connect anything to such pins (like for the sd card, but I don't remember which they are) a quick check of the schematics anyway will clear the doubt

import camera  
[...]
camera.init(0, format=camera.JPEG, fb_location=camera.PSRAM)  
[...]
camera.capture()  

TizioMaurizio avatar Dec 15 '22 20:12 TizioMaurizio

Hi @TizioMaurizio, Thanks for taking the time to respond. I'm away for a few days. I'm going to give that a try next weekend. Thank you again!

wildernessfamily avatar Dec 19 '22 01:12 wildernessfamily