2016-04-16 18 views
0

Ich möchte mit meiner Dynacolor IP-Kamera mit Opencv 2.45 in Microsoft Visual Studio.Verbinden mit IP-Kamera mit opencv

Ich habe seine IP mit iSpy gefunden. und hier ist mein Code.

#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 
} 

nimmt diese mir eine Warnung: 540>, und auch die Kamera ist null: Kann nicht Codec-Parameter < .../.../modules/highgui/src/cap_ffmpeg_impl.hpp finden.

Ich habe viele Threads über dieses Problem gelesen, aber ich konnte diese Probleme nicht beheben.

Jede Hilfe wäre willkommen.

Antwort

0

Überprüfen Sie diesen Code. Für mich geht das. Beachten Sie "? .mjpg" am Ende der Adresse. Ich habe auch IP und Port für den Test geändert.

#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

Danke Adam. Ich habe '? Channel = 0 & .mjpg' hinzugefügt und es funktioniert jetzt. –