OpenCV入门:(七:OpenCV取随机数以及显示文字)
2015-12-09 18:05
411 查看
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.结束
相关文章推荐
- Hbase常用的shell命令
- 多线程之 NSOperation
- RedHat7配置Nginx实现多域名虚拟主机的SSL/TLS认证(实现单IP以不同证书服务于不同域名)
- linux内核源码树构建
- hadoop实战应用
- linux shell脚本查找重复行/查找非重复行/去除重复行/重复行统计
- Nginx 安装
- 安装Tomcat指定JDK ——转
- Centos 安装后不能上网 解决备忘
- linux I2c设备注册
- Hadoop 参数配置优化
- Linux系统复制U盘文件
- CentOS6.5编译安装CodeBlocks13.12
- PopupWindow显示showAsDropDown和showAtLocation区别
- 如何在tomcat启动的时候运行一个Java类
- 【openjudge】分成互质组
- Linux C 编程技巧--利用有限状态机模型编程
- linux应用编程笔记(15)消息队列编程
- POP-一个点击带有放大还原的动画效果
- Hadoop YARN配置参数剖析(1)—RM与NM相关参数