sz3 / libcimbar

Optimized implementation for color-icon-matrix barcodes
https://cimbar.org
Mozilla Public License 2.0
4.22k stars 306 forks source link

Encoder for Android #79

Open Android-Unknown opened 1 year ago

Android-Unknown commented 1 year ago

Hi! How can I build an encoder in an android application?

sz3 commented 1 year ago

It's a good question, and an open request (see this issue: https://github.com/sz3/cfc/issues/17)

Right now to encode on Android you have to download the cimbar.html file to your phone and open it in the web browser. But I admit this is not great (some phones won't even you do it...).

What I'd like to do if I eventually get some time is either (1) add a WebView to the CFC app that loads the encoder, or (2) add native jni bindings for the encoder code.

Android-Unknown commented 1 year ago

@sz3 JNI is a great way! Can you tell me which functions to use and in what format should I send data from the Java layer? I think there will be problems when building source codes for Clang compiler.

sz3 commented 1 year ago

The two places to start are probably:

  1. the existing jni bindings the android app uses for decoding, here: https://github.com/sz3/cfc/blob/master/app/src/cpp/cfc-cpp/jni.cpp#L158-L207
  2. the "cimbar_js" interface the wasm uses for encoding, here: https://github.com/sz3/libcimbar/blob/master/src/lib/cimbar_js/cimbar_js.cpp

One possibility with a jni interface for encoding would be to dump the RGB (or is it BGR...) results from the cv::Mat into a shared uint8* buffer for each frame, and have the android app worry about dumping that to the screen.

Anonymous3-a commented 10 months ago

Just saying, if you install termux (as far as I can tell, the google play version is depreciated, so you'll need to install f-droid or download the apk from f-droid), you can build this from source and encode with the terminal. I'm doing it now, seems to be working.

sz3 commented 10 months ago

Just saying, if you install termux (as far as I can tell, the google play version is depreciated, so you'll need to install f-droid or download the apk from f-droid), you can build this from source and encode with the terminal. I'm doing it now, seems to be working.

Cool! I didn't know that worked!

Interesting that it says the apk/play store version is deprecated(?), I haven't seen that on my end.

Headedbranch225 commented 10 months ago

Just saying, if you install termux (as far as I can tell, the google play version is depreciated, so you'll need to install f-droid or download the apk from f-droid), you can build this from source and encode with the terminal. I'm doing it now, seems to be working.

Can you tell me how to do this please? I have termux installed

Anonymous3-a commented 9 months ago

It didn't compile, but (and this isn't tested, but when I get motivated I will) you can use something like AnLinux (don't know if it's on play store, but it is on fdroid) to set up a ""VM"" (really just a chroot jail type thing) and compile in that. I might make some sort of script to do all that automatically later.

Edit: Keep in mind, it won't just pop up a window with the animated code, you need a vnc for that. If you use AnLinux, it has scripts for that.