Ask Your Question
1

Detecting dent in pipelines

asked 2015-07-09 13:13:31 -0600

nagar92 gravatar image

updated 2015-07-09 15:10:10 -0600

I am doing dent detection for underwater pipeline through image processing(python), a very basic one. As can be seen in the following image i am doing continuous evaluation of the pipe. This is the pipeline without any dent image description

As the system will move forward it will check the pipe continuously and if there is a dent it has to identify it. As shown below(Marked with paint)

image description

After the process is stopped it has to tell if there is any dents. (No need of the number of dents just the text "Dents" or "No Dents"). Now the problem is I cant figure out a way to identify the dent (marked in green). Can anyone help me with this ??

Thank you in advance

edit retag flag offensive close merge delete

Comments

2

may be you can

  1. look for contour
  2. find coordinate left top point A and left bottom point B
  3. if distance(A,B)+threshold < length(contour) there is problem
  4. locate problem using distance from line AB to shape

before you can filter your binary image using opening or closing

LBerger gravatar imageLBerger ( 2015-07-09 14:39:05 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2015-07-09 18:11:16 -0600

champloo11 gravatar image

Method

Extending LBerger's comment, you will definitely be looking to us a contour of some kind. OpenCV has a function that calculates the "convexity defects" of a contour and its context hull, and it gives you a struct with all the pertinent information. You can find more documentation here:

http://docs.opencv.org/modules/imgpro...

Convexity Defect Struct

struct CvConvexityDefect
{
   CvPoint* start; // point of the contour where the defect begins
   CvPoint* end; // point of the contour where the defect ends
   CvPoint* depth_point; // the farthest from the convex hull point within the defect
   float depth; // distance between the farthest point and the convex hull
};

Locating a Dent With the Struct

You can compare the "depth" variable against a threshold. If it's greater than this threshold, you'll consider that defect a "dent". Example Code:

if(defect.depth > threshold):
 // You've found a dent here.
else:
 // This wasn't a dent

Marking It

Using the "start" and "end" point, you can draw rectangle/circle/ellipse that fits these two points.

edit flag offensive delete link more

Comments

2

Ow harsh to see that current documentation still contains OLD C-API code. Lets fix this!

StevenPuttemans gravatar imageStevenPuttemans ( 2015-07-10 03:35:12 -0600 )edit
0

answered 2015-07-09 20:51:45 -0600

you can find biggest contour and analyze it with Contour Approximation here my sample code that you can adopt it to python

#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>

using namespace cv;
using namespace std;

static bool analyzeImage( const Mat& image )
{

    Mat gray,gray0;

    vector<vector<Point> > contours;

    cvtColor(image,gray0,COLOR_BGR2GRAY);

    gray=gray0 > 10 ;

    // find contours and store them all as a list
    findContours(gray, contours, RETR_LIST, CHAIN_APPROX_SIMPLE);

    for( size_t i = 0; i < contours.size(); i++ )
    {

        approxPolyDP(Mat(contours[i]), contours[i], 5, true);

        if( fabs(contourArea(Mat(contours[i]))) > image.rows*image.cols/3 )
        {
            Scalar color;
            String Message;
            if( contours[i].size() >5) // here we test if the biggest contour have 4 or more corner
            {
                color = Scalar(255,127,0);
                Message = "Dents"  ;
            }

            else
            {
                color = Scalar(0,255,0);
                Message = "No Dents"  ;
            }

            drawContours( image,contours,i, color ,2 );
            putText(image, Message, Point(image.cols/5,image.rows/2),FONT_HERSHEY_PLAIN, 2.5, CV_RGB(255,255,255), 2.0);
            imshow("image",image);
            waitKey();
            return true;
        }


    }
    return false;
}

int main( int argc, char** argv )
{

    Mat image = imread(argv[1], 1);
    if( image.empty() )
    {
        cout <<  "Could not open or find the image" << endl ;
        return -1;
    }

    if( !analyzeImage(image) );
    {
        cout <<  "Could not find any result" << endl ;
        return -1;
    }

    return 0;
}

results

image description

image description

edit flag offensive delete link more

Comments

3

This will not work, since a slight deviation of the border will result in an extra corner and a dents warning being fired... this is very tricky with hardcoded thresholds...

StevenPuttemans gravatar imageStevenPuttemans ( 2015-07-10 03:33:32 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-07-09 13:13:31 -0600

Seen: 1,877 times

Last updated: Jul 09 '15