直接代码

 import cv2.cv as cv
saveImagePath = 'E:/ScreenTestImages/' colorRed = [0,0,255]
colorGreen = [0,255,0]
colorBlue = [255,0,0]
colorWhite = [255,255,255]
colorBlack = [0,0,0]
colorAqua = [255,255,0]
colorFuchsia = [255,0,255]
colorYellow = [0,255,255] stardardColors = [colorBlue,colorGreen,colorAqua,colorRed,colorFuchsia,colorYellow,colorWhite] def createImg(depth=3):
return cv.CreateImage((800,480),8,depth) def saveImageFile(typeName,img):
filename = saveImagePath + typeName + '.png'
cv.SaveImage(filename,img)
print typeName+'.png','\t\t...\tok' def createOneColorImage(color):
img = createImg()
cv.Set(img,color)
return img def create64GrayImage():
img = createImg(1)
cv.SetZero(img)
for xPos in range(0,64):
cv.SetImageROI(img,(int(12.5*xPos),0,800,480))
cv.Set(img,xPos*255/63)
cv.ResetImageROI(img)
return img def createCheckBoardPattern(isReserved=False):
img = createImg(1)
boolColor = True
numsX = 4
numsY = 4
pixsX = 800/numsX
pixsY = 480/numsY
for x in range(0,numsX):
for y in range(0,numsY):
cv.SetImageROI(img,(x*pixsX,y*pixsY,(x+1)*pixsX,(y+1)*pixsY))
boolColor = not (x%2) ^ (y%2) ^ isReserved
cv.Set(img,255*boolColor)
cv.ResetImageROI(img)
return img def createStardardImage():
img = createImg()
pixs = 800./7
for i in range(0,7):
cv.SetImageROI(img,(int(i*pixs),0,int(i*pixs+pixs),480))
cv.Set(img,stardardColors[i])
cv.ResetImageROI(img)
return img if __name__ == '__main__':
print 'Start Gen Test Screen Files ...'
saveImageFile('red',createOneColorImage(colorRed))
saveImageFile('green',createOneColorImage(colorGreen))
saveImageFile('blue',createOneColorImage(colorBlue))
saveImageFile('white',createOneColorImage(colorWhite))
saveImageFile('black',createOneColorImage(colorBlack))
saveImageFile('64gray',create64GrayImage())
saveImageFile('checkboard Pattern',createCheckBoardPattern())
saveImageFile('checkboard Pattern(inverted)',createCheckBoardPattern(True))
saveImageFile('standard',createStardardImage())
print 'Generate Success!'

贴上非单色图片的样子:

64 gray:

checkboard pattern:

checkboard pattern(inverted):

standard:

python生成测试图片的更多相关文章

  1. python 生成随机图片验证码

    1.安装pillow模块 pip install pillow (1)创建图片 from PIL import Image #定义使用Image类实例化一个长为400px,宽为400px,基于RGB的 ...

  2. python生成汉字图片字库

    最近做文档识别方面的项目,做汉字识别需要建立字库,在网上找了各种OCR,感觉都不好,这方面的技术应该比较成熟了,OCR的软件很多,但没有找到几篇有含金量量的论文,也没有看到哪位大牛公开字库,我用pyg ...

  3. 最简单的基于FFmpeg的libswscale的示例附件:测试图片生成工具

    ===================================================== 最简单的基于FFmpeg的libswscale的示例系列文章列表: 最简单的基于FFmpeg ...

  4. Python数据展示 - 生成表格图片

    前言 前一篇文章介绍了推送信息到企业微信群里,其中一个项目推送的信息是使用Python自动生成的表格,本文来讲讲如何用Python生成表格图片. 选一个合适库 Python最大的优点就是第三方库丰富, ...

  5. python生成随机图形验证码

    使用python生成随机图片验证码,需要使用pillow模块 1.安装pillow模块 pip install pillow 2.pillow模块的基本使用 1.创建图片 from PIL impor ...

  6. python 将png图片格式转换生成gif动画

    先看知乎上面的一个连接 用Python写过哪些[脑洞大开]的小工具? https://www.zhihu.com/question/33646570/answer/157806339 这个哥们通过爬气 ...

  7. [Python] 将视频转成ASCII符号形式、生成GIF图片

    一.简要说明 简述:本文主要展示将视频转成ASCII符号形式展示出来,带音频. 运行环境:Win10/Python3.5. 主要模块: PIL.numpy.shutil. [PIL]: 图像处理 [n ...

  8. Python测试开发-浅谈如何自动化生成测试脚本

    Python测试开发-浅谈如何自动化生成测试脚本 原创: fin  测试开发社区  前天 阅读文本大概需要 6.66 分钟. 一 .接口列表展示,并选择 在右边,点击选择要关联的接口,区分是否要登录, ...

  9. Python(三) PIL, Image生成验证图片

    Python(三) PIL, Image生成验证图片 安装好PIL,开始使用. 在PyCharm中新建一个文件:PIL_Test1.py 1 # PIL 应用练习 2 # 3 # import PIL ...

随机推荐

  1. 重构——DataTable转泛型

         泛型简单介绍         泛型能够最大限度的重用代码.保护类型的安全.提高性能.         泛型最常见的用途是创建集合类         泛型数据类型中使用的信息可在执行时通过反射 ...

  2. SaltStack快速部署及测试

    测试环境:CentOS6.6 X86_64 # cat /etc/hosts 192.168.199.61 Ansible 192.168.199.60 Nginx1 192.168.199.62 N ...

  3. 9.1 Binder系统_C程序示例_框架分析和编写程序

    IPC : Inter-Process Communication, 进程间通信 A进程把数据原原本本的发给B,这就是IPC RPC : Remote Procedure Call, 远程过程调用 A ...

  4. jQuery插件AjaxFileUpload实现ajax文件上传时老是运行error方法 问题原因

    今天在用jQuery插件AjaxFileUpload实现ajax文件上传时,遇到一个问题,如图: 老是运行error.无法运行succes方法,追踪ajaxfileupload.js源代码发现: wa ...

  5. 学习jquery.pagewalkthroung.js插件记录点

    1.53行:options = $.extend(true, {}, $.fn.pagewalkthrough.defaults, options); $.extend的作用是把第二个对象合并到第一个 ...

  6. STL MAP取消排序

    class MyLess{public: bool operator()(const CString str1,const CString str2)const { return TRUE; }}; ...

  7. Nginx content cache Nginx内容缓存

    原文地址:http://nginx.com/resources/admin-guide/caching/ Nginx content cache Nginx内容缓存 This chapter desc ...

  8. 【u123】最大子段和

    Time Limit: 1 second Memory Limit: 128 MB [问题描述] 给出一段序列,选出其中连续且非空的一段使得这段和最大. [输入格式] 输入文件maxsum1.in的第 ...

  9. [Ramda] Handle Branching Logic with Ramda's Conditional Functions

    When you want to build your logic with small, composable functions you need a functional way to hand ...

  10. c#List泛型数据扩展,把List<>型数据格式化成List<SelectListItem>,用来作dropdownlist的数据

    代码例如以下 public static List<SelectListItem> CreateSelect<T>(this IList<T> t, string ...