Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Slavrix · Oct 07, 2017 at 04:31 AM · augmented realityzxing

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
         {
         }
     }
 }
 }
 }

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Slavrix · Oct 07, 2017 at 04:34 AM 0
Share

@micjahn ill get that color32 dump

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Slavrix · Oct 08, 2017 at 01:33 PM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by speedacidrain · Dec 04, 2017 at 12:33 AM

I'm in the same situation... :/

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

119 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Augmented reality possible functions? 0 Answers

I want to track Bangla single letter, is it possible in unity3D with vuphoria augmented reality? 1 Answer

cannot combine shader of two objects 0 Answers

Why is my app screen black when I build to Android? What am I doing wrong? 1 Answer

how to run ARCore Instant Preview on Android emulator? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges