PIL 对图片进行添加汉字

python-opencv+PIL输入可选转的中文 场景 经常需要再opencv中输入中文, 有的时候还需要旋转. 然而, 中文和旋转都不是没有原生接口, 需要另想办法. 思路 PIL支持unicode字符, 所以将opencv图像换到PIL中.所谓的转换就是更换数据类型以及BGR和RGB的互换. 解决了中文后, PIL有没有原生的旋转字符的接口, 所以要先创建一个临时image, 在上面渲染字体后旋转整个图像再贴到原来的图上. 这里有几个小技巧.... 阅读详情
draw = ImageDraw.Draw(img)

# 加载字体
font = ImageFont.truetype('./font_simsun/simsun.ttc', 24)

(x1, y1)=(100,300)  # 写入图片的坐标位置
str_hinese=‘加油!’
rgb=(255,0,0)

# 进行中文文本写入
draw.text((x1, y1), str_hinese, fill=rgb,font=font)

字体与我联系给百度网盘链接!

Python3使用PIL在图片中写文字支持中文 ​​#功能:通过模板图片 写入文字到指定位置,并分别保存成新的图片 #功能说明:根据"\n"换行 #环境:PyDev 6.5.0 Python3.5.2 立即下载

相关推荐

python下的PIL模块支持的字体文件

python下的PIL模块支持的字体文件

python使用PIL的Image在图片上写中文漢字

【代码】python使用PIL的Image在图片上写中文漢字。

sdhdsf132452的博客 628

C++ 程序稳定运行一段时间后异常中止?vc6 运行库的bug!!!

事件查看器提示:错误应用程序 xxxxxxx.exe,版本 0.0.0.0,错误模块 MSVCRTD.DLL,版本 6.0.9782.0,错误地址 0x00012b40。这是一个通信方面的软件,需要长期运行,在压力测试时,高负荷连续运行一定天数时必定崩溃,而且都是在msvcrtd.dll中崩溃。后来在dump文件中发现调用栈在是MSVCRTD.DLL模块,跟踪代码发现是在void * __cdecl _heap_alloc_dbg(        size_t nSize,        int nBloc

qingflying的专栏 2678

python利用opencv或PIL给图片加文字(中文)

使用opencv和PIL库给图片添加文字

Xu_sa_sa的博客 5154

ADI恒流驱动芯片LT3763调试心得(25A恒流驱动)

看似很简单的一个电路,调了好几版硬件,中间还出现过一个插曲,就是电感,我用的是27A,1.5uH的,贴片封装,由于频繁试板,电感来回用热风枪拆了3次,结果上电空载到3A都没有问题,但是以上10A以上,就出现烧LT3763和mos的情况,一连烧了8片,搞得有点怀疑人生,一度觉得我的电路设计有问题,邮件咨询ADI的FAE后,确认电路设计没有问题。1、大功率同步整流的Nmos管都是取不同的型号,就是厂家推荐的主开关管和续流管的型号往往都不一样,这个里面有什么讲究,我没有整明白,暂时也不需要弄明白。

liming98lm的博客 3914

C++实战:基于ONNX Runtime与OpenCV部署XFeat图像匹配模型

本文详细介绍了在C++环境中,利用ONNX Runtime与OpenCV高效部署XFeat图像匹配模型的完整流程。内容涵盖环境搭建、模型转换、核心代码封装及可视化实现,旨在帮助开发者将这一先进的深度学习模型集成到对性能要求苛刻的工业或嵌入式应用中,实现鲁棒且快速的特征匹配。

gpu4optimizer的博客 521

Python 图形库 PIL, matplotlib 显示中文

想让这个两个图形库能够支持中文的显示其实还是挺简单的,下面分开说明PIL支持中文:1.从windows的C:\Windows\Fonts\ 目录下拷贝一份字体文件,比如"msyh.ttc" 到某个目录,一般是"/usr/share/fonts/truetype/",当然这个无所谓2.定义一个myfont变量, myfont = ImageFont.truetype(fontpath, 24); 第

mlnotes 2186

IEEE论文投稿必看:PDF eXpress报错font not embedded的3种修复方法(附Adobe Acrobat DC操作截图)

本文针对IEEE论文投稿时PDF eXpress系统常见的“font not embedded”报错,提供了三种核心修复方案。首先,详细解析了使用Adobe Acrobat DC进行专业修复的完整操作流程与关键技巧。其次,介绍了无需付费软件的开源与免费工具链(如Ghostscript)解决方案。最后,从源头出发,指导LaTeX和Microsoft Word用户在生成PDF时正确设置以确保字体自动嵌入,帮助研究者彻底解决格式问题,确保投稿顺利。

ujm56789012的博客 516

如何给图片添加汉字 ,PIL方法

问题描述: 在作人脸识别时遇到一个问题,在识别出人脸后无法使用opencv在图片上添加汉字,只能加字母,在网上搜索后综合得到使用PIL的方法最为简单,特记于此。 解决步骤: 1.使用cv2.imdecode打开图片 image = cv2.imdecode(np.fromfile(img, dtype=np.uint8),cv2.IMREAD_COLOR) 在此不用cv...

BYWXBYJB的博客 1014

告别玄学调参:手把手教你用20元件模型搞定GaN HEMT高频仿真(附S参数提取避坑指南)

本文详细介绍了如何使用20元件模型优化GaN HEMT高频仿真,解决传统16元件模型在10GHz以上频段的误差问题。通过S参数提取避坑指南和实战案例,帮助工程师精准建模分布式电极效应和寄生反馈路径,提升射频电路设计效率。

weixin_42523693的博客 441

PaddleOCR训练自己的数据

一 、数据准备 采用PPOCRLabel标注自己的数据 PPOCRLabel是一款适用于OCR领域的半自动化图形标注工具,内置PP-OCR模型对数据自动标注和重新识别。使用Python3和PyQT5编写,支持矩形框标注和四点标注模式,导出格式可直接用于PaddleOCR检测和识别模型的训练。 1.1 安装PaddlePaddle pip3 install --upgrade pip # 如果您的机器安装的是CUDA9或CUDA10,请运行以下命令安装 python3 -m pip in.

zyb的博客 1万+

Python用qrcode和PIL制作二维码并添加汉字(用Python在图片上添加汉字)

python制作二维码,python批量制作二维码,python批量制作带汉字的二维码,在图片上添加汉字,用Python在图片上添加汉字

BH.百行的博客 3095

QEMU pcie config空间访问机制

而pci_host_conf/data_le_ops的定义是在hw/pci/pci-host.c里,对于0xCF8端口的处理,因为是地址选通,所以只需要在write的时候记录、read的时候返回记录的值即可。而pci_host_config_write/read_common接口,在前256Bconfig空间的模拟中,也同样是会调用这个接口,所以后续的处理都是一样的。这是真实的硬件设计,而对于QEMU+KVM的虚机场景,显然是要基于硬件实现和虚拟化的需求设计虚机访问config空间的完整流程。

leiyanjie8995的博客 1949

python 图片加字软件下载_python 实现图片添加文字水印

您现在的位置是:网站首页>>Python>>pythonpython 实现图片添加文字水印发布时间:2019-11-16 09:39:09作者:wangjian浏览量:623点赞量:0在python中我们可以使用openCV给图片添加水印,这里注意openCV无法添加汉字水印,添加汉字水印上可使用PIL库给图片添加水印一:openCV给图片添加水印1:安装openCVpip...

weixin_40004659的博客 89

eMMC数据擦除的方式

接下来主要是讲解erase、trim、discard的差异,涉及的command有CMD35、CMD36、CMD38。一般用来擦除整卡或者某些分区,如果只想擦除一个。以下是device status的部分解释。eMMC的数据擦除方式有6种,分别是。将会跳过写保护,只执行其他的范围。Discard的命令序列是。Erase的命令序列是。的范围有包含写保护,Trim的命令序列是。

DPJimmy的博客 1763

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

python 实现图片添加文字水印

在python中我们可以使用openCV给图片添加水印,这里注意openCV无法添加汉字水印,添加汉字水印上可使用PIL库给图片添加水印 一:openCV给图片添加水印 1:安装openCV pipinstallopencv-python 如果安装报错的话,可以参考:https://www.wj0511.com/site/detail.html?id=230 2:使用openCV给...

huaweichenai的博客 2852

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

python 如何在图片上写汉字?

如何在图片上写汉字?opencv & PIL

guopeiAI 2147

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

opencv在图片上添加中文汉字(c++以及python)

运用opencv添加中文,在C++中虽然也有多种方法添加中文,但都很复杂,而python的方法就很简单了。

qq_35662333的博客 1788

Opencv学习记录(四)——基于Python(pil、imageio)、Opencv处理 GIF图片

** 加粗样式 ** 1. 使用python pil库进行gif图片的分成静态图片格式 注意:不支持生成 jpg、jpeg格式;支持生成bmp、png,推荐**png**格式,因为后面使用 **imageio**库进行生成 gif格式时仅支持 png格式。 ![一共生成了167帧,我们只需要处理有文字的帧](https://img-blog.csdnimg.cn/20181126201943738...

stupid_miao的博客 5361

opencv中,给图片添加汉字的问题

背景,是需要在一个图片上进行画线,等操作,需要写入汉字,但OpenCV的cv2的putText不支持中文查看资料发现2个方法:    1,将cv2图片转为pil然后在添加上汉子后,在转成cv2格式((pil下载地址)https://www.lfd.uci.edu/~gohlke/pythonlibs/#pillow)    2,freetype实现OpenCV2.x的中文输出这里我使用了第一种方法...

半吊子python全栈 5166

python绘制汉字_OpenCV Python 绘制中文字

By 凌顺2019年9月12日本示例使用的OpenCV版本是:4.1.1运行Python的编辑器:Jupyter notebook示例目的通过使用PLI在图片上添加中文字符。PIL(Python Imaging Library)是Python常用的图像处理库,而Pillow是PIL的一个友好Fork,提供了了广泛的文件格式支持,强大的图像处理能力,主要包括图像储存、图像显示、格式转换以及基本的图像...

weixin_39657444的博客 2376

python绘制汉字_Python.在图片上绘制文字

如下from PIL import Image,ImageDraw,ImageFontimport timeimport ossourceimg = "/Users/a1/Desktop/head.png"savepath = "/Users/a1/Desktop/img/"def imgaddnum(img):# 将img添加到画板imgdraw = ImageDraw.Draw(img)# 设...

weixin_39759270的博客 3818

python识别中文验证码_python PIL模块与随机生成中文验证码

在这之前,你首先得了解Python中的PIL库。PIL是Python Imaging Library的简称,PIL是一个Python处理图片的库,提供了一系列模块和方法,比如:裁切,平移,旋转,改变尺寸等等。在PIL库中,任何一个图像都是用Image对象来表示的,所以要加载一张图片,最简单的形式如下:from PIL import Imageimage = Image.open("1.jpeg")...

weixin_39825105的博客 175

python 生成图片_python练习_读图图片在其中随机生成汉字以及线条

上一个opencv_Random generator and text,代码是c++,这里写一个类似的python代码,实现相似的随机生成器与文本打印的功能。其中涉及1.jpg如下,来自网络图,侵删。1.jpg# -*- coding:utf-8 -*- #yys import random # Python随机生成中文字符的方法 def Unicode(): # 在unicode码中...

weixin_39637975的博客 313
上一篇: invalid argument 2 pytorch
下一篇: Non-UTF-8 code starting with '\xe7'
color丶瞎
博客等级 码龄9年 13粉丝 52原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值