1

我想改进我的专为对象检测而设计的项目。

首先,为了得到我使用的实际结果absdiff,接下来我在下面的代码中使用以下操作:

cv::threshold(subtractionResultEdges, threshold, 0, 255, CV_THRESH_BINARY | CV_THRESH_OTSU);

    Sobel(threshold, sobel, CV_32F, 1, 0);

    minMaxLoc(sobel, &minVal, &maxVal);

    sobel.convertTo(sobel, CV_8U, 255.0 / (maxVal - minVal), -minVal * 255.0 / (maxVal - minVal));

    dilate(subtractionResultEdges, subtractionResultEdges, verticalStructreMat, Point(-1, -1));


    erode(subtractionResultEdges, filteredResult, verticalStructreMat, Point(-1, -1));

    Canny(filteredResult, filteredResult, 33, 100, 3);

我的最后一次手术是findContours(canny_output, *contours, *hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0));

这是我使用accumulate函数(20帧)得到的每个函数和前景后的结果:

前景:http: //j71i.imgup.net/foregroundc3dc.PNG

减法: http: //p81i.imgup.net/subtractio2866.PNG

索贝尔: http: //g51i.imgup.net/sobela1fb.PNG

阈值:http: //p46i.imgup.net/treshold14c9.PNG

扩张、侵蚀和 Canny:

http://q68i.imgup.net/canny2e1a.PNG

findContours:http: //v76i.imgup.net/contours6845.PNG

背景也是从accumulate函数中获得的。

你能帮我获得更好的角落或轮廓检测吗?我需要它,以像素为单位获取对象大小。

提前致谢!

4

1 回答 1

1

对扩张/侵蚀部分使用更大的内核,可能是 (11, 11) 甚至更大,或者进行多次迭代(这可以设置为参数。这应该更好地连接检测到的对象的各个部分,然后你会轮廓较少。

要计算面积,您可以使用contourArea()

于 2015-12-09T07:38:42.073 回答