Search code examples
pythonopencvdeep-learningconv-neural-networkobject-detection

Detection model for metallic elements


I am new to image processing and learned only the basics from my studies. I have the following questions:

  1. Is it possible to create a CNN model to detect the scratches, pinholes, etc. in a metallic object?
  2. Are there already any solution for it or does it need to be done manually for a desired project? The scratches can be so small that they are barely visible by human eye. So, will the CNN model be a right choice or will it need to much calculations for a computer to handle?
  3. How to set proper lighting condition to reduce reflection and maybe flatten the object?

I am searching whole internet for any available solution. I've read multiple articles about this topic and finally decided that the only option is to use neural network, because the scratch sizes and positions can be infinity, so the hard-coded algorithm can be wrong in most situations.

As I said, I'm not experienced, but I have time to learn right now and it will be awesome to gain new experience and knowledge.

Hope someone has the idea what steps I need to take in order to get the desired effect.

Actually, I had just the sample code using Python and Opencv to preprocess the image, get the shape of the object and highlight the dark field on it. But it all depends on the proper lighting, so the pinholes are not exactly of the same color.

Below are the photo of my try to set the light properly.

Unpolished material


Solution

  • It seems that you have multiple questions and you are a bit out of clue to decide from where to begin. I have narrowed down 3 questions which I'll try to answer one by one:

    1. As Hissaan already mentioned, it is possible to create your own neural network to detect your object of interest. You would need to have a labelled dataset to train your model.
    2. There are off-the-shelf object detectors such as YOLO, MaskRCNN etc. that you can use but they don't always work well for specific tasks. You would get better performance by fine-tuning them with your custom dataset. For starters, you can look at this implementation from Roboflow on how to train a YOLOv8 using a custom dataset. This would get you some ideas for labelling your dataset and fine-tuning a pre-trained model. You can also check this article which implements both MaskRCNN and YOLOv5 for a vehicle scratch detection project.
    3. There is no single general technique to manipulate the light intensity in an image. You need to apply the techniques however it may seem fit for your problem. You can check this link to get a basic idea.