Git Product home page Git Product logo

unitybarcodescanner's Introduction

Unity Barcode Scanner

Unity Barcode Scanner Logo Build Status

IMPORTANT: This Project is not supported anymore !!! Link

Since months, I was looking for a good way to parse QRCodes (and generic barcode) in Unity. So, I was just trying to do something simple, readable, cross-platform and open source.

  • Tested with Unity 5.3.x, 5.4.x, 5.5.x , 2017.3.x
  • Tested on PC, Mac, Android, iOS, WebGL
  • Tested with the following barcode format:
    • 1D : Code 39, Code 128, ISBN
    • 2D : QR Code, Aztec, Data Matrix

How does that work ?

This project is a Unity Project you can use directly.

Every part is separated and can be replaced or extended if needed

  • Camera : use directly the API of unity to access the webcam (available on iOS, Android, Windows, Mac, Linux, ...)
  • Parser : use zxing to extract the data https://zxingnet.codeplex.com/ (Apache 2)
  • Scanner : use Camera & Parser and manage them in a unity context

And that's it, few C# files and a dll

How to use it ?

License

Under license WTFPL (http://www.wtfpl.net/about/)

unitybarcodescanner's People

Contributors

kefniark avatar sakaro01 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unitybarcodescanner's Issues

Camera permissions on Android and IOS

In the sample project above Samsung, the camera can be turned on normally, but the camera screen will be stuck at SONY before the screen appears, IOS will ask the camera permission

But when I packaged the package and imported it into my project, the IOS camera permissions were not accessed.
Where can I make changes?

What am I missing?

Hi! Great work on the QR Scanner!
I'm trying to add it to my project, but I seem to be missing something...I am using Unity 2018.2.10f1, building for Android 4.4 (even tried going 5.0, but no go). I get the demo working, with simple and continuos working great, but I can't start my own scene.

I've even exported the boot , simple and continuos scenes to a new project, built it and it does not work, the phone freezes. The boot scene loads ok, but when I click simple or continuous, it freezes, doesn't even ask for the permission.

I've tried editing the AndroidManifest.xml and nothing...I did notice one thing, when I build your demo, the app asks for authorization to use the camera (upon clicking simple or continuous) but on my project it does not. What am I missing? Is there another setting on the project or libraries that I'm missing? It all seems to be there, and the editor show no errors...

Thanks!

Not working ons IOS

I tried compiling the code on IOS and it does not seem to work for me.
All it does is shows a white raw image.
It looks like it is not recognizing the camera.
My unity version is: 2017.3.1f1
Xcode version: 9.2
IOS version: 9.x
I hope you can help me with this issue.
Note:
It works really good on android and windows good job :)

EDIT:
Xcode error: Exception: This Webcam Library can't work without the webcam authorization

This project is not supported anymore !

Description

Hello everyone,

Glad to see you here and thanks for using my QRCode plugin for so long.
Sadly I have to announce that this unity plugin is not supported anymore:

  • I don't have the need or the motivation for such plugin anymore
  • This has been developed mainly for unity 5.3-5.4 more than 3 years ago, there are probably better implementation nowadays
  • I don't have time to keep it up-to-date with unity upgrades, and testing it across devices
  • Most question are not about this plugin but related to android/ios or other SDK
  • I don't have half of the devices people are asking question about (AR, iphone, ...)

So feel free to fork and make your own version or go to the Assetstore.

See you ... space cowboys o/

Goodbye

Open Front Camera for scanning

Hey, You have done fantastic job..!!

Here is how I use it in my project. when you open the app QR Scanning is there for login purpose. Now I want the scanning camera to be front camera but not the back camera. I have searched the Plugin for front camera access but could not find one.

I saw in project tab, There is card for multiple, I am not sure if that is the one which I am referring too.

Getting NullReferenceException when BarcodeScanner.Update() and BarcodeScanner.Scan() are called

Hi,

I am trying to integrate this plugin in my unity project and I am using 2019.2.5f1 editor. I have followed all the steps mentioned in the docs and copy pasted the code mentioned in the sample SimpleDemo.cs with few modifications for camera permission for iPhone (the code related to camera permissions can be added as an improvement).

After running the application in iPhone, I am getting the following exception:

NullReferenceException: Object reference not set to an instance of an object.
at Scene1.g__c_statusChanged|3_1 (System.Object sender, System.EventArgs e) [0x00000] in <00000000000000000000000000000000>:0
at System.EventHandler.Invoke (System.Object sender, System.EventArgs e) [0x00000] in <00000000000000000000000000000000>:0
at BarcodeScanner.Scanner.Scanner.set_Status (BarcodeScanner.Scanner.ScannerStatus value) [0x00000] in <00000000000000000000000000000000>:0
at BarcodeScanner.Scanner.Scanner.Update () [0x00000] in <00000000000000000000000000000000>:0
at Scene1.Update () [0x00000] in <00000000000000000000000000000000>:0

and same one when I tried to call the BarcodeScanner.Scan():

NullReferenceException: Object reference not set to an instance of an object.
at Scene1.g__c_statusChanged|3_1 (System.Object sender, System.EventArgs e) [0x00000] in <00000000000000000000000000000000>:0
at System.EventHandler.Invoke (System.Object sender, System.EventArgs e) [0x00000] in <00000000000000000000000000000000>:0
at BarcodeScanner.Scanner.Scanner.set_Status (BarcodeScanner.Scanner.ScannerStatus value) [0x00000] in <00000000000000000000000000000000>:0
at BarcodeScanner.Scanner.Scanner.Scan (System.Action2[T1,T2] callback) [0x00000] in <00000000000000000000000000000000>:0 at Scene1.scanQR () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.Events.UnityAction.Invoke () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.Events.InvokableCall.Invoke () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.Events.UnityEvent.Invoke () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.UI.Button.Press () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.ExecuteEvents+EventFunction1[T1].Invoke (T1 handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction1[T1] functor) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchPress (UnityEngine.EventSystems.PointerEventData pointerEvent, System.Boolean pressed, System.Boolean released) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchEvents () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.StandaloneInputModule.Process () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.EventSystem.Update () [0x00000] in <00000000000000000000000000000000>:0 UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object) UnityEngine.DebugLogHandler:LogException(Exception, Object) UnityEngine.Logger:LogException(Exception, Object) UnityEngine.Debug:LogException(Exception) UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction1)
UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean)
UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents()
UnityEngine.EventSystems.StandaloneInputModule:Process()
UnityEngine.EventSystems.EventSystem:Update()

I have wasted hours trying to figure out the exact root cause of these issues and think it is something related to the statusChanged as it can be seen in exceptions and which traces back to BarcodeScanner.Update() and BarcodeScanner.Scan(). Hence finally raising this issue. It would be great if some solution is provided quickly. Really stuck with this.

Trying to use barcode scanner with AR Foundation app

Hi
I have an AR app where i use AR Foundation for all the AR stuff.
I am trying to scan a barcode using this project.
I copied everything from the Simple sample example, but when i hit click the button to start the scanner it just gets stuck on "Status: running" without ever detecting a barcode.
Any ideas?

How to Run?

Apologies if this comes off as too novice, but I can't seem to figure out how to work with this project? Can someone please help me with a few steps-to-follow? How do I run one of the samples (simple/continuous) or how do I use this inside a new Unity scene and scan codes?

The (little) documentation suggests copying Assets/Scripts into my project and using it. Can someone help me with more precise steps? Thanks!

It doesn't work for me ,even use demo Scene

Scan callback do not Called,anyone can help me please?

		BarcodeScanner.Scan((barCodeType, barCodeValue) => {
			BarcodeScanner.Stop();
			TextHeader.text = "Found: " + barCodeType + " / " + barCodeValue;

			// Feedback
			Audio.Play();

			#if UNITY_ANDROID || UNITY_IOS
			Handheld.Vibrate();
			#endif
		});

Fullscreen?

Can you display the scanner image to fullscreen?
If so, how do I do this? :)
I'm pretty new to this

Camera stuck on scene change

Is there any way to implement stoping camera on scene destroy?

I use this code and it works fine:

	public IEnumerator StopCamera(Action callback)
	{
		// Stop Scanning
		Image = null;
		BarcodeScanner.Destroy();
		BarcodeScanner = null;
		// Wait a bit
		yield return new WaitForSeconds(0.1f);
		callback.Invoke();
	}

But if I change scene from menu (different scene as overlay with dynamic content references to other scenes) using SceneManager my camera gets stuck until closing Unity editor.

Would you be so kind to suggest any solution? I dont want to drag refrence to camera everywhere just to make sure it closes or reimplement scene manager... =(

ARCamera compatibility?

Question: Can your UnityBarcodeScanner work with ARCamera from Vuforia? It works wonders in normal mode, how can I use it for ARCamera?

How to switch camera

How to switch between front and back camera in android with this bar code reader?
Any help will be appreciated.

Thank you,

Destroy then Instantiate prefab

If I instantiate the prefab first time it works, but if I destroy it and try to instantiate again I get the following:

[UnityBarcodeScanner] Camera Not Ready Yet ...
UnityEngine.Debug:LogWarning(Object)
Wizcorp.Utils.Logger.Service.ConsoleService:AddLog(LogLevel, Object, Object) (at Assets/Scripts/External/WizUtils/Logger/Services/ConsoleService.cs:39)
Wizcorp.Utils.Logger.Log:AddLog(LogLevel, Object, Object) (at Assets/Scripts/External/WizUtils/Logger/Log.cs:56)
Wizcorp.Utils.Logger.Log:Warning(Object, Object) (at Assets/Scripts/External/WizUtils/Logger/Log.cs:77)
BarcodeScanner.Scanner.Scanner:Update() (at Assets/Scripts/Scanner/Scanner.cs:275)
ContinuousDemo:Update() (at Assets/Samples/Continuous/ContinuousDemo.cs:108)

NOTE: My fault, I had BarcodeScanner.Destroy() commented out. stupid face

Improvement : Keep Aspect ratio

Description

This could be great to update the samples.
In the OnReady method, to add an easy way to keep the same aspect ratio on the rawTexture.
That's probably not really difficult to implement (2~3 lines of math)

Scanner.Stop: ThreadAbortException Error

It seems that CodeScannerThread.Abort(); should be avoid when stopping the camera.
I got that error:

System.Threading.ThreadAbortException: Thread was being aborted
  at ZXing.Common.HybridBinarizer.calculateBlackPoints (System.Byte[] luminances, Int32 subWidth, Int32 subHeight, Int32 width, Int32 height) [0x00000] in <filename unknown>:0 
  at ZXing.Common.HybridBinarizer.binarizeEntireImage () [0x00000] in <filename unknown>:0 
  at ZXing.Common.HybridBinarizer.get_BlackMatrix () [0x00000] in <filename unknown>:0 
  at ZXing.BinaryBitmap.get_BlackMatrix () [0x00000] in <filename unknown>:0 
  at ZXing.QrCode.QRCodeReader.decode (ZXing.BinaryBitmap image, IDictionary`2 hints) [0x00000] in <filename unknown>:0 
  at ZXing.MultiFormatReader.decodeInternal (ZXing.BinaryBitmap image) [0x00000] in <filename unknown>:0 
  at ZXing.MultiFormatReader.decodeWithState (ZXing.BinaryBitmap image) [0x00000] in <filename unknown>:0 
  at ZXing.BarcodeReaderGeneric`1[T].Decode (ZXing.LuminanceSource luminanceSource) [0x00000] in <filename unknown>:0 
  at ZXing.BarcodeReaderGeneric`1[T].Decode (.T rawRGB, Int32 width, Int32 height) [0x00000] in <filename unknown>:0 
  at BarcodeScanner.Parser.ZXingParser.Decode (UnityEngine.Color32[] colors, Int32 width, Int32 height) [0x0001e] in /Users/emmanuelah-kouen/Projects/ghm-unity/Assets/Libraries/UnityBarcodeScanner/Parser/ZXingParser.cs:41  :   at ZXing.Common.HybridBinarizer.calculateBlackPoints (System.Byte[] luminances, Int32 subWidth, Int32 subHeight, Int32 width, Int32 height) [0x00000] in <filename unknown>:0 
  at ZXing.Common.HybridBinarizer.binarizeEntireImage () [0x00000] in <filename unknown>:0 
  at ZXing.Common.HybridBinarizer.get_BlackMatrix () [0x00000] in <filename unknown>:0 
  at ZXing.BinaryBitmap.get_BlackMatrix () [0x00000] in <filename unknown>:0 
  at ZXing.QrCode.QRCodeReader.decode (ZXing.BinaryBitmap image, IDictionary`2 hints) [0x00000] in <filename unknown>:0 
  at ZXing.MultiFormatReader.decodeInternal (ZXing.BinaryBitmap image) [0x00000] in <filename unknown>:0 
  at ZXing.MultiFormatReader.decodeWithState (ZXing.BinaryBitmap image) [0x00000] in <filename unknown>:0 
  at ZXing.BarcodeReaderGeneric`1[T].Decode (ZXing.LuminanceSource luminanceSource) [0x00000] in <filename unknown>:0 
  at ZXing.BarcodeReaderGeneric`1[T].Decode (.T rawRGB, Int32 width, Int32 height) [0x00000] in <filename unknown>:0 
  at BarcodeScanner.Parser.ZXingParser.Decode (UnityEngine.Color32[] colors, Int32 width, Int32 height) [0x0001e] in /Users/emmanuelah-kouen/Projects/ghm-unity/Assets/Libraries/UnityBarcodeScanner/Parser/ZXingParser.cs:41 
UnityEngine.Debug:LogError(Object)
Wizcorp.Utils.Logger.Service.ConsoleService:AddLog(LogLevel, Object, Object) (at Assets/Libraries/UnityBarcodeScanner/External/WizUtils/Logger/Services/ConsoleService.cs:36)
Wizcorp.Utils.Logger.Log:AddLog(LogLevel, Object, Object) (at Assets/Libraries/UnityBarcodeScanner/External/WizUtils/Logger/Log.cs:56)
Wizcorp.Utils.Logger.Log:Error(Object, Object) (at Assets/Libraries/UnityBarcodeScanner/External/WizUtils/Logger/Log.cs:82)
BarcodeScanner.Parser.ZXingParser:Decode(Color32[], Int32, Int32) (at Assets/Libraries/UnityBarcodeScanner/Parser/ZXingParser.cs:49)
BarcodeScanner.Scanner.Scanner:ThreadDecodeQR() (at Assets/Libraries/UnityBarcodeScanner/Scanner/Scanner.cs:209)

What do you think about adding a boolean in Scanner and put a condition on it inside the thread loop:

public void ThreadDecodeQR()
{
	while (Result == null && !stopBGThread)
	{
		//....
	}
}

Broken build on desktop

Since the last PR (and usage of Handheld), it doesn't build anymore on some platform

Unity] -----CompilerOutput:-stdout--exitcode: 1--compilationhadfailure: True--outfile: Temp/Assembly-CSharp.dll
[Unity] Compilation failed: 1 error(s), 0 warnings
[Unity] Assets/Samples/Continuous/ContinuousDemo.cs(47,25): error CS0103: The name `Handheld' does not exist in the current context
[Unity] Assets/Samples/Continuous/ContinuousDemo.cs(47,25): error CS0103: The name `Handheld' does not exist in the current context
[Unity] Error building Player because scripts had compiler errors
[Unity] Player export failed. Reason: 2 errors
! build of 'default-windows-desktop-64-bit' failed. compile failed
publishing finished successfully.

Just need to had a directive around those call

Auto Focus on Android/iOS?

Hello, first of all, I wanted to thank you for this awesome repo. Had it up and running in minutes!

Is there any way to enable auto focus for mobile devices?

Thanks!

Activate camera light while scanning

Hello,

I've been using this plugin and we've had no issues so far, however, having a way to turn the camera light on while camera is active will help with scanning codes in low light conditions. Is there a way to incorporate this feature in a future release?

Zorcher

The BarCode 3D Position?

Hello,

nice asset, thanks a lot!

Can I get the Barcode "real world" Position and Rotation? I also tried with ZXIng itself but did not succeed…

Thanks a lot!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.