Lamelynx / GodotGetImagePlugin-Android

Godot plugin to select image from gallery or camera on Android device.
MIT License
71 stars 4 forks source link

Video and QRcode #11

Closed Swaraj-cs closed 2 years ago

Swaraj-cs commented 2 years ago

Hi, any option to take video? add face recognition, capture it in a window? To read QR code?

Lamelynx commented 2 years ago

I have thought of implementing video selection from gallery/camera but not come around it yet. If you feel to take on the challenge you are welcome :-) . Face recognition is a lot of work and I think it should be better to put it in a separate plugin. What do you mean with "capture it to a window"?, please explain. To read QR code you may use a modification of this (Godot Mono) script https://github.com/tavurth/godot-qr-scanner/blob/master/GodotQrScanner.cs

Swaraj-cs commented 2 years ago

Hi, thank you for the info.

I meant like a node, Drag it anywhere and set its options. May be inside a TextureRect. Something like this? https://github.com/iamfunsho/godot-camera-plugin/pull/4

Also can we expect an update with QR code scanner? Can't find much options for Godot.

Lamelynx commented 2 years ago

This plugin is not a camera application, it's request (through "intent") a image from the android system. Then the device open default application for the current intent. Therefore it's not possible to get a live camera directly into your application with this plugin.

To parse a QR code you could use something like this C# script (Godot-mono): (have not tested it and most certainly does not work without any editing)

using Godot;
using System;

using ZXing;
using ZXing.QrCode;
using ZXing.QrCode.Internal;
using ZXing.Common;

public class QrParser : Node
{

    public void ParseQR(byte[] byteArray)
    {
        LuminanceSource source = new RGBLuminanceSource(
            byteArray,
            GetTexture().GetWidth(),
            GetTexture().GetHeight()
        );

        var binarizer = new HybridBinarizer(source);
        var binBitmap = new BinaryBitmap(binarizer);

        QRCodeReader qr = new QRCodeReader();

        Result str = qr.decode(binBitmap);

        GD.Print(str);
    }

}

Pass your image as bytearray to function "ParseQR()"

Swaraj-cs commented 2 years ago

Hi, thank you so much for the response. But this will work only when we capture the image right? while scanning the Qrcode, it will not detect the code right? Hope you can add this in the plugin with the option to set the camera (front or back). Its the only available plugin for android now. It will be a great help as Godot is not providing android camera feature.

Lamelynx commented 2 years ago

You can try this plugin (GodotUniversalIntentPlugin-Android) to read QR code. It's a small "intent" wrapper for android devices. Se the example code here.

Swaraj-cs commented 2 years ago

Thank you so much. I will try this.