opencv 笔记07Core_RND

随机数发生器类 (RNG) 并得到均匀分布的随机数。

RNG:: RNG ( )
RNG:: RNG (uint64  state )

RNG constructors

Parameter: state – the 64-bit value used to initialize the RNG
These are the RNG constructors. The first form sets the state to some pre-defined value, equal to  2**32-1  in the current implementation. The second form sets the state to the specified value. If the user passed  state=0  , the constructor uses the above default value instead, to avoid the singular random number sequence, consisting of all zeros.

unsigned  RNG:: next ( )
Returns the next random number,The method updates the state using MWC algorithm and returns the next 32-bit random number.
int  RNG:: uniform ( int  a , int  b)

Returns the next random number sampled from the uniform distribution

Parameters:
  • a – The lower inclusive boundary of the returned random numbers
  • b – The upper non-inclusive boundary of the returned random numbers
double  RNG:: gaussian (double  sigma )

Returns the next random number sampled from the Gaussian distribution

Parameter: sigma – The standard deviation of the distribution

void  putText ( Mat&  img, const string&  text, Point  org, int  fontFace, double  fontScale, Scalar  color, int  thickness=1, int lineType=8, bool  bottomLeftOrigin=false )

Draws a text string

Parameters:
  • img – The image
  • text – The text string to be drawn
  • org – The bottom-left corner of the text string in the image
  • fontFace –

    The 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 orFONT_HERSHEY_SCRIPT_COMPLEX ,

    where each of the font id’s can be combined with  FONT_HERSHEY_ITALIC to get the slanted letters.
  • fontScale – The font scale factor that is multiplied by the font-specific base size
  • color – The text color
  • thickness – Thickness of the lines used to draw the text
  • lineType – The line type; see line for details
  • bottomLeftOrigin – When true, the image data origin is at the bottom-left corner, otherwise it’s 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);

函数 putText 都做了些什么?在我们的例子中:

  • 在 image 上绘制文字 “Testing text rendering” 。
  • 文字的左下角将用点 org 指定。
  • 字体参数是用一个在 [0, 8> 之间的整数来定义。
  • 字体的缩放比例是用表达式 rng.uniform(0, 100)x0.05 + 0.1 指定(表示它的范围是 [0.1, 5.1>)。
  • 字体的颜色是随机的 (记为 randomColor(rng))。
  • 字体的粗细范围是从 1 到 10, 表示为 rng.uniform(1,10) 。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值