您的位置:首页 > 运维架构

opencv 笔记07Core_RND

2013-04-10 17:41 211 查看
随机数发生器类 (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 t
c4d9
he 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, intlineType=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 指定。
字体参数是用一个在 

 之间的整数来定义。
字体的缩放比例是用表达式 rng.uniform(0, 100)x0.05 + 0.1 指定(表示它的范围是 

)。
字体的颜色是随机的 (记为 randomColor(rng))。
字体的粗细范围是从 1 到 10, 表示为 rng.uniform(1,10) 。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  OpenCV core