DieCenterLib 1.0.0
dotnet add package DieCenterLib --version 1.0.0
NuGet\Install-Package DieCenterLib -Version 1.0.0
<PackageReference Include="DieCenterLib" Version="1.0.0" />
<PackageVersion Include="DieCenterLib" Version="1.0.0" />
<PackageReference Include="DieCenterLib" />
paket add DieCenterLib --version 1.0.0
#r "nuget: DieCenterLib, 1.0.0"
#:package DieCenterLib@1.0.0
#addin nuget:?package=DieCenterLib&version=1.0.0
#tool nuget:?package=DieCenterLib&version=1.0.0
DieCenterLib
A lightweight, high-precision die center detection library designed for personal or internal use.
⚠️ Note: This library is tailored for specific die images that contain an inner seal ring.
It is not intended as a universal die/wafer detection framework.
Table of Contents
- Features
- Supported Scenarios
- How It Works
- Pipeline Overview
- Installation
- Basic Usage
- API Summary
- Troubleshooting
- Recommended Image Conditions
- License
- Acknowledgements
Features
- Automatic or manual ROI selection
- Gradient-based edge extraction (Scharr filter)
- Canny edge detection with adaptive behavior
- Outlier rejection using k-sigma filtering
- Linear regression for the four die edges
- Intersection-based corner finding
- Subpixel die center estimation
- Residual statistics: RMSE, Std, MaxAbs, R²
- Optional ROI intensity export to CSV
Supported Scenarios
This library works best when:
✔ The die has a clear rectangular boundary
✔ There is a seal ring (inward dark/bright border)
✔ Lighting is relatively even
✔ Edges are not heavily occluded
✔ Input resolution ≥ 800 × 800 px
How It Works
DieCenterLib extracts die boundaries by analyzing gradient magnitudes within predefined band regions near each side of the ROI:
ROI Selection
- Auto ROI using contour detection
- Or manual ROI defined by user
Gray Conversion + Scharr Gradient
High-accuracy gradient operator for clean edge responses.Band Extraction (70–80% coverage)
Each edge is analyzed only in its dedicated band
→ avoids mixing with corners or noise.Canny Edge Detection
Detects candidate edge points.Line Fitting (with Outlier Removal)
Using OpenCV’s robust fit + k-sigma rejection.Corner Finding
Intersection of opposite edges.Center Calculation
Intersection of diagonals formed by TL–BR and TR–BL.
Pipeline Overview
+-------------------+
| Input Bitmap |
+---------+---------+
|
v
+-------------------+
| ROI Selection |
| Auto / Manual |
+---------+---------+
|
v
+-------------------+
| Gray + Scharr |
| Gradient (Gx, Gy) |
+---------+---------+
|
v
+-------------------+
| Region Separation |
| (Top/Bottom/...) |
+---------+---------+
|
v
+-------------------+
| Canny Edges |
+---------+---------+
|
v
+-------------------+
| Extract Points |
| (per side) |
+---------+---------+
|
v
+-------------------+
| Line Fitting |
| + Residual Stats |
+---------+---------+
|
v
+-------------------+
| Corner Detection |
+---------+---------+
|
v
+-------------------+
| Center Position |
+-------------------+
Installation
Install-Package DieCenterLib
Dependencies / Prerequisites
DieCenterLib does not include OpenCvSharp4 binaries.
Before using this library, please install the following NuGet packages into your project:
OpenCvSharp4(tested with 4.11.0.20250507)OpenCvSharp4.runtime.win(same version as OpenCvSharp4)OpenCvSharp4.Extensions(same version as OpenCvSharp4)
Example (Package Manager Console):
Install-Package OpenCvSharp4 -Version 4.11.0.20250507
Install-Package OpenCvSharp4.runtime.win -Version 4.11.0.20250507
Install-Package OpenCvSharp4.Extensions -Version 4.11.0.20250507
Basic Usage
using DieCenterLib;
var parameters = new DieCenterParameters
{
UseAutoRoi = true,
RoiWidth = 480,
RoiHeight = 480,
Coverage = 0.8f,
BandWidth = 50,
MinGrad = 5.0f,
KSigma = 2.0,
};
var result = DieCenterDetector.Run(bitmap, parameters);
// Die center in original image coordinates
var center = result.CenterInImage;
Console.WriteLine($"Center X={center.X}, Y={center.Y}");
Console.WriteLine(result.SummaryText);
API Summary
DieCenterParameters
| Property | Description |
|---|---|
| UseAutoRoi | Auto ROI by contour detection |
| ManualRoi / RoiOnImage | Manual ROI mode |
| RoiWidth / RoiHeight | Cropping size |
| Coverage | % of ROI width/height used |
| BandWidth | Edge band thickness |
| MinGrad | Minimum gradient magnitude |
| KSigma | Outlier rejection (k-sigma) |
| CannyLow / CannyHigh | Canny thresholds |
| ExportIntensityCsv | Export grayscale CSV |
| IntensityCsvPath | Output CSV path |
Troubleshooting
Problem: Edges missing
- Increase
BandWidth - Increase
MinGrad - Ensure ROI is correct
Problem: Weak contrast
- Apply CLAHE
- Increase exposure
- Increase Canny thresholds
Problem: Bad line fitting
- Increase
KSigma - Check extracted points
Problem: Auto ROI incorrect
- Switch to
ManualRoi
Recommended Image Conditions
✔ Stable illumination
✔ Visible seal ring
✔ Moderate contrast
✔ No large scratches
✔ 800×800 px or higher resolution
License
- MIT License © 2025 Napat Sutikant
- Uses OpenCvSharp (Apache 2.0).
Acknowledgements
- OpenCvSharp4 by shimat
- OpenCV Community
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.6.2
- OpenCvSharp4 (= 4.11.0.20250507)
- OpenCvSharp4.Extensions (= 4.11.0.20250507)
- OpenCvSharp4.runtime.win (= 4.11.0.20250507)
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 |
|---|---|---|
| 1.0.0 | 246 | 11/26/2025 |
Initial public release.