I need to use the barcode tool

  • I need to use the barcode tool … How can be programmed when pressed is open the camera and read the barcode ?i am use basic language.

Did you look at the samples?

Do “Open Samples”, then type barcode in the search bar.

Yes, I tried the barcode template in samples but it seems to be connected to the barcode reader, I want when I click on the barcode tool it opens the camera and read the barcode and accordingly shows the required information

The Barcode sample shows how to do this. There isn’t any magic way of doing this automatically.

I know that, but the barcode model does not read by the camera must be linked to a barcode reader and the function of the model it shows the number of the barcode read … While I want to read from the mobile without the need for any device when you click the barcode tool opens the camera and scan the barcode and I have already written the code If the result of reading the barcode is a text for example (A) will appear in the tool labe information that I have already written in the conditional sentence … I hope that you understood on my idea very much like the program qr qode, but barcode images designed by me and I program the application

Are you trying to read or create barcodes?

I want to read a barcode using my mobile without an external device
I will design barcodes containing text and when the application reads the text appears in a message or text box.Please guide me the way because I am a student and prepare a project

The Barcode sample shows how to do this.

If you want do it without a webservice, you will need to use a library. We don’t have a sample showing how to do this, but here’s an example of a library:

Hi

I’ve been trying out this Quagga library. It looks like it will be better than pic2shop.

I’ve successfully got 'Quagga.init(obj,func)' loaded after a button click. The camera feed displays in the container it is linked to.

I’m struggling to get Quagga.onProcessed() and Quagga.onDetected() to fire. I’m out of my league here but with my understanding so far the library has, as shown below, init(), onProcessed() and onDetected() within the startScanner() function. How do I replicate that structure in Basic code? Or do I need to setup a listener for Quagga? Any direction pointing greatly appreciated.

function startScanner() {
            Quagga.init({
                inputStream: {
                    name: "Live",
                    type: "LiveStream",
                    target: document.querySelector('#scanner-container'),
                    constraints: {
                        width: 480,
                        height: 320,
                        facingMode: "environment"
                    },
                },
                decoder: {
                    readers: [
                        "code_128_reader",
                        "ean_reader",
                        "ean_8_reader",
                        "code_39_reader",
                        "code_39_vin_reader",
                        "codabar_reader",
                        "upc_reader",
                        "upc_e_reader",
                        "i2of5_reader"
                    ],
                    debug: {
                        showCanvas: true,
                        showPatches: true,
                        showFoundPatches: true,
                        showSkeleton: true,
                        showLabels: true,
                        showPatchLabels: true,
                        showRemainingPatchLabels: true,
                        boxFromPatches: {
                            showTransformed: true,
                            showTransformedBox: true,
                            showBB: true
                        }
                    }
                },

            }, function (err) {
                if (err) {
                    console.log(err);
                    return
                }

                console.log("Initialization finished. Ready to start");
                Quagga.start();

                // Set flag to is running
                _scannerIsRunning = true;
            });

            Quagga.onProcessed(function (result) {
                var drawingCtx = Quagga.canvas.ctx.overlay,
                drawingCanvas = Quagga.canvas.dom.overlay;

                if (result) {
                    if (result.boxes) {
                        drawingCtx.clearRect(0, 0, parseInt(drawingCanvas.getAttribute("width")), parseInt(drawingCanvas.getAttribute("height")));
                        result.boxes.filter(function (box) {
                            return box !== result.box;
                        }).forEach(function (box) {
                            Quagga.ImageDebug.drawPath(box, { x: 0, y: 1 }, drawingCtx, { color: "green", lineWidth: 2 });
                        });
                    }

                    if (result.box) {
                        Quagga.ImageDebug.drawPath(result.box, { x: 0, y: 1 }, drawingCtx, { color: "#00F", lineWidth: 2 });
                    }

                    if (result.codeResult && result.codeResult.code) {
                        Quagga.ImageDebug.drawPath(result.line, { x: 'x', y: 'y' }, drawingCtx, { color: 'red', lineWidth: 3 });
                    }
                }
            });


            Quagga.onDetected(function (result) {
                console.log("Barcode detected and processed : [" + result.codeResult.code + "]", result);
            });
        }


        // Start/stop scanner
        document.getElementById("btn").addEventListener("click", function () {
            if (_scannerIsRunning) {
                Quagga.stop();
            } else {
                startScanner();
            }
        }, false);
    </script>
</body>````

Is the above code what you are trying to replicate in BASIC?

Function InitButton_onclick()
  Textarea1.value = "Init"
  inptStrm = {name: "Live", type: "LiveStream", constraints: {width: 360, height: 220, facingMode: "environment"}, target: ScannerContainer}
  dbg = {showCanvas: True,showPatches: True,showFoundPatches: True,showSkeleton: True,showLabels: True,showPatchLabels: True,showRemainingPatchLabels: True,boxFromPatches: {showTransformed: True,showTransformedBox: True,showBB: True}}
  decoda = {readers: ["code_128_reader","ean_reader","ean_8_reader","code_39_reader","code_39_vin_reader","codabar_reader","upc_reader","upc_e_reader","i2of5_reader"],debug: dbg}
  ob = {inputStream: inptStrm, decoder: decoda}
  console.log(JSON.stringify(ob,null,vbTab))  
  Quagga.init(ob,ReturnFunc)
End Function 

Function Quagga_onProcessed(result)
  Textarea1.value = "Quagga_onProcessed(result)" & Now
  console.log("Quagga_onProcessed(result):" & result)
  If result = True Then
    'drawguides
  End If
End Function

Function Quagga_onDetected(result)
  console.log("Barcode detected and processed : [" + result.codeResult.code + "]")
  Textarea1.value = Textarea1.value & vbCRLF & "Barcode detected and processed : [" + result.codeResult.code + "]"
End Function

This is my BASIC interpretation. I start the camera with InitButton_onclick() no worries. Just not sure how to get Quagga_onprocessed and Quagga_ondetected to fire. Quagga.init returns an error on devices with no camera and undefined on devices with a camera. I read that is what to expect.

Ive not used Quagga but looking at the code i think you need to follow your Quagga.init with Quagga.onProcessed( Quagga_onProcessed ) and Quagga.onDetected( Quagga_onDetected )

Thanks for your time. When you say “follow” are you able to write exactly what I need?
In the ReturnFunc? In the InitButton_onclick?

I would try the following:

Function InitButton_onclick()
  Textarea1.value = "Init"
  inptStrm = {name: "Live", type: "LiveStream", constraints: {width: 360, height: 220, facingMode: "environment"}, target: ScannerContainer}
  dbg = {showCanvas: True,showPatches: True,showFoundPatches: True,showSkeleton: True,showLabels: True,showPatchLabels: True,showRemainingPatchLabels: True,boxFromPatches: {showTransformed: True,showTransformedBox: True,showBB: True}}
  decoda = {readers: ["code_128_reader","ean_reader","ean_8_reader","code_39_reader","code_39_vin_reader","codabar_reader","upc_reader","upc_e_reader","i2of5_reader"],debug: dbg}
  ob = {inputStream: inptStrm, decoder: decoda}
  console.log(JSON.stringify(ob,null,vbTab))  
  Quagga.init(ob,ReturnFunc)
  Quagga.onProcessed( Quagga_onProcessed )
  Quagga.onDetected( Quagga_onDetected )
End Function 

This is the basic code converted to JS.

    console.log(JSON.stringify(ob, null, '\t'));
    Quagga.init(ob, ReturnFunc);
    Quagga.onProcessed(Quagga_onProcessed());
    Quagga.onDetected(Quagga_onDetected());
};

brings up "Uncaught ReferenceError: Quagga_onProcessed is not defined"
I did also try it in the ReturnFunc, same result.

Did you leave in your code for Quagga_onProcessed etc as the error suggests those are not in your code anymore?

This is what I tried…

Function ReturnFunc(s)
  console.log(s)
  Textarea1.value = s & vbCRLF & "Initialization finished"
End Function

Function InitButton_onclick()
  Textarea1.value = "Init"
  inptStrm = {name: "Live", type: "LiveStream", constraints: {width: 360, height: 220, facingMode: "environment"}, target: ScannerContainer}
  dbg = {showCanvas: True,showPatches: True,showFoundPatches: True,showSkeleton: True,showLabels: True,showPatchLabels: True,showRemainingPatchLabels: True,boxFromPatches: {showTransformed: True,showTransformedBox: True,showBB: True}}
  decoda = {readers: ["code_128_reader","ean_reader","ean_8_reader","code_39_reader","code_39_vin_reader","codabar_reader","upc_reader","upc_e_reader","i2of5_reader"],debug: dbg}
  ob = {inputStream: inptStrm, decoder: decoda}
  console.log(JSON.stringify(ob,null,vbTab))  
  Quagga.init(ob,ReturnFunc)
  Quagga.onProcessed( Quagga_onProcessed )
  Quagga.onDetected( Quagga_onDetected )
End Function 

Function Quagga_onProcessed(result)
  Textarea1.value = "Quagga_onProcessed(result)" & Now
  console.log("Quagga_onProcessed(result):" & result)
End Function