if ((int)res[j].class_id == 0)
{
cv:Mat imgThresholded;
sum, blacksum = 0;
head_num++;
cv::Mat dst = ori_img(helmet_r);
inRange(dst, Scalar(0, 0, 0), Scalar(127, 127, 127), imgThresholded); //黑色
for(int i = 0; i < imgThresholded.rows; ++i){ //遍历行
for(int j = 0; j < imgThresholded.cols; ++j){
sum++;
if (imgThresholded.at<uchar>(i, j)>10){blacksum++;}}}
black_rate = blacksum/sum;
if (black_rate > 0.85){
cv::putText(pr_img, " helmet W", cv::Point(r.x, r.y - 1), cv::FONT_HERSHEY_PLAIN, 1.2, cv::Scalar(0xFF, 0xFF, 0xFF), 2);
}
}
C/C++ 图像颜色判断
最新推荐文章于 2024-03-11 18:02:18 发布