2016-04-16 7 views
0

Je veux prendre des photos avec ma caméra IP Dynacolor en utilisant opencv 2.45 dans Microsoft Visual Studio. J'ai trouvé son ip avec iSpy. et voici mon code.se connecter à la caméra IP en utilisant opencv

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

Cela me prend un avertissement: Impossible de trouver les paramètres de codec < .../.../modules/highgui/src/cap_ffmpeg_impl.hpp: 540>, et aussi l'appareil photo est nulle.

J'ai lu beaucoup de discussions sur ce problème mais je n'ai pas pu résoudre ce problème.

Toute aide serait appréciée.

Répondre

0

Vérifiez ce code. Ça marche pour moi. Notez '? .mjpg' à la fin de l'adresse. J'ai également changé IP et port pour le test.

#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

Merci Adam. J'ai ajouté '? Channel = 0 & .mjpg' et ça marche maintenant. –