contourArea计算的是什么面积
答案:2 悬赏:80 手机版
解决时间 2021-04-24 05:07
- 提问者网友:斑駁影
- 2021-04-23 05:51
contourArea计算的是什么面积
最佳答案
- 五星知识达人网友:英雄的欲望
- 2021-04-23 06:33
/边缘检测
Canny(gray, canny_output, 15, 30, 3);
//寻找轮廓
findContours(canny_output, g_Contours, Hierarchy, RETR_EXTERNAL, CHAIN_APPROX_NONE, Point(0, 0));
//计算矩
vector mu(g_Contours.size());
for(unsigned int i = 0; i
{
mu[i] = moments(g_Contours[i], false);
}
//计算中心矩
vector mc(g_Contours.size());
for (unsigned int i = 0; i
{
mc[i] = Point2f(static_cast(mu[i].m10/mu[i].m00), static_cast(mu[i].m01 / mu[i].m00));
}
//绘制轮廓
Mat drawing = Mat::zeros(canny_output.size(), CV_8UC3);
Area = 0;
for (unsigned int i = 0; i < g_Contours.size(); i++)
{
drawContours(drawing, g_Contours, i, 255, 2, 8, Hierarchy, 0, Point());
//绘制圆
circle(drawing, mc[i], 4, 255, -1, 8, 0);
Area = Area + contourArea(g_Contours[i]);
}
resize(drawing, drawing, Size(drawing.cols / 2, drawing.rows / 2), (0, 0), (0, 0), 3);
imshow(window_name2, drawing);
printf("计算出的轮廓面积:m00=%0.2f\n", Area);
Canny(gray, canny_output, 15, 30, 3);
//寻找轮廓
findContours(canny_output, g_Contours, Hierarchy, RETR_EXTERNAL, CHAIN_APPROX_NONE, Point(0, 0));
//计算矩
vector
for(unsigned int i = 0; i
mu[i] = moments(g_Contours[i], false);
}
//计算中心矩
vector
for (unsigned int i = 0; i
mc[i] = Point2f(static_cast
}
//绘制轮廓
Mat drawing = Mat::zeros(canny_output.size(), CV_8UC3);
Area = 0;
for (unsigned int i = 0; i < g_Contours.size(); i++)
{
drawContours(drawing, g_Contours, i, 255, 2, 8, Hierarchy, 0, Point());
//绘制圆
circle(drawing, mc[i], 4, 255, -1, 8, 0);
Area = Area + contourArea(g_Contours[i]);
}
resize(drawing, drawing, Size(drawing.cols / 2, drawing.rows / 2), (0, 0), (0, 0), 3);
imshow(window_name2, drawing);
printf("计算出的轮廓面积:m00=%0.2f\n", Area);
全部回答
- 1楼网友:平生事
- 2021-04-23 07:11
区域铣削在区域铣削驱动里更改
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯