如何在 C# 中检测图像中的对象?
How to detect objects in an image in c#?
我正在构建一个 C# 项目来检测图像中的所有对象,我不希望它检测这些对象是什么,我只希望它检测图像中对象的位置。
我已经尝试了很多方法来做到这一点,比如 this (using imageai python library then I used this script in c#) and this(使用 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();
}
}
有人可以帮忙或推荐其他方法吗?
Here 是一个类似的问题,其中的一些答案可能对您有所帮助。以下是我找到的几个选项:
一些方法:
* ColorFiltering
* ChannelFiltering
* HSLFiltering
* YCbCrFiltering
* EuclideanColorFiltering
我正在构建一个 C# 项目来检测图像中的所有对象,我不希望它检测这些对象是什么,我只希望它检测图像中对象的位置。
我已经尝试了很多方法来做到这一点,比如 this (using imageai python library then I used this script in c#) and this(使用 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();
}
}
有人可以帮忙或推荐其他方法吗?
Here 是一个类似的问题,其中的一些答案可能对您有所帮助。以下是我找到的几个选项:
一些方法:
* ColorFiltering
* ChannelFiltering
* HSLFiltering
* YCbCrFiltering
* EuclideanColorFiltering