#include<iostream>
#include<opencv2/opencv.hpp>
#include<string>
#include "CvxText.h"
#include<stdlib.h>
#include<time.h>
#include <random>
#include <fstream>
using namespace std;
using namespace cv;
int main(){
// //index = { "京": 0, "沪" : 1, "津" : 2, "渝" : 3, "冀" : 4, "晋" : 5, "蒙" : 6, "辽" : 7, "吉" : 8, "黑" : 9, "苏" : 10, "浙" : 11, "皖" : 12,
// // "闽" : 13, "赣" : 14, "鲁" : 15, "豫" : 16, "鄂" : 17, "湘" : 18, "粤" : 19, "桂" : 20, "琼" : 21, "川" : 22, "贵" : 23, "云" : 24,
// // "藏" : 25, "陕" : 26, "甘" : 27, "青" : 28, "宁" : 29, "新" : 30, "0" : 31, "1" : 32, "2" : 33, "3" : 34, "4" : 35, "5" : 36,
// // "6" : 37, "7" : 38, "8" : 39, "9" : 40, "A" : 41, "B" : 42, "C" : 43, "D" : 44, "E" : 45, "F" : 46, "G" : 47, "H" : 48,
// // "J" : 49, "K" : 50, "L" : 51, "M" : 52, "N" : 53, "P" : 54, "Q" : 55, "R" : 56, "S" : 57, "T" : 58, "U" : 59, "V" : 60,
// // "W" : 61, "X" : 62, "Y" : 63, "Z" : 64 };
// //char chars[] = { '京', '沪', '津', '渝', '冀', '晋', '蒙', '辽', '吉', '黑', '苏', '浙',
// // '皖', '闽', '赣', '鲁', '豫', '鄂', '湘', '粤', '桂','琼', '川', '贵', '云', '藏', '陕',
// // '甘', '青', '宁', '新', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A','B', 'C',
// // 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
// // 'W', 'X','Y', 'Z' };
fstream outfile("image1/a.txt", ios::out);
string chars[] = { "京", "云", "津", "渝", "冀", "晋", "蒙", "辽", "吉", "黑", "苏", "浙", "皖", "闽", "赣", "鲁", "豫", "鄂", "湘", "粤", "桂",
"琼", "川", "沪", "贵", "藏", "陕", "甘", "青", "宁", "新", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A",
"B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X",
"Y", "Z" };
int sum = 0;
for (int i = 0; i < 31; ++i){
const char *msg0 = chars[i].c_str();
string h = "head/"+to_string(i) + ".bmp";
Mat logo = imread(h, 1);
Mat mask = logo(Range(0, 184), Range(0, 94)); //截取头部汉字;
for (int j = 41; j < 65; ++j){
const char *msg1 =chars[j].c_str();
for (int k = 0; k < 5; ++k){
string s[5] , label = ""; //label记录后5个的标签;
int b[2][5] = {453,623,793,963,1126,531,691,851,1011,1171};
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(0, 9);
for (int t = 0; t < 5; ++t){
int a = dis(gen);
if (a == 1) b[0][t] =b[1][t];
label += to_string(a) + " ";
s[t]= chars[a+31];
}
string src = "img/14.bmp"; //添加背景图片;
Mat img = imread(src), des;
CvxText text("chepai.ttf"); //显示数字和字母
float p = 1.f; //设置字体的透明度
text.setFont(NULL, &cvScalar(400, 0.5, 0.074, 0), NULL, &p);
text.putText(&IplImage(img), msg1, Point(216, 346), CV_RGB(255, 255, 255)); //显示第二位;
//text.putText(&IplImage(img), s[0].c_str(), Point(453, 346), CV_RGB(255, 255, 255)); //显示后1位;
//text.putText(&IplImage(img), s[1].c_str(), Point(623, 346), CV_RGB(255, 255, 255)); //显示后2位;
//text.putText(&IplImage(img), s[2].c_str(), Point(793, 346), CV_RGB(255, 255, 255)); //显示后3位;
//text.putText(&IplImage(img), s[3].c_str(), Point(963, 346), CV_RGB(255, 255, 255)); //显示后4位;
//text.putText(&IplImage(img), s[4].c_str(), Point(1126, 346), CV_RGB(255, 255, 255)); //显示后5位;
//text.putText(&IplImage(img), s[0].c_str(), Point(531, 346), CV_RGB(255, 255, 255)); //显示后1位;
//text.putText(&IplImage(img), s[1].c_str(), Point(691, 346), CV_RGB(255, 255, 255)); //显示后2位;
//text.putText(&IplImage(img), s[2].c_str(), Point(851, 346), CV_RGB(255, 255, 255)); //显示后3位;
//text.putText(&IplImage(img), s[3].c_str(), Point(1011, 346), CV_RGB(255, 255, 255)); //显示后4位;
//text.putText(&IplImage(img), s[4].c_str(), Point(1171, 346), CV_RGB(255, 255, 255)); //显示后5位;
text.putText(&IplImage(img), s[0].c_str(), Point(b[0][0], 346), CV_RGB(255, 255, 255)); //显示后1位;
text.putText(&IplImage(img), s[1].c_str(), Point(b[0][1], 346), CV_RGB(255, 255, 255)); //显示后2位;
text.putText(&IplImage(img), s[2].c_str(), Point(b[0][2], 346), CV_RGB(255, 255, 255)); //显示后3位;
text.putText(&IplImage(img), s[3].c_str(), Point(b[0][3], 346), CV_RGB(255, 255, 255)); //显示后4位;
text.putText(&IplImage(img), s[4].c_str(), Point(b[0][4], 346), CV_RGB(255, 255, 255)); //显示后5位;
resize(img, des, Size(img.size().width*0.444, img.size().height*0.444+1));
cv::Rect roi = Rect(0, 0, mask.cols, mask.rows);
mask.copyTo(des(roi));
string imgname ="image/"+ to_string(sum)+".jpg";
outfile << sum << ".jpg " <<i<<" "<< j - 41 << " " << label << endl;
imwrite(imgname, des);
cout << sum << endl;
++sum;
}
}
}
return 0;
}
//
//
//
//
// ////载入希望输入的字体,可在目录C:\WINDOWS\Fonts中选择相应字体文件,并复制到工程下。
// //CvxText text0("车牌字体.ttf"); //显示汉字字体
// //CvxText text1("chepai.ttf"); //显示数字和字母
// ////CvxText text("车牌字体DIN1451.ttf");
// ////Scalar size(15, 0.5, 0.8, 0); //设置字体的大小/空白比例/间隔比较/旋转角度
// //float p = 1.f; //设置字体的透明度
// ////const char *msg0 = "京";
// ////const char *msg1 = "A";
// //const char *msg2 = "F0236";
// //text0.setFont(NULL, &cvScalar(317, 0.5, 0.074, 0), NULL, &p);
// //text1.setFont(NULL, &cvScalar(400, 0.5, 0.074, 0), NULL, &p);
// ////text1.setFont(NULL, &cvScalar(100, 0.5, 0.1, 0), NULL, &p);//<span style="font-family:Arial;">cvScalar</span><span style="font-family:Arial;">设置字体的大小/空白比例/间隔比较/旋转角度 </span>
// ////text.setFont(NULL, &size, NULL, &p);
// //text0.putText(&IplImage(img), msg0, Point(40, 350), CV_RGB(255, 255, 255)); //显示第一位;
// //text1.putText(&IplImage(img), msg1, Point(213, 346), CV_RGB(255, 255, 255)); //显示第二位;
// //text1.putText(&IplImage(img), msg2, Point(446, 346), CV_RGB(255, 255, 255)); //显示后5位;
// //imshow("image", img);
//
//
// //resize(img, des, Size(img.size().width*0.461, img.size().height*0.461));
// //imwrite("2.jpg",des);
// //waitKey();
// //putText(des, "好", Point(50, 60), FONT_HERSHEY_COMPLEX, 1, Scalar(255, 23, 0), 4, 8);//在图片上写文字
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
c++批量车牌生成程序 (291个子文件)
16.bmp 2.42MB
15.bmp 2.42MB
2.bmp 2.42MB
1.bmp 2.42MB
6.bmp 1.54MB
3.bmp 1.54MB
5.bmp 1.54MB
11.bmp 1.54MB
9.bmp 1.54MB
8.bmp 1.54MB
12.bmp 1.54MB
10.bmp 1.54MB
14.bmp 1.54MB
7.bmp 1.54MB
13.bmp 1.54MB
4.bmp 1.54MB
7.BMP 415KB
6.BMP 415KB
1.BMP 415KB
19.BMP 415KB
26.BMP 415KB
22.BMP 415KB
29.BMP 415KB
27.BMP 415KB
20.BMP 415KB
10.BMP 415KB
17.BMP 415KB
3.BMP 415KB
14.BMP 415KB
23.BMP 415KB
11.BMP 415KB
21.BMP 415KB
9.BMP 415KB
8.BMP 415KB
15.BMP 415KB
2.BMP 415KB
4.BMP 415KB
24.BMP 415KB
18.BMP 415KB
12.BMP 415KB
30.BMP 415KB
0.BMP 415KB
25.BMP 415KB
16.BMP 415KB
13.BMP 415KB
28.BMP 415KB
5.BMP 415KB
main.cpp 6KB
CvxText.cpp 5KB
plase.exe 1.6MB
plase.vcxproj.filters 1KB
freetype.h 281KB
tttypes.h 94KB
ftobjs.h 81KB
ftimage.h 74KB
ftoption.h 61KB
ttnameid.h 59KB
ftserv.h 56KB
ftcache.h 56KB
sfnt.h 45KB
tttables.h 45KB
ftglyph.h 38KB
ftmodapi.h 37KB
psaux.h 35KB
ftoutln.h 35KB
fttypes.h 35KB
ftmm.h 34KB
t1tables.h 34KB
ftheader.h 26KB
ftstream.h 23KB
pshints.h 22KB
ftstroke.h 22KB
ftdriver.h 21KB
ftautoh.h 19KB
ftconfig.h 19KB
ftmac.h 17KB
ftlist.h 16KB
ftmemory.h 16KB
ftsnames.h 16KB
ftttdrv.h 15KB
ftcalc.h 15KB
ftrfork.h 15KB
ftbitmap.h 14KB
fterrdef.h 14KB
autohint.h 14KB
ftgxval.h 13KB
ftlcdfil.h 12KB
ftcffdrv.h 12KB
ftdebug.h 11KB
ftincrem.h 11KB
fterrors.h 11KB
ftrender.h 11KB
ftadvanc.h 10KB
ftsystem.h 10KB
ftmoderr.h 10KB
ftwinfnt.h 10KB
t1types.h 10KB
ftchapters.h 9KB
ftsizes.h 9KB
fttrigon.h 8KB
共 291 条
- 1
- 2
- 3
资源评论
cdwxx1234
- 粉丝: 5
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功