如何使用Windows Phone应用程序扫描数字并获取其值


我是Windows Phone

应用程序中的新蜜蜂。 我目前正在模拟器和设备中使用Windows Phone 7.1操作系统。我有一个包含数字的贴纸。 我想使用相机扫描此代码并将数字保存到我的数据库中。 我对相机的扫描值一无所知。

我通过使用相机获得了扫描条形码和QR码的代码。
我尝试的代码如下:-

 void cam_Initialized(object sender, Microsoft.Devices.CameraOperationCompletedEventArgs e)
    {
        if (e.Succeeded)
        {
            this.Dispatcher.BeginInvoke(delegate()
            {
                // Write message.
                txtDebug.Text = "Camera initialized.";
                // Set flash button text.
            });
        }
    }
    void CaptureImage(object sender, PhotoResult e)
    {
        if (e.TaskResult == TaskResult.OK)
        {
            MessageBox.Show(e.ChosenPhoto.Length.ToString());
            //Code to display the photo on the page in an image control named myImage.
            //System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
            //bmp.SetSource(e.ChosenPhoto);
            //myImage.Source = bmp;
        }
    }

    private void ShutterButton_Click(object sender, RoutedEventArgs e)
    {
        WP7.ScanBarCode.BarCodeManager.StartScan(
            // on success
    (b) => Dispatcher.BeginInvoke(() =>
    {
        txtDebug.Text = b;
        NavigationService.GoBack();
    }),
            // on error
    (ex) => Dispatcher.BeginInvoke(() =>
    {
        txtDebug.Text = ex.Message;
        NavigationService.GoBack();
    })
            // Default : please, decode any bar-code
    );
        //if (cam != null)
        //{
        //    try
        //    {
        //        // Start image capture.
        //        cam.CaptureImage();
        //        txtDebug.Text = "Image Taken";
        //    }
        //    catch (Exception ex)
        //    {
        //        this.Dispatcher.BeginInvoke(delegate()
        //        {
        //            // Cannot capture an image until the previous capture has completed.
        //            txtDebug.Text = ex.Message;
        //        });
        //    }
        //}
    }
    private int photoCounter = 0;
    void cam_CaptureImageAvailable(object sender, Microsoft.Devices.ContentReadyEventArgs e)
    {
        photoCounter++;
        string fileName = photoCounter + ".jpg";
        Deployment.Current.Dispatcher.BeginInvoke(delegate()
        {
            txtDebug.Text = "Captured image available, saving picture.";
        });
        Deployment.Current.Dispatcher.BeginInvoke(delegate()
        {
            txtDebug.Text = "Picture has been saved to camera roll.";
        });
    }

您应该使用 Aforge.NET 库进行图像比较或图像过滤。

锻造

最新更新