How to capture a camera photo on an Android emulator?

Based on this article, I am trying to take a picture from a camera on an Android emulator. I followed the instructions as they said. But I did not get a positive result.

I get Player nullwhile I run WebcamBroadcaster.java(Java application).

Does anyone have this before? If so, just give me how to do it.

Or

Is there any other way to capture camera photos on an Android emulator?

+5
source share
2 answers

In Android emulator 2.1, my code works to capture an image , but it doesn't work in other versions of android

,

Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, CAMERA_RESULT);

,

if (resultCode == RESULT_OK && requestCode == CAMERA_RESULT) {
    Bundle extras = data.getExtras();
    if(extras.containsKey("data")) {
        Bitmap bmp = (Bitmap) extras.get("data");
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bmp.compress(Bitmap.CompressFormat.PNG, 100, baos);
        byte[] image = baos.toByteArray();
        if(image != null) {
            //User this byte array in your application
        }
    }else {
        Toast.makeText(getBaseContext(), "Fail to capture Image", Toast.LENGTH_LONG).show();
    }
}

Edit:

.

+9

, , , , . , .

, :

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();

, , ? , , . /!

, , . , - , .

, :/

+2

All Articles