I have to use image processing for quality control of a cookie manufacturer (as a part of my project). The program must be able to detect oversized, undersized, distorted cookies, cookies having cracks, etc. I am new to opencv. Can you please suggest which all functions would help me?


Your first task is to collect examples of various defects and narrow the requirements down from "find defective cookies" to "identify these particular precisely-defined categories of defects". You will also want to define allowable failure rates (and how much you prefer false positives vs. false negatives) if you want to have a requirement that can actually be met. Once you have that, you can start designing the optics and lighting you will need to acquire images that highlight the various defects. This might require more than one imaging operation, as different lighting/optical conditions will highlight different features.

Once the above is done, you can start capturing images; once you have images, you can start to explore what vision tools will work for identifying the various defect categories you defined previously. A few thoughts:

  1. Identify cookie shape/size. A back-light is often ideal for this kind of application, but you can sometimes get away with more direct lighting if you have a good even background that is easy to identify. Your first goal is to separate the cookie from the background; next, you can use a tool like Blob Analysis to look at the distribution of the cookie's shape.

  2. Look for cracks. Here you will want to investigate edges. Using the segmented image from above (so you know what part of the image is 'cookie'), you use various edge filters, like the Sobel operator, to identify areas with sharp transitions. You would then want to experiment with various 'normal' and 'cracked' cookies to understand how the edges vary between them. You might be able to look at a threshold for the total intensity of edges in the cookie to classify a defect, but this is something that will require more investigation before you can make a good design decision.

One side note: the process of designing lighting/optics, taking images, designing/implementing algorithms, and testing their results is, in practice, an iterative one. You will learn from your experiments what areas you need to improve and will make adjustments to your earlier imaging system designs to better achieve the results you're after. You will also likely discover new categories of defects or new ways that the system behavior can change that you did not anticipate. A long-term systems approach to this kind of task involves a lot of ongoing monitoring and data gathering to characterize the performance of the system over time. You might find interesting trends like an increase in failures between 1:00 and 3:00 pm, when external light comes through a window and happens to interfere with your processing, for instance.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.