Load a table containing images and ground truth bounding box labels. The first column contains the images, and the remaining columns contain the labeled bounding boxes.
Set the value of the dataDir variable as the location where the vehicleTrainingData.mat file is located. Load the test data into a local vehicle data folder.
Create an imageDatastore using the files from the table.
Create a boxLabelDatastore using the label columns from the table.
Load a pretrained YOLO v2 object detector trained to detect vehicles into the workspace.
Compute Object Detection Performance Metrics
Run the detector on the test images. Set the detection threshold to a low value to detect as many objects as possible. This helps you evaluate the detector precision across the full range of recall values.
Compute metrics for evaluating the performance of an object detector using the evaluateObjectDetection function.
Evaluate Metrics Across Object Size Ranges
Extract the anchor boxes from the detector, calculate their areas, and sort the areas.
Define area range limits using the calculated areas. The upper limit for the last range is set to three times the size of the largest area, which is sufficient for the objects in this data set.
areaRanges = 4×2
64 960
960 1536
1536 3456
3456 10368
Evaluate detector performance across vehicle size ranges using the metricsByArea object function. Specify the object size ranges using the bounding box area ranges. The number of vehicles falling into each area range is computed in the NumObjects column.
AreaRange NumObjects APOverlapAvg
_____________ __________ ____________
64 960 119 0.9887
960 1536 12 0.99359
1536 3456 45 0.99952
3456 10368 141 0.98551
Plot the average precision (AP) metric, averaged across all overlap thresholds, as a function of the mean object size per vehicle size range.