Bootstrap

C++ 对OPENCV rect矩形进行颜色填充

C++ 对OPENCV rect rectangle 矩形进行颜色填充


// An highlighted block
                cv::Mat test_map(800,800,CV_8UC3,cv::Scalar(0,0,0));
                Rect rec = cv::Rect(cv::Point(100,100),cv::Point(200,200));
                vector<Point>  contour;
                contour.push_back(rec.tl());
                contour.push_back(Point(rec.tl().x + rec.width , rec.tl().y ) );
                contour.push_back(Point(rec.tl().x + rec.width , rec.tl().y + rec.height));
                contour.push_back(Point(rec.tl().x , rec.tl().y + rec.height ));

                cv::fillConvexPoly(test_map, contour, cv::Scalar(255,255,255   ));//fillPoly函数的第二个参数是二维数组!!

   

                cv::namedWindow("test_map", cv::WINDOW_AUTOSIZE);
                cv::imshow("test_map", test_map);
                cv::waitKey();

结果展示:就是填充了白色
在这里插入图片描述

;