Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mask function #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class PanelDetectorHsv {
public:
PanelDetectorHsv(const int, const int, const int,
const int, const int, const int);


cv::Mat mask(const cv::Mat &);
cv::Mat hsv_filter(const cv::Mat &);
std::vector<Bbox> detect(const cv::Mat &);

Expand Down
13 changes: 12 additions & 1 deletion core1_panel_detector/src/panel_detector_hsv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,19 @@ cv::Mat PanelDetectorHsv::hsv_filter(const cv::Mat& img) {
return result;
}

cv::Mat PanelDetectorHsv::mask(const cv::Mat& img) {
int mask_height = 250; //$BMWD4@0(B
cv::Mat mask = cv::Mat::ones(img.size(), CV_8UC1) * 255;
cv::Rect mask_roi(0, 0, img.cols, mask_height);
mask(mask_roi) = 0;
cv::Mat result;
img.copyTo(result, mask);
return result;
}

std::vector<Bbox> PanelDetectorHsv::detect(const cv::Mat& img) {
cv::Mat img_filtered = hsv_filter(img);
cv::Mat img_mask = mask(img);
cv::Mat img_filtered = hsv_filter(img_mask);
cv::Mat img_gray;
cv::cvtColor(img_filtered, img_gray, cv::COLOR_BGR2GRAY);
cv::Mat img_thresh;
Expand Down