[Plugin] Android Camera

Hi Forum,
Some guy ask me for an plugin develop by me some time ago, about how to access the android camera and display as an texture, now with the new APL system we can develop our own plugins for android without modify the engine source, take it as a little tutorial instead as a plugin, because AFAIK that functionality comes with the new 4.13 or 4.14 (not sure, MR Chris Babcock told me), meanwhile you can use mine.

I split the core functionality inside an UActorComponent with only 3 methods, one to call and open the camera, other for update, and finally one for shutdown. the code itself it´s easy, however if you have some question please post the thread

EDIT: I add a full project inside my drive, for some reason I have unexpected pixel convertion in unreal 4.13 when use development mode, for now just deploy on shipping mode and will be work, ue 4.12 keep working on both develop and shipping

flick fixed
**4.14.1 update link here: ** https://drive.google.com/file/d/0B8MQ0PFXL_i7alVjTFpJSnZhNFU/view?usp=sharing

**4.13 Link here: ** Android Camera UE - Google Drive

see the video:

basic BP sample

3 Likes

Great stuff! Gonna tinker with it soon :smiley:

Awesome stuff! Thank you! :smiley: Very useful for games like Pokemon GO :cool:

jajaja now everybody want to create their own pokemon go.
Glad to help

Cheers

I feel dumb for asking this, but how do you add the plugin to a project?

Hi PappySnail,
There is lot of threads talking about the topic, anyway let me write a little step by step:

1.-Create a new empty c++ project, once is open, just close for a while.
2.-Copy the “Plugins” folder inside your new project here:

image1.png

3.-Now you need regenerate your visual studio solution, or xcode because plugin works for both, right click on your project and hit Generate Visual Studio Project Files:

4.- Final step, open your visual studio solution or xcode project and compile, and enjoy!

Note: once you compile the plugin, you don´t need re-compile everytime, just open your UE project in regular way

Hope help

Cheers!

Hi ZkarmaKun,
It is great to have access to the android camera in such a straightforward plugin. I compiled it fine and got it activated and entered the basic blueprint code you included, but its not working. There are no errors in the logs. I am using a nexus 5x. Everything is good but the camera image never shows up, the dynamic texture is assigned to the geometry and my blueprint looks precisely like yours. I wonder if there is more in the construction script or material script that I need to do to make this work. I’m excited to try it.
Thanks for sharing,
O

MMM perhaps is my fault, I forget to mention something important, go ahead and open your project settings -> Android ->APK packaging->Target SDK version (9=Gingerbrid, 14 ice cream, 21= Lolipop) set to 14 or higher, the java camera code need it.
I think is all, must be work

Yep works now, ZkarmaKun, thanks very much!! Great work. O

Hi Zkarma, I’ve been trying to get this to work now for a bit but I seem to be having some issues. I’ve loaded it up with the blueprint and I can’t seem to get the camera to actually turn on. I only see whatever the environment is around the cube. I have already checked the sdk target and set it to 21 in case that was the issue.
Here is what I’ve done thusfar :

Hi MaxMendelsohn,
you can’t debug in editor, deploy on your android

Thanks a lot for your great work, ZkarmaKun.
However, I didn’t get the idea of applying this masterpiece.
I’ve created an new actor and created a new blueprint based on it, and even created a blueprint of the gamemode, both of the two eventgraphs are exactly the same like yours, but what appeared on my Android device were just a floor and a cube.
Would you please tell me whether I missed some important process?
BTW sorry for my poor English, I’m Chinese, if my words is not that appropriate, please don’t take offense.><

Hi KAI_CHENG,
MaxMendelsohn have same trouble, on curiosity I just test right now, indeed we have a problem inside 4.13, I will fix that!, as soon as posible, meanwhile use for 4.12!, and don’t worry my English is not perfect too

Cheers!

So kind of you, ZkarmaKun!
I’m a beginner who have just started how to create a plugin for UE4. I aim to make a plugin of the functionalities like yours, so I start by take your work for a reference. Do you know any websites or online resources suitable for a UE4 plugin beginner? Or the official documentation is just a great start?https://docs.unrealengine.com/latest/INT/Programming/Plugins/

mmm yeah the official paper is not the best, is the only place to start, but that doc is very old and almost useless, try to use the editor’s plugin wizard and read all the structure inside the code at least is well comented. this weekend i’m busy but i will fix the plugin for 4.13 by next week

Hi guys,
Sorry about all the mess, I just up an full project, for now UE 4.13 works only for shipping mode

Cheers!

Thank you for your work!

I have some questions about the plugin:
1- My material render is getting poor resolution (13mp camera), is there any way of setting the resolution we want to use?
2- I want to render this material fixed to the camera, but always at the bottom of every actor (in other words, I want to use it at background while rotating the camera, so I attached the plane to the camera component, and I want this plane to be at the bottom of the rendering pill)

Thank you again :slight_smile:

  • Nes

Hi Nesjett,
Yes, open the AndroidCamera.h and change the resolution by change the value on width and height, but remember higher values eat performance.
if you want set your camera texture as background you need calculate the distance of the plane based on FOV, of course the plane size must match with the texture resolution, quick formula: float distanceToCamera = (texture->GetSizeX() / 2.f) / FMath::Tan(PI / 180.f * (horizontalFOV / 2.f));
as far as I know you can access everything in blueprint if you want, even your FOV.

Hope helps

Cheers!

Thank you ZkarmaKun, Ill take a look into that as soon as possible.

Keep up the good work!

hello ZkarmaKun and thanks for the download.
I am not a developer but I know how to a deploy from ue4 to android (galaxy s6)…
can I simply open your ue4 project (AndroidCameraProj.uproject) and deploy it or i need to do some actions out of ue4 ?
thanks
amir