DocumentScannerSDK 2.0.2

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package DocumentScannerSDK --version 2.0.2                
NuGet\Install-Package DocumentScannerSDK -Version 2.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DocumentScannerSDK" Version="2.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DocumentScannerSDK --version 2.0.2                
#r "nuget: DocumentScannerSDK, 2.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DocumentScannerSDK as a Cake Addin
#addin nuget:?package=DocumentScannerSDK&version=2.0.2

// Install DocumentScannerSDK as a Cake Tool
#tool nuget:?package=DocumentScannerSDK&version=2.0.2                

.NET Document Scanner SDK

The .NET Document Scanner SDK is a C# wrapper for Dynamsoft Document Normalizer SDK. It is used to do document edge detection, image cropping, perspective correction and image enhancement.

License Activation

Click here to get a 30-day trial license key.

Supported Platforms

  • Windows (x64)
  • Linux (x64)
  • Android
  • iOS

API

  • public static void InitLicense(string license): Initialize the license key. It must be called before creating the document scanner object.
  • public static DocumentScanner Create(): Create the document scanner object.
  • public Result[]? DetectFile(string filename): Detect documents from an image file.
  • public Result[]? DetectBuffer(byte[] buffer, int width, int height, int stride, ImagePixelFormat format): Detect documents from a buffer.
  • public NormalizedImage NormalizeFile(string filename, int[] points): Normalize the detected documents from an image file.
  • public NormalizedImage NormalizeBuffer(byte[] buffer, int width, int height, int stride, ImagePixelFormat format, int[] points): Normalize the detected documents from a buffer.
  • public static string? GetVersionInfo(): Get SDK version number.
  • public void SetParameters(string parameters): Customize the parameters. Refer to Parameter Organization for more details.

Usage

  • Set the license key:

    DocumentScanner.InitLicense("LICENSE-KEY"); 
    
  • Initialize the document scanner object:

    DocumentScanner scanner = DocumentScanner.Create();
    
  • Detect documents from an image file:

    Result[]? resultArray = scanner.DetectFile(filename);
    
  • Detect documents from a buffer:

    Result[]? resultArray = scanner.DetectBuffer(bytes, width, height, stride, DocumentScanner.ImagePixelFormat.IPF_RGB_888);
    
  • Normalize the detected documents from an image file:

    if (resultArray != null)
    {
        foreach (Result result in resultArray)
        {
            if (result.Points != null)
            {
                NormalizedImage image = scanner.NormalizeFile(filename, result.Points);
                if (image != null)
                {
                    image.Save(DateTime.Now.ToFileTimeUtc() + ".png");
                }
            }
    
        }
    }
    
  • Normalize the detected documents from a buffer:

    if (resultArray != null)
    {
        foreach (DocumentScanner.Result result in resultArray)
        {
            if (result.Points != null)
            {
                int length = mat.Cols * mat.Rows * mat.ElemSize();
                byte[] bytes = new byte[length];
                Marshal.Copy(mat.Data, bytes, 0, length);
    
                DocumentScanner.NormalizedImage image = scanner.NormalizeBuffer(bytes, mat.Cols, mat.Rows, (int)mat.Step(), DocumentScanner.ImagePixelFormat.IPF_RGB_888, result.Points);
                if (image != null && image.Data != null)
                {
                    image.Save(DateTime.Now.ToFileTimeUtc() + ".png");
                }
            }
    
        }
    }
    
  • Get SDK version number:

    string? version = DocumentScanner.GetVersionInfo();
    
  • Customize the parameters:

    // Refer to https://www.dynamsoft.com/document-normalizer/docs/parameters/parameter-organization-structure.html?ver=latest
    scanner.SetParameters(DocumentScanner.Templates.color);
    

Quick Start

using System;
using System.Runtime.InteropServices;
using Dynamsoft;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            DocumentScanner.InitLicense("LICENSE-KEY"); // Get a license key from https://www.dynamsoft.com/customer/license/trialLicense?product=ddn
            DocumentScanner? scanner = null;
            try {
                scanner = DocumentScanner.Create();
                scanner.SetParameters(DocumentScanner.Templates.color);
                Console.WriteLine("Please enter an image file: ");
                string? filename = Console.ReadLine();
                if (filename != null) {
                    Result[]? resultArray = scanner.DetectFile(filename);
                    if (resultArray != null)
                    {
                        foreach (DocumentScanner.Result result in resultArray)
                        {
                            Console.WriteLine("Confidence: " + result.Confidence);
                            if (result.Points != null)
                            {
                                foreach (int point in result.Points)
                                {
                                    Console.WriteLine("Point: " + point);
                                }

                                DocumentScanner.NormalizedImage image = scanner.NormalizeFile("1.png", result.Points);
                                if (image != null)
                                {
                                    image.Save(DateTime.Now.ToFileTimeUtc() + ".png");
                                }
                            }

                        }
                    }
                    else {
                        Console.WriteLine("No document detected.");
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
    }
}

Example

Building NuGet Package from Source Code

# build dll for desktop
cd desktop
dotnet build --configuration Release

# build dll for android
cd android
dotnet build --configuration Release

# build dll for iOS
cd ios
dotnet build --configuration Release

# build nuget package
nuget pack .\DocumentScannerSDK.nuspec
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-android33.0 is compatible.  net7.0-ios was computed.  net7.0-ios16.1 is compatible.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated

Update native libraries for Windows and Windows