//在二维数据中,将点阵包围的区域填充,并返回区域内所有点位置
void getRegionPoint(int size[2], std::vector<cv::Point> edge, std::vector<cv::Point> &outResult)
{
cv::Mat mat = cv::Mat::zeros(size[1], size[0], CV_8UC1);
std::vector<std::vector<cv::Point>> contours;
contours.push_back(edge);
cv::drawContours(mat, contours, -1, cv::Scalar(255), CV_FILLED);
unsigned char *p = mat.data;
for(int y = 0; y < size[1]; y++)
{
for(int x = 0; x < size[0]; x++)
{
long long offset = y * size[0] + x;
if(*(p+offset) > 0)
{
outResult.push_back(cv::Point(x, y));
}
}
}
}