|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Get Camera Image
does anyone know how to get images from the Axis camera? what we want to do is make a custom Dashboard in Java. the only thing we need on it is the Camera image. If we use the AxisCamera class and the getImage() method, we will get an image but since the code is running on the CRIO, we cannot use Swing to display the image. Any one have any ideas? I think ideally, we should connect the Camera directly to the DLINK.
As far as the Swing part, im sure we can do that. Its just getting the image from the camera that we need help with. |
|
#2
|
|||
|
|||
|
Re: Get Camera Image
the ideal solution is to create a custom dashboard in labview
The following link allows a direct connection from the camera to the DLINK to the dashboard http://decibel.ni.com/content/docs/DOC-15144 |
|
#3
|
|||
|
|||
|
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); } |
|
#4
|
||||
|
||||
|
Re: Get Camera Image
You can also use ZomB to read the camera: add a camera view, select MJPEG as the source, and put the ip address as the source params. (make sure you have a frc account with password FRC)
and if you want to do it yourself, have a look at the ZomB source under ZomBdll/NetAndDataProcessing/Video/MJpegStream.cs Last edited by byteit101 : 08-03-2011 at 20:11. |
|
#5
|
|||
|
|||
|
Re: Get Camera Image
Here's more sample code to fetch an image from the mpeg stream. It copies the image into the provided buffer.
It's part of a larger program, but it should give you an idea on how it works. |
|
#6
|
|||
|
|||
|
Re: Get Camera Image
Thanks for the C code, but what about Java?
|
|
#7
|
|||
|
|||
|
Re: Get Camera Image
The part about processing from an MJPG stream whenever you want will lead to a very lagged display. If the camera is sending 20 fps, you need to read at least 20 fps, or you will quickly find the camera acting like a time machine and showing you what the robot was doing 2, 3, 4, or 5 seconds in the past.
Greg McKaskle |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|