1 使用RotatedRect minAreaRect(InputArray points)獲取這個旋轉矩形
2 將其四角存到某vector<Point>裏面,變成壹個輪廓,怎麽獲取四角?參見http://docs.opencv.org/modules/core/doc/basic_structures.html?highlight=rotatedrect#RotatedRect
妳壹定能搞出來。
3 然後遍歷內部那個輪廓的各個點,然後使用pointPolygonTest這個opencv函數確定此點與四邊形的距離。
4 要註意的是因為點在輪廓內部,所獲距離為負數。