Comment se connecter avec une caméra IP Tenvis à partir d'une application java à l'aide d'OpenCV


J'ai Tenvis Caméra IP avec un nom d'utilisateur et un mot de passe. Je veux capturer une photo ou une vidéo en direct dans une simple application java développée dans Eclipse ID en utilisant OpenCV .

J'utilise le code suivant pour servir mon but.

public class Hello {

   public static void main( String[] args )
   {
       try
       {
            System.out.println("Welcome to OpenCV " + Core.VERSION);
            System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
            Mat m  = Mat.eye(3, 3, CvType.CV_8UC1);
            System.out.println("m = " + m.dump());

 // VideoCapture cap= new VideoCapture("D:/css/pizzavideo.mp4");

VideoCapture cap = new VideoCapture("http://192.168.2.106:7777/video/livesp.asp? 
user=admin&pwd=admin&resolution=32"); 

           if(cap.isOpened())
           {
               System.out.println(" camera found----"+cap);   

                    Mat frame = new Mat();
                    while(true){
                        if (cap.read(frame)){
                            System.out.println("Frame Obtained");
                            System.out.println("Captured Frame Width " + frame.width() + " Height " + frame.height());
                            Highgui.imwrite("img1.jpg", frame);

                            System.out.println("OK");
                            break;
                        }
                    }      
           }
           else
           {   
               System.out.println("Did not connect to camera");   
           }
               cap.release();
       }
       catch(Exception e)
       {
           System.out.println("Exception---"+e.getMessage());
       }
    }

}

Résultat :When using http://192.168.2.106:7777/video/livesp.asp? user=admin&pwd=admin&resolution=32

   Welcome to OpenCV 2.4.8.0
   m = [1, 0, 0;
        0, 1, 0;
        0, 0, 1]
   Did not connect to camera

Résultat (j'obtiens avec succès une image de vidéo en tant qu'img1.jpg): Lors de l'utilisation D:/css/pizzavideo.mp4

   Welcome to OpenCV 2.4.8.0
   m = [1, 0, 0;
        0, 1, 0;
        0, 0, 1]
    camera found----org.opencv.highgui.VideoCapture@87816d
    Frame Obtained
    Captured Frame Width 480 Height 262
    OK

Veuillez répondre si quelqu'un sait comment connecter ma caméra IP et prendre des photos ou des vidéos dans mon application java?

Author: Faisal Habib, 2014-04-05