I’m getting good results detecting crops in a field, but the detection boxes are coalescing when the plants are closer together:
I vaguely remember seeing something somewhere in some code that could possibly stop this happening … but where / how? It might even have been when using YOLO3.
I need to have small, tight boxes around each plant, not boxes that seem to join together to form bigger boxes. The terminal output on the right shows the box sizes.
How do I correct this when using detectNet?
Do i need to edit the prototext when training to change stride or clustering or something?
Her is the ROI merge code:
You can turn-off or add some mechanism to meet your requirement.
I got it cured with this:
inline static bool rectOverlap(const float6& r1, const float6& r2)
// The rectangles do not overlap at all
if ( r2.x > r1.z || r2.z < r1.x ||
r2.y > r1.w ||
r2.w < r1.y ) return false;
float overlap_x = std::min(r2.z,r1.z) - std::max(r2.x,r1.x);
float overlap_y = std::min(r2.w,r1.w) - std::max(r2.y,r1.y);
float area_overlap = overlap_x * overlap_y;
float area_r1 = (r1.z-r1.x) * (r1.w-r1.y);
float area_r2 = (r2.z-r2.x) * (r2.w-r2.y);
// The rectangles overlap by less than 75% of either's area
if ((area_overlap < 0.25*area_r1) && (area_overlap < 0.25*area_r2)) return false;
// The rectangels overlap
You can update the function for the merged effect you preferred.
Any update? Still need suggestions?