A cam clamp angle position deviation detection method based on image feature recognition
By selecting the effective contour segment of the top surface under the fixture reference coordinate system and determining the angular feature axis, the problem of false edge misjudgment in the clamping detection of cam parts is solved, and accurate angular deviation detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CNAIC CHENGDU AUTO PARTS
- Filing Date
- 2026-06-09
- Publication Date
- 2026-07-14
Smart Images

Figure CN122391208A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image detection technology, and more specifically, to a method for detecting cam fixture angular deviation based on image feature recognition. Background Technology
[0002] In the machining and inspection of irregularly shaped metal workpieces such as cam components and wedges, the workpiece is usually first placed in the positioning area of the fixture, and then the clamping mechanism, such as a pressure block, cylinder, lever cylinder, or wedge block, completes the limiting and clamping. Under the clamping state, the angular deviation of the workpiece relative to the fixture positioning reference is judged. This type of inspection scenario usually requires the inspection results to reflect not only whether the cam component is within the allowable angular range, but also its skew direction relative to the fixture reference line, in order to distinguish between qualified state, forward skew state, and reverse skew state.
[0003] Existing image detection solutions mostly employ edge detection, corner extraction, line fitting, boundary matching, or template matching to calculate workpiece angles. For example, CN103837097A discloses an automatic workpiece angle measurement device and method based on image processing, which obtains workpiece angles through image capture, preprocessing, corner extraction, and angle calculation; CN102799865A discloses an angle recognition method based on image boundary polar coordinate discrete sequences, which extracts the target image boundary and performs angle matching with a template image to obtain the rotation angle. These solutions can handle angle recognition problems with clear boundaries and relatively well-defined contours.
[0004] However, in the clamping inspection scenario of thick-walled cam components, high-contrast edges in the inspection image do not necessarily correspond to the true contour of the cam component's top surface. Because metal surfaces are sensitive to light, the top surface contour, sidewall contour, chamfer shadows, machining textures, inner hole boundaries, opening end boundaries, and clamping block occlusion boundaries of the cam component may all appear simultaneously within the workpiece inspection area. The abrupt changes in grayscale formed at the sidewall or chamfer locations are sometimes more pronounced than the true top surface boundary; the shadow edges generated by the clamping block occlusion may also be close to the outer peripheral edge of the workpiece in a local direction. If significant edges, overall shape boundaries, or template matching results from the inspection image are directly used for angle calculation, the edges involved in the calculation may deviate from the effective contour of the cam component's top surface.
[0005] Therefore, existing processing methods, under conditions of clamping, multi-layered edge superposition, and partial obstruction, are prone to mistakenly using sidewall edges, chamfered reflective edges, machined texture edges, or clamp-obstructed edges as the basis for angular position judgment. This results in detection results reflecting the direction of false edges rather than the true angular position of the cam component relative to the clamping positioning datum. This problem can lead to misjudgment of qualified parts, missed detection of skewed parts, or inability to accurately distinguish between forward and reverse skew. Therefore, a cam clamping angular position deviation detection method is needed that can use the clamping fixing datum as a unified reference, identify the effective top surface contour from candidate edge segments, and then output a symbolic angular position deviation value based on this.
[0006] To address the aforementioned problems, a technical solution is provided. Summary of the Invention
[0007] To overcome the aforementioned deficiencies of the prior art, embodiments of the present invention provide a cam fixture angular deviation detection method based on image feature recognition. This method involves acquiring a detection image of the cam component under fixture clamping conditions, locating a first fixture circular reference and a second fixture circular reference, and establishing a fixture reference coordinate system. A preset cam mounting window is extracted within this coordinate system as the workpiece detection area. The workpiece detection area is then segmented at the edges, and effective top surface contour segments are selected by combining standard top surface contour, top surface contour constraint band, geometric assignment, and grayscale assignment. Subsequently, based on the effective outer perimeter segment, the effective inner hole segment, and the effective opening end segment, a uniquely oriented angular feature axis is determined, and its directional angle relative to the preset fixture angular reference line is calculated. A symbolic angular deviation value and the cam fixture angular deviation detection result are output, thus solving the problems mentioned in the background art.
[0008] To achieve the above objectives, the present invention provides the following technical solution: Acquire detection images of the cam component under clamping state, locate the first and second clamping circular references in the detection images, establish a clamping reference coordinate system based on the center of the first and second clamping circular references, and extract a preset cam mounting window in the clamping reference coordinate system as the workpiece detection area. Candidate edge segments are obtained by performing edge segmentation on the workpiece inspection area. The standard top surface contour is placed in the workpiece inspection area according to the fixture reference coordinate system and a top surface contour constraint band is generated. The geometric assignment and grayscale assignment are calculated for each candidate edge segment. Based on the geometric assignment and grayscale assignment, the candidate edge segments are divided into effective top surface contour segments and non-top surface interference edge segments. The effective contour segments of the top surface are classified into outer perimeter effective segments, inner hole effective segments, and opening end effective segments according to their proximity in the standard top surface contour. The attitude matching angle is obtained based on the minimum distance residual from the outer perimeter effective segments and inner hole effective segments to the corresponding parts of the standard top surface contour. The angular uniqueness is verified by the side of the opening end effective segment relative to the standard opening end under the attitude matching angle, and the angular feature axis is obtained. In the fixture reference coordinate system, calculate the directed angle between the angular feature axis and the preset fixture angular reference line. Use the directed angle as a symbolic angular deviation value. Based on the inclusion relationship between the symbolic angular deviation value and the preset allowable angular range, output one of the following cam fixture angular deviation detection results: qualified state, forward skew state, and reverse skew state.
[0009] Furthermore, the geometrical attribution is determined by the length ratio of the candidate edge segment into the top surface contour constraint band, and the consistency between the tangent of the candidate edge segment and the tangent of the adjacent position of the standard top surface contour. When the length ratio is not lower than the preset falling ratio boundary and the consistency is not lower than the preset tangential consistency boundary, the corresponding candidate edge segment is determined to satisfy the geometric belonging condition. When at least one of the length ratio and consistency is lower than the corresponding boundary, the corresponding candidate edge segment is determined to not meet the geometric belonging condition.
[0010] Furthermore, the gray-level assignment is determined by the proportion of the gray-level change direction obtained by sampling the edge points of the candidate edge segment along both sides of the normal direction to the gray-level change direction of the standard top surface boundary at the adjacent position of the standard top surface contour. When the consistency ratio is not lower than the preset grayscale consistency boundary and the candidate edge segment meets the geometric assignment condition, the corresponding candidate edge segment is divided into the top surface effective contour segment. When the consistency ratio is lower than the preset grayscale consistency boundary, or when the candidate edge segment does not meet the geometric assignment conditions, the corresponding candidate edge segment is classified as a non-top surface interference edge segment.
[0011] Furthermore, when determining the attitude matching angle, an attitude search angle sequence is generated within a preset allowable search range. The distance residuals from the effective outer periphery segment and the effective inner hole segment to the corresponding parts of the standard top surface contour are calculated for each rotation angle to be verified. Candidate attitude angle sequences are formed in ascending order of distance residuals. For each rotation angle to be verified in the candidate attitude angle sequence, the side containing the effective segment of the opening end is verified sequentially. When the rotation angle to be verified passes the verification on the side where it is located, the rotation angle to be verified is determined as the attitude matching angle and the angular feature axis is generated; If the rotation angle to be verified fails the verification on the side it belongs to, the rotation angle to be verified is excluded, and the next rotation angle to be verified is selected from the candidate attitude angle sequence to continue the verification on the side it belongs to.
[0012] Furthermore, the standard top surface profile is obtained by converting the cam component design profile; When establishing the standard top surface profile, mark the outer perimeter profile, inner hole profile, and opening end profile. When the standard top surface contour is placed in the workpiece inspection area according to the fixture reference coordinate system, the location marks of the outer perimeter contour, inner hole contour and opening end contour are simultaneously entered into the fixture reference coordinate system.
[0013] Furthermore, the first clamp circular reference and the second clamp circular reference are two clamp fixed references that are fixed in position on the clamp and can form a circular boundary in the detection image; Extract the edge point sets of the first and second circular reference datums of the fixture within the area where the fixture is fixed; Perform circle fitting on the edge point sets of the first and second circular reference fixtures respectively to obtain the center of the first and second circular reference fixtures.
[0014] Furthermore, in the verification of the effective segment of the opening end relative to the side of the standard opening end under the attitude matching angle, the effective contour points in the effective segment of the opening end are read, and the side of the effective contour points relative to the end direction line of the standard opening end under the attitude matching angle is compared with the corresponding side of the standard opening end. When the number of consistent sides is greater than the number of opposite sides, the corresponding attitude matching angle is retained; When the number of opposite sides is greater than or equal to the number of consistent sides, the corresponding attitude matching angle is excluded, and the next rotation angle to be verified is selected according to the candidate attitude angle sequence to continue the verification of the side.
[0015] Furthermore, when outputting the cam fixture angular deviation detection results, a detection record is generated; The test record includes a symbolic angular deviation value, as well as one of the following test result states: qualified, forward skew, or reverse skew. When the symbolic angle deviation value falls within the preset allowable angle range, the detection record is written as qualified. When the symbolic angle deviation value is higher than the positive boundary of the preset allowable angle range, the detection record is written in the forward skew state; When the symbolic angle deviation value is lower than the negative boundary of the preset allowable angle range, the detection record is written to the reverse skew state.
[0016] Furthermore, the inspection record also includes the center of the first fixture circular reference, the center of the second fixture circular reference, the fixture reference coordinate system, and the preset cam mounting window; The fixture reference coordinate system is jointly recorded by the center of the first fixture circular reference, the center of the second fixture circular reference, the horizontal axis direction, and the vertical axis direction. The preset cam mounting window is recorded in the form of the window boundary in the fixture reference coordinate system.
[0017] Furthermore, the detection records also include the effective contour segment of the top surface, the non-top surface interference edge segment, the attitude matching angle, the angular feature axis, and the preset fixture angular reference line; Among them, the effective contour segment of the top surface and the non-top surface interference edge segment are recorded using the edge segment coordinates in the fixture reference coordinate system; The angular feature axis is recorded with a start point, an end point, and a directional direction; The preset fixture angular reference line is recorded as the reference start point and reference end point.
[0018] The technical effects and advantages of the cam fixture angular deviation detection method based on image feature recognition of this invention are as follows: This invention establishes a fixture reference coordinate system using first and second fixture circular references. This eliminates the angular deviation detection dependence on the current position of the cam component's outline boundary in the detection image, instead using the fixture's fixed reference as a unified reference. This reduces the impact of camera installation offset, workpiece placement fluctuations, and clamping obstructions on the detection reference. Furthermore, instead of directly calculating angles from high-contrast edges, this invention maps candidate edge segments to the standard top surface contour and top surface contour constraint band, and combines geometric and grayscale assignment values to filter effective top surface contour segments. This ensures that sidewall edges, chamfer shadows, machining textures, and pressure block obstructions are addressed. The barrier boundary does not directly participate in angular position matching, reducing the interference of false edges on the detection results. When the angular position direction is determined, this invention uses the effective segments of the outer periphery and the effective segments of the inner hole to jointly obtain the attitude matching angle, and verifies the uniqueness of the angular direction through the effective segment of the open end, which can avoid misjudgment of direction caused by similar local arc contours or local occlusion. Finally, it outputs symbolic angular position deviation values and qualified state, forward skew state or reverse skew state, so that the detection results include both the magnitude of the deviation and the skew direction. Compared with the method of only outputting the absolute value of the angle, it can more accurately reflect the true angular position state of the cam component relative to the fixture positioning reference under the clamping state. Attached Figure Description
[0019] Figure 1 This is a schematic diagram of the structure of the cam component of the present invention, which is in a clamped state of the fixture, for image acquisition and establishment of the fixture reference coordinate system. Figure 2 This is a schematic diagram of the process for screening the effective contour segments of the top surface of candidate edge segments within the workpiece detection area according to the present invention. Figure 3 This is a schematic diagram of the present invention, which determines the angular feature axis based on the effective contour segment of the top surface and outputs the angular deviation detection result. Detailed Implementation
[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0021] Please see Figure 1 - Figure 3 This invention provides a method for detecting cam fixture angular deviation based on image feature recognition, comprising: This invention uses the detection image of the cam component under clamping condition as the input object. First, a clamping reference coordinate system is established using the first and second clamping circular references in the detection image, so that the workpiece detection area, standard top surface contour, and angle calculation are all under the same clamping reference. Then, candidate edge segments are formed in the workpiece detection area, and combined with the top surface contour constraint band, geometric assignment, and grayscale assignment, the effective top surface contour segment and non-top surface interference edge segment are divided from the candidate edge segments. On this basis, the effective top surface contour segment is assigned to the outer perimeter effective segment, inner hole effective segment, and open end effective segment according to the adjacent position in the standard top surface contour. The attitude matching angle is determined by the outer perimeter effective segment and the inner hole effective segment, and the angle uniqueness is verified by the open end effective segment, forming an angle feature axis with a unique orientation. Finally, the directional angle between the angle feature axis and the preset clamping angle reference line is calculated to obtain a symbolic angle deviation value, and the cam clamping angle deviation detection result is output according to the qualified state, forward skew state, or reverse skew state.
[0022] When detecting angular deviation of the cam component under clamping condition, the subsequent step S2 needs to extract candidate edge segments within a stable workpiece detection area and place the standard top surface contour under a unified reference to generate a top surface contour constraint band. However, the workpiece position in the original detection image is affected by the camera installation, the fixed position of the clamp, and clamping obstruction, and cannot be directly used as the measurement basis for subsequent contour attribution judgment. Therefore, step S1 takes the detection image and the fixed circular reference of the clamp as input, first establishes the clamp reference coordinate system, and then extracts the preset cam installation window to form the workpiece detection area that can be directly called by step S2.
[0023] S101: Image acquisition and fixture fixation reference area extraction.
[0024] Step S101 takes the image state after the cam component has been placed in the fixture positioning area and clamped as the starting point for processing. The same image acquisition unit acquires a detection image containing the cam component, the fixture positioning area, the first fixture circular reference, and the second fixture circular reference. After the detection image is acquired, the areas where the first fixture circular reference and the second fixture circular reference are located are read according to the initial fixture calibration results. Both areas are limited to the location of the fixture fixing reference, so that the subsequent edge point extraction is only carried out around the fixture fixing structure.
[0025] The initial calibration results of the fixture are determined before testing using an image of an empty fixture, a calibration image of a qualified sample, or a fixture design image. Specifically, the areas containing the first and second circular reference datums of the fixture are first manually selected in the calibration image or according to the design dimensions. Then, the boundary ranges of the two areas in the image coordinates are recorded. When the camera, lens, and fixture mounting positions remain fixed, the current testing image directly uses these boundary ranges as the search areas for the two fixture fixing references. If the testing image has undergone distortion correction, the boundary ranges of the two areas are synchronously saved according to the distortion-corrected image coordinates, ensuring that subsequent circle fitting input always comes from the areas containing the fixture fixing references.
[0026] In practical implementation, the detection equipment can be positioned above the fixture. After the cam component is clamped by the pressure block, the detection equipment acquires a detection image containing the circular boundary of the pin and the circular boundary of the fixture fixing hole. The circular boundary of the pin serves as the visible boundary of the first fixture's circular reference, and the circular boundary of the fixture fixing hole serves as the visible boundary of the second fixture's circular reference. When the detection image is a color image, the color channel of each pixel is converted to a grayscale value; when the detection image is a grayscale image acquired by a grayscale camera, the pixel grayscale values are directly read as input for subsequent edge detection and grayscale assignment calculation.
[0027] After image acquisition, grayscale conversion and local denoising are performed on the regions containing the two fixed reference points. Then, edge point sets are extracted within each region to ensure that the outer periphery of the cam component, the inner hole edge, the pressure block occlusion boundary, and the background contact line do not enter the circle fitting input. Local denoising uses median filtering or Gaussian filtering, with the filter kernel size determined by the minimum edge width of the fixture's circular boundary in the image. The minimum edge width of the fixture's circular boundary in the image is obtained from the initial calibration image of the fixture. Specifically, grayscale profiles are sampled along the normal direction at the boundary positions of the first and second circular reference points of the fixture. The pixel widths where the grayscale gradient magnitude is continuously greater than the boundary gradient threshold are taken as the edge widths, and the minimum value of the edge widths obtained from multiple samplings at the boundaries of the two circular reference points is taken as the minimum edge width. The boundary gradient threshold is obtained by Otsu's segmentation of the gradient magnitude sequence on the corresponding gray-level profile. Specifically, for each normal gray-level profile, the absolute value of the gray-level difference between adjacent pixels is calculated to form a profile gradient magnitude sequence, and the Otsu's segmentation threshold of this sequence is used as the boundary gradient threshold. Pixel intervals that are continuously greater than this boundary gradient threshold are identified as gray-level abrupt change intervals of the circular reference boundary, and the width of this interval is taken as the edge width of the sampling position. The filter kernel size is obtained by proportionally converting the minimum edge width. Let the minimum edge width of the circular boundary of the clamp in the image be... The filter kernel size is ,but Take no greater than Maximum odd pixel size; when When less than 3 pixels, Take 3 pixels. This kernel size is used for both median filtering and Gaussian filtering to ensure that the denoising process does not cover the gray-level abrupt change region of the circular reference boundary; among which, The grayscale profile is derived from the boundary grayscale profile of the first and second circular reference points of the fixture in the initial calibration image of the fixture. Used to define the neighborhood range for median filtering or Gaussian filtering.
[0028] After denoising, Canny edge detection is used to extract edge points. The high threshold is determined by the Otsu segmentation result of the corresponding region's gray-level gradient magnitude, while the low threshold is a fixed proportion of the high threshold. Let the gray-level gradient magnitude sequence of the region to be processed be... ,in, For the first in the area to be processed The grayscale gradient magnitude of each pixel participating in the threshold statistics. ; This refers to the total number of pixels included in the Otsu segmentation threshold statistics. to Together they constitute the grayscale gradient magnitude sequence When the statistical object is the area where the circular reference of the fixture is located, This represents the number of pixels included in the statistics within the area containing the fixed reference; when the statistical object is the workpiece inspection area. This represents the number of pixels included in the statistics within the workpiece inspection area. Otsu segmentation threshold. The threshold that maximizes the inter-class variance after the gradient magnitude sequence is divided into low-gradient and high-gradient classes: ; in, This is the high threshold for Canny edge detection; The candidate gradient threshold; The grayscale gradient magnitude is not higher than Pixel percentage; For grayscale gradient magnitude higher than Pixel percentage; The average gradient magnitude of the low-gradient class; This represents the average gradient magnitude of the high-gradient class; all the above quantities are statistically obtained from the grayscale gradient magnitudes of the corresponding fixed reference area or the workpiece detection area. The fixed ratio between the low threshold and the high threshold is determined during the initial fixture calibration stage. Let the low threshold of Canny edge detection be... The fixed ratio is ,but In the calibration image of the qualified sample, the circular reference boundary of the fixture, the true boundary of the top surface, and the background texture area are pre-marked, and a candidate scale sequence is set. For each candidate proportion Perform Canny edge detection and calculate the boundary preservation rate and texture false detection rate: ; ; in, Candidate ratio The corresponding boundary retention rate; The number of pixels that are detected as edge points at this candidate scale and fall within the marked jig circular reference boundary and the top surface true boundary; The total number of pixels that have been marked as the circular reference boundary and the true boundary of the top surface of the fixture; Candidate ratio The corresponding texture false detection rate; The number of pixels that are detected as edge points and fall into the background texture area at this candidate scale; This represents the total number of pixels in the background texture area. This will satisfy... Not lower than the preset boundary retention rate and The candidate proportion with the largest value among the candidate proportions that are not higher than the preset texture false detection rate is determined as the fixed proportion. If multiple candidate ratios have the same judgment result, the candidate ratio with the lowest texture false detection rate is selected. Fixed ratio It remained unchanged during subsequent testing.
[0029] After the edge points within each fixed reference area are extracted, the set of edge points corresponding to the circular or near-circular boundaries is retained according to the edge connectivity. If multiple connected edge segments exist within the same area, the selection is based on the segment closure degree and the distance from the segment to the center of the corresponding fixed reference area, retaining the set of edge points used for circle fitting. The set of edge points corresponding to the first fixture circular reference is output as the first reference edge point set, and the set of edge points corresponding to the second fixture circular reference is output as the second reference edge point set. The first and second reference edge point sets serve as the input for the circle center calculation in S102.
[0030] After performing circle fitting on each connected edge segment, the segment closure degree is calculated based on the proportion of the arc length of the fitted circle covered by that connected edge segment. The segment closure degree is: ; in, The degree of closure of connected edge segments; This represents the cumulative edge length of the connected edge segment; The candidate radius is obtained by fitting the connected edge segment; Let be the candidate circle circumference. For each retained connected edge segment, further calculate the average radial residual: ; in, This represents the average radial residual of the connected edge segment; This represents the number of edge points in the connected edge segment. For the connected edge segment, the first Image coordinates of the edge points; The coordinates of the candidate circle center obtained by fitting the connected edge segment; Candidate radii. When selecting a circular reference edge segment, exclude it first. Connected edge segments below the lower limit of the visible arc segment of the circular reference are then selected from the remaining connected edge segments. The smallest connected edge segment; when two connected edge segments are... When the distances are equal, the connected edge segment whose center is closer to the center of the region corresponding to the fixed reference is selected. The lower limit of the visible arc segment of the circular reference is determined by the minimum visible arc segment ratio of the first and second circular references in the initial calibration image of the fixture.
[0031] S102: Circular fitting calculation and establishment of fixture reference coordinate system.
[0032] Step S102 receives the first reference edge point set and the second reference edge point set output by S101, and performs circle fitting processing on the two edge point sets respectively. The circle fitting adopts the least squares circle fitting method, using the image coordinates of each edge point as input points to construct a radial residual sequence to the fitted circle. When the sum of squared radial residuals is minimized, the corresponding circle center coordinates and radius are output; wherein, the first reference edge point set outputs the center of the first fixture circular reference, and the second reference edge point set outputs the center of the second fixture circular reference.
[0033] For any set of edge points corresponding to a circular datum of a fixture, let the set of points where the first edge point is the .... The image coordinates of the edge points are: The coordinates of the center of the circle are , radius is The solution is obtained by least-squares circle fitting: ; in, The center coordinates and radius of the circle obtained from the fitting; For the set of edge points, the first The image coordinates of each edge point are derived from the edge detection results of the corresponding circular reference area of the fixture. The value represents the number of edge points in the set of edge points; the difference within parentheses is the radial residual from the edge point to the fitted circle, used to measure whether the edge point conforms to a circular or near-circular boundary. The first set of reference edge points is used to obtain the center of the first fixture circular reference using this formula, and the second set of reference edge points is used to obtain the center of the second fixture circular reference using this formula.
[0034] After obtaining the two center points, the center of the first fixture circular reference is taken as the origin of the fixture reference coordinate system. The direction from the center of the first fixture circular reference to the center of the second fixture circular reference is taken as the horizontal axis direction, and the vertical axis direction is determined by the right-hand direction. Specifically, in the calculation, the center of the first fixture circular reference is recorded as the origin of the fixture reference coordinate system. The unit direction vector from the center of the first fixture circular reference to the center of the second fixture circular reference is taken as the horizontal axis unit vector, and then the horizontal axis unit vector is rotated by the right-hand direction. The vertical axis unit vector is obtained, and the coordinate transformation relationship from the detection image coordinates to the fixture reference coordinate system is formed by the origin, the horizontal axis unit vector, and the vertical axis unit vector.
[0035] Let the center of the circular reference of the first fixture be... The center of the circular reference of the second fixture is ,Depend on point to The horizontal unit vector is The unit vector along the vertical axis, determined by the right-hand direction, is: Detect any image point in the image. The coordinates in the fixture's reference coordinate system are: ; ; in, For image points The coordinates in the horizontal axis direction of the fixture reference coordinate system For image points Coordinates along the vertical axis of the fixture reference coordinate system; For image points The displacement vector relative to the center of the circular reference circle of the first fixture; It originates from the direction of the line connecting the centers of the two circular reference circles of the fixtures; Source The right-hand direction is perpendicular to the direction; the dot product operation is used to complete the projection conversion from image coordinates to the fixture reference coordinate system coordinates.
[0036] When any image point in the detection image enters the fixture reference coordinate system, the displacement vector of the image point relative to the center of the first fixture circular reference circle is first calculated. Then, the projections of the displacement vector onto the horizontal and vertical unit vectors are calculated respectively. The projection results are used as the coordinates of the image point in the fixture reference coordinate system. After completing this conversion relationship, subsequent edge points, contour points, angular feature axes, and angular deviations in the detection image are all referenced to the fixture reference coordinate system. S102 outputs the fixture reference coordinate system and its coordinate conversion relationship for use in S103 to capture the preset cam mounting window, and for continued use in step S2 when placing the standard top surface contour.
[0037] S103: Preset cam mounting window capture and workpiece inspection area generation.
[0038] Step S103 uses the fixture reference coordinate system established in S102 as the starting point for processing and reads the preset cam mounting window that has been predetermined in the fixture reference coordinate system. The position and boundary of the preset cam mounting window have been determined by the fixture design drawing, qualified sample calibration image or initial fixture debugging image. It covers the top surface area of the cam component that may appear within the normal clamping and allowable deviation range, and avoids the cylinder, pressure block, bolt and fixture boundary area.
[0039] During the interception process, the boundary points of the preset cam mounting window are first converted to the coordinates of the detection image according to the coordinate conversion relationship output by S102, thus obtaining the corresponding window boundaries within the detection image. The coordinates of any window boundary point in the preset cam mounting window in the fixture reference coordinate system are: At that time, the corresponding detection image coordinates point Obtained using the following formula: ; in, The coordinates of the window boundary points in the detected image; The center of the circle that serves as the circular reference for the first fixture; is the horizontal unit vector of the fixture's reference coordinate system; is the unit vector of the vertical axis of the fixture's reference coordinate system; and These are the coordinates of the window boundary points in the fixture reference coordinate system. The detection image coordinates obtained by transforming the window boundary points together define the cropping range in the detection image.
[0040] The pixel sampling range is then defined by the window boundary, and the image content within the window is extracted from the detected image. During the extraction process, image points within the window boundary are retained and their fixture reference coordinates are recorded synchronously, while image points outside the window boundary do not enter the workpiece detection area, ensuring that subsequent edge segmentation processing is only carried out within the theoretical installation area of the cam component.
[0041] In one specific embodiment, after the cam component is clamped by the fixture, a preset cam mounting window covers the possible locations of the outer periphery of the cam component's top surface, the inner hole, and the open end. When the pressure block in the detection image is located outside the window or near the window edge, the window is cropped based on a fixed boundary in the fixture reference coordinate system and does not move with changes in the shape of the cam component image; the resulting workpiece detection area contains the source of candidate top surface edges required in subsequent step S2, while excluding fixture fixed boundaries unrelated to corner position determination. S103 finally outputs the workpiece detection area, the correspondence between image points within the workpiece detection area and the fixture reference coordinate system, and the window boundary used to place the standard top surface contour.
[0042] In step S1, the two fixed circular references of the fixtures in the detection image are located and their centers are calculated. The fixture reference coordinate system and its coordinate conversion relationship are established, and the preset cam mounting window is converted and cropped into the workpiece detection area. The workpiece detection area, window boundary, and image point coordinate correspondence formed in this step serve as the direct input for edge segmentation processing, standard top surface contour placement, and top surface contour constraint band generation in step S2, ensuring that subsequent angular deviation calculations always use the fixture positioning reference.
[0043] Step S1 has already formed the workpiece detection area in the fixture reference coordinate system and simultaneously recorded the correspondence between image points within the workpiece detection area and the fixture reference coordinate system. However, within the workpiece detection area, there are still real boundaries of the cam top surface, side wall shadows, chamfer reflections, machining textures, and pressure block occlusion boundaries. Directly using all edges in the angle calculation will cause subsequent pose matching to be affected by false edges. Therefore, step S2 takes the workpiece detection area and the standard top surface contour as input, first forms candidate edge segments, then filters the effective top surface contour segments through geometric assignment and grayscale assignment, and outputs the effective edge objects for part assignment in step S3.
[0044] S201: Candidate edge segment formation.
[0045] Step S201 takes the correspondence between the workpiece detection area, window boundary, and image point coordinates output in step S1 as the starting point for processing, and performs grayscale conversion, local denoising, and edge extraction within the workpiece detection area. When the workpiece detection area is a color image, each pixel is converted to a grayscale value; when the workpiece detection area is a grayscale image, the pixel grayscale value is directly read. Local denoising uses median filtering or Gaussian filtering, and the filter kernel size follows the rule determined based on the edge width in S101, so that the fine textures of the metal surface within the workpiece detection area do not directly form subsequent candidate edge segments.
[0046] After denoising, Canny edge detection is used to obtain the edge point map within the workpiece detection area. The high threshold of Canny edge detection is determined by the Otsu segmentation result of the gray-level gradient amplitude of the workpiece detection area, while the low threshold is a fixed ratio determined in S101 using the calibration image of a qualified sample. Subsequently, edge points are traced according to the 8-neighborhood connectivity relationship to form several continuous edge segments, and the edge point sequence of each continuous edge segment is recorded according to the connectivity order. The cumulative length of the consecutive edge segments is: ; in, For the first The cumulative length of a series of consecutive edge segments; For the first continuous edge segment One edge point; This represents the number of edge points in the continuous edge segment. This involves Euclidean distance calculation. The minimum edge length boundary is obtained by statistically analyzing the lengths of the true boundary segments on the top surface in the qualified sample images. Specifically, the same edge extraction and 8-neighborhood connected component tracking are performed on multiple qualified sample calibration images. Based on the standard top surface contour, continuous edge segments belonging to the true boundary of the top surface are marked, and the cumulative length of each true boundary segment is calculated to form a sequence of true boundary segment lengths. This sequence is then sorted in ascending order, and the quartile is taken as the minimum edge length boundary. Continuous edge segments with a cumulative length lower than this minimum edge length boundary are not included in the candidate edge segments, while continuous edge segments with a cumulative length not lower than this minimum edge length boundary are considered candidate edge segments.
[0047] S202: Standard top surface profile placement and top surface profile constraint band generation.
[0048] Step S202 receives the candidate edge segments output by S201 and reads the standard top surface contour. The standard top surface contour is placed in the workpiece detection area according to the fixture reference coordinate system established in step S1. The location marks of the outer peripheral contour, inner hole contour, and opening end contour are synchronously entered into the fixture reference coordinate system along with the standard top surface contour, so that subsequent candidate edge segments can be geometrically compared according to a unified coordinate relationship.
[0049] When the standard top surface profile is expressed as a discrete profile point sequence, adjacent discrete profile points are connected to form a standard profile line segment. If the standard top surface profile is expressed by a design curve, the design curve is first sampled according to the pixel resolution in the fixture reference coordinate system to form a discrete profile point sequence, and then connected to form a standard profile line segment. To standard top surface profile The shortest distance is obtained by taking the minimum value of the shortest distance from the point to each standard contour line segment: ; in, For point The shortest distance to the standard top surface profile; It refers to any standard profile line segment in the standard top surface profile; For point To standard outline segment The shortest distance.
[0050] The top surface contour constraint band extends along both the inner and outer sides of the standard top surface contour, and is expressed as follows: ; in, This is the top surface contour constraint zone; These are image points or edge points within the workpiece detection area; The width of the top surface contour constraint band is determined by the following formula: ; in, The image coordinate error corresponding to the camera calibration error is obtained from the calibration image of the camera calibration board or qualified sample. The image coordinate error corresponding to the normal repeatability positioning error of the fixture is obtained by the offset of the same top surface contour position in multiple qualified clamping images; This is the maximum distance from each contour point on the standard top surface profile to the center of the standard corner position; This is the angle boundary with the larger absolute value within the preset allowable angle range; This indicates the maximum lateral displacement that the standard top surface profile may produce within the permissible angular range. The image coordinate error corresponding to the camera calibration error. The reprojection error is determined from the calibration image of the camera calibration board or qualified sample, and the maximum value or upper quartile of the reprojection error at each calibration point is taken as the standard. Image coordinate error corresponding to the normal repeatability error of the fixture. The coordinates of the fixture reference point are determined by multiple qualified clamping calibration images. Specifically, the fixture reference coordinates of the same standard top surface contour mark point are read from each qualified clamping image, the Euclidean distance relative to the mean of multiple coordinates is calculated, and the upper quartile of the Euclidean distance sequence is taken as the reference coordinate. Therefore, the width of the top surface contour constraint band. It simultaneously covers camera calibration error, normal repeatability positioning error of fixture, and contour displacement within the preset allowable angular range.
[0051] S203: Calculation of geometrical attribution quantity.
[0052] Step S203 takes the candidate edge segments output by S201 and the top surface contour constraint band generated by S202 as input, and calculates the geometrical attribution of each candidate edge segment in terms of position and orientation. For the first... For each candidate edge segment, first calculate the edge length of that segment within the top contour constraint zone. When calculating the edge length within the top contour constraint zone, the candidate edge segment is divided into several edge segments between adjacent edge points according to connectivity. For any edge segment, if its midpoint falls within the top contour constraint zone, then the length of that edge segment is included in the calculation. If the midpoint of the edge segment does not fall within the top surface contour constraint zone, the length of the edge segment is not included in the calculation. The sum of the lengths of all adjacent edge segments of a candidate edge segment is used as... Then, the percentage of the constraint band falling into the constraint band is calculated: ; in, For the first The proportion of each candidate edge segment that falls within the constraint band; The length of the candidate edge segment within the top surface contour constraint band; This represents the total edge length of the candidate edge segment. This is used to characterize whether the candidate edge segment is close to the standard top surface profile in terms of location.
[0053] Then, the tangential consistency ratio of the candidate edge segment is calculated: ; in, For the first The proportion of tangential consistency among candidate edge segments; This represents the number of edge points in the candidate edge segment that participate in the tangential comparison. For the candidate edge segment The unit tangent vector calculated along the connected sequence at each edge point; It is the unit tangent vector at the closest position to the edge point in the standard top surface profile; the absolute value of the dot product is used to represent the degree of consistency between the two tangent directions.
[0054] Among them, the consistency of the tangential direction is determined by the proportion of tangential consistency. Quantification, ; The closer , indicating the first The more consistent the local tangent of each candidate edge segment is with the local tangent of its adjacent position on the standard top surface profile, the better. Let the preset falling-into-the-scale boundary be... The preset tangential consistent boundary is Then the first The geometric assignment metric for each candidate edge segment is: ; in, Indicates the first The candidate edge segments satisfy the geometrical attribution condition. Indicates the first The candidate edge segments do not meet the geometrical attribution criteria; and All data were obtained statistically from the true boundary samples of the top surface in the images of qualified sample pieces.
[0055] Candidate edge segment Unit tangent vector at each edge point Determined by the coordinate difference between the two adjacent edge points before and after the current edge point; when the first... When an edge point is not an endpoint, take After normalization as When the first When each edge point is an endpoint, the normalized difference between its coordinates and those of its adjacent edge points is taken as the endpoint. The unit tangent vector at adjacent positions on the standard top surface profile. It is calculated in the same way from the standard profile point closest to the edge point and its adjacent standard profile points in the standard top profile.
[0056] when Not lower than the preset boundary of the falling proportion, and When the value is not lower than the preset tangential uniform boundary, the first Each candidate edge segment satisfies the geometrical attribution condition. The preset falling proportion boundary and the preset tangential consistency boundary are obtained statistically from the top surface true boundary samples in the qualified sample images. Among them, the preset tangential consistency boundary is formed by calculating the tangential consistency proportion of the marked top surface true boundary segments in multiple qualified sample calibration images to form a statistical sequence, and then taking the lower quartile of the statistical sequence.
[0057] S204: Gray-scale assignment calculation and edge segment division.
[0058] Step S204 uses the candidate edge segments calculated in S203 (after geometric assignment) as input to continue calculating the grayscale assignment of each candidate edge segment. The candidate edge segment's grayscale assignment is... The normal unit vector at each edge point is obtained by rotating the unit tangent vector at that edge point 90° in the right-hand direction of the fixture reference coordinate system. Let the unit tangent vector at that edge point be... Its normal unit vector is ,but: ; in, For the first The candidate edge segment The unit tangent vector at each edge point is derived from the coordinate difference between adjacent edge points of the candidate edge segment in S203; The corresponding normal unit vector is used to determine the positions of both sides of the grayscale sampling. The fixed sampling interval is determined by the edge width of the top surface boundary in the qualified sample calibration image and the width of the top surface contour constraint band. Let the edge width of the top surface boundary in the qualified sample calibration image be... The width of the top surface contour constraint band is Fixed sampling interval is ,but: ; in, It is obtained from the normal grayscale profile at the standard top surface contour boundary in the calibration image of the qualified sample, and its acquisition method is consistent with the acquisition method of the minimum edge width of the circular boundary of the fixture; The width of the top surface contour constraint band generated from S202; Used to determine the sampling positions of the first-side grayscale value and the second-side grayscale value. When When the corresponding sampling point is not located within the workpiece detection area, the edge point is not included in the grayscale direction consistency ratio calculation. Along direction and The directions are each sampled at grayscale points at a fixed sampling interval from the edge point, and the two grayscale sampling points are used to output the grayscale value of the first side. Second side grayscale value .
[0059] No. Among the candidate edge segments, the first The sign of the grayscale change direction of each edge point is: ; in, This indicates the direction of grayscale change at the edge point; and These are the grayscale sampling values on both sides of the edge point in the normal direction, which are derived from the grayscale image of the workpiece detection area; The effective boundary of grayscale difference is determined by the sequence of absolute grayscale differences on both sides of the normal direction of the flat area inside the top surface of the calibration image of the qualified sample. The upper quartile of this sequence is taken as... When the absolute value of the grayscale difference between the two sides is not greater than When the grayscale change direction of the edge point is denoted as 0.
[0060] The proportion of consistent grayscale direction is: ; in, For the first The proportion of candidate edge segments with consistent gray-level direction; For the first The set of edge point indices in which both gray-scale sampling points on both sides of a candidate edge segment are located within the workpiece detection area and actually participate in gray-scale direction comparison; This represents the actual number of edge points involved in grayscale comparison. This is an indicator function; it takes the value when the condition within the parentheses is true. Otherwise take ; This refers to the symbol indicating the direction of grayscale change at the standard top surface boundary adjacent to the standard top surface profile. This is obtained during the standard top surface contour establishment process. Specifically, in the calibration image of the qualified sample, grayscale values are sampled along both sides of the normal direction for each standard contour point of the standard top surface contour, and the grayscale difference sign is recorded according to the direction from the top surface side to the background side, the inner hole side, or the opening side; when the first The first candidate edge segment When an edge point is mapped to an adjacent position of the standard top surface contour, the grayscale difference sign stored at that adjacent position is read as... .
[0061] like Then the first If a candidate edge segment does not meet the grayscale assignment condition; and If the grayscale level is not lower than the preset grayscale uniformity boundary, then the first... Each candidate edge segment satisfies the grayscale assignment condition. The preset falling ratio boundary, preset tangential consistency boundary, and preset grayscale consistency boundary are statistical sequences composed of top surface true boundary samples in qualified sample images. Specifically, the same edge segmentation processing is performed on multiple qualified sample calibration images, and the top surface true boundary segments are marked manually or according to the standard top surface contour; then, the constraint band falling ratio, tangential consistency ratio, and grayscale direction consistency ratio of these top surface true boundary segments are calculated respectively, and each type of index is arranged in ascending order of value, and the quartile is taken as the corresponding preset boundary.
[0062] Candidate edge segments that satisfy both geometric and grayscale assignment conditions are classified as effective top surface contour segments; the remaining candidate edge segments are classified as non-top surface interference edge segments. In specific implementation, even if the dark bands on the sidewalls or the bright bands on the chamfers have a high gradient locally, they will enter the non-top surface interference edge segments because they do not fall into the top surface contour constraint zone, the tangential direction is inconsistent, or the grayscale change direction is inconsistent; the true boundaries of the outer periphery, inner hole, or opening end of the cam component's top surface are output as effective top surface contour segments. Step S2 finally outputs the effective top surface contour segments, non-top surface interference edge segments, and the coordinate correspondence between the effective top surface contour segments and the fixture reference coordinate system, which are used in step S3 to assign the effective outer periphery segment, the effective inner hole segment, and the effective opening end segment.
[0063] In step S2, continuous edge segments within the workpiece detection area are organized into candidate edge segments, and geometric assignment and grayscale assignment are calculated under the constraints of the standard top surface contour and the top surface contour constraint band. The effective top surface contour segment output in this step has excluded non-top surface interference edges such as sidewall edges, chamfer shadows, machining textures, and pressure block occlusion boundaries, and can be used as the contour input for step S3 to obtain the attitude matching angle and angular feature axis.
[0064] Step S1 has already formed the workpiece detection area in the fixture reference coordinate system. Step S2 has completed the screening of candidate edge segments and output the effective top surface contour segment within this area, while retaining the location marks of the outer perimeter contour, inner hole contour, and opening end contour of the standard top surface contour. However, the effective top surface contour segment is still only a local edge fragment and cannot directly represent the actual angular direction of the cam component. Therefore, step S3 performs location assignment, posture matching, and direction verification on the effective top surface contour segment in the fixture reference coordinate system to generate the angular feature axis for step S4 to calculate the symbolic angular deviation value.
[0065] S301: Assignment of adjacent parts to the effective contour segment of the top surface.
[0066] Step S301 takes the effective top surface contour segment, standard top surface contour, and its location markers output in step S2 as the processing starting point, and organizes all contour point coordinates using the fixture reference coordinate system established in step S1. When each effective top surface contour segment enters the processing, the effective contour points on the effective top surface contour segment are first read according to the connected tracing sequence. Then, the standard contour point closest to each effective contour point is found on the standard top surface contour. The adjacent location of the effective contour point is determined by the outer peripheral contour, inner hole contour, or opening end contour to which the nearest standard contour point belongs.
[0067] When all valid contour points on the same valid top surface contour segment are adjacent to the same standard top surface contour location, the entire valid top surface contour segment is assigned to the corresponding category. When the same valid top surface contour segment spans two standard top surface contour locations, it is divided according to the continuous position of the valid contour points in the connection sequence, so that each segment corresponds to only one standard top surface contour location, and then output to the corresponding category. Thus, valid top surface contour segments adjacent to the outer periphery of the standard top surface contour are assigned to the outer periphery valid segment, valid top surface contour segments adjacent to the inner hole of the standard top surface contour are assigned to the inner hole valid segment, and valid top surface contour segments adjacent to the open end of the standard top surface contour are assigned to the open end valid segment.
[0068] In practice, the outer periphery top surface boundary, inner hole top surface boundary, and opening end top surface boundary of the cam component in the detection image may appear as several discontinuous segments after being filtered in step S2. The image processing device first converts all these discontinuous segments into the fixture reference coordinate system, and then projects them point by point to the adjacent positions of the standard top surface contour; for example, segments close to the standard outer periphery arc enter the outer periphery effective segment, segments close to the standard inner hole arc enter the inner hole effective segment, and segments close to the standard opening end boundary enter the opening end effective segment. S301 outputs the outer periphery effective segment, inner hole effective segment, and opening end effective segment, and transmits the attribution relationship between each type of effective segment and the corresponding part of the standard top surface contour to S302.
[0069] S302: The attitude matching angle is obtained based on the minimum distance residual.
[0070] S302 receives the outer peripheral effective segment and inner hole effective segment output by S301, and generates an attitude search angle sequence within a preset allowable search range, using the standard angular center in the standard top surface profile as the rotation center. The attitude search angle sequence is a sequence formed by arranging multiple rotation angles to be verified in angular order within the preset allowable search range. Its range is determined by the preset allowable angular range and the angular margin corresponding to the normal repeatability positioning error of the fixture, and is used to limit attitude matching to only within the possible clamping angle of the cam component.
[0071] Let the negative boundary of the preset allowable angle range be... The positive boundary is The angular margin corresponding to the normal repeatability error of the fixture is The default allowed search range is: ; in, This represents the negative search boundary of the attitude search angle sequence; This represents the positive search boundary of the attitude search angle sequence; and Derived from the preset allowable angle range; It is derived from the maximum normal fluctuation of the attitude matching angle in multiple qualified clamping and calibration images.
[0072] The attitude search angle sequence is as follows: ; in, For the attitude search angle sequence; For fixed angle step size; In order to make No more than The maximum integer. The fixed angle step size is determined based on the maximum profile displacement caused by adjacent rotation angles to be verified. Let the width of the top surface profile constraint band be... The maximum distance from each contour point on the standard top surface profile to the center of the standard corner position is The maximum profile displacement caused by adjacent rotation angles to be verified is calculated based on the chord length as follows: And make it no greater than half the width of the top surface contour constraint band: ; Therefore, the fixed angle step size satisfies: ; in, The fixed angle step size in the attitude search angle sequence; The width of the top surface contour constraint band generated from S202; This is derived from the maximum distance from each contour point on the standard top surface profile to the center of the standard corner. This relationship ensures that the contour displacement between adjacent rotation angles to be verified remains within the allowable range of the top surface profile constraint zone.
[0073] For each rotation angle to be verified in the attitude search angle sequence, first rotate the outer periphery profile and inner hole profile of the standard top surface profile around the standard angle center to the position corresponding to the rotation angle to be verified, to obtain the rotated outer periphery standard part and the rotated inner hole standard part; then calculate the shortest distance from the effective profile point in the effective segment of the outer periphery to the rotated outer periphery standard part, and the shortest distance from the effective profile point in the effective segment of the inner hole to the rotated inner hole standard part, and normalize all the shortest distances according to the number of effective profile points to form the distance residual of the rotation angle to be verified.
[0074] Let any standard profile point in the standard top surface profile be... The standard angular center is The rotation angle to be verified is The coordinates of the standard contour point after rotation for: ; in, For the standard profile points at the rotation angle to be verified The lower position; The standard angular center; For a two-dimensional rotation matrix: ; in, and These are the cosine and sine functions of the rotation angle to be verified, respectively. The outer perimeter profile, inner hole profile, and opening end profile in the standard top surface profile are all rotated to their corresponding positions according to this rotation relationship.
[0075] The calculation relationship for distance residuals is as follows: ; in, Rotation angle to be verified The corresponding distance residual is used to characterize the overall fit between the outer peripheral effective segment and the inner hole effective segment and the corresponding parts of the rotated standard top surface contour; The rotation angle to be verified in the attitude search angle sequence; This is the set of valid contour points in the outer perimeter valid segment, which originates from the outer perimeter valid segment of S301; This is the set of effective contour points in the effective segment of the inner hole, derived from the effective segment of the inner hole in S301; The outer perimeter of the standard top surface profile is rotated about the standard angular center. The standard peripheral area formed later; The inner hole profile in the standard top surface profile is rotated about the standard angular center. The standard part of the inner hole formed later; valid contour points The shortest distance to the standard peripheral location; valid contour points The shortest distance to the standard part of the inner hole; This represents the number of valid contour points in the effective outer perimeter segment. This represents the number of effective contour points within the effective segment of the inner hole. When When the condition is met, it indicates that neither the outer peripheral effective segment nor the inner hole effective segment has formed an effective contour point. In this case, the distance residual calculation is not performed on the current detection image, and an invalid contour matching marker is output.
[0076] The shortest distance from the effective contour point to the rotated outer peripheral standard part or inner hole standard part is calculated according to the shortest distance from the point to the rotated standard contour line segment; when the rotated standard part is expressed by discrete contour points, adjacent discrete contour points are connected into contour line segments, and the minimum value of the distance from the effective contour point to each contour line segment is taken.
[0077] After the distance residual calculation is completed, the distance residuals corresponding to each rotation angle to be verified in the attitude search angle sequence are sorted in ascending order of value to form a candidate attitude angle sequence. The rotation angle to be verified with the smallest distance residual is used as the candidate attitude angle for priority angular uniqueness verification, rather than being directly used as the final attitude matching angle. When the effective outer perimeter segment or the effective inner hole segment consists of multiple segments, the effective contour points in each segment are merged into the corresponding effective contour point set according to their category, and the distance residual is still obtained according to the same calculation relationship. S302 outputs the attitude matching angle and the standard top surface contour rotation position under the attitude matching angle, for S303 to perform angular uniqueness verification on the opening end direction.
[0078] After calculating the distance residuals for each rotation angle to be verified, the rotation angles to be verified in the attitude search angle sequence are arranged in ascending order of distance residuals to form a candidate attitude angle sequence. The candidate attitude angle sequence is used as the calling order when S303 re-executes the judgment on the side where it is located, so that the excluded direction results will not re-enter the generation of the angular feature axis.
[0079] S303: Angular uniqueness check based on the effective segment of the open end.
[0080] S303 takes the attitude matching angle and candidate attitude angle sequence output by S302 and the effective segment of the opening end output by S301 as the starting point for processing. It rotates the opening end contour in the standard top surface contour around the center of the standard angle to the position corresponding to the attitude matching angle, thus obtaining the standard opening end under the attitude matching angle. Then, it reads the effective contour points in the effective segment of the opening end and calculates the side of these effective contour points relative to the standard opening end under the attitude matching angle, which is used to determine whether the attitude matching angle corresponds to the actual opening orientation of the cam component.
[0081] The determination of the side is based on the end direction line of the standard opening end under the attitude matching angle. The end direction line of the standard opening end under the attitude matching angle is a directed line formed by the center of the rotated standard opening end along the direction of the rotated standard angular axis, used to distinguish the corresponding side where the effective segment of the opening end should fall.
[0082] The end direction line of the standard opening end under the attitude matching angle is from the center of the rotated standard opening end. and the rotated standard angular axis direction vector Determined. For any valid profile point in the valid segment at the open end. Calculate the symbol on the side where it is located: ; in, valid contour points The symbol on the side relative to the end direction line; The standard angular position axis direction vector under the attitude matching angle; This is the displacement vector pointing from the center of the rotated standard open end to the effective contour point; This is a two-dimensional cross product scalar operation. The symbol corresponding to the standard open end is obtained by recording the majority of the sides of the standard open end profile relative to the standard angular axis when the standard top surface profile is established. Let the first side of the standard open end profile be... The standard open end profile points are: The standard open end center is The standard angular position axis direction vector is Then the first The standard side symbol for each standard open end profile point is: ; The non-zero standard side symbol with the most occurrences in the standard open end profile is determined as the corresponding side symbol of the standard open end. If the number of non-zero standard side symbols is the same, the non-zero standard side symbol corresponding to the standard open end profile point adjacent to the center of the standard open end is taken as the corresponding side symbol of the standard open end. The standard side symbol for the standard open end profile point; Derived from the open end profile in the standard top surface profile; Originating from the center of the standard open end; Originates from the standard angular axis direction; This is a two-dimensional cross product scalar operation. The symbolic function on the corresponding side is defined as: ; like If the symbol on the side corresponding to the standard open end is consistent, then the valid contour point is counted in the same side count; if The symbol on the corresponding side of the standard open end is inconsistent, or If the valid contour point is counted in the number of non-same-side points, then the effective contour point is included in the number of
[0083] To ensure that the uniqueness of the angular orientation has a quantifiable basis, this specification defines the uniqueness of the angular orientation as the difference in the number of sides containing the effective segments at the opening end corresponding to the candidate attitude angle. For the first... An unverified rotation angle Let the set of valid contour points in the effective segment at the open end be... The standard open end corresponding side symbol is Then the number of items on the same side, the number of items on different sides, and the uniqueness determination quantity of the angular direction are respectively: ; ; ; in, valid contour points Rotation angle to be verified The lateral sign is calculated according to the formula for the lateral sign; when When this occurs, the valid contour point is included in the count of non-same-side points; Rotation angle to be verified The number of effective contour points that correspond to the side of the standard open end; Rotation angle to be verified The number of valid contour points that do not correspond to the standard open end; This is an indicator function; the value is taken when the condition inside the parentheses is true. Otherwise take ; This is a dimensionality criterion for angular uniqueness. When... When, it indicates that the rotation angle to be verified has passed the angular uniqueness check; when If the value is less than 1, it indicates that the rotation angle to be verified has failed the angular uniqueness check. The attitude matching angle is determined as follows: ; in, This is the attitude matching angle output after passing the angular uniqueness check; The first candidate attitude angle sequence to satisfy The sequence number. If there is no such sequence number. If the rotation angle to be verified is not specified, then an invalid contour matching flag will be output.
[0084] After calculating the side symbol for each valid contour point in the valid segment of the open end, count the number of valid contour points that are consistent with the corresponding side of the standard open end and the number of points that are not on the same side. When the number of points on the same side is greater than the number of points on the same side, it is determined that the valid segment of the open end is on the corresponding side of the standard open end, and the current rotation angle to be verified is retained as the attitude matching angle that passes the angular uniqueness check. When the number of points on the same side is greater than or equal to the number of points on the same side, it is determined that the valid segment of the open end does not fall on the corresponding side of the standard open end, the direction result corresponding to the rotation angle to be verified is excluded, and the next rotation angle to be verified with a smaller distance residual is selected according to the candidate attitude angle sequence to re-execute the side judgment until the attitude matching angle that passes the angular uniqueness check is obtained.
[0085] If all the rotation angles to be verified in the candidate attitude angle sequence fail the judgment on their respective sides, the current detection image will not generate an angular feature axis and will output an invalid contour matching mark. The invalid contour matching mark is used to indicate that the current image cannot enter the symbolic angular deviation value calculation in step S4, and does not replace the qualified, forward skew, or reverse skew angular deviation detection results.
[0086] In practice, the effective outer perimeter segment and the effective inner hole segment may have similar arc contours, resulting in small distance residuals for both rotation angles to be verified. In this case, the image processing device reads the effective top surface contour segment located at the opening end of the cam component and compares it with the standard opening end under the current attitude matching angle. If the actual opening end boundary is located on the corresponding side of the standard opening end, this angle is taken as the true angular direction of the cam component; if the actual opening end boundary is located on the opposite side, this angle only reflects the fitting relationship of similar arcs and is not output as the angular direction. S303 outputs the attitude matching angle verified by angular direction uniqueness and transmits this angle to S304.
[0087] S304: Generation of angular feature axes with unique orientation.
[0088] If S303 does not output an invalid profile matching flag and the attitude matching angle that has passed the angular uniqueness check has been obtained, S304 receives the attitude matching angle that has passed the angular uniqueness check and reads the standard angular axis from the standard top surface profile. The standard angular axis has been determined according to the angular position definition when the standard top surface profile was established. Its starting point is the standard angular position center, and its ending point is the standard opening end center or a preset asymmetric feature point in the standard profile. When generating the angular feature axis, the standard angular axis is rotated around the standard angular position center by the attitude matching angle that has passed the angular uniqueness check, and the starting point, ending point, and direction after rotation are all converted into the fixture reference coordinate system.
[0089] After rotation, the starting point of the rotated standard angular axis is taken as the starting point of the angular feature axis, and the ending point of the rotated standard angular axis is taken as the ending point of the angular feature axis. The direction from the starting point to the ending point is taken as the orientation of the angular feature axis. Since the attitude matching angle has been verified by the side where the effective segment of the open end is located, the generated angular feature axis has a unique orientation and is no longer determined by the local similarity of the effective segment of the outer perimeter or the effective segment of the inner hole. S304 outputs the angular feature axis and retains its starting point, ending point and directed direction in the fixture reference coordinate system as the direct input for step S4 to calculate the directed angle relative to the preset fixture angular reference line.
[0090] In step S3, the effective contour segments of the top surface obtained in step S2 are classified into outer perimeter effective segments, inner hole effective segments, and opening end effective segments. The outer perimeter effective segments and inner hole effective segments are used together to obtain the candidate attitude angle sequence, and the opening end effective segments are used to complete the angular uniqueness verification. When there is a rotation angle to be verified that passes the angular uniqueness verification in the candidate attitude angle sequence, step S3 outputs an angular feature axis with a unique orientation, and provides it to step S4 in the form of a directed axis in the fixture reference coordinate system for calculating the symbolic angular deviation value; when there is no rotation angle to be verified that passes the angular uniqueness verification in the candidate attitude angle sequence, step S3 outputs an invalid contour matching mark, and the current detection image is not included in the calculation of the symbolic angular deviation value in step S4.
[0091] Step S1 has unified the edge points and contour points in the detected image to the fixture reference coordinate system. Step S2 has eliminated non-top surface interference edges and formed a valid top surface contour segment. Step S3 outputs an angular feature axis with a unique orientation when passing the angular uniqueness check. However, the angular feature axis only represents the actual angular direction of the cam component and does not yet give the magnitude and direction of the deviation relative to the correct clamping direction of the fixture. Therefore, step S4 only introduces a preset fixture angular reference line into the fixture reference coordinate system when the angular feature axis is output in step S3, calculates the directional angle between the angular feature axis and the preset fixture angular reference line, and converts the calculation result into the cam fixture angular deviation detection result.
[0092] S401: The angular feature axis is aligned with the preset fixture angular reference line.
[0093] When step S3 outputs the angular feature axis, step S401 uses the angular feature axis output in step S3 and the fixture reference coordinate system established in step S1 as the processing starting point, and simultaneously reads the preset fixture angular reference line. When step S3 outputs an invalid contour matching mark, the current detection image is not included in the calculation of the symbolic angular deviation value. The angular feature axis already includes the start point, end point, and orientation, and the preset fixture angular reference line has already been determined in the fixture reference coordinate system. Both are expressed using the same coordinate relationship established by the fixture fixed circular reference, so that the angular deviation calculation no longer depends on the workpiece outline boundary position in the detection image.
[0094] Before performing calculations, the starting and ending coordinates of the angular feature axis are read, and a angular feature axis direction vector is generated from the starting point to the ending point. Then, the reference starting and ending coordinates of the preset fixture angular reference line are read, and a fixture angular reference direction vector is generated from the reference starting point to the reference ending point. The angular feature axis direction vector represents the actual angular direction of the cam component under its current clamping state, while the fixture angular reference direction vector represents the angular direction that the cam component should correspond to when it is in the correct clamping state. After the two direction vectors are generated, their lengths are normalized so that subsequent dot products and cross products only reflect the directional relationship. The normalized relationship of the direction vectors is: ; in, This is the normalized direction vector; This is the direction vector before normalization, specifically corresponding to the angular feature axis direction vector or the fixture angular reference direction vector; This is the length of the direction vector.
[0095] In one specific embodiment, after the cam component is clamped, the image processing device has obtained the angular feature axis pointing from the standard angular position center to the standard opening end center through step S3. Subsequently, it reads the preset fixture angular position reference line determined by the initial fixture calibration result in the fixture reference coordinate system. If the angular feature axis deviates clockwise or counterclockwise relative to the preset fixture angular position reference line, the deviation relationship is not directly determined by the slope of the outer perimeter edge, but is determined by the operation of two directed vectors in the fixture reference coordinate system. S401 outputs the angular feature axis direction vector and the fixture angular position reference direction vector as inputs for S402 to calculate the symbolic angular deviation value.
[0096] S402: Calculation of symbolic angular deviation value.
[0097] S402 receives the angular feature axis direction vector and the fixture angular reference direction vector output by S401, and obtains the symbolic angular deviation value according to the directed angle calculation method. During the calculation, the fixture angular reference direction vector is used as the reference direction, and the angular feature axis direction vector is used as the actual direction. First, the two-dimensional cross product scalar of the two is calculated, then the dot product scalar of the two is calculated, and finally the angle with positive and negative directions is obtained through the arctangent function.
[0098] The calculation relationship for symbolic angular deviation values is as follows: ; in, The symbolic angular deviation value represents the directional angle between the angular feature axis and the preset fixture angular reference line; The reference direction vector for the fixture angular position is derived from the reference start point and reference end point of the preset fixture angular position reference line in S401; The angular feature axis direction vector originates from the start and end points of the angular feature axis in S401; It is a two-dimensional cross product scalar used to give the direction sign of the angular deviation; This is a dot product scalar function used to give the angular deviation magnitude. The output range of the arctangent function is expressed according to the directed angular range defined in the fixture reference coordinate system.
[0099] The directions of forward and reverse skew are bound to the positive and negative directions of the directed angles in the fixture reference coordinate system during the initial calibration of the fixture. Specifically, during the initial calibration stage, a preset fixture angular position reference line is used as the reference direction, and the directional angle sign corresponding to the forward adjustment direction defined on-site in the fixture reference coordinate system is recorded. When the directional angle sign of the angular feature axis relative to the preset fixture angular position reference line is consistent with the forward adjustment direction, the symbolic angular position deviation value is positive and corresponds to forward skew; when the signs are opposite, the symbolic angular position deviation value is negative and corresponds to reverse skew. The negative and positive boundaries of the preset allowable angular position range are recorded using the same directional convention, enabling the symbolic angular position deviation value to be directly determined to have an inclusion relationship with the preset allowable angular position range.
[0100] When the angular feature axis direction vector is consistent with the angular reference direction vector of the fixture, the cross product scalar is: Furthermore, the dot product of the scalar is positive, and the symbolic angle deviation value is... or close to When the angular feature axis direction vector is located on the forward side of the preset fixture angular reference line, the cross product scalar output has the same sign as the forward convention, and the symbolic angular deviation value is positive; when the angular feature axis direction vector is located on the reverse side of the preset fixture angular reference line, the cross product scalar output has the same sign as the reverse convention, and the symbolic angular deviation value is negative. S402 outputs the symbolic angular deviation value and passes this value to S403 for inclusion relationship determination with the preset allowable angular range.
[0101] S403: Preset allowed angle range inclusion relationship determination.
[0102] S403 takes the symbolic angular deviation value output by S402 as the starting point for processing and reads the preset allowable angular deviation range. The preset allowable angular deviation range includes a negative boundary and a positive boundary. The negative boundary represents the maximum allowable reverse skew angle, and the positive boundary represents the maximum allowable forward skew angle. Both are predetermined by the cam part machining requirements, the fixture clamping allowable error, or the assembly requirements of subsequent processes, and are expressed under the directional angle convention of the same fixture reference coordinate system.
[0103] During the judgment process, the symbolic angular deviation value is first compared with the negative boundary, and then compared with the positive boundary. When the symbolic angular deviation value is greater than or equal to the negative boundary and less than or equal to the positive boundary, the symbolic angular deviation value is determined to fall within the preset allowable angular range, generating a qualified judgment result. When the symbolic angular deviation value is greater than the positive boundary, the cam component is determined to have a forward skew relative to the preset fixture angular reference line, generating a forward skew judgment result. When the symbolic angular deviation value is less than the negative boundary, the cam component is determined to have a reverse skew relative to the preset fixture angular reference line, generating a reverse skew judgment result.
[0104] In one specific implementation, the same image processing device completes all calculations from S1 to S4. After the cam is clamped, the device first obtains the angular feature axis, and then reads the preset fixture angular reference line and preset allowable angular range saved during fixture debugging. If the angular feature axis only produces a directed angle within the allowable range relative to the preset fixture angular reference line, the detection result is output as qualified; if the angular feature axis deviates to the forward side and crosses the positive boundary, the detection result is output as forward skew; if the angular feature axis deviates to the reverse side and crosses the negative boundary, the detection result is output as reverse skew. S403 outputs the judgment result, which, together with the symbolic angular deviation value, enters the result organization in S404.
[0105] S404: Output of cam fixture angular deviation detection results.
[0106] S404 receives the symbolic angular deviation value output by S402 and the judgment result output by S403, and organizes them into a cam fixture angular deviation detection result. When outputting the result, the symbolic angular deviation value represents the magnitude and direction of the deviation, and the classification status is represented by qualified, forward deviation, or reverse deviation. This ensures that the detection result can reflect both whether the angular deviation exceeds the preset allowable angular deviation range and the deviation direction of the cam component relative to the fixture positioning reference.
[0107] During the output process, the symbolic angular deviation value retains its positive or negative sign, and the judgment result maintains consistency with the preset allowable angular range. If the judgment result is qualified, the test result records the symbolic angular deviation value and the qualified status; if the judgment result is forward skew, the test result records the symbolic angular deviation value and the forward skew status; if the judgment result is reverse skew, the test result records the symbolic angular deviation value and the reverse skew status. The test result, angular feature axis, and preset fixture angular baseline all maintain a correspondence under the same fixture reference coordinate system, which can be directly called for test recording, on-site display, or fixture adjustment direction judgment.
[0108] In step S4, the angular feature axis formed in step S3 is converted into a symbolic angular deviation value relative to the preset fixture angular baseline, and the inclusion relationship is determined according to the preset allowable angular range. This step ultimately outputs the cam fixture angular deviation detection result as qualified, forward skew, or reverse skew, while retaining the symbolic angular deviation value, so that the angular state of the cam component under clamping condition forms a recordable, comparable, and traceable final detection result.
[0109] The above embodiments are merely preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for detecting angular deviation of a cam fixture based on image feature recognition, characterized in that, include: Acquire detection images of the cam component under clamping state, locate the first and second clamping circular references in the detection images, establish a clamping reference coordinate system based on the center of the first and second clamping circular references, and extract a preset cam mounting window in the clamping reference coordinate system as the workpiece detection area. Candidate edge segments are obtained by performing edge segmentation on the workpiece inspection area. The standard top surface contour is placed in the workpiece inspection area according to the fixture reference coordinate system and a top surface contour constraint band is generated. The geometric assignment and grayscale assignment are calculated for each candidate edge segment. Based on the geometric assignment and grayscale assignment, the candidate edge segments are divided into effective top surface contour segments and non-top surface interference edge segments. The effective contour segments of the top surface are classified into outer perimeter effective segments, inner hole effective segments, and opening end effective segments according to their proximity in the standard top surface contour. The attitude matching angle is obtained based on the minimum distance residual from the outer perimeter effective segments and inner hole effective segments to the corresponding parts of the standard top surface contour. The angular uniqueness is verified by the side of the opening end effective segment relative to the standard opening end under the attitude matching angle, and the angular feature axis is obtained. In the fixture reference coordinate system, calculate the directed angle between the angular feature axis and the preset fixture angular reference line. Use the directed angle as a symbolic angular deviation value. Based on the inclusion relationship between the symbolic angular deviation value and the preset allowable angular range, output one of the following cam fixture angular deviation detection results: qualified state, forward skew state, and reverse skew state.
2. The method for detecting cam fixture angular deviation based on image feature recognition according to claim 1, characterized in that, The geometrical attribution quantity is determined by the length ratio of the candidate edge segment into the top surface contour constraint band, and the consistency between the tangent of the candidate edge segment and the tangent of the adjacent position of the standard top surface contour. When the length ratio is not lower than the preset falling ratio boundary and the consistency is not lower than the preset tangential consistency boundary, the corresponding candidate edge segment is determined to satisfy the geometric belonging condition. When at least one of the length ratio and consistency is lower than the corresponding boundary, the corresponding candidate edge segment is determined to not meet the geometric belonging condition.
3. The method for detecting cam fixture angular deviation based on image feature recognition according to claim 2, characterized in that, The gray-level assignment is determined by the proportion of the gray-level change direction obtained by sampling the edge points of the candidate edge segment along both sides of the normal direction to the gray-level change direction of the standard top surface boundary at the position adjacent to the standard top surface contour. When the consistency ratio is not lower than the preset grayscale consistency boundary and the candidate edge segment meets the geometric assignment condition, the corresponding candidate edge segment is divided into the top surface effective contour segment. When the consistency ratio is lower than the preset grayscale consistency boundary, or when the candidate edge segment does not meet the geometric assignment conditions, the corresponding candidate edge segment is classified as a non-top surface interference edge segment.
4. The method for detecting cam fixture angular deviation based on image feature recognition according to claim 3, characterized in that, When determining the attitude matching angle, an attitude search angle sequence is generated within a preset allowable search range. The distance residuals from the effective outer periphery segment and the effective inner hole segment to the corresponding parts of the standard top surface contour are calculated for each rotation angle to be verified. Candidate attitude angle sequences are formed in ascending order of distance residuals. For each rotation angle to be verified in the candidate attitude angle sequence, the side containing the effective segment of the opening end is verified sequentially. When the rotation angle to be verified passes the verification on the side where it is located, the rotation angle to be verified is determined as the attitude matching angle and the angular feature axis is generated; If the rotation angle to be verified fails the verification on the side it belongs to, the rotation angle to be verified is excluded, and the next rotation angle to be verified is selected from the candidate attitude angle sequence to continue the verification on the side it belongs to.
5. The method for detecting cam fixture angular deviation based on image feature recognition according to claim 1, characterized in that, The standard top surface profile is obtained by converting the cam component design profile; When establishing the standard top surface profile, mark the outer perimeter profile, inner hole profile, and opening end profile. When the standard top surface contour is placed in the workpiece inspection area according to the fixture reference coordinate system, the location marks of the outer perimeter contour, inner hole contour and opening end contour are simultaneously entered into the fixture reference coordinate system.
6. The method for detecting cam fixture angular deviation based on image feature recognition according to claim 5, characterized in that, The first and second circular references of the clamp are two fixed references on the clamp that are fixed in position and can form a circular boundary in the detection image; Extract the edge point sets of the first and second circular reference datums of the fixture within the area where the fixture is fixed; Perform circle fitting on the edge point sets of the first and second circular reference fixtures respectively to obtain the center of the first and second circular reference fixtures.
7. The method for detecting cam fixture angular deviation based on image feature recognition according to claim 4, characterized in that, In the verification of the effective segment of the opening end relative to the side of the standard opening end under the attitude matching angle, the effective contour points in the effective segment of the opening end are read, and the side of the effective contour points relative to the end direction line of the standard opening end under the attitude matching angle is compared with the corresponding side of the standard opening end. When the number of consistent sides is greater than the number of opposite sides, the corresponding attitude matching angle is retained; When the number of opposite sides is greater than or equal to the number of consistent sides, the corresponding attitude matching angle is excluded, and the next rotation angle to be verified is selected according to the candidate attitude angle sequence to continue the verification of the side.
8. The method for detecting cam fixture angular deviation based on image feature recognition according to claim 1, characterized in that, When outputting the cam fixture angular deviation detection results, a detection record is generated; The test record includes a symbolic angular deviation value, as well as one of the following test result states: qualified, forward skew, or reverse skew. When the symbolic angle deviation value falls within the preset allowable angle range, the detection record is written as qualified. When the symbolic angle deviation value is higher than the positive boundary of the preset allowable angle range, the detection record is written in the forward skew state; When the symbolic angle deviation value is lower than the negative boundary of the preset allowable angle range, the detection record is written to the reverse skew state.
9. The method for detecting cam fixture angular deviation based on image feature recognition according to claim 8, characterized in that, The inspection record also includes the center of the first fixture circular reference, the center of the second fixture circular reference, the fixture reference coordinate system, and the preset cam mounting window; The fixture reference coordinate system is jointly recorded by the center of the first fixture circular reference, the center of the second fixture circular reference, the horizontal axis direction, and the vertical axis direction. The preset cam mounting window is recorded in the form of the window boundary in the fixture reference coordinate system.
10. The method for detecting cam fixture angular deviation based on image feature recognition according to claim 8, characterized in that, The detection record also includes the effective contour segment of the top surface, the non-top surface interference edge segment, the attitude matching angle, the angular feature axis, and the preset fixture angular reference line; Among them, the effective contour segment of the top surface and the non-top surface interference edge segment are recorded using the edge segment coordinates in the fixture reference coordinate system; The angular feature axis is recorded with a start point, an end point, and a directional direction; The preset fixture angular reference line is recorded as the reference start point and reference end point.