当前位置:网站首页>opencv 画黑色矩形,并写上序号
opencv 画黑色矩形,并写上序号
2022-07-17 12:05:00 【IM-STONE】
1、图片上均匀画黑色矩形
2、给每个矩形写上序号
#include <iostream>
#include <stdio.h>
#include "opencv2/core.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/ocl.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/calib3d.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/xfeatures2d.hpp"
#include<list>
#include<windows.h>
#include <opencv2/highgui/highgui_c.h>
#include<string>
using namespace cv;
using namespace cv::xfeatures2d;
using namespace std;
void func2()
{
int t_width = 3500;
int t_height = 2474;
int t_width_all = 9;
int t_height_all = 9;
Mat displayMat = cv::Mat(t_height , t_width, CV_8UC3, Scalar(255, 255, 255));
int t_per_width = t_width / t_width_all;
int t_per_height = t_height / t_height_all;
int t_index = 1;
for (int i = 0; i < t_width_all; )
{
for (int j = 0; j < t_height_all;)
{
vector<Point> m1;
m1.push_back(Point(t_per_width * i, t_per_height * j));
m1.push_back(Point(t_per_width * (i + 1), t_per_height * j));
m1.push_back(Point(t_per_width * (i + 1), t_per_height * (j + 1)));
m1.push_back(Point(t_per_width * i, t_per_height * (j + 1)));
fillPoly(displayMat, m1, Scalar(0, 0, 0), 8);
String t_tep_index = to_string(t_index);
while (t_tep_index.length() != 3)
{
t_tep_index = "0" + t_tep_index;
}
putText(displayMat, t_tep_index.c_str(), Point(t_per_width * i+ t_per_width/5, t_per_height * j+ t_per_height/3*2), FONT_HERSHEY_SIMPLEX, 4, Scalar(255, 255, 255), 8, 8);
t_index++;
j += 2;
}
i += 2;
}
cv::imshow("displayMat", displayMat);
imwrite("D:\\11.jpg", displayMat);
cv::waitKey(0);
}
int main()
{
func2();
return 0;
}
效果如下:
边栏推荐
- R语言dplyr包select函数删除dataframe数据中包含指定字符串内容的数据列(drop columns in dataframe)
- 读取二进制文件的中文乱码问题
- 网络安全学习(千锋网络安全笔记)1--搭建虚拟机
- Ffmpeg record video, stop (vb.net, step on the pit, class library - 10)
- Huawei ascend910 running yolov3 tutorial
- 华为昇思MindSpore详细教程
- HCIA 静态综合实验报告 7.10
- LVI-SAM:激光-IMU-相机紧耦合建图
- 【CSP-J 2021】总结
- 笔记本键盘失灵解决办法
猜你喜欢

Go to school = earn money? Immortal college without paying tuition fees!

Data Lake (XII): integration of spark3.1.2 and iceberg0.12.1

【排序】归并排序

如何在双链笔记软件中建立仪表盘和知识库?以嵌入式小组件库 NotionPet 为例

喜报

C语言之构造类型细讲

Let, const, VaR in ES6

Flink入门到实战-阶段四(时间和窗口图解)

Run yolov3 on Huawei modelarts_ coco_ detection_ dynamic_ AIPP sample

2022年湖南 省中职组“网络空间安全”Windows渗透测试 (超详细)
随机推荐
Network Security Learning (Qianfeng network security notes) 1-- building virtual machines
如何在双链笔记软件中建立仪表盘和知识库?以嵌入式小组件库 NotionPet 为例
上学=挣钱?无需缴纳学费的神仙院校!
押注.NET 是件好事
[Mori city] random talk on GIS data (IV) - coordinate system
Online education knowledge payment website source code system + live broadcast + applet, installation tutorial
Excel表格转换为Word表格,并且保留Excel表格中公式不发生变化
软件工程——软科中国大学专业排名
How to save and exit VIM
6G空天地一体化网络高空平台基站下行频谱效率研究
2022.07.14 暑假集训 个人排位赛(九)
Simulation Research on optimal detection of fault data in communication network
Cmake -- Notes
SSH連接華為ModelArts notebook
完全背包问题代码模板
Relationship between standardization, normalization and regularization
Quick completion guide of manipulator (XIII): joint space trajectory planning
【分离式超图像分类平台】使用深度学习中那些令人兴奋的模型搭建图像分类平台
读取二进制文件的中文乱码问题
基于AI智能关联技术的5G网络切片研究与实现