~eliasnaur/gio

2 2

[android] access to camera

Details
Message ID
<efTSrqZ3YmIw_nduu8_gY2h3TumQTYybDmuJxAXB71YMDJFELamRZ6mWGi6FHiiRllA6_Rg9o2uAZZeqwaJfJQkupZhOxUyxoksJXVH6Bqk=@sbinet.org>
DKIM signature
missing
Download raw message
hi there,

for a small pet project of mine (easily building a library of my books + their inventory),
I'd like to be able to write a small (android) app that
could scan the ISBN barcode of the book, fetch the associated title from
the ISBN and populate some db.

I've managed to write a small barcode reader that kinda works (offline
for now).

now, I'd like to be able to access my smartphone's camera, either take a
photo and send it to the barcode application, or directly analyze the
video stream.

is it possible to do that from Gio+android? (or should this be a
Gio+wasm+small-web-page ?)
I didn't manage to find a small example for that use case.

thx,
-s
Gregory Pomerantz
Details
Message ID
<8e80799b-f1bd-aec0-abc5-d69b24255613@wow.st>
In-Reply-To
<efTSrqZ3YmIw_nduu8_gY2h3TumQTYybDmuJxAXB71YMDJFELamRZ6mWGi6FHiiRllA6_Rg9o2uAZZeqwaJfJQkupZhOxUyxoksJXVH6Bqk=@sbinet.org> (view parent)
DKIM signature
pass
Download raw message
On 8/27/20 10:02 AM, Sebastien Binet wrote:

> hi there,
>
> for a small pet project of mine (easily building a library of my books + their inventory),
> I'd like to be able to write a small (android) app that
> could scan the ISBN barcode of the book, fetch the associated title from
> the ISBN and populate some db.
>
> I've managed to write a small barcode reader that kinda works (offline
> for now).
>
> now, I'd like to be able to access my smartphone's camera, either take a
> photo and send it to the barcode application, or directly analyze the
> video stream.
>
> is it possible to do that from Gio+android? (or should this be a
> Gio+wasm+small-web-page ?)
> I didn't manage to find a small example for that use case.

I am not aware of any Gio project that works with the Android camera. 
There are three obvious approaches, either a Java wrapper on the native 
camera2 API, a Java fragment that sends Intents to an existing Camera 
app, or an NDK version with a C wrapper around the ndk/camera header files.

In any case I believe there will need to be entries in your 
AndroidManifest requesting camera permissions and feature use. Gio can't 
do this yet but it would be straightforward to add that. Since the 
camera is a "dangerous" permission you would have to install a Java 
fragment and prompt the user at runtime to grant this permission.

Whatever you do, it would be great to have a nicely packaged Gio 
compatible go library that provides access to the Android camera. This 
could be the basis of a cross-platform package. Keep us posted on your 
progress.
Details
Message ID
<bT8w5utwGM66iKQxQJo-B9snb1fZacplqoFCx0vdwGp2D9Udn92VhJ6vukY5exWp6z29qsRvEN3fjd9rbjDAIECq8yNH4Fazx2biI789dws=@sbinet.org>
In-Reply-To
<8e80799b-f1bd-aec0-abc5-d69b24255613@wow.st> (view parent)
DKIM signature
missing
Download raw message
hi Gregory,


‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Thursday, August 27, 2020 11:46 PM, Gregory Pomerantz <gmp.gio@wow.st> wrote:

> On 8/27/20 10:02 AM, Sebastien Binet wrote:
>
> > hi there,
> > for a small pet project of mine (easily building a library of my books + their inventory),
> > I'd like to be able to write a small (android) app that
> > could scan the ISBN barcode of the book, fetch the associated title from
> > the ISBN and populate some db.
> > I've managed to write a small barcode reader that kinda works (offline
> > for now).
> > now, I'd like to be able to access my smartphone's camera, either take a
> > photo and send it to the barcode application, or directly analyze the
> > video stream.
> > is it possible to do that from Gio+android? (or should this be a
> > Gio+wasm+small-web-page ?)
> > I didn't manage to find a small example for that use case.
>
> I am not aware of any Gio project that works with the Android camera.
> There are three obvious approaches, either a Java wrapper on the native
> camera2 API, a Java fragment that sends Intents to an existing Camera
> app, or an NDK version with a C wrapper around the ndk/camera header files.
>
> In any case I believe there will need to be entries in your
> AndroidManifest requesting camera permissions and feature use. Gio can't
> do this yet but it would be straightforward to add that. Since the
> camera is a "dangerous" permission you would have to install a Java
> fragment and prompt the user at runtime to grant this permission.
>
> Whatever you do, it would be great to have a nicely packaged Gio
> compatible go library that provides access to the Android camera. This
> could be the basis of a cross-platform package. Keep us posted on your
> progress.

thanks for your reply.

for the last item, I guess it's just a matter of creating `gioui.org/app/permission/camera` along the lines of app/permission/storage/main.go and modifying gogio to recognize that new "special" package.
one obvious place is in:
- https://git.sr.ht/~eliasnaur/gio/tree/master/cmd/gogio/permission.go
- add '<uses-permission android:name="android.permission.CAMERA"/>'

for the first leg of the journey, that might be a tad more difficult for me, as I am a complete ignorant wrt Android development.
what would be the easiest/straightforward strategy to get a stream of data from that camera, possibly also displaying that stream (and overlaying some barcode-scanner related data) ?
would you have some pointers to get me starting?

cheers,
-s
Export thread (mbox)