【问题标题】:OpenCV VideoCapture digest authenticationOpenCV VideoCapture 摘要认证
【发布时间】:2018-03-02 20:19:55
【问题描述】:

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

我有一个新的使用摘要认证的大华云台摄像机,OpenCV 中的 VideoCapture 无法打开它。通过 WireShark,我可以看到相机正在返回 401 Unaothorized。

我在 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);
    }
}

这是相机的响应:

【问题讨论】:

  • VideoCapture 使用哪个 API?
  • 尝试了所有三个都无济于事(CAP_IMAGES、CAP_DSHOW 和 CAP_FFMPEG)
  • 先尝试通过FFMPEGGstreamer命令行访问摄像头。找到工作管道后,将该管道转换为 VideoCapture 输入,这很容易做到。但是您必须使用 FFMPEGGstreamer 构建 OpenCV 才能使管道与 VideoCapture 一起使用。

标签: c++ opencv ip-camera digest-authentication opencv3.3


【解决方案1】:

我通过使用相机的 rtsp 流而不是 http 图像解决了这个问题。谢谢! (如果你的 ip camera 有这个问题,试试 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);

}

由于某些原因,opencv 在使用 rtsp 时可以执行摘要认证。

【讨论】:

  • 正是我想要的。太棒了!
猜你喜欢
  • 2012-07-18
  • 2015-01-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-12-24
  • 2020-09-17
  • 2012-05-26
相关资源
最近更新 更多