WO2022206022A1 - 基于多模板匹配和自动对焦功能的尺寸测量仪系统 - Google Patents
基于多模板匹配和自动对焦功能的尺寸测量仪系统 Download PDFInfo
- Publication number
- WO2022206022A1 WO2022206022A1 PCT/CN2021/137820 CN2021137820W WO2022206022A1 WO 2022206022 A1 WO2022206022 A1 WO 2022206022A1 CN 2021137820 W CN2021137820 W CN 2021137820W WO 2022206022 A1 WO2022206022 A1 WO 2022206022A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- template
- measurement
- image
- user
- interface
- Prior art date
Links
- 238000005259 measurement Methods 0.000 claims abstract description 189
- 238000012545 processing Methods 0.000 claims abstract description 35
- 238000000034 method Methods 0.000 claims description 85
- 230000008569 process Effects 0.000 claims description 84
- 238000001514 detection method Methods 0.000 claims description 18
- 238000012790 confirmation Methods 0.000 claims description 15
- 238000004519 manufacturing process Methods 0.000 claims description 12
- 230000002159 abnormal effect Effects 0.000 claims description 6
- 230000005856 abnormality Effects 0.000 claims description 6
- 230000001960 triggered effect Effects 0.000 claims description 3
- 238000003825 pressing Methods 0.000 claims description 2
- 238000012423 maintenance Methods 0.000 claims 1
- 238000004364 calculation method Methods 0.000 description 11
- 238000011156 evaluation Methods 0.000 description 9
- 230000006978 adaptation Effects 0.000 description 8
- 238000013519 translation Methods 0.000 description 8
- 238000012360 testing method Methods 0.000 description 7
- 238000010586 diagram Methods 0.000 description 4
- 238000012986 modification Methods 0.000 description 4
- 230000004048 modification Effects 0.000 description 4
- 238000006073 displacement reaction Methods 0.000 description 3
- 238000003708 edge detection Methods 0.000 description 3
- 238000001914 filtration Methods 0.000 description 3
- 239000011521 glass Substances 0.000 description 3
- 238000012217 deletion Methods 0.000 description 2
- 230000037430 deletion Effects 0.000 description 2
- 238000000605 extraction Methods 0.000 description 2
- 239000011159 matrix material Substances 0.000 description 2
- 238000012546 transfer Methods 0.000 description 2
- 230000003044 adaptive effect Effects 0.000 description 1
- 238000012937 correction Methods 0.000 description 1
- 230000007812 deficiency Effects 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
- 229920001296 polysiloxane Polymers 0.000 description 1
- 230000011218 segmentation Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01B—MEASURING LENGTH, THICKNESS OR SIMILAR LINEAR DIMENSIONS; MEASURING ANGLES; MEASURING AREAS; MEASURING IRREGULARITIES OF SURFACES OR CONTOURS
- G01B11/00—Measuring arrangements characterised by the use of optical techniques
- G01B11/002—Measuring arrangements characterised by the use of optical techniques for measuring two or more coordinates
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01B—MEASURING LENGTH, THICKNESS OR SIMILAR LINEAR DIMENSIONS; MEASURING ANGLES; MEASURING AREAS; MEASURING IRREGULARITIES OF SURFACES OR CONTOURS
- G01B11/00—Measuring arrangements characterised by the use of optical techniques
- G01B11/02—Measuring arrangements characterised by the use of optical techniques for measuring length, width or thickness
- G01B11/03—Measuring arrangements characterised by the use of optical techniques for measuring length, width or thickness by measuring coordinates of points
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01B—MEASURING LENGTH, THICKNESS OR SIMILAR LINEAR DIMENSIONS; MEASURING ANGLES; MEASURING AREAS; MEASURING IRREGULARITIES OF SURFACES OR CONTOURS
- G01B11/00—Measuring arrangements characterised by the use of optical techniques
- G01B11/24—Measuring arrangements characterised by the use of optical techniques for measuring contours or curvatures
Definitions
- the present invention relates to the field of size measurement, and more particularly, to a size measurement instrument system based on multi-template matching and auto-focus functions.
- image sizers which are often used to measure two-dimensional dimensions. Widely used in various precision industries. At present, it is mainly used for the dimensions and angles of components that are difficult or impossible to measure with calipers and angle rulers but play an important role in assembly, such as silicone, the creepage distance of circuit boards, electrical clearances, and control panels. Light holes, certain sizes of plastic parts, etc., can also be used to take pictures of certain parts to analyze the cause of failure.
- the existing image size measuring instruments still have many shortcomings in actual use. At present, it is difficult to achieve fully automatic detection. The detection process is varied and there is no certain standard, which makes the final detection results prone to deviations, resulting in low work efficiency. , For the detection of high-precision products, it greatly increases the labor intensity of the staff, and it is difficult to effectively help the staff to reduce workload and improve work efficiency.
- the invention overcomes the deficiencies of the prior art, and provides a fully automatic, standardized and efficient working size measuring instrument system based on multi-template matching and automatic focusing functions.
- the technical scheme of the present invention is as follows:
- Initialization steps start the measuring instrument, open the operating software, enter the startup initialization interface, and perform startup initialization in this interface; the startup initialization process mainly performs the detection of system-related software and hardware, and the reading and setting of parameters.
- the hardware detection result information is processed to determine whether there is a software or hardware abnormality that the system cannot operate normally; if there is, wait for the user to confirm the abnormal information and exit the system; if not, enter the template selection interface;
- Template selection interface processing steps When entering the template selection interface, the template selected by the user before exiting the system last time is checked or selected by default, and the user can select one or more workpiece templates to be measured in this interface; the user completes the selection Then click the "Enter Measurement” button to enter the next interface or click the "Exit System” button to exit the system;
- a confirmation exit system dialog box pops up. If the user selects OK, the system exits the system. Otherwise, the exit system dialog box is closed.
- the multi-template matching function of the present invention realizes real-time measurement of various types of workpieces without switching templates. All templates are displayed in real time on the measurement interface, and the selection template can be switched to realize fast workpiece template selection and improve measurement efficiency.
- the real-time image processing algorithm the optimization of the processing flow includes reducing the image resolution (pixel merging processing) and improving the image processing speed; inter-frame image comparison: judge whether the workpiece under test is moving according to the difference between the frames and the previous frame image, if not. , directly rotate and translate the image of the current frame according to the result of the rotation and translation of the previous frame, and then perform the relevant size measurement according to the mask information of the template of the previous frame.
- Incoming template matching sequence Pass in the number of the template image matched by the previous real-time image.
- the algorithm reads the template and mask information directly according to the corresponding number, performs matching and measurement, and processes it according to whether the measured object is moving.
- Comparison of the image to be measured and the source image of the template according to the difference with the source image of the current template, determine whether the workpiece under test moves, if not, measure the relative size according to the mask information of the current template.
- the horizontal mirror image of the object to be tested and the template source image are then matched to detect whether the object to be tested is reversed. Specifically, it is sorted and refined through the single image size measurement module.
- FIG. 2 is a schematic diagram of the device of the present invention.
- Fig. 3 is the partial structure schematic diagram of Fig. 2 of the present invention.
- FIG. 4 is a schematic diagram of the lift adjustment part of FIG. 2 according to the present invention.
- the dimension measuring instrument system based on multi-template matching and auto-focus function, wherein the dimension measuring instrument is shown in Fig. 2 to Fig. 4, the dimension measuring instrument includes a lift adjustment part and a support part, and the lift adjustment part is arranged in the on the support part.
- the support part includes a load-bearing plate (20) installed on the base (11), a light source (19) installed in the load-bearing plate (20), and a one-key measurement button (12) in the base, located on the stage glass (13)
- the external special fixture fixing hole belts (10) on both sides are suitable for clamping some parts that are inconvenient to place through special fixtures, and the four pieces for fixing and adjusting the level of the stage glass (13) Knob screw (9).
- the lift adjustment part includes a lift arm (21) mounted on the bearing plate (20), a lift arm knob (7) for controlling the movement of the lift arm (21), and a lens bracket (8) mounted on the lift arm (21). ), a component mounted on the lens bracket (8), the components include a lens cover (16) and a displacement sensor bracket (3).
- the displacement sensor (5) is mounted on the displacement sensor bracket (3).
- the lift arm housing (1) wraps the lift arm (21), and on the lift arm housing (1), there are six-row annular light bracket fixing holes (2) symmetrical on both sides for fixing the annular light bracket at a suitable position (4), a ring light fixture (15) is arranged on the ring light bracket (4), and the ring light (14) is fixed on the ring light fixture (15).
- the industrial camera (16) is mounted on the lens bracket (8), and the lens (18) is mounted on the industrial camera (17), which is covered by the lens cover (16) so as not to expose the structure, which is convenient for protecting the internal instruments.
- the rotating vertical arm knob (7) drives the gear (25) to transmit power to the rack (26) engaged with it, thereby driving the slider (24) on which the rack (26) is installed. ) in the vertical direction.
- the gear (25) to transmit power to the rack (26) engaged with it, thereby driving the slider (24) on which the rack (26) is installed.
- the locking paddle (6) down in the locking direction, and drive the thread on the locking shaft (27) to move it inward.
- the locking rubber pad (28) installed at the end of the locking shaft (27) The rough belt (23) on the rack (26) will be tightly pressed to achieve the purpose of locking.
- the dimension measuring instrument Using the dimension measuring instrument, first place the object to be measured on the stage glass (13), then adjust the vertical arm knob (7) to make the industrial camera (17) and lens (18) reach the proper position, and then turn the locking dial. Pull the tab (6) down in the locking direction, then adjust the ring light bracket (4) to a suitable position, press the one-key measurement button (12), and the corresponding size of the required part to be measured can be displayed on the external touch screen .
- Initialization steps start the measuring instrument, open the control software, and the operating software enters the startup initialization interface, where the startup initialization is performed; the startup initialization process mainly performs the detection of system-related software and hardware, as well as the reading and setting of parameters.
- Relevant software and hardware include: database, camera, ring light source and backlight source, and the parameters mainly include camera configuration parameters, serial port configuration parameters, authority management parameters and size measurement related parameters.
- Process the detection result information of the relevant software and hardware to determine whether there is a software or hardware abnormality that the system cannot run normally; if so, wait for the user to confirm the abnormal information and exit the system; if not, enter the template selection interface.
- Template selection interface processing steps When entering the template selection interface, the template selected by the user before exiting the system last time is checked or selected by default (checking means that the user selects the required template, and the selection is the template information that the user needs to view, generally the above The template selected by the user before exiting the system for the first time, but can be selected again), the user can select one or more workpiece templates to be measured in this interface. If the template is selected, the interface will display the measurement result of the template. and measurement result information, the selection operation has and only one template can be selected.
- a confirmation exit system dialog box pops up. If the user selects OK, the system exits the system. Otherwise, the exit system dialog box is closed.
- the startup initialization process is completed. If there is no specified abnormality, the system will enter the template selection interface.
- the user After entering the template selection interface, the user can enter the template name in the template search input box to quickly search for the specified template.
- the real-time measurement module includes the current measurement workpiece collection picture display, measurement result data display and template selection box area for interface display and the specific functions are as follows:
- the "Start Measurement” button When the "Start Measurement” button is not pressed, the workpiece image captured by the camera in real time and the template source image of the currently selected template are superimposed and displayed in a certain ratio. When the "Start Measurement” button is pressed, the real-time measurement of the workpiece to be measured is performed. , the measurement result graph will be displayed, and the focus definition and the currently matched template name will be displayed;
- the measurement result data is displayed on the right side of the interface according to the measurement result of the current workpiece, and the measurement number and the measurement result are displayed respectively.
- the measurement number corresponds to the number displayed on the measurement result graph.
- the size to be measured is displayed, the number of the unmeasured size is displayed, and the unmeasured size is displayed in the result column;
- a template selection box is displayed in the middle at the bottom of the interface.
- the user can select a template in this selection box; in this selection box, all templates made by the system will be displayed, but no empty templates are included.
- Users can select the template of the workpiece to be tested by checking the check box in front of the template icon, and click the template icon to select the template, but the template selection operation can only be selected in the selected template, and the template source image of the selected template It is used to display in the picture display area after being superimposed with the real-time picture.
- the interface includes four buttons: "System Settings”, “Temporary Production”, “Start Measurement/Stop Measurement” and "Exit System”. Different operations can be performed by clicking different buttons.
- the implementation is as follows:
- the unmeasured measurement types perform or process the corresponding mask image according to the gray value of the pixel point, where the mask image is a gray image, and the gray value of the pixel point is 255 or 0.
- the OR process of the two images is as follows: the two mask images correspond to the gray value of each row and each column of pixels, and the result image is obtained. If the gray value of the two pixels is 255 and 255, the result The gray value of the pixel at the corresponding position of the image is set to 255. Similarly, if 255 and 0, it is set to 255, and if it is 0 and 0, it is set to 0.
- Double loop traverse the final result graph and measurement result graph obtained in the previous step.
- the BGR value of the corresponding pixel in the corresponding measurement result graph is set to be different from the measured value.
- the automatic exposure adjustment parameters include automatic exposure selection, exposure adjustment target gray value, target gray value ratio lower limit, target gray value ratio upper limit, and exposure adjustment scale;
- the specific execution parameter configuration in the parameter configuration is as follows:
- the new template name input box will pop up, waiting for the user to enter the new template name; in the new template name input box, determine whether the user clicks the "OK” button, if so, traverse the system If all template names already exist, judge whether the new template name entered by the user already exists; otherwise, judge whether the user clicks the "Cancel” button, if so, close the input box for the new template name; Wait for the user to click the "OK” button, close the information prompt box, and return to judge the user's operation; if it does not exist, turn on the camera to capture images in real time, and pop up a confirmation box for creating a new template, in which the images captured by the camera are displayed in real time.
- the new template confirmation box Let the user confirm the current template through the real-time display of the captured image; in the new template confirmation box, if the user clicks the "OK" button, the user input template name will be recorded, the new template confirmation box will be closed, and the template task editing interface will be opened after turning off the camera; When the user clicks the "Cancel” button, the new template confirmation box is closed and the camera is closed, and the user's operation is returned to be judged;
- the template task editing interface it is necessary to determine whether the user clicks the "Return” button. If the user clicks the "Return” button, the template information acquisition process is executed to obtain template information, and the template information of the newly created template is added to the list of template information created by the system. It is saved to the template information summary table and template mask information table in the database; close the template task editing interface, return to the template creation interface, and update the display information of the template creation interface;
- the update information is as follows: First, add a new template to the template display list, and check and select the corresponding template; the measurement result graph and measurement result information of the corresponding template information are displayed on the interface, and the template measurement result graph will be based on the area to be measured. The measurement results are shown in the result drawing; then in the prompt information, select the template information to add the template, and the selected template information can be displayed as the template name;
- the template making interface judge whether the user clicks the "Remake” button, and a template remaking confirmation box will pop up; in the confirmation box, judge whether the user clicks the "OK” button and the "Cancel” button. If the "OK” button is clicked, Then close the template re-creation confirmation box, open the template task editing interface, and transfer the currently selected template source image to the interface for template task editing.
- the template task editing and exit operations are the same as when creating a new template.
- the created template information list already exists, and the information of this template in the template information list needs to be updated according to the template information obtained after re-production, and the database operation is also updated for this template information;
- a template deletion confirmation box will pop up, waiting for the user to perform the "OK” button and "Cancel” button operations;
- This template is deleted, and the template information in the database is deleted, and the information displayed in the template operation interface is updated according to the currently checked and selected template status; if the "Cancel" button is clicked, the template deletion confirmation box will be closed, and then return to judge the user operation;
- the template name input box will pop up, waiting for the user to enter the template name, and in the input box, determine whether the user presses the "OK" button or "Cancel” button. If you click the "OK” button, it will determine whether the template name entered by the user already exists in the template created by the system. If you click the "Cancel” button, the template input box will be closed and then return to determine the user's operation; if it does not exist, the template will be modified. After updating the template name in the template information in the database and the information related to the template in the template creation interface, close the template name input box. If it already exists, the template name already exists information prompt box will pop up, waiting for the user to click "OK" After pressing the button, close the information prompt box and return to judge the user operation;
- creating a template, deleting a template, re-creating a template, renaming a template, deleting a template, and copying a template all require administrator privileges to operate. Therefore, the administrator password input box will pop up before the corresponding operation, and can only be performed when the correct password is entered again.
- Corresponding operations perform multiple administrator privilege operations in the template creation interface, and enter the administrator password once, but as long as you return to the real-time measurement interface and re-enter the template creation interface, you need to re-enter the correct administrator password. permissions to operate.
- the template source image is the front and side images of the standard part obtained by the camera;
- thresholding processing is that the pixel gray value greater than the set threshold value is set to 0, otherwise, it is set to 255;
- ROI 5 Extract the ROI according to the coordinates and radius of the center of the circle; this ROI is a rectangle whose side length is the diameter of the minimum circumscribed circle of the standard part in the template source image, its center is the center of the minimum circumscribed circle of the standard part, and its rotation angle is zero ; ROI indicates the region of interest.
- the hierarchical contour information includes the outer contour information and the inner contour information, and the outer contour and the inner contour satisfy the parent-child hierarchical relationship; if the outer contour and the inner contour satisfy the parent-child hierarchical relationship, the outer contour is the parent contour, The inner contour is a sub-contour;
- step 8 If the length or width of the rectangle is greater than the set value, the standard part is out of bounds, and jump to step 16;
- step 16 If there is no inner contour, go to step 16;
- step 16 If there is only one valid inner contour, obtain the center of mass, the coordinates of the center of the minimum circumscribed rectangle, the rotation angle, the length and width, and the area, and go to step 16;
- step 14 If the difference between the maximum value and the minimum value of the minimum circumscribed rectangle area is greater than the set value, it indicates that there are both the maximum inner contour and the minimum inner contour; respectively obtain their centroid, the center coordinates of the minimum circumscribed rectangle, and the rotation angle , length, width, area, go to step 16;
- step 15 If the difference between the maximum value and the minimum value of the minimum circumscribed rectangle area is less than or equal to the set value, it indicates that there are multiple valid maximum inner contours for the standard part, and any one is selected to obtain the centroid, the center coordinates of the minimum circumscribed rectangle, and the rotation angle. , length, width, area, go to step 16;
- the autofocus module continuously measures the sharpness of the real-time images collected by the camera; through the sharpness, it prompts the user whether it is clear, if not, the user is asked to adjust the height of the camera until the image is clear;
- the left side of the interface of the autofocus module displays the real-time image of the camera, and the right side displays the image of the area selected by a rectangular frame in the real-time image; the top of the image on the right displays the progress bar of clarity, and the parameters are set below the image on the right.
- the focus parameters include: Edge detection threshold, focus standard ratio value and focus lower limit ratio threshold; edge detection threshold is 0-255 for black and white edge area segmentation, and the default is 100; The default setting is 90; the lower limit of focus ratio threshold is 0-100, and the alarm threshold is 0-100, and the default setting is 70;
- the specific processing of the auto focus module is as follows:
- the progress bar will display the ratio value and the color will display green, indicating that the current area has good sharpness, and there is no need to adjust the camera height; if the sharpness evaluation value is smaller than the focus standard ratio value and greater than the focus lower limit ratio value, the progress bar will display yellow, indicating that the current area has poor sharpness, and you can fine-tune the camera height; if the sharpness evaluation value is less than the focus lower limit ratio value, the progress bar will display red, indicating that the current area has poor sharpness and must be adjusted.
- the camera height is adjusted to adjust the image clarity, otherwise accurate size measurement cannot be performed;
- the real-time size measurement of a single image is as follows:
- the real-time measurement process of a single image is ended; if there is a temporary template name, the temporary template source image is pixel-merged, and then the pixel-merged image to be tested and the pixel-merged temporary template source image are subjected to differential processing. If it is inconsistent, output the object to be measured out of bounds, and end the real-time measurement process of a single image; if they are consistent, rotate and translate the current frame image according to the rotation and translation results of the temporary template source image;
- the AF flag is valid. If it is valid, call the measurement type for AF area selection, execute the real-time measurement AF sharpness evaluation function, return the sharpness value, and then perform the related measurement type according to the current frame mask information. Size measurement; if invalid, directly measure the size of the relevant measurement type according to the current frame mask information;
- the detection result is not out of bounds, perform pixel merging on the previous frame to be tested, and then compare images between frames, that is, perform inter-frame difference processing on the pixel-merged image to be tested and the pixel-merged previous frame to be tested. , if the two are consistent, it means that the object to be tested has not moved, then directly rotate and translate the image of the current frame according to the result of the rotation and translation of the previous frame; judge whether the auto-focus flag is valid, if so, call the auto-focus area selection function.
- Measurement type execute the real-time measurement autofocus sharpness evaluation function, return the sharpness value, and then measure the size of the relevant measurement type according to the mask information of the previous frame; if invalid, directly carry out the measurement of the relevant measurement type according to the mask information of the previous frame.
- Size measurement if the two are inconsistent, it means that the object to be tested has moved, and then traverse all the selected template information, among which the template information corresponding to the template number is preferentially matched first, and the corresponding template source image is merged into pixels.
- the image to be tested and the template source image are subjected to differential processing. If the two are consistent, the traversal is terminated, and the rotation and translation of the current frame image is directly performed according to the rotation and translation results of the current template source image.
- the traversal is terminated, and the translation amount of the object to be measured after the pixel combination obtained in the object matching process is converted into the translation amount without pixel combination according to the pixel combination coefficient; it is judged whether the auto focus flag is valid, if it is valid , call the measurement type used for AF area selection, execute the real-time measurement AF sharpness evaluation function, return the sharpness value, and then measure the size of the relevant measurement type according to the current frame mask information; if invalid, directly measure the size according to the current frame mask
- the film information is used to measure the size of the relevant measurement type; if the object to be measured is not successfully matched, the center of the smallest circumcircle of the object to be measured is used as the vertical axis, and the image of the object to be measured is horizontally mirrored on this axis to obtain the horizontal mirror image as the input parameter.
- pixel merging is to merge the pixels of each row in the image into one pixel in turn with every four adjacent pixels, and its gray value is averaged.
- the adjacent pixels are merged into one pixel in turn, and their gray values are averaged.
- the out-of-bounds detection process is as follows:
- the filtered image is subjected to grayscale threshold binarization; the pixel grayscale value greater than the set threshold value is set to 255, otherwise, it is set to 0; in this embodiment, the threshold value is set to 180;
- the closed-loop contour refers to that the distance between any two adjacent contour points in the contour is less than the set value, and the set value of the present embodiment takes 2 pixels;
- the setting conditions are that the maximum closed-loop contour perimeter is not less than 0.99 times the image perimeter and not greater than 1.01 times the image perimeter; if the perimeter meets the conditions , the object to be tested is not out of bounds, and the process ends; if the perimeter does not meet the conditions, the object to be tested is out of bounds, and the process ends;
- test object matching process is as follows:
- the contour information of the part to be detected includes the outer contour information and the inner contour information of the part to be detected, and the outer contour and the inner contour satisfy the parent-child hierarchical relationship, wherein the outer contour is the parent contour and the inner contour is the child contour;
- the absolute value of the difference between the minimum circumscribed rectangle area of the outer contour of the object to be inspected and the minimum circumscribed rectangle area of the template source image is less than the set value, then determine the aspect ratio of the outer contour of the part to be inspected and the template source image. Whether the absolute value of the aspect ratio difference of the minimum circumscribed rectangle of the outer contour is less than the set value; in this embodiment, the range of the set value is 10% of the aspect ratio of the minimum circumscribed rectangle of the outer contour of the template source image;
- step 7 If the absolute value of the difference between the aspect ratio of the minimum enclosing rectangle of the outer contour of the object to be detected and the aspect ratio of the minimum enclosing rectangle of the outer contour of the template source image is greater than or equal to the set value, the object is not matched successfully, and skip to step 4 to execute;
- step 18 If the distance between the center of mass of the outer contour of the template source image and the center of the minimum circumscribed rectangle of the outer contour of the template source image is less than or equal to the set value, go to step 18;
- the set value ranges from the centroid of the outer contour of the template source image to 10% of the aspect ratio of the minimum circumscribed rectangle of the outer contour ;
- step 18 If the absolute value of the difference between the centroid of the outer contour of the object to be detected and the center of the minimum circumscribed rectangle and the difference between the centroid of the outer contour of the template source image and the aspect ratio of the minimum circumscribed rectangle of the outer contour is greater than or equal to the set value, then jump to step 18 ;
- the ROI is a rectangle whose side length is the diameter of the minimum circumscribed circle of the template source image, and its center is the minimum circumscribed circle of the object to be detected. circle center;
- the set value is 7.5 degrees.
- step 16 If the difference between the vector angles in step 15 is less than the set value, it means that the object is successfully matched, and the end of step 2;
- step 17 If the difference between the vector angles in step 15 is greater than or equal to the set value, go to step 18;
- valid inner contour matching includes judging whether the maximum inner contour and minimum circumscribed rectangle area of the part to be detected match with the template source image’s maximum inner contour and minimum circumscribed rectangle area. , and further judge whether the aspect ratio of the maximum inner contour and the minimum circumscribed rectangle matches, and whether the center distance of the outer contour and the minimum circumscribed rectangle of the maximum inner contour match, and find the rotation angle of the part to be detected relative to the template source image, combined with the template source image center coordinates and Angle information, rotating and translating objects, whether the vector angle of the center of the smallest circumscribed rectangle of the outer contour and the largest inner contour matches, to detect whether the matching is successful;
- the template source image has multiple maximum inner contours, traverse all the inner contours in the part to be detected, perform effective inner contour matching for each inner contour, and determine whether there is at least one inner contour that is successfully matched. If so, the object is successfully matched. End this process; if no, the object is not matched successfully, end this process;
- the number of selected templates must be less than the threshold set by the system and the camera calibration result data exists;
- the control status is set as follows: the real-time image display will no longer superimpose the template image display; the size measurement result data display will be cleared; the template display frame can only be scrolled to the display frame, and the system has created All the templates in the Button and the currently checked template to be matched; the "System Settings", "Temporary Production” and “Exit System” buttons are invalid;
- the image captured by the previous frame of the camera is used to quickly judge the workpiece after the frame difference processing with the current frame image. Whether to move; the image captured by the camera in this frame is used as the image for size measurement; all checked template information, including template source image, template source image ROI information, template source image feature information, and the number of contours in the template source image , stencil mask image, stencil mask feature information, stencil mask accurate feature information; the template number is matched first, when the real-time image and the template image are successfully matched, after the execution of the size measurement algorithm, the location of the successfully matched template image will be checked. The position in the template list, and its position sequence is used as the priority matching template number, and the next time the camera captures an image, the setting value is passed to the size measurement algorithm;
- the returned sharpness value is greater than the focus standard ratio value set by the system, it is judged whether the number of captured images is greater than the number of images at the interval of sharpness calculation interval set by the system.
- the sharpness calculation is performed, otherwise the autofocus flag is cleared; finally, the size measurement results of this time are saved, and the specific values of each measurement type are specified;
- Temporary Production Users can directly enter the template task interface for template production by clicking the "Temporary Production" button on the real-time measurement interface. After the production is completed, a temporary template is generated, and the temporary template is selected in the template selection interface, template creation interface or real-time measurement interface. Then perform size measurement of the selected temporary template; temporary production will generate a temporary template, which will be displayed and selected in the template display list of the template selection interface, template creation interface and real-time measurement interface, and the original one will be replaced after re-production. Temporary template, so there is only one temporary template in the system at most; the user can quickly make a temporary template through the temporary measurement function, and then quickly measure the temporary workpiece.
- the automatic frame skipping and frame rate adaptation process is performed according to the execution time of the size measurement algorithm and the frame rate time of the camera captured image;
- Automatic frame skipping is for the processing of a single image.
- the processing time of a single image exceeds the system constraints, it will automatically skip the frame or end the single image processing, thereby preventing the system crash caused by the long processing time of a single image;
- the average time of multiple image processing is calculated as the basis for adjusting the frame rate, so that the frame rate of image acquisition can meet the processing requirements of most images in real-time image processing.
- the processing time is too long, automatic frame skipping is adopted;
- First carry out the frame skipping process determine whether the camera has captured an image, if it has captured an image, then determine whether the number of images captured by the current measurement is greater than 1, and if it is greater than 1, determine whether the specified image size measurement thread before the current image is End, where the designation basis of the designated image thread is: when the current measurement collects the first image, the first image is designated as the designated image; if it is not over, the designated image size measurement thread passes through the number of images plus 1, and at the same time, the designated image The number of images passed by the unprocessed size measurement thread between the current image and the current image is also incremented by 1; if it has ended, the image corresponding to the earliest established unprocessed size measurement thread is selected between the current image and the specified image.
- For the specified image add 1 to the number of images passed by all processing threads between the specified image and the current image; judge whether the number of images passed by the specified image size measurement thread reaches the set threshold, and if so, judge the thread Whether the execution time reaches the set threshold, if so, the thread will be destroyed, and the image corresponding to the earliest established unprocessed size measurement thread between the current image and the specified image is selected as the specified image;
- Frame rate adaptation process First, after the camera captures the image and performs frame skipping processing, the current image creation thread executes the single image real-time size measurement process; judges whether the single image size measurement process is completed, and if so, judges that the image template matches Whether it is successful, otherwise it will return to judge whether the image is collected; the purpose of judging whether the template matching is successful is that the frame rate adaptation only performs time statistics on the images whose template matching is successful, because in the image processing algorithm, the running time when the template matching is successful is long. It can represent the normal image processing algorithm time, so this time is selected as the adjustment basis for frame rate adaptation;
- the template matching is successful, the running time of the image size measurement process is saved, and then it is judged whether the number of images successfully matched by the template is greater than the set threshold; After processing, average the remaining time to obtain the average time; determine whether the average time is greater than the frame rate time threshold, where the frame rate time threshold is the product of the time corresponding to the image acquisition frame rate and the frame rate adaptive upper limit proportional threshold, If it is greater than that, adjust the camera capture frame rate to the frame rate corresponding to the average time;
- the template calibration process includes the following steps:
- Step 1 Place the calibration plate at different positions in the field of view, and collect images of the calibration plate respectively;
- Step 2 After the image acquisition of the calibration board is completed, turn off the camera acquisition, and call the calibration algorithm to perform image calibration processing;
- Step 3 After the calibration process is completed, update the calibration parameters to the latest calibration parameters
- Step 4 Exit the template calibration interface
- the image calibration process includes acquiring camera distortion parameters, camera internal parameter matrix and acquiring magnification; acquiring camera distortion parameters and internal parameter matrix through Zhang Zhengyou's distortion correction algorithm, including the following steps:
- Step 1.1 Read the calibrated image data and calibration parameters that have been captured.
- the number of horizontal points in the calibration parameter refers to the number of rows of the checkerboard on the fixed board, the number of vertical points refers to the number of columns of the checkerboard, and the unit spacing is the number of cells in each small grid of the checkerboard. true physical size;
- Step 1.2 Extract corner point information for each frame of calibration image
- Step 1.3 Use the extracted corner information to further extract sub-pixel corner information
- Step 1.4 Initialize the spatial three-dimensional coordinate system of the corner points on the calibration board
- Step 1.5 Use the extracted sub-pixel corner point information and the spatial three-dimensional coordinate system information of the corner points on the calibration board to calibrate the camera, and obtain the distortion parameters participating in each frame of image in the camera, the rotation vector and translation vector of each frame image;
- Step 1.6 Evaluate the calibration results; first obtain the distortion parameters through the camera calibration, re-project the spatial three-dimensional coordinate points of each frame of images, obtain new projection points, and calculate the error between the new projection point and the old projection point, If the error is less than the set value of 0.15 pixels, it meets the requirements, save the calibration results and distortion parameters, and end the process; if the error is greater than or equal to the set value of 0.15 pixels, it does not meet the requirements, end the process and prompt to re-collect the calibration image;
- the process of obtaining magnification includes the following steps:
- Step 2.1 Use the calibration result to correct a certain frame of the collected calibration image
- Step 2.2 Extract corner information from the corrected image
- Step 2.3 Extract sub-pixel corner information
- Step 2.4 Traverse the number of corrected image columns, calculate and save the distance from the first row to the penultimate row of each column;
- Step 2.5 Sort the spacing saved in each column
- Step 2.6 Centering on the middle column, select several columns, and accumulate the saved spacing of the selected columns;
- Step 2.7 Calculate the mean value according to the accumulated value
- Step 2.8 According to the mean value, the number of columns, and the physical size, find the magnification ratio.
- the calculation formula of the magnification ratio is the mean value/(the number of columns-2)/physical size;
- Step 2.9 End the process.
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Length Measuring Devices By Optical Means (AREA)
Abstract
基于多模板匹配和自动对焦功能的尺寸测量仪系统,包括:1)初始化步骤、2)模板选择界面处理步骤、3)实时测量步骤。实现全自动、标准化、高效工作。
Description
本发明涉及尺寸测量领域,更具体地说,它涉及基于多模板匹配和自动对焦功能的尺寸测量仪系统。
在自动化生产过程中,为了保证产品质量,需要使用尺寸测量仪对产品的尺寸进行测量操作。
传统的尺寸测量仪,难以很好的在保证自动化程度的前提下保证测量的精准度,容易出现由于测量误差过大而导致的不合格产品占有比例过大,增加成本的同时降低了工作效率,给使用者的使用带来不便。
因此图像尺寸测量仪成为一种趋势,其常用于测量二维尺寸。广泛应用在各种不同的精密产业中。目前主要用于在卡尺、角度尺很难测量到或根本测量不到的但在装配中起着重要的零部件尺寸、角度等,如硅胶、电路板的爬电距离、电器间隙、控制面板的灯孔、塑料件的某些尺寸等等,还可用于对某些零部件的图片进行拍摄用于分析不良原因。
但是现有的图像尺寸测量仪在实际使用时,仍旧存在较多缺点,目前难以做到全自动化检测,检测的过程五花八门没有一定的标准,使得最终检测结果也容易出现偏差,使得工作效率不高,对于高精度产品的检测,反而大大增加了工作人员的劳动强度,难以有效的帮助工作人员降低工作量,提高工作效率。
发明内容
本发明克服了现有技术的不足,提供了全自动、标准化、高效工作的基于多模板匹配和自动对焦功能的尺寸测量仪系统。为了解决上述技术问题,本发明的技术方案如下:
基于多模板匹配和自动对焦功能的尺寸测量仪系统,
1)初始化步骤:启动测量仪,打开操作软件后,进入开机初始化界面,在该界面中进行开机初始化;开机初始化流程主要进行系统相关软硬件的检测以及参数的读取和设置工作,对相关软硬件的检测结果信息进行处理,判断是否存在系统无法正常运行的软硬件异常;若存在,则等待用户进行异常信息确认并退出系统;若不存在,则进入模板选择界面;
2)模板选择界面处理步骤:进入模板选择界面时,默认勾选或选择上次退出系统前用户选择的模板,用户可在该界面中勾选一个或者多个需要测量的工件模板;用户完成选择后点 击“进入测量”按钮进入下一个界面或者点击“退出系统”按钮退出系统;
3)实时测量步骤:实时测量界面内进行工件尺寸的实时测量、系统设置、临时制作和退出系统的操作;
在实时测量界面中点击“开始测量”按钮进入被测工件的实时尺寸测量流程;先判断是否满足测量条件,分别判断勾选模板数是否符合约束条件和相机校准结果数据是否存在,若满足测量条件,则判断是否采集到图像,否则根据未满足的测量条件弹出信息提示框提示,等待用户进行信息确认后返回,等待用户操作;若采集到图像,则进行连续测量和一键测量版本的判断;若为一键测量版本,则进入一键测量版本单张图像实时尺寸测量流程,完成该流程后再判断处理图像张数是否达到设定值,若达到则进行多张图像数据处理流程,完成该流程后结束本次测量,等待用户操作,若未达到,则返回判断是否采集到图像;若为连续测量版本,则进入连续测量版本单张图像实时尺寸测量流程,完成后进入连续测量版本的多张图像数据处理流程,完成该流程后进入下一次循环,判断是否采集到图像;
退出系统触发后,弹出确认退出系统对话框,若用户选择确定,则退出系统,若否则关闭退出系统对话框。
相比现有技术优点在于:本发明的多模板匹配功能,实现多种不同类型工件实时测量,无需切换模板。所有模板在测量界面实时显示,并可进行选择模板的切换,实现快速的工件模板选择,提高测量效率。其中实时图像处理算法:处理流程优化包括减少图像分辨率(像素合并处理),提高图像处理速度;帧间图像比较:根据与上一帧图像的帧间差分判断被测工件是否移动,若未移动,直接根据上一帧的旋转平移结果进行当前帧图像的旋转平移,再根据上一帧模板的掩膜信息进行相关尺寸测量。传入模板匹配顺序:传入上一帧实时图匹配到的模板图的编号,算法直接根据相应编号,读取模板及掩膜信息,进行匹配、测量,结合被测物是否移动进行处理。待测图和模板源图的比较:根据与当前模板源图的差分判断被测工件是否移动,若未移动,则根据当前模板的掩膜信息进行相关尺寸测量。当待测物和模板源图未匹配成功时,再将待测物水平镜像图像和模板源图进行匹配,用来检测待测物是否放反。具体通过单张图像尺寸测量模块进行整理细化。
图1为本发明的系统框图;
图2为本发明的设备示意图;
图3为本发明的图2的部分结构示意图;
图4为本发明的图2的升降调整部分的示意图
下面结合附图和具体实施方式对本发明进一步说明。
如图1所示,基于多模板匹配和自动对焦功能的尺寸测量仪系统,其中的尺寸测量仪如图2至图4所示,尺寸测量仪包括升降调整部分、支撑部分,升降调整部分设置在支撑部分上。
支撑部分包括安装在底座(11)上的承重板(20),安装在承重板(20)内的光源(19),底座中含有一键测量按钮(12),位于载物台玻璃(13)两侧的外置专用夹具固定孔带(10)适用于在测量一些不便于摆放的零件通过专用的工装夹具进行夹持,以及负责固定以及调整载物台玻璃(13)水平度的四颗旋钮螺丝(9)。
升降调整部分包括安装在承重板(20)上的升降立臂(21)、控制升降立臂(21)运动的立臂旋钮(7)、安装在升降立臂(21)上的镜头支架(8)、安装在镜头支架(8)上的部件,部件包括镜头罩(16)、位移传感器支架(3)。位移传感器(5)安装在位移传感器支架(3)上。升降立臂外壳(1)将升降立臂(21)包裹住,在升降立臂外壳(1)上,有两边对称的六行环形光支架固定孔(2)用于在合适位置固定环形光支架(4),环形光支架(4)上设置环形光夹具(15),环形光(14)固定在环形光夹具(15)上。工业相机(16)安装在镜头支架(8)上,镜头(18)安装在工业相机(17)上,其被镜头罩(16)包住达到不将结构外露即可,便于保护内部的仪器。
在升降立臂(21)内,旋转立臂旋钮(7)带动齿轮(25)从而将动力传动给与之啮合的齿条(26),从而带动安装有齿条(26)的滑块(24)在竖直方向上运动。当运动到合适位置时,将锁定拨片(6)向锁定方向拨下,带动锁定轴(27)上的螺纹带动其向内运动,安装在锁定轴(27)末端的锁定橡胶垫(28)便会紧紧顶住齿条(26)上的粗糙带(23),从而达到锁定的目的。
使用尺寸测量仪,首先将被测物体放在载物台玻璃(13)上,然后通过调整立臂旋钮(7)来使得工业相机(17)和镜头(18)达到合适的位置,将锁定拨片(6)向锁定方向拨下,然后在调整环形光支架(4)到合适位置,按下一键测量按钮(12),便可以在外接触控屏上显示出所需要的待测零件的相应尺寸。
基于多模板匹配和自动对焦功能的尺寸测量仪系统的具体运作步骤如下:
1)初始化步骤:启动测量仪,打开控制软件后,操作软件进入开机初始化界面,在该界 面中进行开机初始化;开机初始化流程主要进行系统相关软硬件的检测以及参数的读取和设置工作,系统相关的软硬件包括:数据库、相机、环形光源和背光源,参数主要包括相机配置参数、串口配置参数、权限管理参数和尺寸测量相关参数等。对相关软硬件的检测结果信息进行处理,判断是否存在系统无法正常运行的软硬件异常;若存在,则等待用户进行异常信息确认并退出系统;若不存在,则进入模板选择界面。
2)模板选择界面处理步骤:进入模板选择界面时,默认勾选或选择上次退出系统前用户选择的模板(勾选表示用户选择需要的模板,选择为用户需要查看的模板信息,一般为上次退出系统前用户选择的模板,但可以重新进行选择),用户可在该界面中勾选一个或者多个需要测量的工件模板,若进行选中模板操作,界面中会显示该模板的测量结果图和测量结果信息,选中操作有且只能选中一个模板,用户完成选择后点击“进入测量”按钮进入下一个界面或者点击“退出系统”按钮退出系统;此时,若用户选择空模板,则弹出管理员密码输入对话框,用户输入正确的管理员密码后进入模板操作界面;若用户选择其他模板,则进入实时测量界面。
3)实时测量步骤:实时测量界面内进行工件尺寸的实时测量、系统设置、临时制作和退出系统的操作;
在实时测量界面中点击“开始测量”按钮进入被测工件的实时尺寸测量流程;先判断是否满足测量条件,分别判断勾选模板数是否符合约束条件和相机校准结果数据是否存在,若满足测量条件,则判断是否采集到图像,否则根据未满足的测量条件弹出信息提示框提示,等待用户进行信息确认后返回,等待用户操作;若采集到图像,则进行连续测量和一键测量版本的判断;若为一键测量版本,则进入一键测量版本单张图像实时尺寸测量流程,完成该流程后再判断处理图像张数是否达到设定值,若达到则进行多张图像数据处理流程,完成该流程后结束本次测量,等待用户操作,若未达到,则返回判断是否采集到图像;若为连续测量版本,则进入连续测量版本单张图像实时尺寸测量流程,完成后进入连续测量版本的多张图像数据处理流程,完成该流程后进入下一次循环,判断是否采集到图像。
在实时尺寸测量过程中,实时判断用户是否点击“停止测量”按钮,若是,则结束本次测量,返回等待用户操作,否则继续执行实时尺寸测量流程。
在实时测量界面点击临时制作,触发后会弹出管理员密码输入框,若用户输入正确的管理员密码将打开模板任务编辑界面,否则提示用户密码输入错误,用户可关闭管理员密码输入框或者在管理员密码输入框内重新输入密码;在模板任务编辑界面内进行临时模板制作流程,同时判断用户是否点击“返回”按钮,若是,则生成临时模板后关闭模板任务编辑界面, 返回实时测量界面;
退出系统触发后,弹出确认退出系统对话框,若用户选择确定,则退出系统,若否则关闭退出系统对话框。
完成开机初始化流程,若不存在指定的异常情况,则系统将进入模板选择界面。
在进入模板选择界面后,用户可在模板搜索输入框输入模板名进行指定模板的快速查找。
实时测量模块包括当前测量工件采集图片显示、测量结果数据显示和模板选择框区域进行界面显示和具体作用如下:
当未按下“开始测量”按钮时,对相机实时采集的工件图像和当前选中模板的模板源图按照一定的比例叠加后进行显示,当按下“开始测量”按钮进行待测工件的实时测量时,显示测量结果图,并显示对焦清晰度和当前匹配到的模板名;
在实时测量过程中,根据当前工件的测量结果在界面右侧进行测量结果数据显示,分别显示测量编号和测量结果,测量编号与测量结果图上显示的编号一一对应;若工件存在未测到的待测尺寸,则显示该未测到尺寸的编号,并在结果栏显示未测到;
在界面下方中间位置显示模板选择框,当未进行实时测量时,用户可在该选择框内进行模板选择;在该选择框内会显示系统制作的所有模板,但是不包含空模板,在选择框内用户可通过勾选模板图标前的勾选框进行待测工件的模板选择,点击模板图标可进行模板选中操作,但选中模板操作只能在勾选模板中进行选中,选中模板的模板源图用于与实时图进行叠加后在图片显示区域显示。进入实时测量界面时,根据勾选模板变量进行模板的勾选操作,同时选中模板默认为勾选模板数组变量中的第一个变量对应的模板。该界面包括“系统设置”、“临时制作”、“开始测量/停止测量”和“退出系统”四个按钮,通过点击不同的按钮进行不同的操作。
具体的,实现方式如下:
1.对已测到的测量类型,根据测量数据,在测量结果图中画红线和绿色字母M加序号进行标记。
2.对未测到的测量类型,把对应的掩膜图按像素点灰度值进行或处理,此处掩膜图是灰度图,其像素点灰度值为255或0。两张图像按或处理过程如下:两张掩膜图对应每行每列像素点灰度值按或处理,得到结果图,若灰度值为255和255的两个像素点进行或运算,结果图对应位置像素点灰度值置为255,同理,若255和0,置为255,若0和0,置为0。
3.若只有一张未测到的掩膜图,则既是最终结果图;若有两张未测到的掩膜图,将它们 按或处理,得到最终结果图,若有两张以上,则按顺序先进行前两张图按或处理,得到中间结果图1,再将中间结果图1和第三张未测到的掩膜图按或处理,得到中间结果图2,再将中间结果图2和第四张未测到的掩膜图按或处理,得到中间结果图3,依次类推,得到最终结果图。
4.双循环,遍历前一步骤得到的最终结果图和测量结果图,对于最终结果图中灰度值为255的像素点,对应测量结果图相应像素点BGR值设为不同于已测到的标记颜色,本实施例中设为B=0,G=255,R=255,即显示黄色。
自动曝光调节参数包括自动曝光选择、曝光调节目标灰度值、目标灰度值比例下限、目标灰度值比例上限、曝光量调节刻度;
在参数配置具体的执行参数配置如下:
首先将本参数配置界面中的所有参数都存入暂存变量;再判断各个参数输入框中的内容是否修改,若修改,则判断输入格式是否正确,若未修改则判断是否点击“权限管理”按钮;若格式正确,则判断输入框输入数据是否符合当前参数的约束范围,若格式不正确,则弹出格式错误提示框,等待用户点击“确定”按钮后返回用户操作判断;若输入数据在当前参数的约束范围内,则修改当前修改参数为输入框输入数据,同时将所有输入框状态设置为可输入状态,界面所有按钮设置为使能状态;若输入数据不在当前参数的约束范围内,则将无关联的参数输入框设置为不可输入状态,该界面有些参数为关联参数,自动对焦参数中的对焦标准比例值和对焦下限比例值,对焦下限比例值必须小于对焦标准比例值,同时将界面中所有按钮设置为失能状态,再弹出变量修改异常框,在异常框内显示当前输入数据和约束范围,等待用户点击“确定”按钮后返回用户操作判断。
点击系统设置界面中的“模板操作”按钮后,进入模板操作界面,在该界面中将执行模板操作流程。在该界面内,可进行新建模板、修改模板、删除模板、复制模板、搜索模板等操作,同时该界面实时显示当前系统的所有已制作模板,在模板列表中可通过勾选框选中待测工件的模板,此操作可以多选,同时通过点击模板图标显示该模板的测量结果图和测量结果信息。模板操作的具体执行如下:
首先判断用户是否点击“新建模板”按钮,若是,则弹出新建模板名输入框,等待用户输入新建模板名;在新建模板名输入框内,判断用户是否点击“确定”按钮,若是,则遍历系统已存在所有模板名,判断用户新输入的模板名是否已存在;否则判断用户是否点击“取消”按钮,若是,则关闭新建模板名输入框;若存在,则弹出模板名已存在信息提示框,等待用户点击“确定”按钮后关闭信息提示框,返回判断用户操作;若不存在,则打开相机使 其实时采集图像,弹出新建模板确认框,在该确认框中实时显示相机采集到的图像,通过采集图像的实时显示让用户确认当前模板;在新建模板确认框内,若用户点击“确定”按钮,则记录用户输入模板名,关闭新建模板确认框,关闭相机后打开模板任务编辑界面;若用户点击“取消”按钮,则关闭新建模板确认框和关闭相机,返回判断用户操作;
接着模板任务编辑界面内进行当前新建模板和重新制作模板的待测尺寸的区域编辑;如进行圆、线、角、弧等元素及其任意两元素组合等区域的编辑,每个测量任务的编辑都会返回其掩膜图和区域信息。
在模板任务编辑界面要判断用户是否点击“返回”按钮,若点击返回按钮,则执行模板信息获取流程,获取模板信息,将该新建模板的模板信息添加到系统已制作模板信息列表中,并将其保存到数据库中的模板信息总表和模板掩膜信息表中;关闭模板任务编辑界面,返回模板制作界面,并更新模板制作界面显示信息;
其中更新信息具体如下:首先模板显示列表中添加新建模板,并勾选和选中相应模板;相应模板信息的测量结果图和测量结果信息在界面中显示,其中模板测量结果图会根据待测区域的测量结果进行结果绘图示意;接着提示信息中勾选模板信息添加该模板,选中模板信息显示为该模板名即可;
然后在模板制作界面,判断用户是否点击“重新制作”按钮,则弹出模板重新制作确认框;在该确认框内判断用户是否点击“确定”按钮和“取消”按钮,若点击“确定”按钮,则关闭模板重新制作确认框,打开模板任务编辑界面并将当前选中的模板源图传入该界面进行模板任务编辑,模板任务编辑和退出操作与新建模板时操作相同,其中不同在于该模板在系统已制作的模板信息列表中已存在,需根据重新制作后获取的模板信息对模板信息列表中本模板的信息进行更新,数据库操作也是针对本模板信息进行更新;
判断用户是否点击“删除模板”按钮,若是,则弹出模板删除确认框,等待用户进行“确定”按钮和“取消”按钮操作;若点击“确定”按钮,则从系统已制作模板信息列表中删除本模板,并删除数据库中本模板信息,根据当前勾选和选中模板状态更新模板操作界面显示信息;若点击“取消”按钮,则关闭模板删除确认框后返回判断用户操作;
判断用户是否在模板显示列表内右击选择“复制”,若是则判断用户是否在模板显示列表内右击选择“粘贴”,若是则弹出复制模板确认框,等待用户进行“确定”按钮或“取消”按钮操作;若点击“确定”按钮,则复制模板显示列表内的选中模板,将其命名为选中模板名的副本,并将选中模板的模板信息复制到该副本后将该副本模板添加到系统已制作模板信息列表中,并将该副本模板信息写入数据库,复制标志位清零后关闭复制模板确认框,同时在 模板制作界面内,模板显示列表添加该副本模板;若点击“取消”按钮,则将复制标志位清零后关闭复制模板确认框,返回判断用户操作;
判断用户是否对模板显示列表中选中模板右击选择“重命名”,若是,弹出模板名输入框,等待用户输入模板名,在该输入框内判断用户是否进行“确定”按钮或“取消”按钮操作,若点击“确定”按钮,则判断用户输入模板名是否已存在系统已制作模板中,若点击“取消”按钮,则关闭模板输入框后返回判断用户操作;若不存在,则修改该模板名,并更新数据库中该模板信息中的模板名和模板制作界面内与该模板相关的信息后关闭模板名输入框,若已存在,则弹出模板名已存在信息提示框,等待用户点击“确定”按钮后关闭信息提示框,返回判断用户操作;
判断用户是否点击“返回测量”按钮,若是,则遍历所有模板显示列表中勾选模板,进行模板信息完整性和模板源图尺寸大小判断;若存在异常,则根据异常情况弹出异常信息提示框,等待用户点击“确定”按钮后关闭异常信息提示框,返回判断用户操作;若不存在异常,则存储当前勾选模板和选中模板的信息到数据库对应模板中,开启相机进行采图后进入实时测量界面;
判断用户进行模板勾选、模板选中、取消勾选模板和搜索模板操作,其处理过程同模板选择流程中的操作相同;
其中新建模板、删除模板、重新制作模板、重命名模板、删除模板和复制模板都需要管理员权限才能操作,因此进行相应操作前都会弹出管理员密码输入框,只有再输入正确的密码时才能进行相应操作;在模板制作界面中进行多次管理员权限操作,管理员密码输入一次即可,但是只要返回实时测量界面后重新进入模板制作界面,则需要重新输入正确的管理员密码磁能进行管理员权限的操作。
模板信息提取具体步骤如下:
1:对模板源图进行均值滤波处理;所述模板源图为相机获得的标准件正面以及侧面的图像;
2:进一步进行阈值化处理;阈值化处理为大于设定阈值的像素灰度值被设置为0,反之,则被设置为255;
3:提取模板源图中标准件的外轮廓点;
4:求外轮廓的最小外接圆,得到圆心坐标和半径;
5:根据所求圆心坐标和半径,提取ROI;此ROI为一个矩形,其边长为模板源图中标准 件的最小外接圆直径,其中心为标准件最小外接圆圆心,其旋转角度为零;ROI表示感兴趣区域。
6:对ROI提取层级轮廓信息,层级轮廓信息包括外轮廓信息和内轮廓信息,且外轮廓与内轮廓满足父子层级关系;若外轮廓与内轮廓满足父子层级关系,则外轮廓为父轮廓,内轮廓为子轮廓;
7:求其外轮廓的零旋转度角最小外接矩形,得到矩形长宽,判断此矩形的长或宽是否大于设定值;
8:若矩形的长或宽大于设定值,则标准件出界,跳转到步骤16;
9:若矩形的长或宽没有大于设定值,则求外轮廓的质心、最小外接矩形,得到矩形中心坐标、旋转角度、长宽、面积;接着判断是否存在内轮廓;
10:若不存在内轮廓,跳转到步骤16;
11:若存在内轮廓,再判断是否只有一个有效内轮廓;
12:若只有一个有效内轮廓,则求得质心、最小外接矩形中心坐标、旋转角度、长宽、面积,跳转到步骤16;
13:若存在多个有效内轮廓,则遍历全部有效内轮廓,求出内轮廓最小外接矩形面积的最大值和最小值,并比较最大值和最小值的差值是否大于设定值;
14:若最小外接矩形面积的最大值和最小值的差值大于设定值,则表明既有最大内轮廓,又有最小内轮廓;分别求得它们的质心、最小外接矩形中心坐标、旋转角度、长宽、面积,跳转到步骤16;
15:若最小外接矩形面积的最大值和最小值的差值小于等于设定值,标明标准件存在多个有效最大内轮廓,任意取其一,求得质心、最小外接矩形中心坐标、旋转角度、长宽、面积,跳转到步骤16;
16:结束模板信息提取流程。
自动对焦模块是对相机采集的实时图像连续进行清晰度测量;通过清晰度,提示用户是否清晰,若不清晰,则让用户去调节相机高度,直到图像清晰;
自动对焦模块的界面中左边显示相机的实时图像,右边显示在实时图像中用矩形框框选的区域图像;右边图像上方显示清晰度的进度条,右边图像下方进行参数的设置,其中对焦参数包括:边缘检测阈值、对焦标准比例值和对焦下限比例阈值;边缘检测阈值为黑白边缘区域分割的阈值为0-255,默认设为100;对焦标准比例阈值为设定的黑白区域比例为0-100, 默认设为90;对焦下限比例阈值为对焦不清晰报警阈值为0-100,默认设为70;
自动对焦模块的具体处理如下:
首先判断是否点击“开始对焦”按钮,若是,则判断实时显示图上是否已进行对焦区域编辑,若已编辑,则将编辑矩形框的左上角X坐标和Y坐标、长度、宽度、实时图像和边缘检测阈值传给算法,执行区域清晰度计算流程;根据区域清晰度计算流程得到该区域的清晰度评价值,在界面上实时显示;根据对焦标准比例值和对焦下限比例值进行显示,若实时获取的清晰度评价值大于对焦标准比例值,则进度条显示比例值,颜色显示绿色,表示当前区域清晰度良好,不需调节相机高度;若清晰度评价值小于对焦标准比例值大于对焦下限比例值,则进度条显示黄色,表示当前区域清晰度不太好,可进行微调相机高度;若清晰度评价值小于对焦下限比例值,则进度条显示红色,表示当前区域清晰度很差,必须进行相机高度调节进而调整图像清晰度,否则无法进行精确尺寸测量;
区域清晰度计算流程执行过程,将实时判断停止清晰度计算流程标志位是否置位,若是,则停止该流程执行,返回判断用户操作;
即“开始对焦”按钮点击后,开始执行清晰度计算流程,此时“开始对焦”按钮会变成“停止对焦”按钮,此时用户可点击“停止对焦”按钮,从而设置停止清晰度计算流程标志;
判断用户是否在实时图显示上框选对焦区域,若是,则保存框选区域的左上角坐标和框选区域的长宽;判断用户是否点击“获取高度”按钮,若是,则通过控制高度传感器获取相机高度信息,再根据相机高度信息查表获取相机校准参数,作为实时尺寸测量的参数使用;判断用户是否点击“返回测量”按钮,若是,则关闭辅助对焦界面,返回实时测量界面。
其中,单张图像实时尺寸测量具体如下:
首先对待测图进行像素合并,再对像素合并后的待测图进行出界检测;若检测结果为出界,遍历所有勾选的模板名称,判断有无临时模板名称;若无临时模板名称,则输出待测物出界,结束单张图像实时测量流程;若有临时模板名称,对临时模板源图进行像素合并,再将像素合并后的待测图和像素合并后的临时模板源图做差分处理,若不一致,则输出待测物出界,结束单张图像实时测量流程;若一致,则根据临时模板源图的旋转平移结果进行当前帧图像的旋转平移;
接着判断自动对焦标志位是否有效,若有效,调用用于自动对焦区域选择的测量类型,执行实时测量自动对焦清晰度评价函数,返回清晰度值,再根据当前帧掩膜信息进行相关测量类型的尺寸测量;若无效,直接根据当前帧掩膜信息进行相关测量类型的尺寸测量;
若检测结果为未出界,对上一帧待测图进行像素合并,再进行帧间图像比较,即对像素合并后的待测图和像素合并后的上一帧待测图进行帧间差分处理,若两者一致,表明待测物未移动,则直接根据上一帧的旋转平移结果进行当前帧图像的旋转平移;判断自动对焦标志位是否有效,若有效,调用用于自动对焦区域选择的测量类型,执行实时测量自动对焦清晰度评价函数,返回清晰度值,再根据上一帧掩膜信息进行相关测量类型的尺寸测量;若无效,直接根据上一帧掩膜信息进行相关测量类型的尺寸测量;若两者不一致,表明待测物已移动,再遍历所有勾选的模板信息,其中优先匹配模板编号对应的模板信息先进行,把相应的模板源图进行像素合并,对像素合并后的待测图和模板源图进行差分处理,若两者一致,终止遍历,直接根据当前模板源图的旋转平移结果进行当前帧图像的旋转平移。判断自动对焦标志位是否有效,若有效,调用用于自动对焦区域选择的测量类型,执行实时测量自动对焦清晰度评价函数,返回清晰度值,再根据当前帧掩膜信息进行相关测量类型的尺寸测量;若无效,直接根据当前帧掩膜信息进行相关测量类型的尺寸测量;若两者不一致,先将相应的模板源图特征信息按像素合并系数缩小,再执行待测物匹配流程,若待测物匹配成功,终止遍历,将待测物匹配流程中得到的像素合并后的待测物平移量按像素合并系数转换为未进行像素合并的平移量;判断自动对焦标志位是否有效,若有效,调用用于自动对焦区域选择的测量类型,执行实时测量自动对焦清晰度评价函数,返回清晰度值,再根据当前帧掩膜信息进行相关测量类型的尺寸测量;若无效,直接根据当前帧掩膜信息进行相关测量类型的尺寸测量;若待测物未匹配成功,过待测物最小外接圆圆心做垂直轴线,以此轴线对待测物图像进行水平镜像,得到水平镜像图像,做为输入参量,跳转到待测物匹配流程执行;若匹配成功,则提示用户待测物放反,结束本流程;若未匹配成功,则输出待测物未匹配成功,结束单张图像实时测量;
其中,像素合并是将图像中每行像素点以每四个相邻像素点依次合并成一个像素点,其灰度值取均值,全部行处理完毕后,再将其每列像素点以每四个相邻像素点依次合并成一个像素点,其灰度值取均值。
出界检测流程具体如下:
1:对像素合并后的待测图滤波处理;通过中值滤波处理去除高频噪点,保留轮廓边缘信息,本实施例中值滤波窗口为9个像素*9个像素;
2:滤波后图像进行灰度阈值二值化处理;其中大于设定阈值的像素灰度值被设置为255,反之,则被设置为0;本实施例设定阈值取180;
3:寻找图像中所有闭环轮廓;所述闭环轮廓是指该轮廓内任意相邻两个轮廓点间距小于 设置值,本实施例设置值取2个像素;
4:求最大闭环轮廓周长,判断此周长是否满足设置条件;设置条件为最大闭环轮廓周长不小于图像周长的0.99倍且不大于图像周长的1.01倍;若此周长满足条件,则待测物未出界,结束本流程;若此周长不满足条件,则待测物出界,结束本流程;
待测物匹配流程具体如下:
1:对像素合并后的待测图进行均值滤波处理;本实施例均值滤波窗口为3个像素*3个像素;
2:进行阈值化处理,将大于设定阈值的像素灰度值被设置为0,反之,则被设置为255,本实施例中设定阈值取100;
3:提取待检测层级零件轮廓信息;待检测层级零件轮廓信息包括待检测零件外轮廓信息和内轮廓信息,且外轮廓与内轮廓满足父子层级关系,其中外轮廓为父轮廓,内轮廓为子轮廓;
4:判断待检测物外轮廓最小外接矩形面积与模板源图的外轮廓最小外接矩形面积的差的绝对值是否小于设定值;本实施例该设定值取值范围为模板源图的外轮廓最小外接矩形面积的15%;
5:若待检测物外轮廓最小外接矩形面积与模板源图的外轮廓最小外接矩形面积的差的绝对值大于等于设定值,则物体未匹配成功,本流程结束;
6:若待检测物外轮廓最小外接矩形面积与模板源图的外轮廓最小外接矩形面积的差的绝对值小于设定值,则判断待检测零件外轮廓最小外接矩形长宽比与模板源图的外轮廓最小外接矩形长宽比差的绝对值是否小于设定值;本实施例该设定值取值范围为模板源图的外轮廓最小外接矩形长宽比的10%;
7:若待检测物外轮廓最小外接矩形长宽比与模板源图的外轮廓最小外接矩形长宽比差的绝对值大于等于设定值,则物体未匹配成功,跳转到步骤4执行;
8:若待检测物外轮廓最小外接矩形长宽比与模板源图的外轮廓最小外接矩形长宽比差的绝对值小于设定值,则求外轮廓最小外接圆,将其圆心作为旋转中心;
9:判断模板源图外轮廓质心与模板源图的外轮廓最小外接矩形中心间距是否大于设定值;本实施例中设定值为20个像素;
10:若模板源图外轮廓质心与模板源图的外轮廓最小外接矩形中心间距小于等于设定值,则跳转到步骤18;
11:若模板源图外轮廓质心与模板源图的外轮廓最小外接矩形中心间距大于设定值,则判断待检测物外轮廓质心与其最小外接矩形中心间距与模板源图的外轮廓质心到其外轮廓最小外接矩形长宽比的差的绝对值是否小于设定值;本实施例该设定值取值范围为模板源图的外轮廓质心到其外轮廓最小外接矩形长宽比的10%;
12:若待检测物外轮廓质心与其最小外接矩形中心间距与模板源图的外轮廓质心到其外轮廓最小外接矩形长宽比的差的绝对值大于等于设定值,则跳转到步骤18;
13:若待检测物外轮廓质心与其最小外接矩形中心间距与模板源图的外轮廓质心到其外轮廓最小外接矩形长宽比的差的绝对值小于设定值,则求待检测零件相对模板源图的旋转角度;
14:结合模板源图中心坐标和角度信息,平移旋转待测图,即先在待测图中提取待检测物感兴趣区域(ROI);接着新建与待测图等大空白图,将待检测物平移至空白图中心,再将待检测物旋转至模板源图同角度;在本实施例中ROI为一个矩形,其边长为模板源图最小外接圆直径,其中心为待检测物最小外接圆圆心;
15:判断待检测物外轮廓质心到待检测物最小外接矩形中心的矢量角与模板源图的外轮廓质心到模板源图的最小外接矩形中心的矢量角相比较,是否小于设定值,本实施例设定值取7.5度。
16:若步骤15中矢量角的差值小于设定值,表示物体匹配成功,结束步骤2;
17:若步骤15中矢量角的差值大于等于设定值,则进入步骤18;
18:根据模板源图最大内轮廓最小外接矩形面积判断是否存在内轮廓;若否,则物体匹配成功,求待检测物相对模板源图的旋转角度,结合模板源图中心坐标和角度信息,平移旋转物体,结束本流程;若是,判断模板源图是否只有一个有效最大内轮廓;
19:若模板源图只有一个有效最大内轮廓,则进行有效内轮廓匹配;有效内轮廓匹配包括判断待检测零件的最大内轮廓最小外接矩形面积和模板源图最大内轮廓最小外接矩形面积是否匹配,进一步依次判断最大内轮廓最小外接矩形长宽比是否匹配,外轮廓和最大内轮廓的最小外接矩形中心间距是否匹配,求待检测零件相对模板源图的旋转角度,结合模板源图中心坐标和角度信息,旋转平移物体,外轮廓和最大内轮廓的最小外接矩形中心的矢量角是否匹配,来检测是否匹配成功;
20:若模板源图不满足只有一个有效最大内轮廓,则判断模板源图有多个最大内轮廓还是既有最大内轮廓又有最小外轮廓;
21:若模板源图有多个最大内轮廓,则遍历待检测零件中所有内轮廓,对每个内轮廓进行有效内轮廓匹配,判断是否存在至少一个内轮廓匹配成功,若是,物体匹配成功,结束本流程;若否,物体未匹配成功,结束本流程;
22:若模板源图既有最大内轮廓又有最小外轮廓;先对最大内轮廓进行有效内轮廓匹配;若最大内轮廓匹配,则物体匹配成功,结束本流程;
23:若最大内轮廓不匹配,再对最小内轮廓检测物体进行有效内轮廓匹配;若最小内轮廓匹配,则物体匹配成功,结束本流程;若最小内轮廓不匹配,则物体未匹配成功,结束本流程;
执行连续测量实时尺寸需满足勾选模板数小于系统设置阈值变量和相机校准结果数据存在;
在执行连续测量实时尺寸的界面中控件状态设置如下:实时图显示中不再叠加模板图显示;将尺寸测量结果数据显示清空;模板显示框中只能对显示框进行滚动操作,查看系统已制作的所有模板和当前勾选的要进行匹配的模板;“系统设置”、“临时制作”和“退出系统”按钮失效;
连续测量版本实时尺寸的具体执行流程如下:
首先判断是否采集到图像,若采集到图像,传递模板信息和实时图到单张图像尺寸测量算法,执行单张图像实时尺寸测量流程;其中传递到单张图像尺寸测量算法的参数包括执行自动对焦标志位、上一帧相机采集图像、本帧相机采集图像、所有勾选的模板信息、相机校准参数、优先匹配模板编号;
执行自动对焦标志位,根据该标志位确定尺寸测量算法中是否需要进行指定掩膜区域清晰度评价函数计算;上一帧相机采集图像,用于与本帧图像进行帧间差分处理后快速判断工件是否移动;本帧相机采集图像,作为进行尺寸测量的图像;所有勾选的模板信息,其中模板信息包括模板源图、模板源图ROI信息、模板源图特征信息、模板源图内轮廓个数、模板掩膜图、模板掩膜特征信息、模板掩膜准确特征信息;优先匹配模板编号,当实时图与模板图匹配成功时,尺寸测量算法执行完成后将输出匹配成功的模板图所在勾选模板列表中的位置,将其位置序列作为优先匹配模板编号,下次相机采集到图像时,将该设置值传递给尺寸测量算法;
接着执行单张图像实时尺寸测量流程后,根据其返回值,判断工件是否出界,若未出界,则判断当前测量工件是否与勾选模板中的模板有匹配成功,若匹配成功,则执行如下操作:先保存匹配成功的模板的所在勾选模板序列中的位置编号,作为下次采集到图像的优先匹配 模板进行匹配;若本次算法根据自动对焦标志位执行清晰度计算,则根据算法返回的清晰度值和之前图像执行清晰度计算情况设置自动对焦标志位;当返回的清晰度值小于系统设置的对焦标准比例值,则置位自动对焦标志位,下次采集到图像执行算法时执行清晰度计算,若返回的清晰度值大于系统设置的对焦标准比例值,则判断采集图像张数是否大于系统设置清晰度计算间隔图像张数,若大于则置位自动对焦标志位,下次采集到图像执行算法时执行清晰度计算,否则清零自动对焦标志位;最后保存本次尺寸测量结果,具体各个测量类型的具体数值;
判断匹配到的图像张数是否达到设定阈值,若是,则计算各个测量掩膜类型数据的标准差,根据系统设定的标准差系统对各个掩膜类型数据数组内数据进行标准差剔除,对剔除后的数据计算平均值,将得到的平均值在实时测量界面进行编号显示;若否,则对各个测量掩膜类型数据直接求平均值,再在界面上进行编号显示。
还包括临时测量模块,用户可通过点击实时测量界面的“临时制作”按钮直接进入模板任务界面进行模板制作,制作完成后生成临时模板,在模板选择界面、模板制作界面或者实时测量界面选择临时模板后进行该选中临时模板的尺寸测量;临时制作会生成一个临时模板,在模板选择界面、模板制作界面和实时测量界面的模板显示列表中进行显示和选中勾选操作,再次制作后会替代原先的临时模板,因此系统中最多只有一个临时模板;用户可通过临时测量功能快速制作临时模板,进而进行临时工件的快速测量。
在实时测量过程中,根据尺寸测量算法执行时间和相机采集图像帧率时间执行自动跳帧和帧率自适应流程;通过执行该流程,使图像采集速度和尺寸测量算法执行时间实现合理配置,防止由于算法执行时间太长导致系统运行崩溃;
自动跳帧针对单张图像的处理,当单张图像处理时间超过系统约束条件时,进行自动跳帧或者结束单张图像处理,从而防止单张图像处理时间过长而导致的系统崩溃问题;
帧率自适应针对多张图像的处理,计算多张图像处理的平均时间,作为调整帧率的依据,使图像采集的帧率能满足实时图像处理时大多数图像的处理要求,而当个别图像处理时间过久时,采用自动跳帧;
具体自动跳帧和帧率自适应的执行流程如下:
先进行跳帧处理流程:判断相机是否采集到图像,若采集到图像,则判断当前测量采集到的图像数是否大于1张,若大于1张,则判断当前图像之前的指定图像尺寸测量线程是否结束,其中指定图像线程的指定依据为:当前测量采集到第一张图像时,指定第一张图像为指定图像;若未结束,则指定图像尺寸测量线程经过图像数加1,同时,指定图像和当前图 像之间未处理完成的尺寸测量线程经过的图像张数也进行加1处理;若已结束,则在当前图像和指定图像之间选择最早建立的未处理完成的尺寸测量线程对应的图像为指定图像,并对指定图像和当前图像之间的所有处理线程经过的图像张数进行加1处理;判断指定图像尺寸测量线程经过的图像张数是否达到设定阈值,若是,则判断该线程执行时间是否达到设定阈值,若是,则对该线程进行销毁处理,并在当前图像和指定图像之间选择最早建立的未处理完成的尺寸测量线程对应的图像为指定图像;
帧率自适应流程:首先相机采集到图像进行跳帧处理后,对当前图像创建线程执行单张图像实时尺寸测量流程;判断单张图像尺寸测量流程是否完成,若完成,则判断该图像模板匹配是否成功,否则返回判断是否采集到图像;判断模板匹配成功的目的是,帧率自适应只对模板匹配成功的图像进行时间统计,因为在图像处理算法中模板匹配成功时的运行时间较长,能代表正常的图像处理算法时间,因此选用该时间作为帧率自适应的调整依据;
其中,若模板匹配成功,则保存该图像尺寸测量流程的运行时间,再判断模板匹配成功的图像张数是否大于设定阈值,若是,则对当前匹配成功的图像的所有处理时间进行标准差剔除处理后,对剩下的时间进行平均值运算得到平均时间;判断平均时间是否大于帧率时间阈值,其中帧率时间阈值为图像采集帧率对应的时间与帧率自适应上限比例阈值的乘积,若大于,则调整相机采集帧率为该平均时间对应的帧率;
在自动跳帧和帧率自适应过程中,实时判断用户是否点击“停止测量”按钮,若是,则将图像张数和时间等统计量清零后结束自动跳帧和帧率自适应模块。
模板校准流程包括如下步骤:
步骤1:将标定板放置在视场内的不同位置,分别采集标定板图像;
步骤2:标定板图像采集完成后,关闭相机采集,调用校准算法进行图像校准处理;
步骤3:校准处理完成后,将校准参数更新为最新的校准参数;
步骤4:退出模板校准界面;
所述步骤2中图像校准处理包括获取相机畸变参数、相机内参矩阵和获取放大率;获取相机畸变参数和内参矩阵通过张正友畸变校正算法,包括如下步骤:
步骤1.1:读取已采图的标定图像数据和标定参数,标定参数中横向点数是指标定板棋盘格的行数,纵向点数是指棋盘格的列数,单位间距是棋盘格每小格的真实物理尺寸;
步骤1.2:对每帧标定图像提取角点信息;
步骤1.3:利用已提取的角点信息,进一步提取亚像素角点信息;
步骤1.4:初始化标定板上角点的空间三维坐标系;
步骤1.5:利用已提取的亚像素角点信息及标定板上角点的空间三维坐标系信息,进行相机标定,得到相机内参与每帧图像的畸变参数、每帧图像的旋转向量和平移向量;
步骤1.6:对标定结果进行评价;首先通过相机标定得到畸变参数,对每帧图像的空间三维坐标点进行重新投影计算,得到新的投影点,计算新的投影点与旧的投影点的误差,若该误差小于设定值0.15个像素,则符合要求,保存标定结果与畸变参数,结束本流程;若该误差大于等于设定值0.15个像素,则不合要求,结束本流程并提示重新采集标定图像;
获取放大率流程包括如下步骤:
步骤2.1:利用标定结果对已采集的某一帧标定图像进行校正;
步骤2.2:对已校正图像提取角点信息;
步骤2.3:提取亚像素角点信息;
步骤2.4:遍历校正图像列数,计算并保存每一列第一行至倒数第一行的间距;
步骤2.5:对每列所保存的间距进行排序;
步骤2.6:以中间列为中心,选择若干列,并累加所选列的所保存的间距;
步骤2.7:根据累加值,求均值;
步骤2.8:根据均值、列数、物理尺寸,求放大率,放大率的计算公式为均值/(列数-2)/物理尺寸;
步骤2.9:结束本流程。
以上所述仅是本发明的优选实施方式,应当指出,对于本技术领域的普通技术人员,在不脱离本发明构思的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本发明保护范围内。
Claims (4)
- 基于多模板匹配和自动对焦功能的尺寸测量仪系统,其特征在于,1)初始化步骤:启动测量仪,打开操作软件后,进入开机初始化界面,在该界面中进行开机初始化;开机初始化流程主要进行系统相关软硬件的检测以及参数的读取和设置工作,对相关软硬件的检测结果信息进行处理,判断是否存在系统无法正常运行的软硬件异常;若存在,则等待用户进行异常信息确认并退出系统;若不存在,则进入模板选择界面;2)模板选择界面处理步骤:进入模板选择界面时,默认勾选或选择上次退出系统前用户选择的模板,用户可在该界面中勾选一个或者多个需要测量的工件模板;用户完成选择后点击“进入测量”按钮进入下一个界面或者点击“退出系统”按钮退出系统;3)实时测量步骤:实时测量界面内进行工件尺寸的实时测量、系统设置、临时制作和退出系统的操作;在实时测量界面中点击“开始测量”按钮进入被测工件的实时尺寸测量流程;先判断是否满足测量条件,分别判断勾选模板数是否符合约束条件和相机校准结果数据是否存在,若满足测量条件,则判断是否采集到图像,否则根据未满足的测量条件弹出信息提示框提示,等待用户进行信息确认后返回,等待用户操作;若采集到图像,则进行连续测量和一键测量版本的判断;若为一键测量版本,则进入一键测量版本单张图像实时尺寸测量流程,完成该流程后再判断处理图像张数是否达到设定值,若达到则进行多张图像数据处理流程,完成该流程后结束本次测量,等待用户操作,若未达到,则返回判断是否采集到图像;若为连续测量版本,则进入连续测量版本单张图像实时尺寸测量流程,完成后进入连续测量版本的多张图像数据处理流程,完成该流程后进入下一次循环,判断是否采集到图像;退出系统触发后,弹出确认退出系统对话框,若用户选择确定,则退出系统,若否则关闭退出系统对话框。
- 根据权利要求1所述的基于多模板匹配和自动对焦功能的尺寸测量仪系统,其特征在于,步骤2)中若进行选中模板操作,界面中会显示该模板的测量结果图和测量结果信息,选中操作有且只能选中一个模板,若用户选择空模板,则弹出管理员密码输入对话框,用户输入正确的管理员密码后进入模板操作界面;若用户选择其他模板,则进入实时测量界面。
- 根据权利要求1所述的基于多模板匹配和自动对焦功能的尺寸测量仪系统,其特征在于,步骤1)中的系统相关的软硬件包括:数据库、相机、环形光源和背光源,参数主要包括相机配置参数、串口配置参数、权限管理参数和尺寸测量相关参数。
- 根据权利要求1所述的基于多模板匹配和自动对焦功能的尺寸测量仪系统,其特征在于,初始化步骤具体如下:1.1)同时开启数据库操作流程、相机连接操作流程和串口转IO模块连接操作流程;根据操作结果判断数据库和相机是否都连接成功;若存在连接不成功,则显示“退出系统”按钮,等待用户点击“退出系统”按钮后退出系统;由于数据库中存储着相机配置参数、模板信息和测量结果信息,只有当数据库和相机全部连接成功,才能继续;否则进行检修,等数据库和相机都连接成功;1.2)若数据库和相机都连接成功,则判断串口转IO模块连接是否成功;若连接不成功,则显示“进入系统”和“退出系统”按钮,等待用户进行按钮操作;若连接成功,则进入光源检测模块;若用户点击“进入系统”按钮,则根据当前版本号判断是一键测量版本还是连续测量版本,若为一键测量版本则进入一键测量功能,若为连续测量版本则进入连续测量版本;若用户点击“退 出系统”按钮,则退出系统;1.3)光源检测模块判断环形光源和背光源是否能正常工作;光源检测流程执行完成后,判断光源是否都正常,若存在不能正常工作的光源则显示“进入系统”和“退出系统”按钮,等待用户进行按钮操作,若光源都能正常工作,则根据当前版本号选择相应的测量功能;若用户点击“进入系统”按钮,则根据当前版本号选择相应的测量功能;若用户点击“退出系统”按钮,则退出系统。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110356536.7A CN113639630B (zh) | 2021-04-01 | 2021-04-01 | 基于多模板匹配和自动对焦功能的尺寸测量仪系统 |
CN202110356536.7 | 2021-04-01 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2022206022A1 true WO2022206022A1 (zh) | 2022-10-06 |
Family
ID=78415739
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2021/137820 WO2022206022A1 (zh) | 2021-04-01 | 2021-12-14 | 基于多模板匹配和自动对焦功能的尺寸测量仪系统 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN113639630B (zh) |
WO (1) | WO2022206022A1 (zh) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113639630B (zh) * | 2021-04-01 | 2024-07-19 | 浙江大学台州研究院 | 基于多模板匹配和自动对焦功能的尺寸测量仪系统 |
CN114547356B (zh) * | 2022-04-27 | 2022-07-12 | 深圳百里科技有限公司 | 模板图像存储方法、装置、设备及存储介质 |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CA2249092A1 (en) * | 1998-09-30 | 2000-03-30 | Hydroscope Canada Inc. | Method and system for determining pipeline defects |
CN108534684A (zh) * | 2018-03-08 | 2018-09-14 | 上海第二工业大学 | 一种基于Lab VIEW开发平台的尺寸测量系统及其测量方法 |
CN112284250A (zh) * | 2020-10-15 | 2021-01-29 | 浙江大学台州研究院 | 一种基于机器视觉的尺寸测量评分系统及测量方法 |
CN112304217A (zh) * | 2020-10-15 | 2021-02-02 | 浙江大学台州研究院 | 一种基于机器视觉的尺寸测量评分装置及评分方法 |
CN112330599A (zh) * | 2020-10-15 | 2021-02-05 | 浙江大学台州研究院 | 一种尺寸测量评分装置及调节方法和评分方法 |
CN113467664A (zh) * | 2021-04-01 | 2021-10-01 | 浙江大学台州研究院 | 一种基于模板匹配的尺寸测量仪使用方法 |
CN113624129A (zh) * | 2021-04-01 | 2021-11-09 | 浙江大学台州研究院 | 一种尺寸测量仪的实时测量方法 |
CN113645398A (zh) * | 2021-04-01 | 2021-11-12 | 浙江大学台州研究院 | 一种基于自动对焦功能的尺寸测量仪系统 |
CN113639630A (zh) * | 2021-04-01 | 2021-11-12 | 浙江大学台州研究院 | 基于多模板匹配和自动对焦功能的尺寸测量仪系统 |
Family Cites Families (29)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2001194126A (ja) * | 2000-01-14 | 2001-07-19 | Sony Corp | 三次元形状計測装置および三次元形状計測方法、並びにプログラム提供媒体 |
JPWO2002029870A1 (ja) * | 2000-10-05 | 2004-02-19 | 株式会社ニコン | 露光条件の決定方法、露光方法、デバイス製造方法及び記録媒体 |
US7636478B2 (en) * | 2006-07-31 | 2009-12-22 | Mitutoyo Corporation | Fast multiple template matching using a shared correlation map |
CN100449571C (zh) * | 2006-09-15 | 2009-01-07 | 东南大学 | 三维扫描系统中基于单像素的阈值分割方法 |
JP4967992B2 (ja) * | 2007-10-30 | 2012-07-04 | 株式会社ニコン | 画像認識装置及び焦点検出装置並びに撮像装置 |
US8127060B2 (en) * | 2009-05-29 | 2012-02-28 | Invensys Systems, Inc | Methods and apparatus for control configuration with control objects that are fieldbus protocol-aware |
JP2011138882A (ja) * | 2009-12-28 | 2011-07-14 | Sanyo Electric Co Ltd | コンデンサ用電極体の製造方法およびコンデンサの製造方法 |
JP5505007B2 (ja) * | 2010-03-18 | 2014-05-28 | 富士通株式会社 | 画像処理装置、画像処理方法及び画像処理用コンピュータプログラム |
JP5639797B2 (ja) * | 2010-07-01 | 2014-12-10 | 株式会社日立ハイテクノロジーズ | パターンマッチング方法,画像処理装置、及びコンピュータプログラム |
CN102607421A (zh) * | 2012-04-12 | 2012-07-25 | 苏州天准精密技术有限公司 | 一种大视野影像测量方法与设备 |
CN103499296A (zh) * | 2013-10-21 | 2014-01-08 | 东华大学 | 基于机器视觉的批量零件自动检测系统及方法 |
CN103823145B (zh) * | 2014-03-18 | 2016-08-31 | 福建联迪商用设备有限公司 | 硬件自动化测试平台 |
CN104700415B (zh) * | 2015-03-23 | 2018-04-24 | 华中科技大学 | 一种图像匹配跟踪中匹配模板的选取方法 |
US10620802B1 (en) * | 2015-08-10 | 2020-04-14 | Cadence Design Systems, Inc. | Algorithmic modeling interface process |
CN105241399B (zh) * | 2015-09-09 | 2018-04-10 | 合肥芯碁微电子装备有限公司 | 一种精密定位平台动态平面度的测量方法 |
CN105910563B (zh) * | 2016-03-31 | 2018-07-31 | 刘玉芳 | 一种三坐标测量机工件连续测量方法 |
CN106101697B (zh) * | 2016-06-21 | 2017-12-05 | 深圳市辰卓科技有限公司 | 图像清晰度检测方法、装置及测试设备 |
CN106303242A (zh) * | 2016-08-18 | 2017-01-04 | 上海交通大学 | 多光谱显微成像的快速主动对焦系统及方法 |
JP2018195070A (ja) * | 2017-05-17 | 2018-12-06 | キヤノン株式会社 | 情報処理装置、情報処理方法、及びプログラム |
CN108628061B (zh) * | 2018-05-07 | 2020-09-29 | 凌云光技术集团有限责任公司 | 一种工业相机自适应自动对焦方法及装置 |
CN109685758B (zh) * | 2018-10-29 | 2020-10-16 | 中国化学工程第六建设有限公司 | 基于多模板匹配的焊缝视觉定位方法 |
CN109357630B (zh) * | 2018-10-30 | 2019-10-18 | 南京工业大学 | 一种多类型工件批量视觉测量系统及方法 |
CN109856157A (zh) * | 2019-01-24 | 2019-06-07 | 武汉精立电子技术有限公司 | 一种基于自适应对焦的lcd面板缺陷检测方法 |
CN110136120B (zh) * | 2019-05-16 | 2021-04-06 | 燕山大学 | 一种基于机器视觉的丝网印刷样板尺寸测量方法 |
CN110132548A (zh) * | 2019-05-16 | 2019-08-16 | 上海乂义实业有限公司 | 一种机载发光体综合测试系统及方法 |
CN110956624B (zh) * | 2019-12-02 | 2023-09-01 | 河海大学常州校区 | 一种针对立体物体的图像清晰度评价方法 |
CN111458835A (zh) * | 2020-04-16 | 2020-07-28 | 东南大学 | 一种显微镜多视野自动对焦系统及其使用方法 |
CN111698420A (zh) * | 2020-05-18 | 2020-09-22 | 桂林优利特医疗电子有限公司 | 一种用于图像分析仪的自动对焦方法 |
CN113721072A (zh) * | 2021-08-18 | 2021-11-30 | 宁波云太基智能科技有限公司 | 智能测量仪的流程测量方法 |
-
2021
- 2021-04-01 CN CN202110356536.7A patent/CN113639630B/zh active Active
- 2021-12-14 WO PCT/CN2021/137820 patent/WO2022206022A1/zh active Application Filing
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CA2249092A1 (en) * | 1998-09-30 | 2000-03-30 | Hydroscope Canada Inc. | Method and system for determining pipeline defects |
CN108534684A (zh) * | 2018-03-08 | 2018-09-14 | 上海第二工业大学 | 一种基于Lab VIEW开发平台的尺寸测量系统及其测量方法 |
CN112284250A (zh) * | 2020-10-15 | 2021-01-29 | 浙江大学台州研究院 | 一种基于机器视觉的尺寸测量评分系统及测量方法 |
CN112304217A (zh) * | 2020-10-15 | 2021-02-02 | 浙江大学台州研究院 | 一种基于机器视觉的尺寸测量评分装置及评分方法 |
CN112330599A (zh) * | 2020-10-15 | 2021-02-05 | 浙江大学台州研究院 | 一种尺寸测量评分装置及调节方法和评分方法 |
CN113467664A (zh) * | 2021-04-01 | 2021-10-01 | 浙江大学台州研究院 | 一种基于模板匹配的尺寸测量仪使用方法 |
CN113624129A (zh) * | 2021-04-01 | 2021-11-09 | 浙江大学台州研究院 | 一种尺寸测量仪的实时测量方法 |
CN113645398A (zh) * | 2021-04-01 | 2021-11-12 | 浙江大学台州研究院 | 一种基于自动对焦功能的尺寸测量仪系统 |
CN113639630A (zh) * | 2021-04-01 | 2021-11-12 | 浙江大学台州研究院 | 基于多模板匹配和自动对焦功能的尺寸测量仪系统 |
Also Published As
Publication number | Publication date |
---|---|
CN113639630A (zh) | 2021-11-12 |
CN113639630B (zh) | 2024-07-19 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2022206022A1 (zh) | 基于多模板匹配和自动对焦功能的尺寸测量仪系统 | |
TWI467161B (zh) | 用以檢驗圖案之線寬及/或位置錯誤之檢驗系統及方法 | |
US20190265027A1 (en) | System and method for efficient surface measurement using a laser displacement sensor | |
CN110858899B (zh) | 一种摄像机机芯光轴中心和视场角的测量方法及系统 | |
WO2022170702A1 (zh) | 模具的状态监测方法、装置、工控机、存储介质及系统 | |
WO2019001164A1 (zh) | 滤光片同心度测量方法及终端设备 | |
JP2006246502A (ja) | 画像歪み補正機能を備えたプロジェクタ装置 | |
JPH09190531A (ja) | 実装データ作成方法と装置、および基板と実装の検査方法 | |
CN113645398B (zh) | 一种基于自动对焦功能的尺寸测量仪系统 | |
CN113624129B (zh) | 一种尺寸测量仪的实时测量方法 | |
CN113467664B (zh) | 一种基于模板匹配的尺寸测量仪使用方法 | |
CN110658215B (zh) | 一种基于机器视觉的pcb板自动拼接检测方法与装置 | |
JP2016035542A (ja) | 位置測定方法、位置ずれマップの作成方法および検査システム | |
CN115727762A (zh) | 基于机器视觉的舵类结构件形位误差检测方法及装置 | |
JP7380332B2 (ja) | 画像処理装置、画像処理装置の制御方法およびプログラム | |
JP2000028336A (ja) | 形状測定装置及び形状測定方法 | |
JPH04295748A (ja) | パターン検査装置 | |
CN1323417C (zh) | 荫罩网板孔径的智能测量仪 | |
JP2565585B2 (ja) | スクライブライン交差領域の位置検出方法 | |
KR940003791B1 (ko) | 폭측정장치 | |
JP2001241921A (ja) | 板ガラスの寸法測定方法 | |
WO2021111768A1 (ja) | 設定システム、設定方法及びプログラム | |
CN118081535B (zh) | 偏光片的自动加工系统及方法 | |
JPH1097983A (ja) | 位置検出方法 | |
JPS6048683B2 (ja) | 物体表面状態検査方法とその検査装置 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 21934658 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 21934658 Country of ref document: EP Kind code of ref document: A1 |