Stop Double Scan?

Jul 11, 2013 at 1:08 AM
Edited Jul 11, 2013 at 5:40 PM
Hi

I am wondering how I can stop double scans?

Example

I hold up my phone to a barcode and it scans the barcode, before I move my phone away from the item it scans the same barcode again. This can all happen within a second or 2.

These means now I got 2 requests going to my server and I rather just have one. So would be good if I could get a delay or something to stop it from scanning the same barcode right after each other.
Coordinator
Jul 11, 2013 at 1:19 PM
What exactly do you mean? Please describe your use case in more detail.
Jul 11, 2013 at 5:40 PM
micjahn wrote:
What exactly do you mean? Please describe your use case in more detail.
Ok, I updated my post, hopefully it is more clear now.
Coordinator
Jul 12, 2013 at 8:51 PM
I think you talk about a demo application. The library itself doesn't scan for barcodes continuously.
Mainly you have to stop the scanning thread or scanning timer if a barcode is found.
But how you have to do it depends on your current implementation.
For a more detailed answer I need the code of your app.
Jul 12, 2013 at 9:15 PM
micjahn wrote:
I think you talk about a demo application. The library itself doesn't scan for barcodes continuously.
Mainly you have to stop the scanning thread or scanning timer if a barcode is found.
But how you have to do it depends on your current implementation.
For a more detailed answer I need the code of your app.
My code is basically based off this example - Very Basic WP7.1 Demo Client
Coordinator
Jul 12, 2013 at 9:41 PM
I think it should work if you change the following methods
        private void TryDecode()
        {
            try
            {
                var previewBuffer = new byte[_width*_height];
                _photoCamera.GetPreviewBufferY(previewBuffer);

                _barcodeReader.Decode(previewBuffer, _width, _height, RGBLuminanceSource.BitmapFormat.Gray8);
            }
            catch
            {
            }
        }

        private void PhotoCameraOnAutoFocusCompleted(object sender, CameraOperationCompletedEventArgs cameraOperationCompletedEventArgs)
        {
            try
            {
                TryDecode();
                _photoCamera.Focus();
            }
            catch
            {
            }
        }
to the following
        private bool TryDecode()
        {
            try
            {
                var previewBuffer = new byte[_width*_height];
                _photoCamera.GetPreviewBufferY(previewBuffer);

                var result = _barcodeReader.Decode(previewBuffer, _width, _height, RGBLuminanceSource.BitmapFormat.Gray8);
                return result != null;
            }
            catch
            {
            }
            return false;
        }

        private void PhotoCameraOnAutoFocusCompleted(object sender, CameraOperationCompletedEventArgs cameraOperationCompletedEventArgs)
        {
            try
            {
                if (!TryDecode())
                    _photoCamera.Focus();
            }
            catch
            {
            }
        }