55

Does anybody know is it possible to open some personal picture when emulator camera starts?

I have an application which is based on image analysis and I would like when I click a button for camera that camera opens not that default Android emulator moving image. I want it to open some image which I set as a default image. So when I choose to take a picture it will show only that image and when I take a take a picture, that image will be saved to gallery, not Android default image.

Kas Elvirov
  • 6,646
  • 4
  • 35
  • 57
Cristiano
  • 2,929
  • 9
  • 42
  • 67

5 Answers5

115

Under Tools > AVD Manager, select the "pencil" to get to "Virtual Device Configuration". Show Advanced Settings > Camera will give you the option of using emulated, or a device:

Device - use host computer webcam or built-in camera

Virtual Device Camera Configuration

If all you need is to get a still image into the camera, starting with Android Studio 3.2 you can put your static images into the virtual scene:

Virtual Scene Demo

as discussed in this entry from Android developers blog. Note that you'll need to move the camera position into the dining room to see your images (turn around and use Alt-w to move forward).

Bek
  • 6,295
  • 4
  • 16
  • 31
Dale
  • 4,966
  • 4
  • 39
  • 75
  • 2
    Here's a more direct [link](https://developers.google.com/ar/develop/java/emulator) than the blog link to the documentation for the virtual scene changes. Additionally, I didn't know how to access the "Extended controls" to find that "Camera" link. I found those instructions [here](https://developer.android.com/studio/run/emulator.html#extended): "To open the Extended controls window, click More in the emulator panel." – gabe Aug 28 '19 at 05:01
  • 3
    I made a comprehensive list of steps https://gist.github.com/gabrieljoelc/df8256b896cac46bd51fd2deb412da5f – gabe Aug 28 '19 at 18:59
  • 2
    this answer teach me how to use it. thank you Dale !! – Yakob Ubaidi Feb 19 '21 at 08:48
  • If you're having difficulties getting to "Advanced Settings" try this. Tools > AVD Manager . Click on the down arrow (within the 'Actions' column) associated with the AVD you're interested in, then select EDIT from the resulting menu. Click on the 'Show Advanced Settings' button. I think this is where the earlier instructions were trying to get you to. This is valid for the 2020.3.1 Patch 2 – glaucon Nov 28 '21 at 20:41
  • First option worked (a notebook camera), while the second didn't. – CoolMind Mar 05 '22 at 16:16
22

Finally!

  1. Append to file ~/Android/Sdk/emulator/resources/Toren1BD.posters
poster custom
size 2 2
position 0 0 -1.8
rotation 0 0 0
default custom.png
  1. Place 'custom.png' in ~/Android/Sdk/emulator/resources/
  2. Restart! emulator @Phone -no-snapshot -no-boot-anim (replace 'Phone' with the name of your avd! (see: emulator -list-avds)
  3. Profit!

Now you have a texture just in front of camera-default-position.

RedCore
  • 221
  • 2
  • 3
  • +1 this works fine for the standard camera app on the emulator, but i have the problem that my own app using camerax does not see the custom.png. I get only teh default environment. @RedCore do you have any suggestions why different apps on same emulator might get different environments? – cguenther Mar 26 '21 at 15:30
  • This is exactly what I was looking for, thanks for posting this solution here. Do we have anything similar in iOS simulators as well? – Dhiman Apr 01 '21 at 14:58
  • 1
    Thanks, this is working for me! I think this is should be the accepted answer. – Chen Li Yong Apr 29 '21 at 08:54
5

Update 2022

The best way use the OBS. this project creates a virtual webcam and you can play videos or show picture.

Step 1: Download the OBS Studio from this site and create a virtual webcam and add a video for plying that.

enter image description here

Step 2: Changing the config in android AVD. change front and back camera to webcom0.

enter image description here

Rasoul Miri
  • 7,206
  • 57
  • 67
-1

It seems the only solution is to use a remote camera.

This is one way to do it: http://www.tomgibara.com/android/camera-source

It's not something what I was looking for but I think it can be used for testing. Maybe even barcode scanner would work with this if the barcode is placed properly in front of camera.

Cristiano
  • 2,929
  • 9
  • 42
  • 67
  • Hi you can use android 3D gallery source for this. in that you can set the constant image in the camera... – itsrajesh4uguys Dec 20 '12 at 09:02
  • 1
    Hi. If you can please post new answer and explain that a little bit I will accept your answer. I was searching a little bit and I don't see some tutorial. Thanks! – Cristiano Dec 20 '12 at 09:41
  • Normally my application is unchanged and when I use the emulator to go to the camera it shows the default living room with the cat statue and a TV with a moving checkerboard. To implement this suggestion, I would have to change my app rather than configure the emulator or Android Studio? – Dale Apr 18 '19 at 15:33
-1

Download the source from following url . This is work as the another Gallery in the emulator. While passing intent to capture image from camera choose this gallery. this is looks like samsung mobile 3d gallery.. this will return the default images.. in emulators . one more thing it will work fine after 3.0 versions only.

https://github.com/c-jiang/Gallery3D-Mod

itsrajesh4uguys
  • 4,560
  • 3
  • 19
  • 31