Ask Your Question

livingsparks's profile - activity

2014-11-21 04:57:33 -0600 answered a question masking green pixels - HSV

Yesterday I was just working on this, here is my code, it works well for the green and blue on red but you can still do something

cv::Mat src = inputFrame;
if (src.empty())return -1;

if (m_currentView == kStageRedColor) {
    rangeH1 = 0;
    rangeS1 = 35;
    rangeV1 = 182;
    rangeH2 = 35;
    rangeS2 = 255;
    rangeV2 = 255;
}
else if (m_currentView == kStageBlueColor) {
    rangeH1 = 97;
    rangeS1 = 88;
    rangeV1 = 55;
    rangeH2 = 133;
    rangeS2 = 255;
    rangeV2 = 255;
}
else if (m_currentView == kStageGreenColor) {
    rangeH1 = 57;
    rangeS1 = 64;
    rangeV1 = 55;
    rangeH2 = 77;
    rangeS2 = 255;
    rangeV2 = 255;
}
else if (m_currentView == kStageManual) {
}


cv::Mat HSVsrc;
cvtColor(src,HSVsrc, cv::COLOR_BGR2HSV);
cv::inRange(HSVsrc, cv::Scalar(rangeH1,rangeS1,rangeV1), cv::Scalar(rangeH2,rangeS2,rangeV2), HSVsrc);

I hope that could help you , if you have information for the "red channel" please write to me ;)