Zone: Actually clip the zone if it larger than the image
Until now only the boundary box was manually adjusted without actually clipping the polygon.
This commit is contained in:
parent
3c85d63655
commit
ef7a083891
|
@ -23,7 +23,7 @@
|
||||||
#include "zm_fifo_debug.h"
|
#include "zm_fifo_debug.h"
|
||||||
#include "zm_monitor.h"
|
#include "zm_monitor.h"
|
||||||
|
|
||||||
void Zone::Setup(
|
void Zone::Setup(
|
||||||
ZoneType p_type,
|
ZoneType p_type,
|
||||||
const Polygon &p_polygon,
|
const Polygon &p_polygon,
|
||||||
const Rgb p_alarm_rgb,
|
const Rgb p_alarm_rgb,
|
||||||
|
@ -122,7 +122,7 @@ void Zone::RecordStats(const Event *event) {
|
||||||
"PixelDiff=%d, AlarmPixels=%d, FilterPixels=%d, BlobPixels=%d, "
|
"PixelDiff=%d, AlarmPixels=%d, FilterPixels=%d, BlobPixels=%d, "
|
||||||
"Blobs=%d, MinBlobSize=%d, MaxBlobSize=%d, "
|
"Blobs=%d, MinBlobSize=%d, MaxBlobSize=%d, "
|
||||||
"MinX=%d, MinY=%d, MaxX=%d, MaxY=%d, Score=%d",
|
"MinX=%d, MinY=%d, MaxX=%d, MaxY=%d, Score=%d",
|
||||||
monitor->Id(), id, event->Id(), event->Frames(),
|
monitor->Id(), id, event->Id(), event->Frames(),
|
||||||
stats.pixel_diff_,
|
stats.pixel_diff_,
|
||||||
stats.alarm_pixels_,
|
stats.alarm_pixels_,
|
||||||
stats.alarm_filter_pixels_,
|
stats.alarm_filter_pixels_,
|
||||||
|
@ -620,12 +620,12 @@ bool Zone::CheckAlarms(const Image *delta_image) {
|
||||||
stats.score_ = 0;
|
stats.score_ = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max_blob_pixels != 0)
|
if (max_blob_pixels != 0)
|
||||||
stats.score_ = (100*stats.alarm_blob_pixels_)/max_blob_pixels;
|
stats.score_ = (100*stats.alarm_blob_pixels_)/max_blob_pixels;
|
||||||
else
|
else
|
||||||
stats.score_ = (100*stats.alarm_blob_pixels_)/polygon.Area();
|
stats.score_ = (100*stats.alarm_blob_pixels_)/polygon.Area();
|
||||||
|
|
||||||
if (stats.score_ < 1)
|
if (stats.score_ < 1)
|
||||||
stats.score_ = 1; /* Fix for score of 0 when frame meets thresholds but alarmed area is not big enough */
|
stats.score_ = 1; /* Fix for score of 0 when frame meets thresholds but alarmed area is not big enough */
|
||||||
Debug(5, "Current score is %d", stats.score_);
|
Debug(5, "Current score is %d", stats.score_);
|
||||||
|
@ -885,18 +885,10 @@ std::vector<Zone> Zone::Load(Monitor *monitor) {
|
||||||
polygon.Extent().Hi().x_,
|
polygon.Extent().Hi().x_,
|
||||||
polygon.Extent().Hi().y_);
|
polygon.Extent().Hi().y_);
|
||||||
|
|
||||||
if (polygon.Extent().Lo().x_ < 0) {
|
polygon = polygon.GetClipped(Box(
|
||||||
polygon.LoX(0);
|
{0, 0},
|
||||||
}
|
{static_cast<int32>(monitor->Width()), static_cast<int32>(monitor->Height())}
|
||||||
if (polygon.Extent().Hi().x_ >= (int) monitor->Width()) {
|
));
|
||||||
polygon.HiX((int) monitor->Width());
|
|
||||||
}
|
|
||||||
if (polygon.Extent().Lo().y_ < 0) {
|
|
||||||
polygon.LoY(0);
|
|
||||||
}
|
|
||||||
if (polygon.Extent().Hi().y_ >= (int) monitor->Height()) {
|
|
||||||
polygon.HiY((int) monitor->Height());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( false && !strcmp( Units, "Percent" ) ) {
|
if ( false && !strcmp( Units, "Percent" ) ) {
|
||||||
|
|
Loading…
Reference in New Issue