Object detection will take an image and identify and label specific objects within the image. For a complex image with multiple objects in view, object detection will provide a bounding box around each detected object, as well as a label identifying the class to which the object belongs.
obj_detect = edgeiq.ObjectDetection("alwaysai/mobilenet_ssd")
If the model is not an object detection model, the instantiation will fail with
an error message indicating that the model can’t be used. Next, call the
function to initialize the inference engine and accelerator.
results = obj_detect.detect_objects(image, confidence_level=.5)
results object is of type
ObjectDetectionResults and contains
the duration of the inference, in seconds, and a list of predictions. Each
prediction is of type
ObjectDetectionPrediction and contains the
coordinates of a box around the object, the confidence, the label, and the
index of the label in the master label list of the model for
cross-referencing with that list.
It can be useful to visualize the detections. The image can be marked with
the results of the detection using the
new_image = edgeiq.markup_image(image, object_detection_predictions)
markup_image() function takes as its input an
image (the one used for object detection) and a list of
ObjectDetectionPrediction objects and draws the bounding boxes and
labels on the image. Head to the Understanding the Results Objects section
to learn more about how the results objects can be used.