OpenCV4探索學習 輪廓

2021-09-26 07:16:44 字數 1134 閱讀 4693

輪廓提取:findcontours

void findcontours//提取輪廓,用於提取影象的輪廓

( inputoutputarray image,//輸入影象,必須是8位單通道影象,並且應該轉化成二值的

outputarrayofarrays contours,//檢測到的輪廓,每個輪廓被表示成乙個point向量

outputarray hierarchy,//可選的輸出向量,包含影象的拓撲資訊。其中元素的個數和檢測到的輪廓的數量相等

int mode,//說明需要的輪廓型別和希望的返回值方式

int method,//輪廓近似方法

point offset = point()

)

輪廓繪製:drawcontours

void drawcontours//繪製輪廓,用於繪製找到的影象輪廓

(  inputoutputarray image,//要繪製輪廓的影象

inputarrayofarrays contours,//所有輸入的輪廓,每個輪廓被儲存成乙個point向量

int contouridx,//指定要繪製輪廓的編號,如果是負數,則繪製所有的輪廓

const scalar& color,//繪製輪廓所用的顏色

int thickness = 1, //繪製輪廓的線的粗細,如果是負數,則輪廓內部被填充

int linetype = 8, /繪製輪廓的線的連通性

inputarray hierarchy = noarray(),//關於層級的可選引數,只有繪製部分輪廓時才會用到

int maxlevel = int_max,//繪製輪廓的最高端別,這個引數只有hierarchy有效的時候才有效

//maxlevel=0,繪製與輸入輪廓屬於同一等級的所有輪廓即輸入輪廓和與其相鄰的輪廓

//maxlevel=1, 繪製與輸入輪廓同一等級的所有輪廓與其子節點。

//maxlevel=2,繪製與輸入輪廓同一等級的所有輪廓與其子節點以及子節點的子節點

point offset = point()

)

輪廓最小外接矩形:minarearect

水平外接矩形:boundingrect

參考:參考:

OpenCV4探索學習 基礎功能與技巧

mat imagesrc imread 1.png 0 mat imagedst imagesrc 僅是建立了mat的頭部分,共享資料區 mat imagedst imagesrc 僅是建立了mat的頭部分,共享資料區 mat imagedst imagesrc.clone 完全拷貝,把images...

Ubuntu原始碼編譯安裝opencv4 x

進入解壓後原始碼目錄 mkdir build cd build cmake make j4 make installpkg config cflags opencv 檢測是否正常安裝報錯 package opencv was not found in the pkg config search pa...

ubuntu18 04安裝opencv4及使用

這些錯誤可以通過ide跳轉至定義位置解決 1.error cv gray2rgb was not declared in this scope include 2.error cv adaptive thresh mean c was not declared in this scope inclu...