reading barcodes and qr codes using kudan with zxing

HI,

Im trying to add qr code reading to kudan by adding zxing to it also.

This is the code i have got so far to grab the vdeo texture from kuda, convert to color32 then get zxing to decode it.

If i put a texture in instead of trying to get it from the camera (comment out line first line inside the if in the update) the decoding works beautifully

so im not sure what i am missing

  using System.Threading;
  using System;
  using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.UI;

  using ZXing;
 using ZXing.QrCode;
 namespace Kudan.AR {
 public class xzing : MonoBehaviour
{
    public KudanTracker _kudanTracker;
    public Texture2D camTex;
    private Thread qrThread;

    private Color32[] camPix;
    private int W, H;
    public Text resultText;

   private bool isQuit;

   public string LastResult;

   void OnDestroy()
   {
       qrThread.Abort();
   }

   void OnApplicationQuit()
   {
       isQuit = true;
   }

   void Start()
   {
       LastResult = "nothing";
       OnEnable();

       qrThread = new Thread(DecodeQR);
       qrThread.Start();
        
   }

   void Update ()
   {
        
        if(camPix == null) {
        camTex = _kudanTracker._trackerPlugin.GetTrackingTexture() as Texture2D;
        W = camTex.width;
        H = camTex.height;
        camTex.SetPixels32(camPix);
        camPix = camTex.GetPixels32();
        }
   }

   void DecodeQR()
   {
        var barcodeReader = new BarcodeReader {AutoRotate = false, TryHarder = false};

    while (true)
    {
        if (isQuit)
            break;

        try
        {
            var result = barcodeReader.Decode(camPix, W, H);
            Debug.Log("camPix: " + camPix.Length);
            if (result != null)
            {
            LastResult = result.Text;
            Debug.Log("result: " +  result.Text);
            resultText.text = result.Text;
            } else {
                Debug.Log("result: No Code Detected");
                resultText.text = "No Code Detected";
            }

            // Sleep a little bit and set the signal to get the next frame
            camPix = null;
            Debug.Log("camPix: " + camPix);
            Thread.Sleep(1000);
            
        }
        catch
        {
        }
    }
}
}
}

I changed the camTex to a webcamtexture and i get it directly from the camera now and it does seem to work alot better though it looks like i need to tweak the settings a little bit somewhere, or add like a box on the ui as a guide for how much of the image the code needs to take up for it to be read correctly.

I’m in the same situation… :confused: