Skip to content

Commit

Permalink
Add debug image with marker shown on whole picture (#14)
Browse files Browse the repository at this point in the history
When building & running in debug mode (DEBUG_WRITE=y), sometimes you
need to see the marker drawn on the whole picture to get more info on
where the crop is done. This patch adds that functionality.

Signed-off-by: Joakim Roubert <[email protected]>
  • Loading branch information
joakimr-axis authored Aug 29, 2024
1 parent 2dab70f commit ff6ebff
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"vendorUrl": "https://www.axis.com/",
"runMode": "respawn",
"version": "1.0.4"
"version": "1.0.5"
},
"configuration": {
"settingPage": "settings.html",
Expand Down
26 changes: 26 additions & 0 deletions src/colorarea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ ColorAreaEllipse::ColorAreaEllipse(
const uint8_t tolerance)
: ColorArea(img, point_center, color, markerwidth, markerheight, tolerance)
{
#if defined(DEBUG_WRITE)
// Create a debug image tho show the marker
auto marker_img = img.clone();

// Draw the ellipse
Size axes(markerwidth / 2, markerheight / 2);
ellipse(marker_img, point_center, axes, 0, 0, 360, cv::Scalar(0, 0, 0), 3);
ellipse(marker_img, point_center, axes, 0, 0, 360, cv::Scalar(255, 255, 255), 1);

DBG_WRITE_IMG("marker_img.jpg", marker_img);
#endif

// Create color mask
colorarea_mask = Mat::zeros(Size(croprange_x.size(), croprange_y.size()), CV_8U);
ellipse(
Expand All @@ -165,6 +177,20 @@ ColorAreaRectangle::ColorAreaRectangle(
const uint8_t tolerance)
: ColorArea(img, point_center, color, markerwidth, markerheight, tolerance)
{
#if defined(DEBUG_WRITE)
// Create a debug image tho show the marker
auto marker_img = img.clone();

// Draw the rectangle
auto pt1 = point_center - Point(markerwidth / 2, markerheight / 2);
auto pt2 = point_center + Point(markerwidth / 2, markerheight / 2);
rectangle(marker_img, pt1, pt2, Scalar(0, 0, 0), 3);
rectangle(marker_img, pt1, pt2, Scalar(255, 255, 255), 1);

DBG_WRITE_IMG("marker_img.jpg", marker_img);
#endif

// Create color mask
colorarea_mask = Mat::ones(Size(croprange_x.size(), croprange_y.size()), CV_8U) * 255;
DBG_WRITE_IMG("mask_img.jpg", colorarea_mask);
LOG_I("%s/%s: Rectancular colorarea created", __FILE__, __FUNCTION__);
Expand Down

0 comments on commit ff6ebff

Please sign in to comment.