C# バーコード スキャナーを使用して書籍をスキャンします

ブログ カテゴリ: バーコード.NET

2025/06/09

バーコード スキャナーを使用した書籍のスキャンは、図書館、書店、アーカイブ、教育機関の自動化に不可欠な部分になりつつあります。このアプローチにより、大規模なコレクションの処理が高速化され、会計エラーが最小限に抑えられ、書籍と読者との新しい形式のインタラクションも提供されます。



書籍に関するソフトウェア バーコード スキャナーの動作原理

ソフトウェア スキャナーは、カメラ、スキャナー、またはモバイル デバイスを使用して書籍に貼り付けられたバーコードを自動的に認識してデコードする専用のソフトウェア ソリューションです。これを実装すると、手動でデータを入力する必要なく、高速で正確な電子会計、資金管理、およびトランザクション処理を整理できます。

ソフトウェア スキャナーの動作は次の原理に基づいています。デバイス (カメラやスキャナーなど) が本の表紙またはページからバーコードの画像を読み取り、ソフトウェアがそこにエンコードされた情報 (ISBN など) を復号​​化し、このデータをライブラリまたは取引システムに転送してさらに処理します。

書籍のバーコード

ここ数十年で出版されたほとんどの書籍にはバーコードがあります。通常は EAN-13 形式の ISBN (国際標準図書番号) または QR コード (新世代の出版物) です。バーコードには書籍の一意の識別子が含まれており、多くの場合、発行に関する追加情報も含まれています。

カメラとスキャナーの使用

ソフトウェア バーコード スキャナーは、特別な機器 (スキャナー、端末) と Web カメラまたはモバイル デバイスの両方を使用してバーコードを認識できるアプリケーションまたはライブラリであり、プロセスを可能な限りモバイルかつアクセスしやすいものにします。

認識とデータ処理

画像処理アルゴリズムにより書籍のバーコードを検出し、そこに含まれる情報をデコードしてカタログ、データベース、図書館システムに統合し、迅速かつ正確な会計処理を実現します。



書籍スキャンの段階

ソフトウェア バーコード スキャナーを使用した書籍のスキャンには、複数の連続した段階が含まれます。各段階は、会計、書籍の発行および返却のプロセスの正確性と効率性にとって重要です。適切に編成された作業サイクルにより、在庫時間が大幅に短縮され、データ品質が向上し、図書館や書店でのサービスが最適化されます。

機器とソフトウェアの準備

スキャンを開始する前に、使用しているデバイスが選択したソフトウェアとバーコード標準をサポートしていることを確認する必要があります。次に、

バーコードのスキャンと認識

この段階で、書籍からバーコードを実際に読み取ります。
カメラまたはスキャナでバーコードがはっきりと見えるように書籍を配置します。

ライブラリまたは取引システムとの統合

認識が成功すると、ソフトウェア スキャナーは受信したデータを自動的に情報システムに転送します。

データの保存、分析、および後続の作業

情報がデータベースに保存されると、会計および分析プロセスを自動化する機会が開かれます。



最新のソフトウェア スキャナーの技術的特徴と利点

最新のソフトウェア バーコード スキャナーには、次の技術的ソリューションが備わっています。

最新のバーコードスキャナーソフトウェアは、自動化、会計の透明性、サービスのスピードアップを求める図書館や書店にとって不可欠なツールです。このようなソフトウェアのおかげで、紙のコレクションの処理は、最小限のコストと最大限の利益で、最新のデジタルレベルに移行します。

ソフトウェアソリューションの選択

書籍の処理に使用するソフトウェアバーコードスキャナーを選択するときは、次の点を考慮することをお勧めします。

ユニバーサルソリューションは、ITインフラストラクチャに簡単に統合でき、デスクトップPCから携帯電話まで、さまざまなデバイスでの作業をサポートする必要があります。シンプルなインターフェイス、更新機能、テクニカルサポートを備えた製品を選択することをお勧めします。

発展の見通し

ソフトウェアバーコードスキャナを用いた書籍スキャン技術は急速に発展を続けています。近い将来、2次元バーコード(DataMatrixやQRコードなど)がより広く実装されることが期待されます。

スキャナーとクラウドサービスやデジタルライブラリの統合が進み、オンラインリソースへの自動アクセスやユーザー向けサービスの拡張が可能になります。将来的には、書籍の状態の自動分析、推奨事項の生成、エンドツーエンドの分析の開発、図書館資金の動きの監視など、インテリジェントな機能の導入も期待されています。

結論

バーコードスキャンソフトウェアソリューションを選択するには、サポートされている形式、速度、統合機能、使いやすさなど、多くの要素を慎重に検討する必要があります。技術開発の見通しは、自動化の新たな展望を開き、図書館システムの効率を高め、ユーザー向けサービスを向上させます。

VintaSoft Barcode .NET SDKの開発者であるVintaSoftは、図書館バーコードシステムの作成を大幅に簡素化できます。この強力なツールは、幅広い形式のバーコードに対応し、高速かつ高精度なスキャンを実現し、既存の図書館システムとの統合も容易です。VintaSoft Barcode .NET SDKを活用することで、図書館は会計や帳簿管理に関わるあらゆるプロセスを迅速かつ効率的に自動化し、サービス品質の向上と大幅なリソース削減を実現できます。


カメラでキャプチャした画像内の ISBN バーコードを認識する方法を示す C# コードを以下に示します。
/// <summary>
/// Reads barcode from a <see cref="System.Drawing.Bitmap"/>.
/// </summary>
/// <param name="bitmap">A bitmap with barcodes.</param>
public static void ReadIsbnBarcodesFromBitmap(System.Drawing.Bitmap bitmap)
{
    // create barcode reader
    using (Vintasoft.Barcode.BarcodeReader reader = new Vintasoft.Barcode.BarcodeReader())
    {
        // specify that reader must search for ISBN barcodes
        reader.Settings.ScanBarcodeTypes = Vintasoft.Barcode.BarcodeType.ISBN;

        // read barcodes from image
        Vintasoft.Barcode.IBarcodeInfo[] infos = Vintasoft.Barcode.GdiExtensions.ReadBarcodes(reader, bitmap);

        // if barcodes are not detected
        if (infos.Length == 0)
        {
            System.Console.WriteLine("No barcodes found.");
        }
        // if barcodes are detected
        else
        {
            // get information about extracted barcodes

            System.Console.WriteLine(string.Format("{0} barcodes found:", infos.Length));
            System.Console.WriteLine();
            for (int i = 0; i < infos.Length; i++)
            {
                Vintasoft.Barcode.IBarcodeInfo info = infos[i];
                System.Console.WriteLine(string.Format("[{0}:{1}]", i + 1, info.BarcodeType));
                System.Console.WriteLine(string.Format("Value:      {0}", info.Value));
                System.Console.WriteLine(string.Format("Region:     {0}", info.Region));
                System.Console.WriteLine();
            }
        }
    }
}



WinForms アプリケーションで、DirectShow カメラ (VintaSoft Imaging .NET SDK) から画像をキャプチャし、キャプチャした画像 (VintaSoft Barcode .NET SDK) 内の ISBN バーコードを認識する方法を示す C# コードを以下に示します。
public partial class IsbnBarcodeScannerForm : Form
{
    /// <summary>
    /// The camera barcode scanner.
    /// </summary>
    ImagingCameraBarcodeScanner _cameraBarcodeScanner;

    /// <summary>
    /// Initializes a new instance of the <see cref="IsbnBarcodeScannerForm"/> class.
    /// </summary>
    public IsbnBarcodeScannerForm()
    {
        InitializeComponent();

        _cameraBarcodeScanner = new ImagingCameraBarcodeScanner();
        _cameraBarcodeScanner.BarcodeScanner.FrameScanFinished += BarcodeScanner_FrameScanFinished;
        _cameraBarcodeScanner.ScanningException += CameraBarcodeScanner_ScanningException;

        _cameraBarcodeScanner.BarcodeScanner.ScannerSettings.ScanBarcodeTypes = Vintasoft.Barcode.BarcodeType.QR;
    }

    /// <summary>
    /// Starts the capturing of images from seleced device and recognition of barcodes in captured images.
    /// </summary>
    private void startButton_Click(object sender, EventArgs e)
    {
        textBox1.Text = "Scan Barcodes Types: " + _cameraBarcodeScanner.BarcodeScanner.ScannerSettings.ScanBarcodeTypes.ToString();

        _cameraBarcodeScanner.CaptureDevice = _cameraBarcodeScanner.CaptureDevices[0];
        _cameraBarcodeScanner.StartScanning();
    }

    /// <summary>
    /// Stops the capturing of images from seleced device and recognition of barcodes in captured images.
    /// </summary>
    private void stopButton_Click(object sender, EventArgs e)
    {
        textBox1.Text = "";

        _cameraBarcodeScanner.StopScanning();
    }

    /// <summary>
    /// Shows an error.
    /// </summary>
    private void CameraBarcodeScanner_ScanningException(object sender, Vintasoft.Imaging.ExceptionEventArgs e)
    {
        MessageBox.Show(e.Exception.ToString());
    }

    /// <summary>
    /// Handles the FrameScanFinished event of the BarcodeScanner.
    /// </summary>
    private void BarcodeScanner_FrameScanFinished(object sender, Vintasoft.Barcode.FrameScanFinishedEventArgs e)
    {
        if (e.FoundBarcodes.Length > 0)
            Invoke(new ShowRecognitionResultsDelegate(ShowRecognitionResults), new object[] { e.FoundBarcodes });
    }

    /// <summary>
    /// Shows barcode recognition results.
    /// </summary>
    private void ShowRecognitionResults(Vintasoft.Barcode.IBarcodeInfo[] barcodes)
    {
        StringBuilder result = new StringBuilder();

        foreach (Vintasoft.Barcode.IBarcodeInfo barcode in barcodes)
            result.AppendLine(string.Format("{0}: {1}", barcode.BarcodeType, barcode.Value));

        // show barcode recognition in text box
        textBox1.Text = result.ToString();
    }

    delegate void ShowRecognitionResultsDelegate(Vintasoft.Barcode.IBarcodeInfo[] barcodeInfo);
}


/// <summary>
/// Allows to capture images from DirectShow camera (VintaSoft Imaging .NET SDK) and recognize barcodes in captured images (VintaSoft Barcode .NET SDK).
/// </summary>
public class ImagingCameraBarcodeScanner : IDisposable
{

    #region Fields

    /// <summary>
    /// Monitor for capture devices.
    /// </summary>
    Vintasoft.Imaging.Media.ImageCaptureDevicesMonitor _captureDevicesMonitor;

    /// <summary>
    /// Image capture source for barcode recognition.
    /// </summary>
    Vintasoft.Imaging.Media.ImageCaptureSource _imageCaptureSource;

    #endregion



    #region Constructors

    /// <summary>
    /// Initializes a new instance of the <see cref="ImagingCameraBarcodeScanner"/> class.
    /// </summary>
    public ImagingCameraBarcodeScanner()
    {
        _barcodeScanner = new Vintasoft.Barcode.CameraBarcodeScanner();
        _barcodeScanner.FrameScanException += BarcodeScanner_FrameScanException;
        _barcodeScanner.ScannerSettings.ScanBarcodeTypes = Vintasoft.Barcode.BarcodeType.ISBN;

        _captureDevicesMonitor = new Vintasoft.Imaging.Media.ImageCaptureDevicesMonitor();
        _captureDevicesMonitor.CaptureDevicesChanged += CaptureDevicesMonitor_CaptureDevicesChanged;

        if (!Vintasoft.Imaging.ImagingEnvironment.IsInDesignMode)
            _captureDevicesMonitor.Start();

        _imageCaptureSource = new Vintasoft.Imaging.Media.ImageCaptureSource();
        _imageCaptureSource.CaptureCompleted += ImageCaptureSource_CaptureCompleted;

    }

    #endregion



    #region Properties

    Vintasoft.Imaging.Media.ImageCaptureDevice _captureDevice;
    /// <summary>
    /// Gets or sets current capture device.
    /// </summary>
    public Vintasoft.Imaging.Media.ImageCaptureDevice CaptureDevice
    {
        get
        {
            return _captureDevice;
        }
        set
        {
            if (_captureDevice != value)
            {
                _captureDevice = value;

                UpdateCapureFormats();
            }
        }
    }

    ReadOnlyCollection<Vintasoft.Imaging.Media.ImageCaptureFormat> _captureFormats = null;
    /// <summary>
    /// Gets the available capture formats of current capture device.
    /// </summary>
    /// <seealso cref="CaptureDevice"/>
    public ReadOnlyCollection<Vintasoft.Imaging.Media.ImageCaptureFormat> CaptureFormats
    {
        get
        {
            return _captureFormats;
        }
    }

    /// <summary>
    /// Gets available capture devices.
    /// </summary>
    public ReadOnlyCollection<Vintasoft.Imaging.Media.ImageCaptureDevice> CaptureDevices
    {
        get
        {
            return Vintasoft.Imaging.Media.ImageCaptureDeviceConfiguration.GetCaptureDevices();
        }
    }

    Vintasoft.Barcode.CameraBarcodeScanner _barcodeScanner;
    /// <summary>
    /// Gets the barcode scanner.
    /// </summary>
    public Vintasoft.Barcode.CameraBarcodeScanner BarcodeScanner
    {
        get
        {
            return _barcodeScanner;
        }
    }

    /// <summary>
    /// Gets a value indicating whether barcode scanning is started.
    /// </summary>
    public bool IsStarted
    {
        get
        {
            return _imageCaptureSource.State == Vintasoft.Imaging.Media.ImageCaptureState.Started;
        }
    }

    #endregion



    #region Methods

    #region PUBLIC

    /// <summary>
    /// Starts the capturing of images from seleced device and recognition of barcodes in captured images.
    /// </summary>
    public void StartScanning()
    {
        try
        {
            if (CaptureDevice == null)
                throw new ArgumentNullException("CaptureDevice");

            if (CaptureFormats == null || CaptureFormats.Count == 0)
                throw new ArgumentNullException("CaptureFormats");

            if (_imageCaptureSource.State != Vintasoft.Imaging.Media.ImageCaptureState.Started)
            {
                if (CaptureDevice.DesiredFormat == null)
                    CaptureDevice.DesiredFormat = CaptureFormats[0];

                _barcodeScanner.StartScanning();

                _imageCaptureSource.CaptureDevice = _captureDevice;
                _imageCaptureSource.Start();
                _imageCaptureSource.CaptureAsync();

                OnScanningStart(EventArgs.Empty);
            }
        }
        catch (Exception ex)
        {
            OnScanningException(new Vintasoft.Imaging.ExceptionEventArgs(ex));
        }
    }

    /// <summary>
    /// Stops the capturing of images from seleced device and recognition of barcodes in captured images.
    /// </summary>
    public void StopScanning()
    {
        try
        {
            if (_imageCaptureSource.State != Vintasoft.Imaging.Media.ImageCaptureState.Stopped)
            {
                _barcodeScanner.StopScanning();
                _imageCaptureSource.Stop();

                OnScanningStop(EventArgs.Empty);
            }
        }
        catch (Exception ex)
        {
            OnScanningException(new Vintasoft.Imaging.ExceptionEventArgs(ex));
        }
    }

    /// <summary>
    /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
    /// </summary>
    public void Dispose()
    {
        _captureDevicesMonitor.CaptureDevicesChanged -= CaptureDevicesMonitor_CaptureDevicesChanged;
        _barcodeScanner.BarcodeReader.Dispose();
    }

    #endregion


    #region PROTECTED

    /// <summary>
    /// Raises the <see cref="CaptureDevicesChanged" /> event.
    /// </summary>
    /// <param name="args">The <see cref="ImageCaptureDevicesChangedEventArgs"/> instance containing the event data.</param>
    protected virtual void OnCaptureDevicesChanged(Vintasoft.Imaging.Media.ImageCaptureDevicesChangedEventArgs args)
    {
        if (CaptureDevicesChanged != null)
            CaptureDevicesChanged(this, args);
    }

    /// <summary>
    /// Raises the <see cref="ScanningException" /> event.
    /// </summary>
    /// <param name="args">The <see cref="ExceptionEventArgs"/> instance containing the event data.</param>
    protected virtual void OnScanningException(Vintasoft.Imaging.ExceptionEventArgs args)
    {
        if (ScanningException != null)
            ScanningException(this, args);
    }

    /// <summary>
    /// Raises the <see cref="ScanningStart" /> event.
    /// </summary>
    /// <param name="args">The <see cref="EventArgs"/> instance containing the event data.</param>
    protected virtual void OnScanningStart(EventArgs args)
    {
        if (ScanningStart != null)
            ScanningStart(this, args);
    }

    /// <summary>
    /// Raises the <see cref="ScanningStop" /> event.
    /// </summary>
    /// <param name="args">The <see cref="EventArgs"/> instance containing the event data.</param>
    protected virtual void OnScanningStop(EventArgs args)
    {
        if (ScanningStop != null)
            ScanningStop(this, args);
    }

    #endregion


    #region PRIVATE

    /// <summary>
    /// Handles the FrameScanException event of the BarcodeScanner control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="Vintasoft.Barcode.FrameScanExceptionEventArgs"/> instance containing the event data.</param>
    private void BarcodeScanner_FrameScanException(object sender, Vintasoft.Barcode.FrameScanExceptionEventArgs e)
    {
        OnScanningException(new Vintasoft.Imaging.ExceptionEventArgs(e.Exception));
    }

    /// <summary>
    /// Handles the CaptureCompleted event of the ImageCaptureSource.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="ImageCaptureCompletedEventArgs"/> instance containing the event data.</param>
    private void ImageCaptureSource_CaptureCompleted(object sender, Vintasoft.Imaging.Media.ImageCaptureCompletedEventArgs e)
    {
        try
        {
            // get captured image
            Vintasoft.Imaging.VintasoftImage image = e.GetCapturedImage();

            // recognize barcodes from captured image
            using (Vintasoft.Imaging.VintasoftBitmap bitmap = image.GetAsVintasoftBitmap())
                _barcodeScanner.ScanFrame(bitmap);

            // if image capturing is started
            if (_imageCaptureSource.State == Vintasoft.Imaging.Media.ImageCaptureState.Started)
            {
                // capture next image
                _imageCaptureSource.CaptureAsync();
            }
        }
        catch (Exception ex)
        {
            OnScanningException(new Vintasoft.Imaging.ExceptionEventArgs(ex));
        }
    }

    /// <summary>
    /// Handles the CaptureDevicesChanged event of the CaptureDevicesMonitor.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="ImageCaptureDevicesChangedEventArgs"/> instance containing the event data.</param>
    private void CaptureDevicesMonitor_CaptureDevicesChanged(object sender, Vintasoft.Imaging.Media.ImageCaptureDevicesChangedEventArgs e)
    {
        if (Array.IndexOf(e.RemovedDevices, CaptureDevice) >= 0)
        {
            StopScanning();
        }

        OnCaptureDevicesChanged(e);
    }

    /// <summary>
    /// Updates the capture formats.
    /// </summary>
    private void UpdateCapureFormats()
    {
        Vintasoft.Imaging.Media.ImageCaptureDevice device = CaptureDevice;
        if (device == null || device.SupportedFormats == null)
        {
            _captureFormats = null;
        }
        else
        {
            List<Vintasoft.Imaging.Media.ImageCaptureFormat> captureFormats = new List<Vintasoft.Imaging.Media.ImageCaptureFormat>();

            List<uint> imageCaptureFormatSizes = new List<uint>();
            for (int i = 0; i < device.SupportedFormats.Count; i++)
            {
                // if format has bit depth less or equal than 12 bit
                if (device.SupportedFormats[i].BitsPerPixel <= 12)
                {
                    // ignore formats with bit depth less or equal than 12 bit because they may cause issues on Windows 8
                    continue;
                }

                uint imageCaptureFormatSize = (uint)(device.SupportedFormats[i].Width | (device.SupportedFormats[i].Height << 16));
                if (!imageCaptureFormatSizes.Contains(imageCaptureFormatSize))
                {
                    imageCaptureFormatSizes.Add(imageCaptureFormatSize);

                    captureFormats.Add(device.SupportedFormats[i]);
                }
            }
            _captureFormats = captureFormats.AsReadOnly();
        }
    }

    #endregion

    #endregion



    #region Events

    /// <summary>
    /// Occurs when barcode scanning is started.
    /// </summary>
    public event EventHandler ScanningStart;

    /// <summary>
    /// Occurs when barcode scanning is stopped.
    /// </summary>
    public event EventHandler ScanningStop;

    /// <summary>
    /// Occurs when barcode scanning error occurs.
    /// </summary>
    public event EventHandler<Vintasoft.Imaging.ExceptionEventArgs> ScanningException;

    /// <summary>
    /// Occurs when <see cref="CaptureDevices"/> property is changed.
    /// </summary>
    public event EventHandler<Vintasoft.Imaging.Media.ImageCaptureDevicesChangedEventArgs> CaptureDevicesChanged;

    #endregion

}