{"id":15998206,"url":"https://github.com/yushulx/dotnet-document-scanner-sdk","last_synced_at":"2025-10-21T05:30:54.215Z","repository":{"id":65348911,"uuid":"538315274","full_name":"yushulx/dotnet-document-scanner-sdk","owner":"yushulx","description":".NET Document Detection and Rectification SDK built with Dynamsoft Document Normalizer","archived":true,"fork":false,"pushed_at":"2024-09-24T06:28:38.000Z","size":55147,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-24T10:35:38.687Z","etag":null,"topics":["csharp","document-detection","document-rectification","dotnet","maui"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/DocumentScannerSDK","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yushulx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-19T03:11:57.000Z","updated_at":"2024-10-15T06:35:53.000Z","dependencies_parsed_at":"2024-05-21T11:10:42.169Z","dependency_job_id":null,"html_url":"https://github.com/yushulx/dotnet-document-scanner-sdk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yushulx%2Fdotnet-document-scanner-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yushulx%2Fdotnet-document-scanner-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yushulx%2Fdotnet-document-scanner-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yushulx%2Fdotnet-document-scanner-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yushulx","download_url":"https://codeload.github.com/yushulx/dotnet-document-scanner-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237436595,"owners_count":19309944,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","document-detection","document-rectification","dotnet","maui"],"created_at":"2024-10-08T08:08:01.878Z","updated_at":"2025-10-21T05:30:44.194Z","avatar_url":"https://github.com/yushulx.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# .NET Document Scanner SDK\n\nThe .NET Document Scanner SDK is a C# wrapper for [Dynamsoft Document Normalizer SDK](https://www.dynamsoft.com/document-normalizer/docs/core/introduction/). It is used to do document edge detection, image cropping, perspective correction and image enhancement.\n\n\n## License Activation\nClick [here](https://www.dynamsoft.com/customer/license/trialLicense/?product=dcv\u0026package=cross-platform) to get a 30-day trial license key.\n\n## Supported Platforms\n- Windows (x64)\n- Linux (x64)\n- Android\n- iOS\n\n## API\n- `public static void InitLicense(string license)`: Initialize the license key. It must be called before creating the document scanner object.\n- `public static DocumentScanner Create()`: Create the document scanner object.\n- `public Result[]? DetectFile(string filename)`: Detect documents from an image file.\n- `public Result[]? DetectBuffer(byte[] buffer, int width, int height, int stride, ImagePixelFormat format)`: Detect documents from a buffer.\n- `public NormalizedImage NormalizeFile(string filename, int[] points)`: Normalize the detected documents from an image file.\n- `public NormalizedImage NormalizeBuffer(byte[] buffer, int width, int height, int stride, ImagePixelFormat format, int[] points)`: Normalize the detected documents from a buffer.\n- `public static string? GetVersionInfo()`: Get SDK version number.\n- `public void SetParameters(string parameters)`: Customize the parameters. Refer to [Parameter Organization](https://www.dynamsoft.com/document-normalizer/docs/core/parameters/parameter-organization-structure.html) for more details.\n\n## Usage\n- Set the license key:\n    \n    ```csharp\n    DocumentScanner.InitLicense(\"LICENSE-KEY\"); \n    ```\n- Initialize the document scanner object:\n    \n    ```csharp\n    DocumentScanner scanner = DocumentScanner.Create();\n    ```\n- Detect documents from an image file:\n\n    ```csharp\n    Result[]? resultArray = scanner.DetectFile(filename);\n    ```    \n- Detect documents from a buffer:\n\n    \n    ```csharp\n    Result[]? resultArray = scanner.DetectBuffer(bytes, width, height, stride, DocumentScanner.ImagePixelFormat.IPF_RGB_888);\n    ```     \n    \n- Normalize the detected documents from an image file:\n\n    \n    ```csharp\n    if (resultArray != null)\n    {\n        foreach (Result result in resultArray)\n        {\n            if (result.Points != null)\n            {\n                NormalizedImage image = scanner.NormalizeFile(filename, result.Points);\n                if (image != null)\n                {\n                    image.Save(DateTime.Now.ToFileTimeUtc() + \".png\");\n                }\n            }\n\n        }\n    }\n    ```\n- Normalize the detected documents from a buffer:\n\n    \n    ```csharp\n    if (resultArray != null)\n    {\n        foreach (DocumentScanner.Result result in resultArray)\n        {\n            if (result.Points != null)\n            {\n                int length = mat.Cols * mat.Rows * mat.ElemSize();\n                byte[] bytes = new byte[length];\n                Marshal.Copy(mat.Data, bytes, 0, length);\n\n                DocumentScanner.NormalizedImage image = scanner.NormalizeBuffer(bytes, mat.Cols, mat.Rows, (int)mat.Step(), DocumentScanner.ImagePixelFormat.IPF_RGB_888, result.Points);\n                if (image != null \u0026\u0026 image.Data != null)\n                {\n                    image.Save(DateTime.Now.ToFileTimeUtc() + \".png\");\n                }\n            }\n\n        }\n    }\n    ```\n- Get SDK version number:\n\n    ```csharp\n    string? version = DocumentScanner.GetVersionInfo();\n    ```\n- Customize the parameters:\n    \n    ```csharp\n    // Refer to https://www.dynamsoft.com/document-normalizer/docs/parameters/parameter-organization-structure.html?ver=latest\n    scanner.SetParameters(DocumentScanner.Templates.color);\n    ```\n\n## Quick Start\n\n```csharp\nusing System;\nusing System.Runtime.InteropServices;\nusing Dynamsoft;\n\nnamespace Test\n{\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            DocumentScanner.InitLicense(\"LICENSE-KEY\"); // Get a license key from https://www.dynamsoft.com/customer/license/trialLicense?product=ddn\n            DocumentScanner? scanner = null;\n            try {\n                scanner = DocumentScanner.Create();\n                scanner.SetParameters(DocumentScanner.Templates.color);\n                Console.WriteLine(\"Please enter an image file: \");\n                string? filename = Console.ReadLine();\n                if (filename != null) {\n                    Result[]? resultArray = scanner.DetectFile(filename);\n                    if (resultArray != null)\n                    {\n                        foreach (DocumentScanner.Result result in resultArray)\n                        {\n                            Console.WriteLine(\"Confidence: \" + result.Confidence);\n                            if (result.Points != null)\n                            {\n                                foreach (int point in result.Points)\n                                {\n                                    Console.WriteLine(\"Point: \" + point);\n                                }\n\n                                DocumentScanner.NormalizedImage image = scanner.NormalizeFile(\"1.png\", result.Points);\n                                if (image != null)\n                                {\n                                    image.Save(DateTime.Now.ToFileTimeUtc() + \".png\");\n                                }\n                            }\n\n                        }\n                    }\n                    else {\n                        Console.WriteLine(\"No document detected.\");\n                    }\n                }\n            }\n            catch (Exception e)\n            {\n                Console.WriteLine(e.Message);\n            }\n        }\n    }\n}\n```\n\n\n## Example\n\n- [Command-line Document Scanner](https://github.com/yushulx/dotnet-document-scanner-sdk/tree/main/example/command-line) (**Windows \u0026 Linux**)\n    \n    ```bash\n    dotnet run\n    ```\n\n- [Command-line Document Scanner with OpenCVSharp Windows runtime](https://github.com/yushulx/dotnet-document-scanner-sdk/tree/main/example/command-line-cv). To make it work on Linux, you need to install [OpenCVSharp4.runtime.ubuntu.18.04-x64](https://www.nuget.org/packages/OpenCvSharp4.runtime.ubuntu.18.04-x64) package.\n    \n    ```bash\n    dotnet run\n    ```\n\n\n- [WinForms Desktop Document Scanner](https://github.com/yushulx/dotnet-document-scanner-sdk/tree/main/example/desktop-gui) (**Windows Only**)\n  \n    ```bash\n    dotnet run\n    ```\n    \n    ![.NET WinForms Document Scanner](https://camo.githubusercontent.com/ee30a750052f5392f20aefcaffbb4308cfabafa9cd610642f6b0ff669195f2dc/68747470733a2f2f7777772e64796e616d736f66742e636f6d2f636f6465706f6f6c2f696d672f323032322f30392f646f746e65742d77696e666f726d2d646f63756d656e742d7363616e6e65722e706e67)\n\n- [.NET MAUI](https://github.com/yushulx/dotnet-document-scanner-sdk/tree/main/example/MauiApp)\n\n    ![.NET MAUI Document Scanner](https://camo.githubusercontent.com/91a6cb1ea0a964510154e75100c828c2ccf6eece9acbd01ab92a07686e2caa12/68747470733a2f2f7777772e64796e616d736f66742e636f6d2f636f6465706f6f6c2f696d672f323032342f30332f646f746e65742d6d6175692d696f732d646f63756d656e742d646574656374696f6e2e706e67)\n    \n## Building NuGet Package from Source Code\n\n```bash\n# build dll for desktop\ncd desktop\ndotnet build --configuration Release\n\n# build dll for android\ncd android\ndotnet build --configuration Release\n\n# build dll for iOS\ncd ios\ndotnet build --configuration Release\n\n# build nuget package\nnuget pack .\\DocumentScannerSDK.nuspec\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyushulx%2Fdotnet-document-scanner-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyushulx%2Fdotnet-document-scanner-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyushulx%2Fdotnet-document-scanner-sdk/lists"}