Object Detection toolkit based on PaddlePaddle. It supports object detection, instance segmentation, multiple object tracking and real-time multi-person keypoint detection.
$ dotnet add package Sdcb.PaddleDetection| NuGet Package 💼 | Version 📌 | Description 📚 |
|---|---|---|
| Sdcb.PaddleDetection | PaddleDetection library(based on Sdcb.PaddleInference) ⚙️ |
Get your PaddleDetection models ready, or just download a model from my exported models (which is exported from official PaddlePaddle PicoDet and PPYolo).
Check your models
Note: PaddleDetection inference model must should like following format:
model_dir
-> infer_cfg.yml
-> model.pdiparams
-> model.pdiparams.info
-> model.pdmodel
If your model filename is xxx.pdparams, you must export to inference model, you can refer to this document to export a inference model.
Install NuGet Packages:
Sdcb.PaddleInference
Sdcb.PaddleInference.runtime.win64.mkl
Sdcb.PaddleDetection
OpenCvSharp4
OpenCvSharp4.runtime.win
Using following C# code to get result:
string modelDir = DetectionLocalModel.PicoDets.L_416_coco.Directory; // your model directory here
using (PaddleDetector detector = new PaddleDetector(modelDir, Path.Combine(modelDir, "infer_cfg.yml"), PaddleDevice.Mkldnn()))
using (VideoCapture vc = new VideoCapture())
{
vc.Open(0);
while (true)
{
using (Mat mat = vc.RetrieveMat())
{
DetectionResult[] results = detector.Run(mat);
using (Mat dest = PaddleDetector.Visualize(mat,
results.Where(x => x.Confidence > 0.5f),
detector.Config.LabelList.Length))
{
Cv2.ImShow("test", dest);
}
}
Cv2.WaitKey(1);
}
}
running effect(for image):
