The CCD 10 is connected with the image adapter card 20, and mainly includes a focusing which has a fixed capture spectrum. The CCD 10 is configured for capturing images of the workpiece 3 by utilizing the focusing. If the fixed capture spectrum is less than a size of the workpiece 3, the work platform 12 needs to be moved by the x-axis motor 14 and the y-axis motor 16 that are driven by the motion control adapter card 21, so that the CCD 10 can capture other parts of the workpiece 3 horizontally. The z-axis motor 18 is configured for controlling the CCD 10 to move in vertical direction. For example, the z-axis motor 18 controls the focusing to focus on the workpiece 3.
The image obtaining unit 22 is configured for obtaining the image of the workpiece 3 from the image adapter card 20 when the CCD 10 captures the workpiece 3,
The image processing unit 25 is configured for calculating the division value of the obtained image, and executing an image sharpness process and the image binarization process based on the division value. An example of a schematic diagram of the processed image is depicted in
The edge extracting unit 26 is configured for extracting an outline of the processed image according to a designated point(see point “A” in
The image edge scan unit 27 is configured for calculating a normal vector and a tangent vector of each of the edge points, calculating coordinates of an initial point and an end point of each of the scan lines according to the parameters and the normal vector, searching all the edge points accurately as scanned points according to the scan lines, and scanning the edges of the workpiece 3 based on the scanned points.
The scan line calculating module 270 is configured for calculating the normal vector and the tangent vector for each of the edge points, calculating coordinates of an initial point and an end point of each of the scan line according to the scan line length and the normal vector of the edge point. In the preferred embodiment, the image of the workpiece 3 is two-dimensional and mapped with the x-axis and y-axis, the user can set an edge point collection Pi (Xi, Yi) (i=1˜N), sets a linear equation “y=ax+b”, and obtains an objective function by utilizing a least square method. The objective function is
the user solves the two functions, and obtains two parameters:
if the linear equation “y=ax+b” covers the point (0, b, 0), the user can obtain a unit vector (l, m, n) of the tangent vector,
a unit vector (I, J, K) of the normal vector,
Although the edge extracting unit 26 searches the other edge points on the outline of the processed image by utilizing the recursive method, there may be some errors. Therefore, the edge scan module 272 needs to search the edge points accurately as scanned points according to the initial points and the end points, and scan the edges of the workpiece 3 based on the scanned points. For example, if the parameter for drawing scan lines is set, the scan line calculating module 270 draws the scan lines in the obtained image (see in
The detecting unit 24 is further configured for detecting whether each of the scanned points is within the obtained image, and for detecting whether all the scanned points collectively form a closed edge path.
If any of the scanned points is not within the obtained image or all of the scanned points collectively form an open edge path, the edge scan module 272 prompts a message that the work platform 12 needs to be moved with the x-axis motor 14 and the y-axis motor 16 via the motion control adapter card 21.
The calculating unit 28 is configured for calculating a move distance of the work platform 12 and determining the move direction of the work platform 12. The CCD 10 captures other parts of the workpiece 3 according to the move distance and move direction. In the preferred embodiment, the move distance of the work platform 12 is half of the capture spectrum of the CCD 10. For example, if a pixel size is 0.02 millimeters, the capture spectrum of the CCD 10 is 640*480 pixels, the move distance of the work platform 12 is 320×240 pixels, namely, the work platform 12 moves 320*0.02 millimeters in the x-axis and moves 240*0.02 millimeters in the y-axis. The move direction of the work platform 12 is determined according to the tangent vector.
The storing unit 29 is configured for storing coordinates of all the scanned points in a file of the computer 2.
In step S2, the detecting unit 24 detects whether the parameters are valid. For example, if the scan line length has a negative value, it is invalid.
In step S3, if any of the parameters are invalid, the detecting unit 24 prompts the user, and the procedure returns to step S1.
In step S4, if the parameters are valid, the motion control adapter card 21 controls the movement of the z-axis motor 18, and the CCD 10 focuses on the workpiece 3.
In step S5, the image obtaining unit 22 obtains the image of the workpiece 3 from the image adapter card 20 in the capture spectrum when the CCD 10 captures the workpiece 3.
In step S6, the image processing unit 25 calculates the division value of the obtained image, and processes the obtained image based on the division value. The image process includes the image sharpness process and the image binarization process.
In step S7, the user designates a point in the processed image, the edge extracting unit 26 searches the edge point that is adjacent to the designated point in the clockwise direction or the counter-clockwise direction, and searches the other edge points by utilizing the recursive method, the image edge scan unit 27 searches all the edge points accurately in
In step S8, the detecting unit 24 detects whether all the scanned points are within the obtained image.
If any scanned point is not within the obtained image, in step S9, the calculating unit 28 calculates the move distance of the work platform 12 and determines the move direction of the work platform 12, in order to capture the next image of the workpiece 3, and the procedure returns to step S4.
If the scanned points are within the obtained image, in step S10, the detecting unit 24 detects whether all the scanned points collectively form the closed edge path.
If the scanned points form the open edge path, the procedure returns to step S9; otherwise, if all the scanned points collectively form the closed edge path, in step S11, the user uses the storing unit 29 to store the coordinates of all the scanned points in the file.
In step S702, the detecting unit 24 detects whether the designated point is the first edge point. That is, the detecting unit 24 detects whether there is at least one point adjacent to the designated point, whose color is different with the designated point.
If the point is not the first edge point, in step S703, the extracting unit 26 searches the first edge point near the designated point in the clockwise direction, and the procedure directly goes to step S704.
If the point is the first edge point, in step S704, the edge extracting unit 26 searches the next edge point in one direction of the clockwise direction, for example, the edge extracting unit 26 searches the next edge point at the right of the first edge point.
In step S705, the detecting unit 24 detects whether there is one edge point that has been found in the direction.
If there is one edge point that has been found, the procedure returns to step S704, and the edge extracting unit 26 continues to search the edge points in the direction; If there is no edge points that have been found, in step S706, the edge extracting unit 26 considers the last edge point that has been found in the direction as an original point, so as to search the edge points in the second direction of the clockwise direction.
For example, the edge extracting unit 26 can search edge points on the right of the first edge point point-to-point until that there are no edge points to be found; consider the last right edge point that has been found as the original point, in order to search edge points under the last right edge point until there are no edge points to be found; search edge points at the left of the last found edge point until that there are no edge points to be found; and search edge points above the last left edge point until that there are no edge points to be found.
In step S707, the edge extracting unit 26 extracts the outline of the processed image according to all the searched edge point, the scan line calculating module 270 calculates the normal vectors for each edge point, and calculates the initial point and the end point of each of the scan line on the outline according to the scan line length and the corresponding normal vector.
In step S708, the edge scan module 272 searches all the initial points and end points in the obtained image (see in
Alternatively, in the preferred embodiment, the edge extracting unit 26 can also search the edge points along the counter-clockwise direction.
It should be emphasized that the above-described embodiments of the present invention, particularly, any “preferred” embodiments, are merely possible examples of implementations, merely set forth for a clear understanding of the principles of the invention. Many variations and modifications may be made to the above-described embodiment(s) of the invention without departing substantially from the spirit and principles of the invention. All such modifications and variations are intended to be included herein within the scope of this disclosure and the present invention and protected by the following claims.
Number | Date | Country | Kind |
---|---|---|---|
200610062038.7 | Aug 2006 | CN | national |