Search Unity

Easy Code Scanner Unity plugin for Android and iOS

Discussion in 'Assets and Asset Store' started by C4MProdDev, Nov 22, 2012.

  1. C4MProdDev

    C4MProdDev

    Joined:
    Jul 9, 2009
    Posts:
    107
    Hi, don't worry nothing is broken. Just our code that become a little old.

    To fix it,
    - Don't change anything from our plugin except the following.
    in file EZCodeScannerViewController,mm :
    - line 199, change
    mLabel.minimumFontSize = 10;
    by
    mLabel.minimumScaleFactor = 0.66f;

    -line 196, change
    mLabel.textAlignment = UITextAlignmentCenter;
    by
    mLabel.textAlignment = NSTextAlignmentCenter;

    in the project settings on Xcode, in BuildPhases, in Compile Sources. Find the file EZCodeScannerViewController.mm and add the Compiler Flags -fno-objc-arc.

    We are working on a better solution but this will work.
     
  2. C4MProdDev

    C4MProdDev

    Joined:
    Jul 9, 2009
    Posts:
    107
    Could you be more precise please?
    In addition, are you on iOS or Android?
     
  3. MSFX

    MSFX

    Joined:
    Sep 3, 2009
    Posts:
    115
    Really appreciate the quick response, now all working in Unity 5.

    Just FYI with regard to the compiler flags if you select the EZCodeScannerViewController file in Unity, in the Inspector under Platform Settings at the bottom you can add compile flags there, works for me :)
     
  4. MSFX

    MSFX

    Joined:
    Sep 3, 2009
    Posts:
    115
    With regard to the Decode() method... is there any reason why this is iOS only?
    I need to be able to animate UI over the top of the camera feed so the feed is part of the UI in Unity, not a native overlay. On iOS I can use the decode method and pass in a webcam texture (I'm assuming)... is this feature coming on Android?
     
  5. MSFX

    MSFX

    Joined:
    Sep 3, 2009
    Posts:
    115
    After a little bit of playing I've noticed that your EasyCodeScanner.getScannerImage(...) method isn't working correctly. It appears to be returning an invalid texture as when applied to a material it shows the dreaded white/red question mark and then the following Decode(...) method then fails. If I pass in a valid QRCode texture that's within the project to the Decode(...) method then it decodes it correctly so it appears to be an issue with getScannerImage(...)
     
  6. C4MProdDev

    C4MProdDev

    Joined:
    Jul 9, 2009
    Posts:
    107
    A solution for the EasyCodeScanner.getScannerImage is currently tested. If it works, it will be added in the next version very soon.
     
  7. LouiseW

    LouiseW

    Joined:
    Jul 16, 2013
    Posts:
    8
    Hi,

    I just bought EasyCoderScanner and tried it on Android, which works nicely! So thanks for this sweet plugin. One question though: Is there support for Portrait mode? 'Cuz I can't get it to work, maybe I missed a setting somewhere? I only have Portrait mode checked in the Unity settings and I tried "Screen.orientation = ScreenOrientation.Portrait;" in Start() just in case, but without success.
     
  8. Wonderlabs

    Wonderlabs

    Joined:
    Jun 14, 2015
    Posts:
    1
    A quick question about how to use the front camera instead the back on in iOS, i tried to dig out in to the mm files, but not lucky. I will use an iPad for scan QR on a table stand, so back camera is bit difficult for people to reach the target.
     
  9. flyingaudio

    flyingaudio

    Joined:
    Dec 3, 2010
    Posts:
    89
    Can the scanning widow be sized, or does it take up the full screen? Or better yet, is the scan to a texture?
     
  10. MSFX

    MSFX

    Joined:
    Sep 3, 2009
    Posts:
    115
    Can confirm that EasyCodeScanner.getScannerImage is now working on iOS for me - thanks!!

    Also curious about alternatives to the native overlay for the camera feed... would assume that WebcamTexture and then combine with EasyCodeScanner.getScannerImage would be the fastest way?
     
    NAKAS likes this.
  11. MSFX

    MSFX

    Joined:
    Sep 3, 2009
    Posts:
    115
    Just found out that this package is still broken :(

    If the Texture2D passed to EasyCodeScanner.Decode(...) does not have a QR code then the app crashes... :( should it not just return an empty/null string?
     
  12. ibps13

    ibps13

    Joined:
    Oct 6, 2012
    Posts:
    113
    Hi,

    Trying to publish on iOS/IL2CPP, I have more than 20 errors in
    EZCodeScannerViewController.mm and build failed :

    Semantic issue and ARC restrictions, how can I resolve this ? I use last version of your plugin and unity 5.1.1p3 on OSX

    Thanks
     
  13. NAKAS

    NAKAS

    Joined:
    Jan 16, 2013
    Posts:
    21
    An interesting alternative to the native video overlay would be to use Exon OpenCV for unity asset to change the webcam texture directly. It definitely would not be fast, but the filters and control you have over the image is quite powerful. You could use line detection and threshold filters to let the user see essentially a processed frame similar to what the zbar library uses.

    @C4MProdDev
    @MSFX
    Is there some trick to getting the EasyCodeScanner.getScannerImage working?

    I setup a test environment with the image decoding into texture2d, a normal texture and a sprite, but for each one I'm getting an upside-down question mark.

    I'm testing on both iOS and android.
     
  14. eezSZI

    eezSZI

    Joined:
    Nov 16, 2012
    Posts:
    121
    Considering this plugin... @ibps13 did you ever get it working with IL2CPP? @MSFX are you still having problems decoding?

    Thanks in advance!
     
  15. DurbsDev

    DurbsDev

    Joined:
    Sep 16, 2012
    Posts:
    9
    Great product, have got it working with iOS IL2CPP and Android. Only problem is with Samsung Galaxy Tab 3 10.1" GT-P5220. It crashes the app as soon as the scanner starts. The app quits and says "Unfortunately, [ApplicationName] has stopped." All other Android devices seem fine so far.

    C4M, please could you take a look at Tab 3. From a Unity stats perspective, Tab 3 is the most common Android device.
    http://hwstats.unity3d.com/mobile/device.html
     
  16. g8tuananh

    g8tuananh

    Joined:
    Apr 22, 2014
    Posts:
    1
    I used Unity 5.1.3f1, build for Xcode project success, but when use Xcode 6.4 to build to iOS, I got there error:
    /IOSCode/Classes/Unity/CameraCapture.mm:113:2: Use of undeclared identifier 'static_assert'; did you mean 'static_cast'?
    Under Xcode > Build Settings > Apple LLVM 6.1 - Language - C++ >
    C++ Language Dialect: try all options
    Enable C++ Exceptions: Yes
    Could you help me resolve it?
    Thanks so much
     
  17. romaing

    romaing

    Joined:
    Feb 11, 2010
    Posts:
    24
    Some news about it?
    It seems it still doesn't work on iOS, IL2CPP or Mono2x, Xcode can't compile it.
     
  18. Hookkshot

    Hookkshot

    Joined:
    Jan 11, 2013
    Posts:
    15
    Does this work with Data Matrix QR codes. by chance.
     
  19. EddieOffermann

    EddieOffermann

    Joined:
    Sep 13, 2015
    Posts:
    11
    Very interested in this library, but at $75 and recent comments about it not compiling for iOS it's a lot to gamble on. Based on the timing of reports, it seems like it probably broke around the iOS 8.4 rollout, though it may well have been with 8.3 and corresponding updates to XCode around 6.3/6.4. I can't see anything obvious in the iOS or XCode updates but changelists are often incomplete.

    Anyone (including the developer) have a fix?
     
  20. joweb42

    joweb42

    Joined:
    Feb 16, 2015
    Posts:
    8
    hi
    can i use your Plugin with Vuforia 5.I have QR-Code Reading to integrate into an existing Vuforia 5 Project.
    Can i attache your Script on the ARCamera form Vuforia or must i convert your Script to work with the Vuforia CAM ?

    THANK's for your Help
     
  21. kouroshg

    kouroshg

    Joined:
    Jul 5, 2012
    Posts:
    7
    running from Xcode 7.0.1 on iOS 9.0.2
    I get this error:

    Appreciate your advice!
     

    Attached Files:

  22. MSFX

    MSFX

    Joined:
    Sep 3, 2009
    Posts:
    115
    I'm not sure I would recommend this package since the develop has appeared to have gone quiet and has stop replying to this thread... What I will say though is if you are a developer and understand what you're doing with this package and mobile development you can get it working (iOS & Android).. hope that helps..
     
  23. Fabian-Haquin

    Fabian-Haquin

    Joined:
    Dec 3, 2012
    Posts:
    230
    Hello everyone,

    I made this plugin works on IOS using Unity 5.2.1 with Xcode 7.0.1
    I just tested it on an ipad running IOS 7.1.1

    I just had to tweak a bit the EZCodeScannerViewController.mm file, thanks to that topic: http://stackoverflow.com/questions/...e-is-unavailable-not-available-in-automatic-r

    I've removed everything about releasing stuff since it seems to be automatic now.
    I also fixed errors generated by deprecated stuff.

    Since the developer of this plugin seems to have abandoned this project, I upload my modification.

    You just have to replace it in Assets/Plugins/IOS
     

    Attached Files:

  24. ChristianGP

    ChristianGP

    Joined:
    Dec 17, 2014
    Posts:
    1

    Hi Fabian

    Thank you so much for your fix! It worked like a charm!

    I managed to compile my app with your updated EZCodeScannerViewController.mm for iOS 7.1 on Unity 5.1 and my app is now running on my iPhone 4 without a hitch.

    :)

    Thanks Again!!
     
  25. Devcamp

    Devcamp

    Joined:
    Nov 8, 2015
    Posts:
    1
    Hi

    Application die problem occurs in Android 6.0. (Nexus7 2 generations )

    When you click the camera button , the app will be Crash.

    Verification please .
     
  26. nabladigital

    nabladigital

    Joined:
    Feb 11, 2015
    Posts:
    2
    Hi
    I used Unity 5 on android.
    When you orientation landscape , the app will be Crash.
     
  27. Rnunes1984

    Rnunes1984

    Joined:
    Jul 23, 2015
    Posts:
    1
    Hi! Great plugin, but... I really need a PDF417 scanner to work, has anyone made it work or is it planned?

    I know it's not on the supported codes in the asset store description, though I see it is on zbar's docs and on EZCodeScannerExample.cs comments.. If you guys can help me with that I'd appreciate it.

    Also, when not using the UI and I press "Cancel" in the scanning screen the app stops working, the camera view goes black and it doesn't go back to the previous screen.

    Thanks!

    Edit-------
    Running on iPhone 5S, built with Unity 5.2.2f1 and Xcode 7.1.1
     
    Last edited: Nov 18, 2015
  28. Nicolas79

    Nicolas79

    Joined:
    Dec 6, 2013
    Posts:
    24
    Hi everyone,

    I need to change the UI of the scanner (which works thanks to Fabian!). In the readme file, I see :
    Q: How can I change the Scan UI?
    A: You can change the scan message in the launchScanner method. For graphical modification you need to use 2 different tricks
    - convert your images in int arrays and load them statically in your classes
    - Use Resource.Load() and then access them natively via the external data folder

    My problem is the "access them natively". I opened the sources (in the sources.zip) and started looking at the Android version but I dont really have much clue on how to do that. Also I didn't even find where the default UI is (ie red line and semialpha around the middle square), I could have changed that directly if modifying it was possible.

    Could someone provide me some help (or example even better), for both iOS and Android?

    Thanks to any helping hand!

    EDIT : just found where default UI is :
    Android : CameraUI.java : public void onDraw(Canvas canvas)
    iOS : EZCodeScannerViewController.mm : - (void) init_ui
    Any native iOS and Android dev could tell me how to draw an image (my "UI")?
    Or better, is it possible to reduce the size of the camera ouput (with some minor native code changes) so I can keep my UI around it, without recreating it natively?
     
    Last edited: Nov 19, 2015
  29. FatIgor

    FatIgor

    Joined:
    Sep 13, 2015
    Posts:
    29
    This is my attempt at adding an image overlay on the ios version. I've never done any native ios stuff, so it's cobbled together from trawling through google.

    I would appreciate any help in getting it to work
    I tried to get the image address from here
    http://stackoverflow.com/questions/10808632/loading-resources-in-a-native-plugin-unity
    and the actual image display from this
    http://stackoverflow.com/questions/7891613/create-uiimageview

    Here is my code. (From init_ui in EZCodeScannerViewController.mm)

    Code (objective c):
    1.     NSString* bundlePath = [[NSBundle mainBundle] bundlePath];
    2.     NSString* streamingAssetsPath = [NSString stringWithFormat:@"%@/Data/Raw/scanner_overlay.png", bundlePath];
    3.     UIImage *myImageObj = [[UIImage alloc] initWithContentsOfFile:streamingAssetsPath];
    4.     UIImageView *myImageView=[[UIImageView alloc] initWithImage:myImageObj];
    5.     [myImageView setFrame:CGRectMake(0,0,screen_width,screen_height)];
    6.     [self.view addSubview:myImageView];
    7.  
    8.  
     
  30. FatIgor

    FatIgor

    Joined:
    Sep 13, 2015
    Posts:
    29
    OK. I've still not worked out the iOS stuff, but here's is how to do it in Android.

    Firstly, your image goes in plugins/android/res/drawable
    (Depending on what other plugins you have, you may have to create the /res/drawable part of the path yourself)

    In CameraUI.java add this variable

    Bitmap myOverlay;

    Now, in "CameraUI.java", add the following at the end of
    public CameraUI(Context context)

    Code (Java):
    1.  
    2.         int imageResourceId;
    3.      
    4.         String packageName = context.getPackageName();
    5.             imageResourceId = context.getResources().getIdentifier("scanner_overlay", "drawable", packageName);
    6.      
    7.         Drawable myDrawable = getResources().getDrawable(imageResourceId);
    8.         myOverlay = ((BitmapDrawable) myDrawable).getBitmap();
    9.  
    In the above, my file is "scanner_overlay.png". Don't use the file extension in the search, it does not like it.

    Now, in the function
    public void onDraw(Canvas canvas)

    add the following line before the "postInvalidate()" line

    canvas.drawBitmap(myOverlay,null,new Rect(0,0,width,height),null);


    I used eclipse to do this, which lets you go to File>Export.
    Expand java, select jar file, and hit the next button.
    It asks what activity you want, there will only be one shown, so tick the box.
    Then browse to where your unity project is, and overwrite the
    EZCodeScanner.jar in the plugins/android path.
    (And back the original up first in case of problems)

    It's easy enough to add an extra paramater to the scanner call from unity if you want to specify different files.

    I hope I've made the above clear, any problems, just ask.
     
  31. Nicolas79

    Nicolas79

    Joined:
    Dec 6, 2013
    Posts:
    24
    Thanks a lot, I will try this out. Installed Eclipse and Android SDK so far :p

    Do you think if we can specify the width height of the scanner (=camera) and its pos, that it will just overlay the Unity stuff and thus be able to keep UI working with camera being shown only inside that rect ?

    I willl post my progress too.
     
  32. Nicolas79

    Nicolas79

    Joined:
    Dec 6, 2013
    Posts:
    24
    So far I've managed to recompile the jar.
    - but it's 2300 KB while the previous one was 22KB (I guess a x100 factor is sign I export much more than needed)
    - when compiling with unity, it works partially : camera is launched ok, detection is done (I can see the url detected in the qrcode) but the app crashes just after that = it doesn't go back to the unity scene with the label filled as it used to in the demo with the original jar.

    EDIT :
    - when adding your modifications, it crashes and at unity compilation I get the following msg about the png : "OBSOLETE - Providing Android resources in Assets/Plugins/Android/res is deprecated, please move your resources to an Android Library. See "Building Plugins for Android" section of the Manual."

    - no success so far at displaying the camera on only a part of the screen
     
    Last edited: Nov 30, 2015
  33. Nicolas79

    Nicolas79

    Joined:
    Dec 6, 2013
    Posts:
    24
    Made it work with an image provided via unity on Android! (it's pretty ugly : I write it to device in unity and load it in java rightafter). Thanks again to Fatlgor for help.
    Next step : transmit the touch pos to unity from java, so my gui still works...

    EDIT : in case someone wants to do the same thing : since the Activity of this plugin pauses unity, you only get messages in unity after the plugin closes.
    Workaround I did : I transmit every button (as serialized rect[]) that needs to close the camera when starting the plugin, so I can close on the java side when one of them is touched.

    Clearly all this is a pain and I spent much more time than I wanted on this. And I still haven't done the iOS part!! :(
     
    Last edited: Dec 1, 2015
  34. MackNugget

    MackNugget

    Joined:
    Dec 4, 2012
    Posts:
    35
    When using our multi plugin project, the app does not even detect the jar file, causing a java.lang.classnotfoundexception when trying to create the new java class. Every combination of file structure, and AndroidManifest.xml changes i could find or think of has not produced any results.

    java.lang.classnotfoundexception

    com.c4mod.ezcodescan.RootActvity

    Has anyone experienced this or know why this is happening?
     
  35. zengwenhui

    zengwenhui

    Joined:
    Jan 28, 2016
    Posts:
    1
    How will scan interface landscape to portrait?
     
  36. mantraMe

    mantraMe

    Joined:
    Apr 4, 2015
    Posts:
    6
    How do I constrain the rotation to only landscape left in scan interface?
    And how can I disable torch mode
     
  37. Zychew

    Zychew

    Joined:
    Feb 23, 2014
    Posts:
    5
    hey, i just bought the package, but android doesnt work! I'm using unity 5.3.0, new package is 2.3 right?
    no camera function is working!

    does anyone can tell me step by step how to make android device work on it?
     
  38. austin.mayberry

    austin.mayberry

    Joined:
    Feb 6, 2016
    Posts:
    1
    We've been using this package for a while, but it crashes when we deploy our app on Android 6.x devices. Anyone else having this problem - or can anyone confirm that this package does in fact bring up the camera on Android 6.x?
     
  39. hirotetsu

    hirotetsu

    Joined:
    Mar 14, 2013
    Posts:
    9
  40. hirotetsu

    hirotetsu

    Joined:
    Mar 14, 2013
    Posts:
    9
  41. samw3

    samw3

    Joined:
    Apr 27, 2015
    Posts:
    1
    We are also getting a crash. I have an Asus Zenpad 8 on Android 6.0.

    If the device is in portrait mode before launch, the app will crash on launch as it tries to switch to landscape mode. We upgraded to Easy Code Scanner v2.3 and the crash still happens.

    I've attached an adb logcat of the crash. Also of note, as a test we removed Easy Code Scanner from the project and commented out references to it and the crash goes away.
     

    Attached Files:

  42. vanderleifl

    vanderleifl

    Joined:
    Feb 21, 2017
    Posts:
    1
    Hi, this asset works with Microsoft Hololens?
     
  43. sachin1995

    sachin1995

    Joined:
    Jul 18, 2017
    Posts:
    1
    Hello ,I have a problem,
    I used this plugin and build an apk.
    When I start apk and pressed launch scanner button App is crashing everytime.
    I am using android 6.0 and unity 2017.2 versions.
    Please help me