代码之家  ›  专栏  ›  技术社区  ›  Diedre

OpenCV视频捕获摘要身份验证

  •  4
  • Diedre  · 技术社区  · 7 年前

    我有一个正在进行的项目,通过opencv VideoCapture访问多个IP摄像机,为其中大多数摄像机工作。

    我有一个新的大华PTZ相机,使用摘要认证,而OpenCV中的视频捕获无法打开它。通过WireShark,我可以看到摄像机返回的是一个401未经麻醉的图像。

    我在OpenCV文档中没有发现任何关于身份验证问题的信息。

    也许我需要使用其他不是OpenCV的东西来解决这个问题?

    #include <iostream>
    #include <imgproc.hpp>
    #include <opencv.hpp>
    #include <highgui.hpp>
    
    using namespace std;
    using namespace cv;
    int main(){
        while(1){
            VideoCapture cap("http://login:password@111.111.111.111/cgi-bin/snapshot.cgi");
            if(!cap.isOpened()){
                cout << "bug" << endl;
                continue;
            }
            Mat frame;
            cap >> frame;
            imshow("test", frame);
        }
    }
    

    HTTP Unaothorized Response

    1 回复  |  直到 7 年前
        1
  •  5
  •   Diedre    7 年前

    我通过使用相机的rtsp流而不是http图像解决了这个问题。非常感谢。(如果您的ip摄像机中存在此问题,请尝试rtsp流,文档中应该有一个命令)。

    我的大华相机的最终工作代码:

    #include <iostream>
    #include <imgproc.hpp>
    #include <opencv.hpp>
    #include <highgui.hpp>
    using namespace std;
    using namespace cv;
    int main(){
        VideoCapture cap("rtsp://login:password@111.111.111.111/cam/realmonitor?channel=1?subtype=0");
        if(!cap.isOpened()){
            cout << "bug" << endl;
            return 1;
        }
    
        Mat frame;
        cap >> frame;
        imshow("test", frame);
    
    }
    

    推荐文章