zoukankan      html  css  js  c++  java
  • OpenCV入门:(七:OpenCV取随机数以及显示文字)

    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.结束

  • 相关阅读:
    centos 安装 TortoiseSVN svn 客户端
    linux 定时任务 日志记录
    centos6.5 安装PHP7.0支持nginx
    linux root 用户 定时任务添加
    composer 一些使用说明
    laravel cookie写入
    laravel composer 安装指定版本以及基本的配置
    mysql 删除重复记录语句
    linux php redis 扩展安装
    linux php 安装 memcache 扩展
  • 原文地址:https://www.cnblogs.com/Reyzal/p/5033701.html
Copyright © 2011-2022 走看看