mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 03:46:59 +08:00
Fixed a crash caused by detected regions that were beyond the beyond of the image
This commit is contained in:
@@ -116,13 +116,23 @@ namespace alpr {
|
|||||||
PlateRegion PlateReg;
|
PlateRegion PlateReg;
|
||||||
|
|
||||||
PlateReg.rect = PlateRect.boundingRect();
|
PlateReg.rect = PlateRect.boundingRect();
|
||||||
|
|
||||||
|
if (PlateReg.rect.x < 0)
|
||||||
|
PlateReg.rect.x = 0;
|
||||||
|
if (PlateReg.rect.y < 0)
|
||||||
|
PlateReg.rect.y = 0;
|
||||||
|
if (PlateReg.rect.x + PlateReg.rect.width > frame.cols)
|
||||||
|
PlateReg.rect.width = frame.cols - PlateReg.rect.x;
|
||||||
|
if (PlateReg.rect.y + PlateReg.rect.height > frame.rows)
|
||||||
|
PlateReg.rect.height = frame.rows - PlateReg.rect.y;
|
||||||
|
|
||||||
|
|
||||||
detectedRegions.push_back(PlateReg);
|
detectedRegions.push_back(PlateReg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return detectedRegions;
|
return detectedRegions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user