1.随机颜色

OpenCV中自带了取随机数的方法,使用步骤:

RNG rng( 0xFFFFFFFF );
随机数 = rng.uniform( 下限,上限 );

2.显示文字

void putText(Mat& img, const string& text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=8, bool bottomLeftOrigin=false )
img – Image.
text – Text string to be drawn.
org – Bottom-left corner of the text string in the image.
font – CvFont structure initialized using InitFont().
fontFace – Font type. One of FONT_HERSHEY_SIMPLEX, FONT_HERSHEY_PLAIN, FONT_HERSHEY_DUPLEX, FONT_HERSHEY_COMPLEX, FONT_HERSHEY_TRIPLEX, FONT_HERSHEY_COMPLEX_SMALL, FONT_HERSHEY_SCRIPT_SIMPLEX, or FONT_HERSHEY_SCRIPT_COMPLEX, where each of the font ID’s can be combined with FONT_ITALIC to get the slanted letters.
fontScale – Font scale factor that is multiplied by the font-specific base size.
color – Text color.
thickness – Thickness of the lines used to draw a text.
lineType – Line type. See the line for details.
bottomLeftOrigin – When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner.

使用方法:

putText( image, "Testing text rendering", org, rng.uniform(0,8),
rng.uniform(0,100)*0.05+0.1, randomColor(rng), rng.uniform(1, 10), lineType);

3.结束

最新文章

  1. 工作中那些提高你效率的神器(第一篇)_Everything
  2. Android中Listview点击item不变颜色以及设置listselector 无效
  3. 监控阮一峰老师的blog
  4. checkbox点击后出现div
  5. openstackM版本常见问题汇总
  6. 使用Jquery+EasyUI 进行框架项目开发案例讲解之五 模块(菜单)管理源码分享
  7. 夺命雷公狗---微信开发53----网页授权(oauth2.0)获取用户基本信息接口(3)实现世界留言版
  8. Matlab与C/C++联合编程之Matlab以MEX方式调用C/C++代码(三)
  9. 关于帝国cms 列表页SEO优化的问题
  10. MSSQL 各个发行版本版本号以及Compact 版本号
  11. Intellij 快捷键大全
  12. Android动态加载jar、apk的实现
  13. poj1655 Balancing Act 找树的重心
  14. Lucene搜索引擎+HDFS+MR完成垂直搜索
  15. Headless Chrome:服务端渲染JS站点的一个方案【中篇】【翻译】
  16. Jq写个联级菜单
  17. springboot拦截器中获取配置文件值
  18. Groovy 反射字符串常量方法
  19. blog迁移
  20. css基础之line-height

热门文章

  1. 【[JLOI2014]松鼠的新家】
  2. POJ1990 MooFest
  3. 常用PowerShell命令
  4. Doubly Linked List
  5. 【转】Java虚拟机类型卸载和类型更新解析
  6. Win7下运行VC程序UAC权限问题 VC2010设置UAC权限方法
  7. ProjectOnline同步数据到线下
  8. oracle日常监控语句
  9. [SDOI2008]仪仗队(欧拉筛裸题)
  10. Windows获取物理内存的2种方式 - 随笔记录