B.Kosmowski
B.Kosmowski

Reputation: 143

How to improve object detection?

I want to improve my project which is designed for object detection.

Firstly, to get my actual result I use absdiff, and next I use the following operations are in my code below:

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);

My last operation is findContours(canny_output, *contours, *hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0));

This is my result after use every function and foreground which I get with using accumulate function (20 frames) :

foreground: http://j71i.imgup.net/foregroundc3dc.PNG

subtraction: http://p81i.imgup.net/subtractio2866.PNG

Sobel: http://g51i.imgup.net/sobela1fb.PNG

threshold: http://p46i.imgup.net/treshold14c9.PNG

dilate, erode and Canny:

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

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

Background is also obtained from accumulate function.

Could you help me get better corner or contours detection? I need it, to get object size in pixels.

Thanks in advance!

Upvotes: 1

Views: 673

Answers (1)

mirosval
mirosval

Reputation: 6822

Use a larger kernel for dilate/erode part, maybe (11, 11) or even bigger, or alternatively do multiple iterations (this can be set as a parameter. This should connect the individual parts of your detected object better and then you'll have less contours.

To calculate area, you can then use contourArea()

Upvotes: 1

Related Questions