简体   繁体   中英

How to detect objects in an image in c#?

I am building a C# project to detect all objects in the image , I don't want it to detect what is these objects , I just want it to detect the position of the objects in the image .

I have tried many ways to do it like this (using imageai python library then I used this script in c#) and this (using Alturos.Yolo library) tutorials, but these tutorials detect the known objects only but did not detect the position of an object if it do not know what is this object .

What I need is to detect the position of the object whether it recognize what is this object or not .

For example in this image

图片

it detects the only the objects it recognize their type but I want it to detect all the objects in the image.

python code :

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"]  )

using Alturos.Yolo library code :

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();
    }
}

can anyone help or recommend another way please ?

Here is a similar question with some answers that may help you. Here are a few options I have found:

AForge.Net

Some Methods:

* ColorFiltering
* ChannelFiltering
* HSLFiltering
* YCbCrFiltering
* EuclideanColorFiltering

OpenCV

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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