Karthi
Karthi

Reputation: 211

Enable webcam in Android emulator

I am new to Android development. I am using Android 4.x SDK. I can't enable webcam in the Android emulator. Can anyone tell me how to enable it? Thanks!

Upvotes: 19

Views: 25962

Answers (3)

Mustafa
Mustafa

Reputation: 31

open the AVD manager in the android studio and open "edit this AVD" and after that open "show advanced settings", in the camera section, change it to the webcam as it shows in the below screenshot.

enter image description here

Upvotes: 0

ThomasW
ThomasW

Reputation: 17317

There is a way to get this working use the Android Virtual Device Manager. You need to edit your AVD so that in the hardware section either "Configures camera facing front" or "Configures camera facing back" are available. One, but not both, of the values for these properties should be set to "webcam0" (or whatever is available). Then start your virtual device and use your webcam as an emulated camera.

If you have both properties set to "webcam0" then you'll get a warning when you start up the virtual device and the front/back control won't be available in the camera app.

Upvotes: 27

Diego Torres Milano
Diego Torres Milano

Reputation: 69396

Use emulator help to explore the available options

$ emulator -help 2>&1 | grep cam
    -camera-back <mode>            set emulation mode for a camera facing back
    -camera-front <mode>           set emulation mode for a camera facing front
    -webcam-list                   lists web cameras available for emulation

and for example, use -webcam-list to list the recognized cameras

$ emulator -webcam-list @4.1
List of web cameras connected to the computer:
 Camera 'webcam0' is connected to device '/dev/video0' on channel 0 using pixel format 'YUYV'

to see the emulation options for cameras

$ emulator -camera-front help @4.1
emulator: ERROR: Invalid value for -camera-front <mode> parameter: help
Valid values are: 'emulated', 'webcam<N>', or 'none'

Upvotes: 6

Related Questions