直接代码

 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. [Angular] Component architecture and Reactive Forms

    It it recommeded that when deals with form component, we can create a container component to hold st ...

  2. [Angular2Fire] Firebase auth (Google, Github)

    To do auth, first you need to go firebase.console.com to enable the auth methods, for example, enabl ...

  3. java 封装解析 Json数据。

    import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; im ...

  4. Java随机验证吗

    <span style="font-size:18px;">package com.java.process.jsp; import java.awt.Color; i ...

  5. JVM调优基础 分类: B1_JAVA 2015-03-14 09:33 250人阅读 评论(0) 收藏

    一.JVM调优基本流程 1.划分应用程序的系统需求优先级 2.选择JVM部署模式:单JVM.多JVM 3.选择JVM运行模式 4.调优应用程序内存使用 5.调优应用程序延迟 6.调优应用程序吞吐量 二 ...

  6. Java 字符转Unicode

    static String unicode2String(String unicodeStr) { StringBuffer sb = new StringBuffer(); String str[] ...

  7. java异常——捕获异常+再次抛出异常与异常链

    [0]README 0.1) 本文描述+源代码均 转自 core java volume 1, 旨在理解 java异常--捕获异常+再次抛出异常与异常链 的相关知识: [1]捕获异常相关 1.1)如果 ...

  8. [Recompose] Lock Props using Recompose -- withProps

    Learn how to use the ‘withProps’ higher order component to pre-fill a prop, unable to be overridden. ...

  9. RocketMQ 安装详细说明

    原文:RocketMQ 安装详细说明 目录 本文导读 环境说明 RocketMQ 下载 从 Apache 下载 从 GitHub 下载 RocketMQ 安装 文件上传 项目解压 编译部署 Rocke ...

  10. [TypeScript] Typescript Interfaces vs Aliases Union & Intersection Types

    TypeScript has 'interface' and 'type', so when to use which? interface hasName { firstName: string; ...