Identify object on a conveyor belt
Hello! I'm thinking of trying out openCV for my robot.
I want the program to be able to identify the metal parts on a conveyor belt that are single ones, and not the ones lying in clusters.
I will buy a raspberry pie with the raspberry pie camera module(is this a good idea for this project?).
I want the program to return the X-Y coordinate(or position of the pixel on the image) on a specific place on the metal part(so that the robot can lift it where it is supposed to be lifted). I would also want the program to have a adjustable degree of freedom of the orientation(rotation) of the single metal part to be localized.
Where do I even start?
A simple drawing of the robot
An image of what the images could look like the program will process(have not bought the final camera yet and lighting).
Here is the metal part I want to pick up from the conveyor belt.
Binarize the image with color or greyscale thresholding and then do a
cv::findContours()
. Loop through contours filtering by contour size. For those contours within the accepted size bounds, compare moments, either Hu or Flusser, to the canonical item, maybe using Mahalnobis distance for a conscious false negative rate.Thank you! I will start with your advice! Will I need to put a glare filter on the camera lens? Is raspberry pi camera module a good choice?
Try to make your lighting more diffuse, there will be much less glare if there is ambient light and not a point light source. A single color highly saturated background would likely help as well, in which case you could try HSV thresholding.
I'm getting really close now!
I've changed the background to a bright orange.
My code is as follows:
-Take an image -Convert image from BGR to HSV -Threshold the image to filter out the orange -FindContours -Filter out the contours that doesnt match my wanted area. -Process the Moments and HuMoments of the contours that are left -Calculate the centroid from the Moments -Draw the contours and centroid in the original image
In the image I have 2 objects that are with their faces down and 2 object are face up. I only want the program to recognize the 2 object faced upwards. Im trying to print the Moments and HuMoments Array but dont know how to filter out values so that the face-down ones will be filtered out?
area_min=3000 area_max=4000
Resulting image: link text
The returned moments values are too long to attach. And also the HuMoments values.
The sign of the final Hu moment can discriminate mirror images of contours (face-down vs. face-up in your case). Also, have a look at
cv::Mahalanobis()
for obtaining a probability (0-1) that a contour belongs to canonical class.