1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

Merge pull request #23196 from labeeb-7z:printOptionInRoiSelector

Added argument to print notice in `roiSelector.cpp`

Related Issue : https://github.com/opencv/opencv/issues/23175

I've added a printNotice argument to `selectROI` (and it's overload) and `selectROIs` functions.
I've also updated the function declarations in `highgui.hpp`.
Tested by building locally.

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Labib Asari
2023-03-20 12:36:57 +05:30
committed by GitHub
parent 752ac19a2f
commit c4226f0457
2 changed files with 24 additions and 16 deletions
+19 -13
View File
@@ -13,11 +13,14 @@ namespace
class ROISelector
{
public:
Rect select(const String &windowName, Mat img, bool showCrossair = true, bool fromCenter = true)
Rect select(const String &windowName, Mat img, bool showCrossair = true, bool fromCenter = true, bool printNotice = true)
{
// show notice to user
printf("Select a ROI and then press SPACE or ENTER button!\n");
printf("Cancel the selection process by pressing c button!\n");
if(printNotice)
{
// show notice to user
printf("Select a ROI and then press SPACE or ENTER button!\n");
printf("Cancel the selection process by pressing c button!\n");
}
key = 0;
imageSize = img.size();
@@ -83,16 +86,19 @@ class ROISelector
}
void select(const String &windowName, Mat img, std::vector<Rect> &boundingBoxes,
bool showCrosshair = true, bool fromCenter = true)
bool showCrosshair = true, bool fromCenter = true, bool printNotice = true)
{
printf("Finish the selection process by pressing ESC button!\n");
if(printNotice)
{
printf("Finish the selection process by pressing ESC button!\n");
}
boundingBoxes.clear();
key = 0;
// while key is not ESC (27)
for (;;)
{
Rect temp = select(windowName, img, showCrosshair, fromCenter);
Rect temp = select(windowName, img, showCrosshair, fromCenter, printNotice);
if (key == 27)
break;
if (temp.width > 0 && temp.height > 0)
@@ -195,21 +201,21 @@ class ROISelector
};
}
Rect cv::selectROI(InputArray img, bool showCrosshair, bool fromCenter)
Rect cv::selectROI(InputArray img, bool showCrosshair, bool fromCenter, bool printNotice)
{
ROISelector selector;
return selector.select("ROI selector", img.getMat(), showCrosshair, fromCenter);
return selector.select("ROI selector", img.getMat(), showCrosshair, fromCenter, printNotice);
}
Rect cv::selectROI(const String& windowName, InputArray img, bool showCrosshair, bool fromCenter)
Rect cv::selectROI(const String& windowName, InputArray img, bool showCrosshair, bool fromCenter, bool printNotice)
{
ROISelector selector;
return selector.select(windowName, img.getMat(), showCrosshair, fromCenter);
return selector.select(windowName, img.getMat(), showCrosshair, fromCenter, printNotice);
}
void cv::selectROIs(const String& windowName, InputArray img,
std::vector<Rect>& boundingBox, bool showCrosshair, bool fromCenter)
std::vector<Rect>& boundingBox, bool showCrosshair, bool fromCenter, bool printNotice)
{
ROISelector selector;
selector.select(windowName, img.getMat(), boundingBox, showCrosshair, fromCenter);
selector.select(windowName, img.getMat(), boundingBox, showCrosshair, fromCenter, printNotice);
}