当前位置:网站首页>初识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;
}



边栏推荐
猜你喜欢
随机推荐
换电脑后如何配置SSH
kotlin基础知识点
Kotlin协程:协程的基础与使用
[HCTF 2018]admin
Swagger2 shows that there is a problem with the get interface, which can be solved with annotations
学习新技术语言流程
Laravel calls a third party to send mail (PHP)
[code source] daily one question non decreasing 01 sequence
Assignment 7.21 Joseph Ring problem and decimal conversion
In depth interpretation of C language random number function and how to realize random number
初识Opencv4.X----图像直方图均衡
【代码源】每日一题 树
OC--类别 扩展 协议与委托
STM32+HC05串口蓝牙设计简易的蓝牙音箱
【cf】Round 128 C. Binary String
[code source] daily question tree
Data query language (DQL)
自定义 view 实现兑奖券背景[初级]
[code source] score split of one question per day
@1-1 CCF 2021-04-1 gray histogram









