facebook

Javascript barcode scanner

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #335293 Reply

    davidg
    Member

    Hi,

    I want to integrate a barcode scanner in my app.

    I am very new to javascipt and html5 but I came across this javascript code and wanted to see if somebody knew how to make it work.

    Here’s a link to the JAVASCRIPT BARCODE Scanner. http://badassjs.com/post/654334959/barcode-scanning-in-javascript

    If somebody could get this to work and tell me how to do it that would be awesome. Or if somebody knows a way to integrate a simple barcode scanner, let me know (I would prefer a QR code scanner)

    #336860 Reply

    welkhanson
    Member

    Javascript barcode scanner? not Java barcode scanner? I know how to integrate barcode reading function into java project. If this experience will help you a little, free to quote me.

    #336903 Reply

    davidg
    Member

    @welkhanson wrote:

    Javascript barcode scanner? not Java barcode scanner? I know how to integrate barcode reading function into java project. If this experience will help you a little, free to quote me.

    Thanks for the reply. Yes, that would be helpful. Do you have any sample mobi projects I could look at?

    #336905 Reply

    Brandon
    Member

    Here is a working sample of the Javascript barcode scanner. It is the code that is by Tobias Schneider, I put it into a Mobione project.

    Attachments:
    You must be logged in to view attached files.
    #337199 Reply

    davidg
    Member

    @CincyPlanet wrote:

    Here is a working sample of the Javascript barcode scanner. It is the code that is by Tobias Schneider, I put it into a Mobione project.

    Thanks CincyPlanet.

    Your demo worked well. However I am trying to retrieve an image taken with the camera and then read the barcode. I have tried using the cordova/phonegap code:

    navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
    destinationType: Camera.DestinationType.FILE_URI });

    function onSuccess(imageURI) {
    var image = document.getElementById(‘myImage’);
    image.src = imageURI;
    }

    function onFail(message) {
    alert(‘Failed because: ‘ + message);
    }

    But I have not had success retrieving the photo after I take it. It says that there was a compression error.

    Have you had any projects where you successfully implemented a camera option?

    #337200 Reply

    Brandon
    Member

    Try this, will take an image and place it into a image widget where you can read with the barcode sacnner

    
    
     function captureImage() {
     navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
        destinationType: Camera.DestinationType.DATA_URL }); 
    }
    
    function onSuccess(imageData) {
    //Your Image Widget ID below
        var image = document.getElementById('m1-formName-ImageWidget');
        image.src = "data:image/jpeg;base64," + imageData;
     
    }
    
    function onFail(message) {
        alert('Failed because: ' + message);
    }
    
    #337234 Reply

    davidg
    Member

    Thanks CincyPlanet,

    I tried the code and it still doesn’t work.

    I am using an Android Samsung Galaxy SII and I get the following error after the picture is taken(see attached)

    I don’t have the ability to test on the Iphone at this time, but maybe that is the problem.

    I did see settings on the phonegap API but I wasn’t able to figure out how to configure so as not to get the error.

    Attachments:
    You must be logged in to view attached files.
    #337235 Reply

    Brandon
    Member

    This is usually a permissions error.
    Make sure when you build you check the permissions box for external storage.

    #337238 Reply

    davidg
    Member

    Thanks! that was the problem.

    I now takes pictures, Thank you.

    #337243 Reply

    Brandon
    Member

    No problem.

    #337256 Reply

    Brandon
    Member

    Just a note, I am working on a QR Code creator for M1 right now, actually its working fine, Im writing the tutorial for it.

    #337257 Reply

    davidg
    Member

    That’s Great! If you end up posting it on your site I will be sure to check it out. The barcode reader I pieced together works but not very well and it only reads barcodes not QR.

    I saw your site and I like it. In a few weeks I will try to give you a few example projects I made that may be helpful to others. Your code examples were helpful to me so I want to try and help out if I can.

    #337259 Reply

    Brandon
    Member

    Check the Examples, how to forum, I just posted the link, its on my blog.

    http://cincyplanet.com/mobius

    #344305 Reply

    palani91
    Member

    can u post the full code pls

    #349932 Reply

    arronlee
    Member

    @welkhanson wrote:

    Javascript barcode scanner? not Java barcode scanner? I know how to integrate barcode reading function into java project. If this experience will help you a little, free to quote me.

    Hi, welkhanson.
    I am also testing about the related projects these days. Do you have any ideas about it? Or any good suggestion? Or could you offer more info about the barcode project you mentioned above? Thanks in advance.

    Best regards,
    Arron

Viewing 15 posts - 1 through 15 (of 21 total)
Reply To: Javascript barcode scanner

You must be logged in to post in the forum log in