繁体   English   中英

如何在C#中检测图像中的对象?

[英]How to detect objects in an image in c#?

我正在建立一个C#项目来检测图像中的所有对象,我不希望它检测到这些对象是什么,我只是希望它检测对象在图像中的位置。

我已经尝试了许多方法来做到这一点 (使用imageai python库,然后在c#中使用此脚本)和 (使用Alturos.Yolo库)教程,但是这些教程仅检测已知对象,而未检测到对象的位置。对象,如果不知道这个对象是什么。

我需要的是检测对象的位置,无论它是否识别该对象。

例如在这张图片中

图片

它仅检测可识别其类型的对象,但我希望它检测图像中的所有对象。

python代码:

detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath( os.path.join(execution_path , "resnet50_coco_best_v2.0.1.h5"))
detector.loadModel()
detections = 
detector.detectObjectsFromImage(input_image=os.path.join(execution_path , rel_path ,file_name), output_image_path=os.path.join(execution_path ,new_file_name))
for eachObject in detections:
    print(eachObject["name"] , " : " , eachObject["percentage_probability"] ," : "  ,eachObject["box_points"]  )

使用Alturos.Yolo库代码:

var configurationDetector = new ConfigurationDetector();
var config = configurationDetector.Detect();

using (var yoloWrapper = new YoloWrapper(config))
{
    using (MemoryStream ms = new MemoryStream())
    {
        pictureBox1.Image.Save(ms, ImageFormat.Png);
        var items = yoloWrapper.Detect(ms.ToArray());
        yoloItemBindingSource.DataSource = items;
        arr = items.ToArray();
    }
}

任何人都可以帮忙或推荐其他方式吗?

是一个类似的问题,其中的一些答案可能会对您有所帮助。 这是我找到的一些选项:

AForge.Net

一些方法:

* ColorFiltering
* ChannelFiltering
* HSLFiltering
* YCbCrFiltering
* EuclideanColorFiltering

OpenCV的

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM