OlafenwaMoses / ImageAI

A python library built to empower developers to build applications and systems with self-contained Computer Vision capabilities
https://www.genxr.co/#products
MIT License
8.5k stars 2.18k forks source link

How to detect only one object? #134

Closed pytesnim closed 5 years ago

pytesnim commented 5 years ago

Hello, When I use video detection code, it detects all the objects in the scene. ıs it possible to select specific object from the scene? Thanks very much!

mr1985 commented 5 years ago

You can use custom objects detection :

custom_objects = detector.CustomObjects(person=True, bicycle=True, motorcycle=True)

video_path = detector.detectCustomObjectsFromVideo(custom_objects=custom_objects, input_file_path=os.path.join(execution_path, "traffic.mp4"),
                                output_file_path=os.path.join(execution_path, "traffic_custom_detected")
                                , frames_per_second=20, log_progress=True)

More info here : https://github.com/OlafenwaMoses/ImageAI/blob/master/imageai/Detection/VIDEO.md#custom-video-object-detection

pytesnim commented 5 years ago

What if it detects 2 birds?

pytesnim commented 5 years ago

And I want to detect a specific bird?

mr1985 commented 5 years ago

I just started to use imageAI this week, so I just have a basic understanding.

If you want to detect a specific species of bird, I think you will have to train your own model.

Alternative : As the forFrame method will return the frame number and the bounding box of each detected object, you will be able to draw a box around a specific object on a specific frame.

[{'name': 'bird', 'percentage_probability': 44.57316696643829, 'box_points': (55, 585, 626, 808)} ...]
pytesnim commented 5 years ago

Custom trained model can not be used in detecting objects in videos yet, as fas as I understood.