当前位置:网站首页>初识Opencv4.X----ROI截取
初识Opencv4.X----ROI截取
2022-07-25 09:22:00 【F l e】
//ROI截取
#include <stdio.h>
#include <iostream>
#include <string>
#include <opencv2\opencv.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat img = Mat::zeros(Size(400, 400), CV_8UC1);//创建一个黑色背景,注意是Size(x,y),即(列,行)
putText(img, "A", Point(1, 200), 1, 15, Scalar(255), 1);
putText(img, "B", Point(200, 200), 1, 15, Scalar(255), 1);
putText(img, "C", Point(1, 400), 1, 15, Scalar(255), 1);
putText(img, "D", Point(200, 400), 1, 15, Scalar(255), 1);
//使用Rect类型获取ROI--Rect(x,y,width,height)
Mat ROI_Rect;
ROI_Rect = img(Rect(0, 0, 200, 200));
//使用Range类型获取ROI--Range(start,end)
Mat ROI_Range;
ROI_Range = img(Range(200,400),Range(0,200));
imshow("img", img);
imshow("ROI_Rect", ROI_Rect);
imshow("ROI_Range", ROI_Range);
waitKey(0);
return 0;
}



边栏推荐
猜你喜欢

Object initialization

A brief introduction to the interest of convolutional neural networks

cf #785(div2) C. Palindrome Basis

Some operations of main function

关于C和OC

UI - infinite rotation chart and column controller

OC--包装类和处理对象

【cf】Round 128 C. Binary String

Swift创作天气APP

为什么要使用JSON.stringify()和JSON.parse()
随机推荐
Redis list 结构命令
*6-3 save small experts
[GPLT] 2022 大众情人(floyd)
自定义 view 实现兑奖券背景[初级]
Swagger2 shows that there is a problem with the get interface, which can be solved with annotations
对象初始化
【cf】Round 128 C. Binary String
How to write Android switching interface with kotlin
Week summary
Flex layout syntax and use cases
Install MySQL in Ubuntu and create new users
【代码源】每日一题 算的我头都大啦
The shortest path problem Bellman Ford (single source shortest path) (illustration)
Swift创作天气APP
OC -- category extension agreement and delegation
解决QTCreator使用VS编译中文乱码错误
@2-1 safety index predicted by CCF at the end of December 1, 2020
*7-2 CCF 2015-09-2 date calculation
OC--类别 扩展 协议与委托
【代码源】每日一题 国家铁路