山西手机版建站系统信息,招标网有哪些,工作了应该浏览器哪些网站,wordpress无法进入登录页面文章目录 1. 使用矩形将图像中某个区域置为黑色2. cv::Rect 类介绍 1. 使用矩形将图像中某个区域置为黑色
推荐参考博客#xff1a;OpenCV实现将任意形状ROI区域置黑#xff08;多边形区域置黑#xff09;
比较常用的是使用 Rect 矩形实现该功能#xff0c;代码如下… 文章目录 1. 使用矩形将图像中某个区域置为黑色2. cv::Rect 类介绍 1. 使用矩形将图像中某个区域置为黑色
推荐参考博客OpenCV实现将任意形状ROI区域置黑多边形区域置黑
比较常用的是使用 Rect 矩形实现该功能代码如下
#include opencv2\opencv.hppint main() {std::string filePath img.png;cv::Mat img cv::imread(filePath);//创建矩形int x img.cols / 2; // x 对应列坐标int y img.rows / 2; // y 对应行坐标int width 150;int height 80;cv::Rect rect(x, y, width, height);//将矩形贴到img中并将矩形区域置为黑色cv::Mat subImg img(rect);subImg.setTo(0);cv::imwrite(img_rect.png, img);return 0;
}效果如下 2. cv::Rect 类介绍
推荐参考博客OpenCV 中 cv::Rect 矩形类用法
cv::Rect 用于创建矩形API 参数如下
int x; // 左上角 x 坐标对应列坐标
int y; // 左上角 y 坐标对应列坐标
int width; // 宽
int height; // 高源码如下
templatetypename _Tp class Rect_
{
public:typedef _Tp value_type;//! default constructorRect_();Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height);Rect_(const Rect_ r);Rect_(Rect_ r) CV_NOEXCEPT;Rect_(const Point__Tp org, const Size__Tp sz);Rect_(const Point__Tp pt1, const Point__Tp pt2);Rect_ operator ( const Rect_ r );Rect_ operator ( Rect_ r ) CV_NOEXCEPT;//! the top-left cornerPoint__Tp tl() const;//! the bottom-right cornerPoint__Tp br() const;//! size (width, height) of the rectangleSize__Tp size() const;//! area (width*height) of the rectangle_Tp area() const;//! true if emptybool empty() const;//! conversion to another data typetemplatetypename _Tp2 operator Rect__Tp2() const;//! checks whether the rectangle contains the pointbool contains(const Point__Tp pt) const;_Tp x; //! x coordinate of the top-left corner_Tp y; //! y coordinate of the top-left corner_Tp width; //! width of the rectangle_Tp height; //! height of the rectangle
};typedef Rect_int Rect2i;
typedef Rect_float Rect2f;
typedef Rect_double Rect2d;
typedef Rect2i Rect;