当前位置:网站首页>Opencv draw a black rectangle and write the serial number
Opencv draw a black rectangle and write the serial number
2022-07-19 11:38:00 【IM-STONE】
1、 Draw a black rectangle evenly on the picture
2、 Write a sequence number on each rectangle
#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;
}
The effect is as follows :
边栏推荐
- Play with the one-stop scheme of cann target detection and recognition
- 02-2、缺省参数、函数重载、引用、隐式类型转换、关于报错
- 动态内存分配问题
- The concept of data guard broker and the configuration process of data guard broker
- zabbix代理服务器配置
- MySQL autoincrement ID, UUID and snowflake ID
- 【嵌入式单元测试】C语言单元测试框架搭建
- From prediction to decision-making, Chapter 9 Yunji datacanvas launched the ylearn causal learning open source project
- The difference between CPU load and CPU utilization
- 常用getshell工具的下载
猜你喜欢

委派雙親之類加載器

02-3、指针和引用的区别

Leetcode 1328. 破坏回文串(可以,已解决)

Developing those things: how to solve the problem of long-time encoding and decoding of RK chip video processing?

Leetcode 1304. N different integers with zero and

QT -- excellent open source project

Robot development -- common simulation software tools

Introduction of database lock, shared with InnoDB, exclusive lock

How to change and reset forgotten root password in RHEL 9

mysql show processlist 详解
随机推荐
JVM钩子hooks函数
学习笔记3--规划控制中的机器学习基本思想
The basic establishment of the sequence table and the related operations of adding, deleting, modifying and querying (the sequence table described in C language)
TS solves the problem that the type file of the imported plug-in does not exist
Learning note 3 -- basic idea of machine learning in planning control
设置cmd命令提示符窗口的界面语言为英文
动态内存分配问题
Discussion on Euler angle solution of rocket large maneuvering motion
TCP congestion control details | 7 Surpass TCP
Conversion of unity3d model center point (source code)
Robot development -- robot data summary
常见分布式锁介绍
QT two overloaded qlistwidget control objects implement selectitem drag drag
Leetcode 1328. Destroy palindrome string (yes, solved)
搭建OpenStack-M版的Cinder所碰到过的状况
Sword finger offer II 041 Average value of sliding window
【多线程】JUC详解 (Callable接口、RenntrantLock、Semaphore、CountDownLatch) 、线程安全集合类面试题
Getting started with web security - deploy snort open source ids/ips system
How to change and reset forgotten root password in RHEL 9
Unity高版本退回低版本报错问题