2016-04-16 129 views
0

我想在Microsoft Visual Studio中使用opencv 2.45与我的Dynacolor IP摄像机拍照。使用opencv连接到IP摄像机

我发现它的IP与iSpy。这是我的代码。

#include "opencv2/highgui/highgui.hpp" 
#include "opencv2/core/core.hpp" 
#include "opencv2/opencv.hpp" 

int main() 
{ 
    cv::VideoCapture vcap; 
    const std::string videoStreamAddress = "http://Admin:[email protected]:80/cgi-bin/jpg/image.cgi"; 
    if (!vcap.open(videoStreamAddress)) 
    { 
     printf("Camera is null\n"); 
     return -1; 
    } 
    else 
    { 
     cv::Mat image; 
     vcap.read(image); 
     cv::imshow("image",image); 
    } 
    cv::waitKey(100); 
    return 0 
} 

这把我一个警告:找不到编解码器参数< .../... /模块/ highgui/src目录/ cap_ffmpeg_impl.hpp:540>,并相机为空。

我已阅读有关此问题的许多线索,但我无法解决此问题。

任何帮助,将不胜感激。

回答

0

检查此代码。这个对我有用。注意地址末尾的'?.mjpg'。我也改变了IP和端口进行测试。

#include "opencv2/highgui/highgui.hpp" 
#include "opencv2/core/core.hpp" 
#include "opencv2/opencv.hpp" 
#include <cstdio> 

int main() 
{ 
    cv::VideoCapture vcap; 

    // changed address 
    const std::string videoStreamAddress = "http://213.171.96.200/cgi-bin/jpg/image.cgi?.mjpg"; 
    if (!vcap.open(videoStreamAddress)) 
    { 
     printf("Camera is null\n"); 
     return -1; 
    } 
    else 
    { 
     cv::Mat image; 
     vcap.read(image); 
     cv::imshow("image",image); 
    } 
    cv::waitKey(10000); 
    return 0; 
} 
+0

谢谢亚当。我添加了'?channel = 0&.mjpg',它现在可以工作。 –