|
Re: Get Camera Image
There are two methods for getting an image from the camera.
(1) open a socket, ask for a single image, close socket
(2) open a socket, ask for a image stream, read the image
stream, fetching an image when you need it.
By method (1), with code written in C, we only got 4-6 imgs/sec
on the classmate.
With method (2), and a tuned receiver, we were able to get our
desired 20 fps, at 320x240.
Here's a partial example in C. I'll try to post a more complete example later.
char *cont = "Content-Length: ";
char *req = "GET /axis-cgi/mjpg/video.cgi?resolution=320x240 HTTP/1.1\r\n"
"User-Agent: testprog/1.1\r\n"
"Accept: */*\r\n"
"Host: 10.5.37.11\r\n"
"Connection: Keep-Alive\r\n\r\n";
if (0 > (fp = socket(AF_INET, SOCK_STREAM, 0))) {
perror("camera: socket");
exit(1);
}
memset(&serv, 0, sizeof(serv));
serv.sin_family = AF_INET;
serv.sin_port = htons(80);
serv.sin_addr.s_addr = inet_addr((char *) ipaddr);
if (0 > connect(fp, (struct sockaddr *) &serv, sizeof(serv))) {
perror("camera: connect");
exit(2);
}
fprintf(stderr, "sending request\n");
if (0 > (rc = send(fp, req, strlen(req), 0))) {
perror("camera: send");
close(fp);
exit(1);
}
|