June 2018
Intermediate to advanced
436 pages
10h 33m
English
As YOLO predicts more than one bounding box per object, non-max suppression is implemented; it merges all detections that belong to the same object. Therefore, instead of using bx, by, bh, and bw, we can use the top-left and bottom-right points. gridWidth and gridHeight are the number of small boxes we split our image into. In our case, this is 13 x 13, where w and h are the original image frame dimensions:
void markObjectWithBoundingBox(Mat file, int gridWidth, int gridHeight, int w, int h, DetectedObject obj) {
double[] xy1 = obj.getTopLeftXY();
double[] xy2 = obj.getBottomRightXY();
int predictedClass = obj.getPredictedClass(); int x1 = (int) Math.round(w * xy1[0] / gridWidth); ...