As far as i know, Android emulator doesn't have a camera. To capture a live image we have to use the web camera. I have seen code in this web site to use the web camera in the android emulator to capture an image, but I don't know how to use this code.
+2
A:
- Download all the source files listed on the page: CameraSource, GenuineCamera, HttpCamera, SocketCamera, BitmapCamera, and WebcamBroadcaster.
- Create a package in your project called com.tomgibara.android.camera and place the first 4 source files inside.
- Download JMF from here and install it.
- Compile WebcamBroadcaster using the following command: "C:\Program Files (x86)\Java\jdk1.6.0_15\bin\javac.exe" -classpath "C:\Program Files (x86)\JMF2.1.1e\lib" WebcamBroadcaster.java or what's equivalent to it.
- Run it with the following command and keep it running: java "-Djava.library.path=C:\Program Files (x86)\JMF2.1.1d\lib" WebcamBroadcaster
- Use the following code in your program:
CameraSource cs = new SocketCamera("192.168.0.100", 9889, 320, 240, true); if (!cs.open()) { /* deal with failure to obtain camera / } while(/some condition*/) {
cs.capture(canvas) //capture the frame onto the canvas } cs.close();
PS: I haven't been able to test this because I'm getting an error when I run WebcamBroadcaster. PPS: I just started experimenting with Android today so all this could be wrong.
Leo Jweda
2009-08-16 08:06:38
thanks for ur response,While i m trying to create the package com.tomgibara.android.camera,i can get a error in the second file (GenuineCamera) that, no "CameraDevice" class avilable and in the third(HttpCamera) and fourth(SocketCamera) file it shows the error that,method width and height not avilable.Can u pls tell me how to clear these error.
Kumar
2009-08-17 06:02:44
I had the same errors and here's how to remove them: Don't include GenuindCamera in the project (just delete it) 'cause apparently, it's there to ease moving to the real camera when distributing your project (think polymorphism). And for the rest, you just need to comment the @override's in those files.Lemme know if you have any other problems :)BTW, did the WebcamBroadcaster work for you?
Leo Jweda
2009-08-17 14:17:23
Did the NyArttoolkit worked for you? It doesn't compile because OpenGLContext cannot be found. I use Android 1.6 SDK version.
Jenea
2009-10-07 15:11:09
I'm not sure, I DO remember having to mess around with the SDK versions, but I don't remember which one I chose or if it worked at all, sorry.
Leo Jweda
2009-10-08 08:57:13