User login



Syndicate content
Add to Google


Featured App: CameraSource

For all of you that are working on that killer app that is going to process catured images from the camera phone you'll want to check out CameraSource. It's a set of Java classes created by Tom Gibara that allows you to overcome the current limitation of not being able to use a webcam with the SDK.

With CameraSource the emulator can connect to a "remote" webcam, for example the one on your computer. The code looks very easy to work with, and would be a great way to start messing with different cool things you can do with the images captured from a camera phone.

Here is an example to show how easy it is:

  1. CameraSource cs = new RemoteCamera("192.168.0.100", 9889, 320, 240);
  2. if (!cs.open()) { /* deal with failure to obtain camera */ }
  3. while(/*some condition*/) {
  4.   cs.capture(canvas); //capture the frame onto the canvas
  5. }
  6. cs.close();

You can download the classes on Tom Gibara's website.

Comments

Submitted by James (not verified) on Fri, 04/04/2008 - 08:57.

Hi,

I am still a newbie in android and I tried to run this code by adding it to the oncreate method and it did not work.

This is the code:

public class OurCamera extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);

int i = 0;
Canvas canvas = new Canvas();
CameraSource cs = new SocketCamera("192.168.0.100", 9889, 320, 240, true);

if (!cs.open())
{
i = 1;
}
while(i == 0)
{
cs.capture(canvas); //capture the frame onto the canvas
} //end while

cs.close();

}//end OnCreate

}

What am I doing wrong pls?

thanks

regards, james