Featured App: CameraSource
Submitted by hobbs on Tue, 12/11/2007 - 12:17.
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:
- CameraSource cs = new RemoteCamera("192.168.0.100", 9889, 320, 240);
- if (!cs.open()) { /* deal with failure to obtain camera */ }
- while(/*some condition*/) {
- cs.capture(canvas); //capture the frame onto the canvas
- }
- cs.close();
You can download the classes on Tom Gibara's website.
Comments
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