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