How to get images from the camera

General information

The idea behind getting images is similar to the idea of getting information from the low-level control board on the robot: an AgeS server, called the "FramegrabberServer", is started on the robot that handles the acquisition and distribution of images using JAVA RMI.

NOTE: This server needs to run on the robot (similar to the PioneerServer), otherwise you will not get the right images

To facilitate rudimentary image processing, another AgeS server, called "CamViewServer" is provided, which in addition to the functionality of the Framegrabber interface also provides color blob information.

To get images and blob information from the camera the following steps need to be followed:

  1. make sure an AgeS registry is running
  2. the framegrabber server needs to be started on the robot (it will register itself with the registry)
  3. the camview server needs to be started (preferably on the client machine)--again, it will register itself with the registry and connect to the framegrabber server already registered
  4. the user client needs to connect to the camview server via the registry
This could be done, for example, in the following way:
try {
    //name of remote host on which the registry is running
    // put in the right host name here!
    String serverObjectName = "rmi://airolab2/AgeSRegistry";


    //look for object in remote RMI registry
    AgeSRegistry talk = (AgeSRegistry)Naming.lookup(serverObjectName);

    // request a camview server; note you don't have to request a
    // framegrabber server as the camview server will have done it for
    // you already
    CamViewServer cam=(CamViewServer)talk.requestConnection("CamView","admin","MscheutZ");
} catch (Exception e) { System.err.println("Problems connecting to servers: " + e); }	

The Framegrabber Interface

This class defines the basic framegrabber interface, which is implemented by the framegrabber server. Note that the only method defined will return a image in JPEG format. The compression rate for the JPEG can be specified as a parameter to the function (where 100% means no compression).
public interface FramegrabberServer extends AgeSServer {

    // grabs and returns an image in JPEF format, quality specifies
    // the compression rate
    public byte[] getCameraPicture(int quality) throws RemoteException;
}

The CamViewServer Interace

This class defines the basic camera view interface, which is implemented by the camview server. It allows users to get images, display them in a window, and perform color blob detection for multiple color ranges on the image. A data structure with the blob information can be obtained (as shown below), which contains basic information about all detected color blobs (such as centroid, the bounding rectangle, etc.). Different from the framegrabber server, the CamViewServer does not have to run on the robot, but can run on any host. This is advantageous as multiple clients can get blob information from the CamViewServer at the same time without putting additional burden on the wireless connection to the robot.
public interface CamViewServer extends AgeSServer {

        // returns a JPEG image from the framegrabber
	public byte[] getCameraPicture() throws RemoteException;

        // return an image with blobs marked in bright green
	public byte[] getBlobPicture() throws RemoteException;

        // returns a vector of detected blobs
	public Vector getBlobs() throws RemoteException;

        // returns a JPEG form the framegrabber using a particular compression
	public byte[] getCameraPicture(int quality) throws RemoteException;

        // returns the width of the image
	public int getPictureWidth() throws RemoteException;
}


public class Blob implements Serializable {
	int label;        // label of the blob
	public int xcg;   // x coordinate of the centroid
	public int ycg;   // y coordinate of the centroid
	public int area;  // area of blob
	int top;          // bounding rectangle of the blob
	int left;
	int right;
	int bottom;
	float alpha;      // not used
	float beta;       // not used
	float shape;      // not used 
	int colorrange;   // the color range of the blob
	int rgbav;        // the average of the blob color

	public Blob(int l,int cr) {
		label = l;
		xcg = 0;
		ycg = 0;	    
		area = 0;
		// invalidate boundaries
		top = -1; 
		left = -1;
		right = -1;
		bottom = -1;

		alpha = -1;
		beta = -1;
		shape = -1;
		colorrange = cr;
	}
}

This page is maintained by:
Matthias Scheutz
Copyright © Matthias Scheutz, 2003
University of Notre Dame
All rights reserved.
Last revised on February 12, 2003