Esp32 and opencv

I have ESP32 and OV2460 cam. I accessed ESP32 IP address and there is streaming screen. The camera is working well.

I want to use the streaming screen on OpenCV. And this is my code.

#include <opencv2/opencv.hpp>
#include <iostream>

int main() {
    std::string url = "ESP32 IP address";
    cv::VideoCapture cap(url);

    if (!cap.isOpened()) {
        std::cerr << "Error: Could not open video stream" << std::endl;
        return -1;
    }

    cv::Mat frame;

    while (true) {
        cap >> frame;
        if (frame.empty()) {
            std::cerr << "Error: Could not grab frame" << std::endl;
            break;
        }

        cv::imshow("ESP32 Camera", frame);

        if (cv::waitKey(1) == 'q') {
            break;
        }
    }

    cap.release();
    cv::destroyAllWindows();
    return 0;
}

my code stopped at if(!cap.isOpened())
why this happened..?

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