OpenCV入門 文書處理

2021-09-26 06:41:17 字數 3040 閱讀 7909

rng(uint64 state):產生隨機數,state:起始隨機資料的64位值size gettextsize(const string& text, int fontface, double fontscale, int thickness, int baseline):計算文字串的長和寬*

text:輸入的文字串

fontface:字型;此字型將用於puttext()函式

fontscale:字型大小;與puttext相同

thickness:字型筆畫粗細;與puttext相同

baseline:文字底線的y座標

此函式用於算出文字用引數的字型,與筆畫粗細所涵蓋的方形區塊

puttext(mat& img, const string& text, point org, int fontface, double fontscale, scalar color, int thickness, int linetype, bool bottomleftorigin):在影象中繪製文字字串目前opencv還不支援中文

#include#include#include#include#includeusing namespace cv;

//宣告全域性變數

const int number = 100;

const int delay = 5;

const int window_width = 900;

const int window_height = 600;

int x_1 = -window_width / 2;

int x_2 = window_width * 3 / 2;

int y_1 = -window_width / 2;

int y_2 = -window_width * 3 / 2;

//宣告函式

static scalar randomcolor(rng& rng); //產生隨機顏色

int drawing_random_line(mat image, char* window_name, rng rng); //繪製直線

int drawing_random_rectangles(mat image, char* window_name, rng rng); //繪製長方形

int drawing_random_ellipses(mat image, char* window_name, rng rng); //繪製橢圓

int drawing_random_polylines(mat image, char* window_name, rng rng); //繪製多邊形(plotlines)

int drawing_random_filled_polygons(mat image, char* window_name, rng rng); //繪製多邊形

int drawing_random_circles(mat image, char* window_name, rng rng); //繪製圓

int displaying_random_text(mat image, char* window_name, rng rng); //繪製文字

int displaying_big_end(mat image, char* window_name, rng rng); //文字測試,是否可以顯示中文

int main(void)

//定義函式

//產生隨機顏色

static scalar randomcolor(rng &rng)

//繪製直線

int drawing_random_line(mat image, char* window_name, rng rng)

return 0;

} //繪製長方形

int drawing_random_rectangles(mat image, char* window_name, rng rng)

return 0;

}int drawing_random_ellipses(mat image, char* window_name, rng rng)

return 0;

}//繪製多邊形(polylines)

int drawing_random_polylines(mat image, char* window_name, rng rng)

; int npt = ;

polylines(image, ppt, npt, 2, true, randomcolor(rng), rng.uniform(1, 10), linetype);

imshow(window_name, image);

if (waitkey(delay) >= 0)

return -1;

} return 0;

}//繪製多邊形

int drawing_random_filled_polygons(mat image, char* window_name, rng rng)

; int npt = ;

fillpoly(image, ppt, npt, 2, randomcolor(rng), linetype);

imshow(window_name, image);

if (waitkey(delay) >= 0)

return -1;

} return 0;

}//繪製圓

int drawing_random_circles(mat image, char* window_name, rng rng)

return 0;

}//繪製文字

int displaying_random_text(mat image, char* window_name, rng rng)

return 0;

}//測試是否可以顯示中文

int displaying_big_end(mat image, char* window_name, rng rng)

return 0;

}

css3 文書處理

text overflow ellipsis 超出的文字顯示.前提是該盒子必須有overflow hidden 屬性 text shadow 文字陰影 direction 控制文字方向,值有down inherit initial left ltr left to right right rtl u...

文書處理的標籤及屬性

1.標題標籤成對出現 align對齊屬性,屬性值right,left,center 2.段落標籤成對出現 align對齊屬性,屬性值right,left,center 3.換行標籤 單標籤4.水平標籤 單標籤 顯示一條水平線,屬性值 粗細size,寬度width,對齊方式align,顏色color,...

文書處理技術 複雜的行寬計算

下決心重寫行布局,也不能盲目行動。原來的布局有很多細節上的問題,總體上依然是非常好的,功能夠強大,所有要考慮的元素都考慮了。所以吾又採取了老套路 新舊並行 把老的 逐步改造為新的 新 寫好了,功能跟老 一樣,當然在流程上 細節上好很多。然後吾就不得不硬著頭皮看壓縮部分 實在是 夠複雜。於是,對之前那...