Camera extension for Android?


How do i depend on other versions than the master, would like to do it on the camera extensions for example so i can build a Android version as well, does that one only work for Android or Both? @britzl

Dirty Larry Problem (SOLVED)

yes, i got it now, but what do i have to do in my app to make it work on a Android build? it did not work just to build a new android target and install it on the phone, the camera did not start on the phone? @britzel


We do not really have any decent Android support for the camera yet. I was hoping to have time to add proper native support on Android ( The branch containing Android camera support results in slow capture of camera frames on Android. If you want to try the Android branch all you have to do is select the branch on GitHub and then get the link to the zip. Like this:


I have done that all ready, but it doesn’t work with the same LUA app code that works for IOS, on the android phone, the camera never starts.


Oh, ok, well it’s experimental and I thought I did leave it in a working state. I’m not able to look into it now (traveling).


I understand, no worries! whenever you got some time again! :slight_smile: maybe i need to do something with the ext.manifest file included in the camera extension?


Anyone have some time to look at this or give a hint on whats needed to get the camera extension to work on Android as well?anyone else than @britzl, he probably have better things to do :slight_smile:


I tried the dev-android branch and it worked on Android (although it’s slow and it looked like the colours were slightly blueish). What happens when you’re testing it? Does it crash? Note that you need to use this URL as a dependency:


I do have that URL as dependency, Do i need to do something more than that? can i use the same LUA code i have that works for IOS? do i need to point out the manifest file or something?

When i click the “take photo” buton in my app, on IOS the camera starts and i can take a photo, but when i click the same button on Android, the camera does not start, i get no crash, nothing happens.

Dont i need to give permissions on the phone for using the camera like i do on IOS? i never get a question for that on Android?


Yes, same Lua code. That’s the point with the native extensions that the Lua API should be the same and the underlying native code will abstract away the differences.

Yes you need that on Android as well. There’s an AndroidManifest.xml file in the root of the project, used by the example app.


Yes, that manifest file made it work, but like you said, its very blue and slow, and the image is rotated 45 degrees. But at least i get an image!! Yay!! :slight_smile:

I guess its not even on the horizon to continue on this extension and make it just a little bit better, is it?


It’s on the horizon, but for me far away. Why not go ahead and try it yourself? There’s an issue with a link to an NDK camera implementation that if used should be significantly faster than the current Android version.


To make it run faster remove following lines in function onPreviewFrame

To fix color in camera_android.cpp functions yuv to rgb transfomation switch Cb and Cr around.
I also had to change in same function direction of j get image in correct way.


Won’t that result in a fullscreen camera? The idea is to not use the camera preview and then only grab frames and display those somehow (as a texture on a quad for instance).

Would you mind submitting a PR?


I can’t think of any other use than grap preview frames and show them on sprite/quad.


Exactly. But are you saying that it works when those three lines are removed? Have you tried on different Android versions?


I have tried on Samsung galaxy j1 (android 4.4.4) and Sony xperia something (android 7.0). On J1 those lines actually caused some flickering.
I assume that startCapture function’s surfaceCreated sets surfaceView invisible and that it stays like that.


This is interesting, something is happening after all! :slight_smile:


This does not work on my HTC One M9 (Android 7). I get a single frame and nothing more.


@britzl any news on this… still no time for you to look at it i guess?