Ask Your Question
1

Defect detection on metal Object

asked 2017-12-18 14:01:04 -0600

AP108 gravatar image

updated 2017-12-18 15:42:10 -0600

Hello, As a part of a project, I have to decide if a metal object has acceptable quality or not.

image description

So based on a reference image like this one (acceptable object quality) I need to be able to detect possible defects on other images. These may be some big bumps on the flat surface, or broken rims/edges on the circular parts or ''teeth''. For example, injured rim at the picture below

image description

Or missing parts like this

image description image description

Since I know what an acceptable state is, my first attemt was to combine edge detection and template matching on specific ROIs and not on the whole image. Though I haven't tested Haussdorf distance as mentioned on another post link text, using opencv's matchTemplate isn't giving so good results.

To sum up, for a 'generic' approach to such a problem, Haussdorf distance is my only hope? If this doesn't work, the next step is to examine every 'feature'(ROI, cicles or teeth) individually with something like shape signature methods, that i have read in bibliography?

Sorry for being so general but don't know how to tackle such a problem

edit retag flag offensive close merge delete

Comments

please try again with your image, it's probably much helpful

(there's an "upload image" button, if you edit your question)

(also, what you "want to achieve" , is kinda missing)

berak gravatar imageberak ( 2017-12-18 14:05:06 -0600 )edit

hausdorff distance helps to compare contours of different size for similarity. is that your problem, even ?

berak gravatar imageberak ( 2017-12-18 14:45:09 -0600 )edit

Well, my goal is having two images, one of reference part and one of to be tested, in one way to determine if they match(no defects detected). My thought so far, was to crop ROIs, extract the edges and use Template matching with no particular success

AP108 gravatar imageAP108 ( 2017-12-18 14:53:47 -0600 )edit

so we need another image of something defective ?

berak gravatar imageberak ( 2017-12-18 14:55:42 -0600 )edit

yes, let's say a misformed(or missing) tooth from the row on the right or not a good rim because of a hit or something

AP108 gravatar imageAP108 ( 2017-12-18 14:56:26 -0600 )edit

no, it might just need adding an image of a defective part above.

(it is still about understanding your problem)

berak gravatar imageberak ( 2017-12-18 14:59:16 -0600 )edit
1

Can you guarantee that the image will always consist of the same distance and orientation of the metal part? Can you guarantee that there will always be the same lighting? Can you guarantee that the metal will always be the same colour?

If so, you could call absdiff() to do a comparison between the master image (the one without flaws) and the current image (the one that might have flaws). Any difference between the two images will be detected and shown in grey. It's super simple, if only you make some guarantees that make life simple for the computer. The more guarantees that you make, the better.

sjhalayka gravatar imagesjhalayka ( 2017-12-18 18:37:36 -0600 )edit

Here's some code that calls absdiff():

#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world331.lib")

#include <iostream>
using namespace std;


int main(void)
{
    Mat master = imread("master.png");
    Mat current = imread("current.png");

    if (master.empty() || current.empty())
    {
        cout << "Read error" << endl;
        return -1;
    }

    Mat a;

    absdiff(master, current, a);

    imshow("a", a);

    waitKey();

    return 0;
}
sjhalayka gravatar imagesjhalayka ( 2017-12-18 19:10:35 -0600 )edit

Here's the code in Python:

import numpy as np
import cv2
import sys

master = cv2.imread("master.png")
current = cv2.imread("current.png")

if master is None or current is None:
    exit()

a = cv2.absdiff(master, current)

cv2.imshow("a", a)

cv2.waitKey()
sjhalayka gravatar imagesjhalayka ( 2017-12-18 19:51:28 -0600 )edit
1

Thank you very much for your answer. Yes, the distance and orientation of the part is supposed to be the same for each part and so is the lighting as much as possible.The colour of the metal will be the same, but we cannot say the same thing for the surface quality which possible differences between two parts may be due to real defects or lighting conditions.

AP108 gravatar imageAP108 ( 2017-12-19 04:52:08 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-12-19 00:05:32 -0600

VxW gravatar image

Hi,

my experience is that a reliable system with repeatable detection is not possible using such a setup, because of the high complexity of the parts in terms of geometry, surface, reflections, harsh environments, oil stains, influence of ambient light, etc. (see also answer of @sjhalayka). In the end you will need a 3D setup like laser triangulation or structured light system, which makes or life easier. However, it's a good learning example to get familar with image processsing algorithms.

edit flag offensive delete link more

Comments

Well that's what I suspected, too. At the end, I may have to narrow it down to specific defects at specific regions.

AP108 gravatar imageAP108 ( 2017-12-19 05:06:55 -0600 )edit

Have you solved the problem? I am solving a similar problem

Mrunal gravatar imageMrunal ( 2020-08-28 06:34:53 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-12-18 14:01:04 -0600

Seen: 3,724 times

Last updated: Dec 19 '17