Video from IP camera can't find starting number cv::icvExtractPattern

asked 2019-10-26 19:23:42 -0500

Hello, I have working C++ project for openCV 3.4.7 with GPU and CPU object detection with USB camera. Now I try use IP camera via http request. In openCV version 4.1.1 it's works but in 3.4.7 I get error:

OpenCV(3.4.7) Error: Bad argument (CAP_IMAGES: can't find starting number (in the name of file): https://192.168.1.109:8080/video) in cv::icvExtractPattern, file C:\openCV\opencv-3.4.7\modules\videoio\src\cap_images.cpp, line 246 [ERROR:0] VIDEOIO(cvCreateFileCapture_Images(filename.c_str())): raised OpenCV exception:

OpenCV(3.4.7) C:\openCV\opencv-3.4.7\modules\videoio\src\cap_images.cpp:246: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): https://192.168.1.109:8080/video in function 'cv::icvExtractPattern'

This is camera from android app "IP webcam" and "DroidCam".

I use this camera with python scirpt and via web browser and it works.

I looked for this error but i didn't found any information about it.

Regards, Adrian

edit retag flag offensive close merge delete

Comments

I use openCV on windows 10 and I sharing an image from android via ip address.

adi1525 gravatar imageadi1525 ( 2019-10-27 02:12:37 -0500 )edit

I need to see the code for c++ and python for CAP_IMAGES I don't want to entire code. Just a single code.

supra56 gravatar imagesupra56 ( 2019-10-27 09:00:03 -0500 )edit
1

This code it`s build in opencv 4.1.1 and it's works, but in 3.4.7 not.

#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main()
{
    Mat image, dst;
    cv::VideoCapture vcap;
    const std::string videoStreamAddress = "http://192.168.1.109:8080/video";

    if (!vcap.open(videoStreamAddress))
    {
        std::cout << "Error opening video stream or file" << std::endl;
        return -1;
    }
    else {
        cout << "Open." << endl;
    }
    while (vcap.isOpened()) {
        vcap >> image;
        resize(image, dst, cv::Size(640, 320));
        imshow("Input", dst);
        waitKey(1);
    }
}
adi1525 gravatar imageadi1525 ( 2019-10-27 14:54:25 -0500 )edit
1

Python is almost the same:

import cv2

cap = cv2.VideoCapture('http://@192.168.1.109:8080/video')
while(True):

    ret, frame = cap.read()
    cv2.imshow('frame',frame)

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

cap.release()
cv2.destroyAllWindows()
adi1525 gravatar imageadi1525 ( 2019-10-27 14:58:35 -0500 )edit

Don't use port and add some extension.

const std::string videoStreamAddress = "http://192.168.1.109:8080/video";

to:

const std::string videoStreamAddress = "http://192.168.1.109/video.cgi?.mjpg";
supra56 gravatar imagesupra56 ( 2019-10-27 21:28:44 -0500 )edit

Connection via http doesn't work. I was able to run camera only with rtsp protocol.

const std::string videoStreamAddress = "rtsp://192.168.1.109:8080/h264_ulaw.sdp";

Addisionaly when I try give address without specifying the port, opencv set default 80.

adi1525 gravatar imageadi1525 ( 2019-10-29 13:04:18 -0500 )edit