I read many, many threads about streaming images over IP in OpenCV 2.3.1 , but I still can't get my program to work.
I downloaded the IP camera for Android from https://market.android.com/details?id=com.pas.webcam&hl=en and recently taught OpenCV how to receive images from my Android phone camera.
His built-in manual states that the image from the phoneβs camera can be found at http://the.phone.ip.address: 8080 / shot.jpg . I opened it several times from the browser, and it always looks good. I also created OpenCV manually, with support for FFmpeg .
So far i tried
CvCapture* webcam = cvCaptureFromFile("http://192.168.1.220:8080/shot.jpg");
but returns null and outputs
[image2 @ 0xd701e0]Could not find codec parameters (Video: mjpeg, yuv420p)
I also tried replacing http with rtsp, but it still does not work. I also tried replacing the url with a different image URL (one direct link to a random image from Google Images and the other from localhost), and it always kills with segfault.
Here is my complete source
#include <stdlib.h> #include <stdio.h> #include <math.h> #include <cv.h> #include <highgui.h> int main(int argc, char* argv[]) { CvCapture* webcam = cvCaptureFromFile("http://192.168.1.220:8080/shot.jpg"); if(!webcam) { fprintf(stderr, "cannot open webcam\n"); return 1; } IplImage* img = cvQueryFrame(webcam); if(!img) { fprintf(stderr, "cannot get image\n"); return 1; } cvNamedWindow("test", CV_WINDOW_AUTOSIZE); cvShowImage("test", img); cvWaitKey(0); cvReleaseImage(&img); /**/ cvReleaseCapture(&webcam); /**/ cvDestroyWindow("test"); return 0; }
Can OpenCV really read images by IP address, or am I missing something?
source share