Part Alignment Confirmation...

I’m wanting to use openmv to give and GO or NOGO if a part is aligned in a machine. I was looking at the examples in the IDE. Would “Optical Flow” or “Template Matching” work for this? In the comments for “Template Matching” it say that it still doesn’t work correctly.

The camera will will be in a controlled environment and locked down at all times.

any advice or suggestions would be amazing!
thanks all, dan.

I haven’t tested template matching since the v1.8 update. It works a lot better right now but documentation is pending. You’d want to use template matching however. Ibrahim, can you comment in detail on how to use that function?

I don’t think template matching is the best way to go about this, if the part is slightly misaligned it will still match, probably not as much when it’s perfectly aligned, however also keep in mind components may be too homogeneous to detect with templates, think ICs, any black rectangle will match. If you still want to try it, check out the example, use exhaustive search if speed is not a factor, and a step of 1 or 2.

I think a much better approach is to use edge detection, given the controlled environment and the solid color background (the PCB solder mask) you should get good edges. From there you could find lines and then slopes to detect misalignment.

Currently we don’t have a function implemented to find lines, but I may implement something soon.

here is a sample of the part I want to do the alignment on… The shaft will rotate into the proper oration.

Thanks a million for the insight!

Go -

No Go -

Hi Dan,

So, how do you plan to mount the OpenMV Cam? If you have it hooked up in a rig and the part is always in the same place then you can actually just take the color average of a small square area to get if the shaft is looking at you or not. This is very easy:

So, if you known the circle will be in the same place and its dark you’ll know what the response should look like when its aligned. Also, have the OpenMV cam turn a light on per part to fix lighting issues.