Object Detection Not Working with ESP32-CAM

Hello everyone,

I am facing a problem with object detection using ESP32-CAM. I tried to run the object detection code but nothing is happening and no window is popping up for detecting objects. I have tried many troubleshooting techniques but nothing seems to be working. However, when I use IP Webcam app in my mobile and use that URL for OpenCV, it's working perfectly fine.

I have tried object detection with ESP32-CAM and it was not working, so I wanted to check with Mobile IP Webcam to see if object detection is working or not with the mobile app. After running the Python program, it was able to identify the objects and it was working fine but when I run the same code and change the URL with ESP32-CAM, nothing is happening. I have bought another ESP32-CAM and even with that, it's not working.

I am very confused and frustrated as I have seen in YouTube videos that it's working for them. I thought there was a problem with my system, so I used another system, but even there, it's not working.

Here is the code that I am using:

import cv2
import cvlib as cv
from cvlib.object_detection import draw_bbox
import numpy as np
import urllib.request

url = 'http://192.168.0.0:0/video'

while True:
    try:
        with urllib.request.urlopen(url) as url_response:
            break
    except urllib.error.URLError:
        continue

cap = cv2.VideoCapture(url)

cv2.namedWindow("Object Detection", cv2.WINDOW_NORMAL)

while True:
    ret, frame = cap.read()

    if not ret:
        break

    bbox, label, conf = cv.detect_common_objects(frame)
    output_image = draw_bbox(frame, bbox, label, conf)

    cv2.imshow("Object Detection", output_image)

    if cv2.waitKey(1) == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

Please note that I have replaced the IP address with zeroes for privacy reasons.

If anyone can help me with this issue, I would be very grateful. Thank you in advance

What code? Please provide a pointer to the source.

Hi, thanks for responding
I have already mentioned the code. And the code is modified and the source is
"ESP32 CAM Based Object Detection & Identification with OpenCV"

When you run the server code on your ESP32-CAM do you get the expected output in Serial Monitor?

CAMERA OK
http://192.168.xxx.xxx
    /cam-lo.jpg
    /cam-hi.jpg
    /cam-mid.jpg

When you point a browser at http://192.168.xxx.xxx/cam-lo.jpg do you get an image?

Yes, I get the output as http://192.168.xxx.xxx
and I am able to see the video stream in the web Browser

So the problem is not in the ESP32-CAM. I guess the Python code is failing in some way.

But the same code works when i use my mobile app ie, IP webcam.

Then there must be some difference(s) between the data presented by the ESP32-CAM and the IP webcam.

You are in the best possible position to determine the problem. What have you done so far?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.