First a little bit of background information on my system:
- Windows 7 Home Premium 64 bit
- OpenCV 2.4.2 pre-compiled binaries
- Netbeans 7.0.1
- Java 1.6 (not sure of bitness)
- MinGW-32 C Compiler with gcc version 4.5.2
A blog discussing my successes, failures and in-betweeners whilst working on computer vision related projects.
CvCapture *camera = cvCreateFileCapture("rtsp://admin:admin@192.168.1.128/ch1-s1?tcp");
/*
* File: main.cpp
* Author: Ryan
*
* Created on October 27, 2011, 2:23 PM
*/
#include <cstdlib>
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/contrib/contrib.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/legacy/legacy.hpp"
#include "opencv2/video/tracking.hpp"
#include <stdio.h>
using namespace std;
using namespace cv;
int main() {
// CvCapture *camera = cvCreateFileCapture("/home/ryan/NetBeansProjects/OpenRTSP/video-H264-1");
// CvCapture *camera = cvCreateFileCapture("stream_fifo");
// CvCapture *camera = cvCreateFileCapture("Wildlife.wmv");
CvCapture *camera = cvCreateFileCapture("rtsp://admin:admin@192.168.1.128/ch1-s1"); //purple cam /?tcp
// CvCapture *camera=cvCreateFileCapture("http://192.168.1.5/image.jpg"); //black cam
// CvCapture *camera = cvCreateCameraCapture(0); //built in cam
// cvWaitKey(10000);
if (camera == NULL) {
printf("camera is null, aborting...");
return -1;
}
printf("camera is not null\n");
fflush(stdout);
cvNamedWindow("img");
int i = 0;
while (cvWaitKey(100) != 27) {
// CvCapture *camera=cvCreateFileCapture("http://192.168.1.5/image.jpg");
IplImage *img = cvQueryFrame(camera);
if (img == NULL) break;
cvShowImage("img", img);
// cvReleaseCapture(&camera);
// printf("Image: %i\n", ++i);
}
cvReleaseCapture(&camera);
return 0;
}