Сканирование QR-кода в Unity с использованием ZXing и AR Core - PullRequest
0 голосов
/ 03 июля 2018

Я пытаюсь отсканировать QR-код в Unity, используя библиотеки ZXing и AR Core. В данный момент я попробовал следующее:

private void _OnImageAvailable(TextureReaderApi.ImageFormatType format, int width, int height, IntPtr pixelBuffer, int bufferSize)
{
    // pixelBuffer is input image
    byte[] s_ImageBuffer = new byte[bufferSize];     // output image

    System.Runtime.InteropServices.Marshal.Copy(pixelBuffer, s_ImageBuffer, 0, bufferSize);

    //m_EdgeDetectionBackgroundTexture = new Texture2D(width, height, TextureFormat.R8, false, false);
    m_EdgeDetectionBackgroundTexture = new Texture2D(width, height, TextureFormat.RGBA32, false, false);
    m_EdgeDetectionBackgroundTexture.LoadRawTextureData(s_ImageBuffer);
    m_EdgeDetectionBackgroundTexture.Apply();

    var cameraFeed = m_EdgeDetectionBackgroundTexture.GetPixels32();

    BarcodeReader barCodeReader = new BarcodeReader();
    var data = barCodeReader.Decode(cameraFeed, width, height);
    if (data != null)
    {
        // QRCode detected.
        Debug.Log(data.Text);

        //ResultPoints[0].X=bottom right
        //ResultPoints[2].X=top right
        //ResultPoints[2].Y=top left
        //ResultPoints[0].X=bottom left
        Debug.LogError(data.ResultPoints[0].X);
        Debug.LogError(data.ResultPoints[2].X);
        Debug.LogError(data.ResultPoints[2].Y);
        Debug.LogError(data.ResultPoints[0].Y);
        Debug.LogError(data.Text);
    }
    else
    {
        Debug.Log("No QR code detected !");
    }

}

Но кажется, что QR-код не может быть обнаружен. Могу ли я что-нибудь сделать, чтобы извлечь изображение из AR Core Camera и извлечь из него QR-код?

...