Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 246
Registered: ‎01-31-2013
My Device: Developer
Accepted Solution

How to read upc Barcode in app

Hi,

 

Hoping someone can lead me in the right direction I want to be able to read upc Barcodes from within my app. Is there some sample code?, a recommended lib to use?, i.e zbar.

 

Please let me know, interested in your feedback.

 

Thanks

 



GeoYeo - Free Local classifieds - Built for Blackberry 10, if you like it please Rate It and Share it!
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: How to read upc Barcode in app

Hi,

Have you seen this sample?
https://github.com/blackberry/Cascades-Samples/tree/master/barcodereader
This component was a bit buggy though, It needed a delay to properly initialize. If startup animation was removed from this sample code it stopped working. This might be already fixed by now though.

There's also a zxing BlackBerry port on github.

Another example, but I didn't try it:
http://blackberry.github.io/Cascades-Samples/custombarcodescanner.html

Andrey Fidrya, @zmeyc on twitter
Highlighted
Developer
Posts: 126
Registered: ‎06-25-2013
My Device: Z10
My Carrier: none

Re: How to read upc Barcode in app

hi, 

 

main.qml is

 

import bb.cascades 1.2
import bb.multimedia 1.0
import bb.cascades.multimedia 1.0


Page {
    Container {
        id: barcodeContainer
        onCreationCompleted: {
            camera.open(CameraUnit.Rear)
        }
        Camera {
            id: camera
   
            onCameraOpened: {
                getSettings(cameraSettings)
                cameraSettings.focusMode = CameraFocusMode.ContinuousAuto
                cameraSettings.shootingMode = CameraShootingMode.Stabilization
                applySettings(cameraSettings)
                camera.startViewfinder()
            }
            
            onViewfinderStarted: {
                OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.CurrentLocked
            }
            
            onViewfinderStopped: {
                OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All
            }
            
            attachedObjects: [
                BarcodeDetector {
                    id: barcodeDetector
                    camera: camera
                    formats: BarcodeFormat.Any
                    onDetected: {
                        console.log("*********************************************************************************");
                        console.log("Scanned barcode is " + data);
                        console.log("*********************************************************************************");
                    }
                },
                SystemSound {
                    id: scannedSound
                    sound: SystemSound.GeneralNotification
                },
                CameraSettings {
                    id: cameraSettings
                }
            ]
        }
    }
}

 

in .pro file add  -lbbcascadesmultimedia -lbbmultimedia

in bar-descriptor.xml add <permission>use_camera</permission>

Developer
Posts: 246
Registered: ‎01-31-2013
My Device: Developer

Re: How to read upc Barcode in app

Smiley HappyThis is great!!  thank you so much....



GeoYeo - Free Local classifieds - Built for Blackberry 10, if you like it please Rate It and Share it!