Scanning Books Using C# Barcode Scanner

Blog category: Barcode.NET

June 09, 2025

Scanning books with barcode scanners is becoming an integral part of the automation of libraries, bookstores, archives and educational institutions. This approach speeds up the processing of large collections, minimizes accounting errors, and also provides new forms of interaction with the book and the reader.

Principles of operation of a software barcode scanner in the context of books

A software scanner is a specialized software solution that automatically recognizes and decodes barcodes applied to books using cameras, scanners or mobile devices. Its implementation allows to organize the fast and accurate electronic accounting, fund management and transaction processing without the need for manual data entry.

The operation of a software scanner is based on the principle: a device (for example, a camera or scanner) reads an image of a barcode from the cover or page of a book, and the software decrypts the information encoded in it (for example, ISBN) and transfers this data to a library or trade system for further processing.

Barcodes on books

Most books published in recent decades have a barcode — usually an ISBN (International Standard Book Number) in EAN-13 format or a QR code (on new generation publications). It contains a unique identifier for the book, often with additional information about the issue.

Using cameras and scanners

A software barcode scanner is an application or library that can recognize barcodes using both special equipment (scanners, terminals) and webcams or mobile devices, making the process as mobile and accessible as possible.

Recognition and data processing

Image processing algorithms find the barcode on the book, decode the information it contains and integrate it with catalogs, databases and library systems, ensuring fast and accurate accounting.

Stages of book scanning

Scanning books using a software barcode scanner includes several consecutive stages, each of which is critical for the accuracy and efficiency of the processes of accounting, issuing and returning books. A properly organized work cycle can significantly reduce inventory time, improve data quality and optimize service in libraries and bookstores.

Preparing equipment and software

Before starting scanning, you must make sure that the device you are using supports the selected software and barcode standards. Then:

Scanning and recognizing the barcode

At this stage, the actual reading of the barcode from the book is carried out:
The book is positioned so that the barcode is clearly visible to the camera or scanner.

Integration with a library or trade system

After successful recognition, the software scanner automatically transfers the received data to the information system:

Storage, analytics and subsequent work with data

Once the information is in the database, open up opportunities for automating accounting and analytical processes:

Technological features and advantages of a modern software scanner

A modern software barcode scanner features the following technological solutions:

A modern barcode scanner software is a critical tool for any library or bookstore seeking automation, transparency of accounting and increased speed of service. Thanks to such software, the processing of paper collections moves to a modern digital level with minimal costs and maximum returns.

Selecting a software solution

When choosing a software barcode scanner for working with books, it is recommended to consider:

Universal solutions should be easy to integrate into the IT infrastructure and support work on various devices: from desktop PCs to mobile phones. It is advisable to choose products with a simple interface, the ability to update and technical support.

Development Prospects

Book scanning technologies using software barcode scanners continue to develop rapidly. In the near future, 2D barcodes (such as DataMatrix and QR) are expected to be more widely implemented, as they can contain more information — links to electronic versions of books, annotations, secure identifiers.

The integration of scanners with cloud services and digital libraries is growing, which will allow for automated access to online resources and expanded services for users. In the future, the introduction of intelligent functions is also expected: automatic analysis of the state of the book, generation of recommendations, as well as the development of end-to-end analytics and monitoring of the movement of library funds.

Conclusion

Choosing a barcode scanning software solution requires careful consideration of many factors, including supported formats, speed, integration capabilities, and ease of use. Prospects for technology development open up new horizons for automation, increasing the efficiency of library systems and improving service for users.

VintaSoft, the developer of VintaSoft Barcode .NET SDK, can significantly simplify the creation of a library barcode system. This powerful tool supports a wide range of formatted barcodes, provides high scanning speed and accuracy, and easily integrates with existing library systems. With VintaSoft Barcode .NET SDK, libraries will be able to quickly and efficiently automate all processes related to accounting and servicing books, improving the quality of service and providing significant resource savings.


Here is a C# code that demonstrates how to recognize an ISBN barcode in an image captured from a camera:
/// <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();
            }
        }
    }
}



Here is C# code that demonstrates how to capture images from a DirectShow camera (VintaSoft Imaging .NET SDK) and recognize ISBN barcodes in the captured images (VintaSoft Barcode .NET SDK) in a WinForms application:
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

}