Go to Post You can be legal and be graciously professional, but still be dumb. - dlavery [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 08-03-2011, 17:23
sand500 sand500 is offline
Registered User
FRC #3540 (Wildcat Robotics)
 
Join Date: Jan 2011
Rookie Year: 2011
Location: United States
Posts: 81
sand500 is an unknown quantity at this point
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.
Reply With Quote
  #2   Spotlight this post!  
Unread 08-03-2011, 19:04
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
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
__________________
Reply With Quote
  #3   Spotlight this post!  
Unread 08-03-2011, 19:55
codedr codedr is offline
Registered User
FRC #0537
Team Role: Mentor
 
Join Date: Mar 2010
Rookie Year: 2009
Location: Wisconsin
Posts: 72
codedr will become famous soon enoughcodedr will become famous soon enough
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);
}
Reply With Quote
  #4   Spotlight this post!  
Unread 08-03-2011, 20:09
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
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
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib

Last edited by byteit101 : 08-03-2011 at 20:11.
Reply With Quote
  #5   Spotlight this post!  
Unread 09-03-2011, 09:40
codedr codedr is offline
Registered User
FRC #0537
Team Role: Mentor
 
Join Date: Mar 2010
Rookie Year: 2009
Location: Wisconsin
Posts: 72
codedr will become famous soon enoughcodedr will become famous soon enough
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.
Attached Files
File Type: cpp ImageFetchEg.cpp (3.8 KB, 31 views)
Reply With Quote
  #6   Spotlight this post!  
Unread 09-03-2011, 15:26
sand500 sand500 is offline
Registered User
FRC #3540 (Wildcat Robotics)
 
Join Date: Jan 2011
Rookie Year: 2011
Location: United States
Posts: 81
sand500 is an unknown quantity at this point
Re: Get Camera Image

Thanks for the C code, but what about Java?
Reply With Quote
  #7   Spotlight this post!  
Unread 09-03-2011, 19:57
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,753
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
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
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 13:02.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi