Method of adjusting a measurement of a size measurement scoring device
Patent Information
- Application Number
- CN202410112357.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-15
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2040-10-15
AI Technical Summary
[0003]采用传统的测量工具存在如下几点缺陷:1、测量对象定位需耗时;2、单个测量对象测量部位越多,耗时越长;3、长时间测量会对测量人员造成眼部疲劳等各种负担;4、测量位置由测量人员判断,因此会导致测量结果因人而异;5、测量读数也存在人为误差;6、测量数据需要测量人员手动录入及统计,耗时长,效率低,容易出错
[0030]通过在相机和载物板之间设置标准平晶,并且在载物板的四个角上设置微调节旋钮,在相机上设置He-Ne激光器,实现相机的镜头和载物板之间的平行设置;
Smart Images

Figure CN118172303B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image recognition, and in particular to an adjustment measurement method for a size measurement and scoring device. Background Technology
[0002] Currently, some higher education institutions in China offer machining practice courses for certain majors. These courses typically include assessments at the end or during the training period. One widely used assessment method requires students to design and manufacture machined parts based on given specifications. The dimensions of these parts are measured and compared with standard parts or requirements based on accuracy, tolerances, and other indicators, leading to a grade for the student's work. Currently, institutions still rely on traditional measuring tools such as vernier calipers and micrometers for manual inspection to obtain the dimensional specifications of the machined parts.
[0003] Traditional measuring tools have the following drawbacks: 1. Locating the object takes time; 2. The more parts of a single object are measured, the longer the measurement time; 3. Prolonged measurement can cause eye fatigue and other burdens on the measuring personnel; 4. The measurement position is determined by the measuring personnel, which can lead to different measurement results from different people; 5. Human error also exists in measurement readings; 6. Measurement data needs to be manually entered and statistically analyzed by the measuring personnel, which is time-consuming, inefficient, and prone to errors.
[0004] On the other hand, the current assessment and testing methods for mechanical processing training courses lack the following functions: 1. Exam questions are intelligently obtained through a server, ensuring the randomness of the questions; 2. The exam process requires binding the dimensional measurement results of the parts made by the examinee based on their identity information, ensuring the accuracy of the exam scores; 3. Measurement results are evaluated in real time according to the exam requirements, eliminating the need for teachers to manually input the exam results, thus improving efficiency and reducing errors; 4. For the unique exam scenarios of mechanical processing courses in universities, only the front and side views of the same part need to be measured. After the measurement is completed, the measurement results are uploaded to the server to obtain the exam scores, which is accurate and efficient.
[0005] Therefore, there is a need for a device and method that can efficiently and intelligently inspect and score the mechanical parts produced by students. Summary of the Invention
[0006] The purpose of this invention is to overcome the shortcomings of the prior art and provide a visual scoring measurement device and system that can assign permissions to three types of users: teachers, students, and tourists. It can also accurately read the size parameters of objects in images, has a simple structure, and is easy to use.
[0007] A method for adjusting a dimensional measurement and scoring device includes a fixed frame, an operating table, a detection table, a light source, and a camera. The detection table, light source, and camera are mounted on the fixed frame. A through hole is provided in the middle of the detection table, and a transparent plate is provided at the through hole. The light source is located below the detection table and is positioned corresponding to the plate. The camera is mounted on a camera mounting plate directly above the plate. The operating table is electrically connected to the light source and the camera. A standard flat crystal is provided between the camera and the detection table. A telecentric coaxial lens is provided at the lens of the camera, and a He-Ne laser is provided on the side of the telecentric coaxial lens.
[0008] Furthermore, the standard optical flat is mounted on a slide rail adjustment device; the slide rail adjustment device includes a vertical plate and a horizontal plate; the vertical plate passes through the testing table; two parallel vertical rails are provided on the side of the vertical plate near the testing table, and the horizontal plate is mounted on the vertical rail of the vertical plate; a horizontal rail is provided on the side of the horizontal plate near the testing table, and the standard optical flat is mounted on the horizontal rail; a camera support plate is provided at the top of the vertical plate, and a light source support plate is provided at the bottom of the vertical plate.
[0009] Furthermore, a fine-adjustment knob is provided between the carrier plate and the detection stage.
[0010] Furthermore, the testing platform is equipped with a support, which is located on the loading plate; a groove is provided in the middle part of the support.
[0011] Furthermore, a vertical high-precision adjustment slide rail is provided between the testing platform and the fixed frame; the vertical high-precision adjustment slide rail is located at the four corners of the testing platform.
[0012] Furthermore, a laser ranging device is provided between the camera mounting plate and the testing platform; the laser ranging device includes a laser ranging sensor transmitter and a laser ranging receiver; the laser ranging receiver is located at the four corners of the testing platform, and the laser ranging sensor transmitter is located at the four corners of the camera mounting plate, with the laser sensor transmitter facing the laser ranging receiver.
[0013] Furthermore, the fixing frame is generally in the shape of a right quadrangular prism, and the interior of the fixing frame is hollow. The fixing frame is set above the optical vibration isolation table, and the bottom four corners of the optical vibration isolation table are equipped with casters; the detection table is also equipped with a transparent checkerboard and an ID card reader; the operating table is set above the camera fixing plate, and the operating table includes a display module.
[0014] An adjustment measurement method for a size measurement and scoring device includes the following steps:
[0015] Step 1: Fix the camera and light source to the camera mounting plate and light source support plate respectively; set the bracket and the part to be tested on the carrier plate; turn on the light source, and adjust the four vertical high-precision adjustment rails according to the clarity of the images continuously acquired by the camera to make the images clear;
[0016] Step 2: Based on the four sets of data obtained by the four laser sensors in the laser rangefinder, continuously adjust the four vertical high-precision adjustment slides to make the four sets of data equal and the camera fixing plate and the detection platform parallel.
[0017] Step 3: Remove the bracket and the part to be tested from the testing table; adjust the horizontal and vertical adjustment rails on the slide rail adjustment device so that the standard flat crystal is facing the carrier plate at a set distance; turn off the light source; turn on the He-Ne laser and adjust the lower surface of the standard flat crystal to be parallel to the upper surface of the carrier plate.
[0018] Step 4: Turn off the He-Ne laser, turn on the light source, and remove the standard flat crystal; place the support at the set position above the carrier plate, set a transparent checkerboard above the support, acquire images, calibrate the flat field, and calculate the image magnification.
[0019] Step 5: Remove the transparent checkerboard grid, place the part to be inspected with the front side facing up, and use the camera to capture the image to complete the measurement of the front length, width, and internal dimensions of the parts.
[0020] Step Six: Place the part to be inspected side up into the bracket groove, capture the image with the camera, complete the side height measurement, and end the step.
[0021] Furthermore, in step three, adjusting the lower surface of the standard flat crystal to be parallel to the upper surface of the carrier plate requires first ensuring that the light emitted by the He-Ne laser passes through the camera to obtain interference fringes. After processing, the information difference between adjacent interference fringes is obtained. Based on the difference, the four micro-adjustment knobs are continuously adjusted until the information difference between adjacent interference fringes is reduced to the set value, so that the interference fringes are approximately parallel and equally spaced.
[0022] A method for dimensional measurement and scoring includes the following steps:
[0023] Step 1: The control panel senses the operator's input and, based on the operator's input, opens the software and automatically performs the software initialization operation.
[0024] Step 2: After completing the software initialization operation, the display module on the control panel will automatically display the user login interface; the initial user login interface has a "Visitor Measurement" button and an "Exit System" button.
[0025] Step 3: Login users according to the operator's instructions; there are two login methods: one is to log in as a visitor through the "Visitor Measurement" button and enter the visitor measurement process; the other is to log in as a teacher or student through ID card recognition and enter the corresponding teacher operation process or student examination process.
[0026] Step 4: The user logs in to the control panel; if it is a tourist measurement process or a student examination process, the user will automatically enter the size measurement interface, set parameters, complete the size measurement, and end the process; if it is a teacher operation process, the teacher operation panel will be displayed on the user login interface; the teacher operation panel is equipped with buttons for "Download Test Questions", "Upload Test Questions", and "Create Test Questions".
[0027] Step 5: The control panel selects the content for the teacher's operation based on the operator's instructions; the "Download Test Questions" button will take you to the test question download process, and this process will end after the test question download is completed; the "Upload Test Questions" button will take you to the test question upload process, and this process will end after the test question upload is completed; the "Create Test Questions" button will take you to the test question creation process, which will lead you to the size measurement interface, and this process will end after the test question is created.
[0028] In step 3, ID card recognition relies on an ID card reader.
[0029] The beneficial effects of this invention are as follows:
[0030] By setting a standard flat crystal between the camera and the carrier plate, and setting micro-adjustment knobs at the four corners of the carrier plate, and setting a He-Ne laser on the camera, the parallel setting between the camera lens and the carrier plate is achieved.
[0031] By installing a laser rangefinder between the camera mounting plate and the inspection table, and by installing a vertical high-precision adjustment slide rail between the inspection table and the mounting frame, the camera mounting plate and the inspection table are ensured to be set up in parallel.
[0032] By setting a transparent checkerboard pattern on the testing platform, the camera's flat field is calibrated and the image magnification is calculated;
[0033] By setting up a bracket and the groove on the bracket, it is ensured that the images captured are at similar heights when the front of the part to be inspected is facing up and when the side is facing up. This ensures that the image magnification of the camera is consistent, reduces the dependence on the lens depth, avoids systematic errors caused by long-distance camera raising or lowering, and improves accuracy.
[0034] By setting up a support, the parts to be inspected can be placed as close as possible to the set standards, so that front and side images of the parts to be inspected can be obtained that are easy to compare. On the other hand, by setting up a transparent support that is not easy to slide, the parts to be inspected can be kept stable during the process of the camera acquiring images.
[0035] This invention manages the permissions of students, teachers, and visitors, and sets up a test question creation function under the teacher's permission, enabling the editing and confirmation of test questions, as well as the image acquisition of placed parts to complete the measurement.
[0036] By setting up timed reading of ID card information, users can be promptly confirmed to have changed their ID cards.
[0037] By setting the flags for the system's initial reading of exam file size measurement parameters and the flags for the system's initial acquisition of exam information, it can be confirmed whether the system has read the size measurement parameters and exam information. Attached Figure Description
[0038] Figure 1 This is an overall structural diagram of Embodiment 1 of the present invention;
[0039] Figure 2 This is a front view of Embodiment 1 of the present invention;
[0040] Figure 3 This is a schematic diagram of the main body of Embodiment 1 of the present invention;
[0041] Figure 4 This is a front view of the main body of Embodiment 1 of the present invention;
[0042] Figure 5 This is a schematic diagram of the detection station according to Embodiment 1 of the present invention;
[0043] Figure 6 This is a flowchart of the adjustment steps in Embodiment 1 of the present invention;
[0044] Figure 7 This is a detailed flowchart of Embodiment 1 of the present invention;
[0045] Figure 8 This is a simplified flowchart of Embodiment 1 of the present invention;
[0046] Figure 9 This is a flowchart illustrating the extraction of template source image feature information according to Embodiment 1 of the present invention;
[0047] Figure 10 This is a flowchart illustrating the extraction of the measurement results of the template source image circle measurement type in Embodiment 1 of the present invention;
[0048] Figure 11 This is a flowchart illustrating the extraction of template source line measurement type measurement results according to Embodiment 1 of the present invention;
[0049] Figure 12 This is a flowchart illustrating the extraction of template source image angle measurement type measurement results according to Embodiment 1 of the present invention;
[0050] Figure 13This is a flowchart of the algorithm for obtaining distortion parameters according to Embodiment 1 of the present invention;
[0051] Figure 14 This is a flowchart of the algorithm for obtaining magnification according to Embodiment 1 of the present invention;
[0052] Figure 15 This is a flowchart of the out-of-bounds detection algorithm for the part to be detected according to Embodiment 1 of the present invention;
[0053] Figure 16 This is the overall flowchart of the algorithm for measuring the size of the part to be inspected in Embodiment 1 of the present invention;
[0054] Figure 17 This is a flowchart of the object search and matching algorithm according to Embodiment 1 of the present invention;
[0055] Figure 18 This is a flowchart of the circle measurement algorithm for the part to be inspected according to Embodiment 1 of the present invention;
[0056] Figure 19 This is a flowchart of the line measurement algorithm for the part to be inspected according to Embodiment 1 of the present invention;
[0057] Figure 20 This is a flowchart of the angle measurement algorithm for the part to be detected according to Embodiment 1 of the present invention;
[0058] Figure 21 Examples of mask diagrams for four measurement types—circle, line, arc, and angle—in Embodiment 1 of the present invention;
[0059] Figure 22 This is a schematic diagram of the image in step 4.7.11 of Embodiment 1 of the present invention. Detailed Implementation
[0060] The following specific examples illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that, unless otherwise specified, the following embodiments and features described therein can be combined with each other.
[0061] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show the components related to the present invention and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.
[0062] Example 1:
[0063] like Figure 1 As shown, an adjustable size measuring instrument based on machine vision includes an operating table 2, a detection table 3, a light source 4, and a camera 5. The detection table 3 has a through hole in its middle section, and a transparent carrying plate 32 is placed at the through hole. The light source 4 is positioned below the carrying plate 32, corresponding to it. The camera 5 is positioned directly above the carrying plate 32, and is mounted on a camera mounting plate 11. The operating table 2 is electrically connected to the light source 4 and the camera 5, and the operating table 2 can control the movement of the light source 4 and the camera 5.
[0064] like Figure 2 As shown, the detection platform 3, light source 4, and camera 5 are mounted on a fixed frame 1. The fixed frame 1 is generally a right quadrangular prism with a hollow interior. The fixed frame is positioned above the optical vibration isolation platform 12, which lowers the center of gravity and isolates external vibrations. Casters are installed at the four corners of the bottom of the optical vibration isolation platform 12.
[0065] The camera 5 is equipped with a telecentric coaxial lens 51, and a He-Ne laser 52 is provided on the side of the telecentric coaxial lens 51. The purpose is to facilitate the adjustment of the camera 5, the standard flat screen 65 and the carrier plate 32 to the set state.
[0066] like Figure 3 , 4As shown, a standard optical disc 65 is provided between the camera 5 and the detection stage 3. The standard optical disc 65 is mounted on the slide rail adjustment device 6. The upper and lower surfaces of the standard optical disc 65 maintain a set angle. In this embodiment, the lower surface of the standard optical disc 65 is provided with an enhanced transmission film to ensure sufficient transmitted light intensity. An enhanced reflection film is provided on the upper surface of the carrier plate 32. The slide rail adjustment device 6 is located on the side of the camera 5 and the detection stage 3. The slide rail adjustment device 6 includes a vertical plate 61 and a horizontal plate 62. The vertical plate 61 passes through the detection stage 3. Two parallel vertical tracks are provided on the side of the vertical plate 61 near the detection stage 3. The horizontal plate 62 is mounted on the vertical tracks of the vertical plate 61. A horizontal track is provided on the side of the horizontal plate 62 near the detection stage 3. The standard optical disc 65 is mounted on the horizontal track. The position of the standard optical disc 65 is adjusted by adjusting the position of the standard optical disc 65 on the horizontal track and the position of the horizontal plate 62 on the vertical track. The flatness of the part under inspection can be detected by acquiring an image transmitted through a standard optical flat 65. A camera support plate 63 is provided at the top of the vertical plate 61, and a light source support plate 64 is provided at the bottom of the vertical plate 61. The camera support plate 63 and the light source support plate 64 are parallel and horizontally arranged. The camera support plate 63, the light source support plate 64 and the vertical plate 61 are integrally formed, and a support structure is provided at the angle between the light source support plate 64 and the vertical plate 61. The camera support plate 63 is fixedly connected to the camera 5, and the light source support plate 64 is fixedly connected to the light source 4. The camera support plate 63 is also attached to the camera fixing plate 11, which is located on the lower surface of the camera fixing plate 11. The camera fixing plate 11 is also used to fix the camera 5 and is disposed on the mounting bracket 1.
[0067] The inspection stage 3 is equipped with a bracket 34, which is located on the carrier plate 32. The bracket 34 is made of transparent material and is used to fix the part to be inspected, preventing it from shifting. The bracket 34 is generally in the shape of a right quadrangular prism, with a groove in the middle. The top of the bracket 34 allows the part to be inspected to be positioned horizontally, enabling the camera 5 to acquire a front image of the part; the groove in the bracket 34 allows the part to be inspected to be positioned vertically, enabling the camera 5 to acquire a side image of the part. The depth of the groove in the bracket 34 is determined by the difference between the width and thickness of the part to be inspected. By setting up the bracket and the groove on it, the height of the acquired images is similar when the part is positioned with its front facing up and its side facing up, ensuring consistent image magnification of the camera.
[0068] The testing platform 3 is mounted on the fixed frame 1, and a vertical high-precision adjustment slide rail 35 is provided between the testing platform 3 and the fixed frame 1. The vertical high-precision adjustment slide rail 35 is located at the four corners of the testing platform 3. By adjusting the vertical high-precision adjustment slide rail 35, the overall height and tilt angle of the testing platform 3 can be adjusted.
[0069] A laser rangefinder 31 is provided between the camera mounting plate 11 and the detection platform 3, which can detect the distance between the camera mounting plate 11 and the detection platform 3. The laser rangefinder 31 includes a laser range sensor transmitter and a laser range receiver. The laser range receiver is located at the four corners of the detection platform 3, and the laser range sensor transmitter is located at the four corners of the lower surface of the camera mounting plate 11, with the laser sensor transmitter facing the laser range receiver.
[0070] A micro-adjustment knob 33 is provided between the carrier plate 32 and the detection stage 3. The height and tilt angle of the carrier plate 32 can be adjusted by adjusting the micro-adjustment knob 33.
[0071] like Figure 5 As shown, the testing platform 3 is also equipped with a transparent checkerboard 36, which is arranged adjacent to the carrying plate 32. The transparent checkerboard 36 allows for accurate focusing of the camera 5. An ID card reader 37 is also provided on the testing platform 3.
[0072] The operating console 2 is positioned above the camera mounting plate 11. The operating console 2 includes a display module 21, which can display the detection results and process.
[0073] During implementation, the vertical high-precision adjustment slide rail 35 is adjusted using the laser rangefinder 31 to achieve parallelism between the camera mounting plate 11 and the inspection stage 3. A laser beam emitted from the He-Ne laser 52 passes through the telecentric coaxial lens 51, incident on the upper surface of the standard optical flat 65, and is projected from the lower surface of the standard optical flat 65 to the carrier plate 32. This creates alternating bright and dark interference fringes on the lower surface of the standard optical flat 65 and the upper surface of the carrier plate 32. Based on the fringe pattern, the micro-adjustment knob 33 is adjusted to achieve parallelism between the lower surface of the standard optical flat 65 and the carrier plate 32. After adjustment, front and side images of the part to be inspected are acquired and uploaded to the operating table 2 to complete the inspection of the part.
[0074] like Figure 6 As shown, an adjustment measurement method for a size measurement and scoring device includes the following steps:
[0075] Step 1: Fix the camera and light source to the camera mounting plate and light source support plate respectively; set the bracket and the part to be tested on the carrier plate; turn on the light source, and adjust the four vertical high-precision adjustment rails according to the clarity of the images continuously acquired by the camera to make the images clear;
[0076] Step 2: Based on the four sets of data obtained by the four laser sensors in the laser rangefinder, continuously adjust the four vertical high-precision adjustment slides to make the four sets of data equal and the camera fixing plate and the detection platform parallel.
[0077] Step 3: Remove the bracket and the part to be tested from the testing table; adjust the horizontal and vertical adjustment rails on the slide rail adjustment device so that the standard flat crystal is facing the carrier plate at a set distance; turn off the light source; turn on the He-Ne laser and adjust the lower surface of the standard flat crystal to be parallel to the upper surface of the carrier plate.
[0078] Step 4: Turn off the He-Ne laser, turn on the light source, and remove the standard flat crystal; place the support at the set position above the carrier plate, set a transparent checkerboard above the support, acquire images, calibrate the flat field, and calculate the image magnification.
[0079] Step 5: Remove the transparent checkerboard grid, place the part to be inspected with the front side facing up, and use the camera to capture the image to complete the measurement of the front length, width, and internal dimensions of the parts.
[0080] Step Six: Place the part to be inspected side up into the bracket groove, capture the image with the camera, complete the side height measurement, and end the step.
[0081] In step three, adjusting the lower surface of the standard flat crystal to be parallel to the upper surface of the substrate requires first ensuring that the light emitted by the He-Ne laser passes through the camera to obtain interference fringes. After processing, the information difference between adjacent interference fringes is obtained. Based on the difference, the four micro-adjustment knobs are continuously adjusted until the information difference between adjacent interference fringes is reduced to the set value, making the interference fringes approximately parallel and equidistant. This indicates that the lower surface of the standard flat crystal is approximately parallel to the upper surface of the substrate.
[0082] like Figure 7 , 8 As shown, a machine vision-based size measurement and scoring method includes the following steps:
[0083] Step 1: The control panel senses the operator's input and, based on the operator's input, opens the software and automatically performs the software initialization operation.
[0084] Step 2: After completing the software initialization operation, the display module on the control panel will automatically display the user login interface; the initial user login interface has a "Visitor Measurement" button and an "Exit System" button.
[0085] Step 3: Login users according to the operator's instructions; there are two login methods: one is to click the "Visitor Measurement" button to complete visitor login and enter the visitor measurement process; the other is to complete teacher or student login through ID card recognition and enter the corresponding teacher operation process or student examination process.
[0086] Step 4: The user logs in to the control panel; if it is a tourist measurement process or a student examination process, the user will automatically enter the size measurement interface, set parameters, complete the size measurement, and end the process; if it is a teacher operation process, the teacher operation panel will be displayed on the user login interface; the teacher operation panel is equipped with buttons for "Download Test Questions", "Upload Test Questions", and "Create Test Questions".
[0087] Step 5: The operator selects the content to be operated by the teacher based on the operator's operation; if the "Download Test Questions" button is clicked, the test question download process will begin, and the process will end after the test question download is completed; if the "Upload Test Questions" button is clicked, the test question upload process will begin, and the process will end after the test question upload is completed; if the "Create Test Questions" button is clicked, the test question creation process will begin, leading to the size measurement interface, and the process will end after the test question creation is completed.
[0088] In step 1, when the software on the control panel is opened, an automatic software initialization operation is performed. This initialization includes reading the exam folder, hardware initialization, and other initializations. It should be noted that the software on the control panel has two folders related to this embodiment: one is the exam folder, and the other is the question creation folder (generated by the teacher). In this embodiment, the question creation folder is named "ExaminationFiles," and this folder name remains unchanged. After the teacher has created the questions, they can test and upload them.
[0089] Reading the exam folder includes the following steps:
[0090] Step 1.1: Determine if the exam file name record file ExaminationFileName.txt exists. If the ExaminationFileName.txt file exists, read the information from that file; the information read is the name of the exam folder. If the ExaminationFileName.txt file does not exist, prompt the user to download the exam questions from the server first; otherwise, the dimensional measurement operation cannot be performed.
[0091] Step 1.2: Determine if the exam folder exists based on the exam folder name read from ExaminationFileName.txt. If the exam folder exists, it means that the files required for the exam are present; if it does not exist, prompt the user to download the exam questions from the server first, otherwise the size measurement operation cannot be performed.
[0092] Because the exam folder name is randomly generated, it needs to be recorded using an exam file name log file to check if the exam folder exists. However, the existence of an exam file name log file does not guarantee the existence of the exam folder; the log file is only used to locate the exam folder. The exam folder stores all the parameters and tools required for dimensional measurement, including front and side measurement parameters, front and side calibration parameters, and tools for creating test questions. It should be noted that reading the exam folder is a pre-read process to ensure rapid loading during subsequent dimensional measurements, improving efficiency. During actual measurement, the specific information stored in the exam folder will be read based on user permissions.
[0093] The hardware initialization includes opening the camera. If the camera opens successfully, the camera image acquisition function will be enabled when entering the size measurement interface to perform real-time image acquisition. If the camera fails to open, the user will be prompted that the camera failed to open, and the reason for the failure will be given. Step 1 will end and the process will end. The user needs to resolve the camera opening failure issue before proceeding to the subsequent step 2.
[0094] The other initializations include the initialization of the login interface and the initialization of related variables. The initialization of the login interface includes the following aspects:
[0095] I. Teacher's control panel visibility setting: Invisible;
[0096] II. Visibility setting for the guest login and logout system control panel: Visible;
[0097] III. Visibility setting for the test question download and upload progress display panel: Invisible;
[0098] IV. Visibility setting of operation process prompt box: Visible;
[0099] V. Enable the timer for periodically reading identity information;
[0100] VI. Enable the operation timeout timer.
[0101] The initialization of the relevant variables includes the following two aspects:
[0102] 1. The initialization of the flag bit for the size measurement parameter of the examination file when the system first reads it is set to true in this embodiment.
[0103] 2. The initialization of the system's first acquisition of exam information flag is set to true in this embodiment.
[0104] The initial system reads the exam file size measurement parameters flag to confirm whether the size measurement parameters have been read before. If they have, the flag is set to false, meaning the parameters don't need to be read again after the user logs in; they are only updated during each exam question download. The initial system retrieves exam information flag to confirm whether exam information has been read before. For example, if the exam information hasn't been read before when the user logs in for the first time, the flag is set to true, indicating that the exam information needs to be read. This is done while downloading the exam questions. After downloading both the questions and exam information, the flag is set to false. Exam information is a file that records exam folder information, including a record of exam file names.
[0105] In step 3, during the user login process, the ID card information is periodically read upon initial system entry, successful teacher login, login timeout, login error, and incorrect login account. This reading is achieved through an external ID card reader, and in this embodiment, the timer interval is set to 500 milliseconds. The purpose of periodically reading the ID card information is to enable timely responses to new ID card information.
[0106] Upon initial system login, if an ID card is inserted, the system will attempt to log in as a teacher based on the ID card information retrieved by the ID card reader. If teacher login fails, it will attempt to log in as a student. If student login fails, relevant information will be displayed, and the system will periodically re-read the ID card information. If the ID card information reading fails upon initial system login (e.g., no ID card inserted, ID card not recognized, ID card information insufficient for teacher or student login), only guest login is possible, and the guest measurement process will begin. It's important to note that even if the periodically re-reading of ID card information fails after a user has successfully logged in as a student or teacher (e.g., no ID card inserted, ID card not recognized, ID card information insufficient for teacher or student login), the current login status and permissions will not change. The system will only switch to the corresponding ID card information for teacher or student login if the periodically re-reading of ID card information allows for successful login.
[0107] The steps for periodically reading ID card information are as follows:
[0108] Step 2.1: Initialize the ID card reader connection; if initialization is successful, proceed to the next step; if initialization fails, prompt the user to confirm whether the ID card reader is connected properly, and end the current timed reading operation.
[0109] Step 2.2: Card authentication operation between the ID card reader and the ID card; if card authentication is successful, proceed to the next step; if card authentication fails, prompt the user that ID card authentication failed, close the ID card reader connection, and end this timed reading operation.
[0110] Step 2.3: Read ID card information; if the reading is successful, the ID card information will be filled into the interface display, the "Tourist Measurement" button will be disabled, and the login thread will be started automatically; if the reading fails, the user will be prompted that the ID card information reading failed, and the ID card reader connection will be closed and the current timed reading operation will end.
[0111] In step 4, the tourist measurement process requires entering the size measurement interface. Before entering the size measurement interface, the following steps are performed:
[0112] Step 3.1: Determine if the exam folder exists; if it exists, proceed to the next step; if it does not exist, prompt the user to download the exam questions first.
[0113] Step 3.2: Determine whether it is the first time reading the exam file information; in this embodiment, this is expressed as whether the system's first time obtaining exam information flag is true. If yes, then read the exam file information parameters and proceed to the next step; otherwise, proceed directly to the next step.
[0114] Step 3.3: Set the operation permission to guest permission; the guest permission can only perform the size measurement of the part to be inspected, and cannot perform data upload to the server or create test questions;
[0115] Step 3.4: Enter the size measurement interface and set the camera to start acquiring images.
[0116] In step 4, after logging in, the student enters the student examination process. First, a timer is automatically started to count the login time. The student examination process needs to determine whether it is the first time reading examination information after booting up and whether the examination information is empty. If either is true, the examination information is read; if neither is true, the examination information does not need to be read, and the test question information in the examination folder can be read directly.
[0117] The process of reading exam information includes the following steps: If the exam information is read successfully, determine whether the exam file name read upon startup is the same as the exam file name in the exam information; if the names are different, update the exam file name and store it in the exam file name record file; if the names are the same, the exam information reading is complete; if the exam information reading fails, including exam information reading timeout or reading process abnormality, prompt the user with the corresponding information, clear the identity information on the interface, and re-read the ID card information at a set time.
[0118] When the exam information exists or is successfully read, the system checks if the exam file exists. If the exam file does not exist, the user is prompted that the exam questions are missing, and the ID card information is read again at a set time. If the exam file exists, the system checks if this is the first time reading the exam questions. If it is the first time, the system reads the relevant dimensional measurement parameters, including camera configuration parameters, camera calibration parameters, calibration result parameters, and template information, and sets the operation permission to student permission. If it is not the first time, the system does not need to read the relevant dimensional measurement parameters. After determining whether this is the first time reading the exam questions, the system enters the dimensional measurement interface and begins image acquisition. In this embodiment, the exam file includes an exam folder.
[0119] If a student's login process is not completed, including login timeout or login error, relevant information will be displayed, and the ID card information will be reread periodically.
[0120] When the user has student access, the system can submit answers and return to the user login screen. When the user has teacher or visitor access, the system can only return to the user login screen.
[0121] After completing the teacher login process in step 5, a timer is started to track the login time. If the teacher's login times out or there is a network error during the login process, the "Guest Login" button is enabled, and the ID card information is read again.
[0122] The teacher operations include a test question download process, a test question upload process, and a test question creation process. In this embodiment, after completing the teacher login operation, the teacher will not be immediately redirected to the size measurement interface. Instead, the teacher operation panel will be displayed on the user login interface. The teacher operation panel has buttons for "Download Test Questions," "Upload Test Questions," and "Create Test Questions," which correspond to the test question download process, the test question upload process, and the test question creation process, respectively.
[0123] If a user clicks the "Download Exam Questions" button, the "Download Exam Questions," "Upload Exam Questions," "Create Exam Questions," and "Visitor Measurement" buttons will become disabled. A prompt box will appear on the control panel display saying "Downloading exam questions, please wait!", initiating the exam question download thread and simultaneously tracking the download time. It should be noted that exam information will be retrieved before downloading the exam questions. If the exam information is successfully retrieved, the download file name and exam file name will be set according to the exam information, and the exam questions will be downloaded using the compressed file name from the exam information. If the retrieval of exam information fails, times out, or an error occurs, corresponding information will be displayed, the ID card information display will be cleared, and the ID card information will be re-read at a scheduled time. The download progress will be displayed during the download process. Once the exam questions are downloaded, the exam file will be automatically decompressed, the exam file information will be read, and a message indicating successful download will be displayed. The read exam file information includes:
[0124] a. Camera configuration parameters and camera calibration parameters;
[0125] b. Parameters related to calibration results;
[0126] c. Template information.
[0127] If the user clicks the "Upload Questions" button, the question upload process begins. This process first checks if the question creation folder exists. If it does, the folder is compressed, the compression progress is displayed, and the compressed file is uploaded to the server upon completion. Simultaneously, the required dimension number and the criteria for determining whether the measurement is acceptable are extracted from the measurement information within the question creation folder, and then uploaded to the server. If the question does not exist, the user is prompted, "Questions do not exist; please create questions first!" The required dimension number and the criteria for determining whether the measurement is acceptable are extracted after editing in the question creation editor. The editor sets the dimensions to be measured and the upper and lower tolerance limits for acceptable measurement.
[0128] If a user clicks the "Create Test Questions" button, and has not previously accessed the exam file information for teacher-created test questions, the exam file information will be read, and the user's access permissions will be set to teacher permissions. Teachers can create test questions and measure the dimensions of the parts used to create them. The dimension measurement interface will then open, the camera will be set to capture images, parameters will be set, and the test question creation will be completed. It should be noted that the dimension measurement interface accessed with teacher permissions uses information stored in the test question creation folder for part measurement; other permissions, including student and guest permissions, use information stored in the exam folder for dimension measurement.
[0129] Both the user login screen and the size measurement screen allow users to exit the system. After clicking the "Exit System" button on either screen, the user will be prompted to confirm their exit. If the user selects "Yes," the system will exit.
[0130] A machine vision-based dimensional measurement and scoring system includes a dimensional measurement interface with "System Settings," "Front Measurement," and "Side Measurement" buttons. The interface enables parameter configuration, test question creation, template calibration, and dimensional measurement. The "Parameter Configuration," "Test Question Creation," and "Template Calibration" functions are located under the "System Settings" button on the interface. Access to the system settings requires a password; only with a correct password can these functions be performed. The test question creation function is accessible only to teachers. Clicking the "Front Measurement" or "Side Measurement" button initiates the dimensional measurement process. The interface also includes an "Exit System" button. Clicking this button prompts the user for confirmation before exiting the system. For students, the interface also includes a "Submit Answer" button. Clicking this button prompts the user for confirmation before submitting the answer, including uploading images and scores, and then exiting the system.
[0131] Clicking the "Parameter Configuration" button will bring up a parameter settings dialog box, which includes functions for configuring camera parameters, calibration parameters, and data statistics. Camera parameter configuration includes settings for pixel binning, acquisition frame rate, processing frame rate, and exposure. Calibration parameter configuration includes settings for the number of horizontal and vertical points and the unit spacing. Data statistics include settings for the number of images and the filter coefficient.
[0132] Clicking the "Question Creation" button will bring up a question creation dialog box. This dialog box allows you to create front and side test questions. Front test questions correspond to the front of the part to be tested, and side test questions correspond to the side of the part. The front and side test questions are respectively represented by the "Front" and "Side" buttons in the question creation dialog box. Clicking the "Front" or "Side" button in the question creation dialog box will initiate the question creation process, which includes the following steps:
[0133] Step 4.1: Obtain the real-time image captured by the current camera, open the test question creation dialog box, and import the real-time image;
[0134] Step 4.2: Create test questions, including editing tasks for various dimensional measurement types, and setting the upper and lower limits of the maximum tolerance for measurement;
[0135] Step 4.3: When exiting the test question creation dialog box, extract the test question template information and measure the dimensions of the template source image; the template source image represents the image of the standard part placed arbitrarily within the camera's field of view;
[0136] Step 4.4: Save the relevant measurement results for use in real-time dimensional measurements.
[0137] It should be noted that before the camera acquires real-time images, the system guides the placement of the part to be inspected. The process of guiding the placement of the part is as follows: The dimension measurement interface image display window displays a guide image based on the template source image, guiding the user to place the object with the corresponding measurement surface facing upwards within the appropriate area. Guiding the placement of the part prevents measurement errors and facilitates subsequent measurements. The process of creating the guide image includes:
[0138] Step 4.1.1: Take 80% of the original grayscale value of each pixel in the template source image;
[0139] Step 4.1.2: Take 20% of the original gray value of each pixel in a blank image of the same size (where the gray value of each pixel is the maximum value of 255);
[0140] Step 4.1.3: Overlay the two images according to their grayscale values to obtain the guide image; where pixels with a grayscale value of 0 are displayed as pure black, and pixels with a grayscale value of 255 are displayed as pure white.
[0141] like Figure 21 As shown, step 4.2 involves editing the measurement types of various dimensions, including four basic elements: circles, lines, arcs, and angles, to obtain the corresponding mask feature information, i.e., the mask image. The line widths of the circle, line, arc, and angle element measurement types are adjustable and are displayed as white areas in the mask image; after adjusting the line width, the corresponding feature information is output.
[0142] The task editing for the circle measurement type includes the following steps:
[0143] Step 4.2.1: Determine the measurement type name;
[0144] Step 4.2.2: Determine the measurement switch value, accurate circle radius value, upper tolerance limit, and lower tolerance limit; these parameters are input by the user.
[0145] Step 4.2.3: Determine the center coordinates, width, height, and radius; the above parameters are calculated based on the vector information corresponding to the measurement type graphic drawn with the minimum line width during editing.
[0146] The editing of the line measurement type task includes the following steps:
[0147] Step 4.3.1: Determine the measurement type name;
[0148] Step 4.3.2: Determine the measurement switch value, accurate circle radius value, upper tolerance limit, and lower tolerance limit; these parameters are input by the user.
[0149] Step 4.3.3: Determine the tilt angle, line segment length, and coordinates of the two endpoints; the above parameters are calculated based on the vector information corresponding to the measurement type graphic drawn with the minimum line width during editing.
[0150] The arc measurement type task editing includes the following steps:
[0151] Step 4.4.1: Determine the measurement type name;
[0152] Step 4.4.2: Determine the measurement switch value, accurate circle radius value, upper tolerance limit, and lower tolerance limit; these parameters are input by the user.
[0153] Step 4.4.1: Determine the radius of the arc, the arc angle, and the coordinates of three points, two of which are located at the beginning and end points of the arc, and the other point is located elsewhere; the above parameters are calculated based on the vector information corresponding to the measurement type graphic drawn with the minimum line width during editing.
[0154] The editing of the angle measurement type task includes the following steps:
[0155] Step 4.5.1: Determine the measurement type name;
[0156] Step 4.5.2: Determine the measurement switch value, accurate circle radius value, upper tolerance limit, and lower tolerance limit; these parameters are input by the user.
[0157] Step 4.5.3: Determine the included angle and the coordinates of the three points that make up the included angle, one of which is located at the vertex of the included angle; the above parameters are calculated based on the vector information corresponding to the measurement type graphic drawn with the minimum line width during editing.
[0158] By combining the four basic elements of circles, lines, arcs, and angles, we can obtain various measurement types, such as the distance between two points, the distance from a point to a line, and the distance between two line segments. The distance between two points includes: the distance between the centers of a circle, the distance between the center of a circle and the center of an arc, the distance between the center of an arc, the distance between the center of a circle and the vertex of an included angle, the distance between the center of an arc and the vertex of an included angle, and the distance between the vertices of two included angles. The distance from a point to a line includes: the distance from the center of a circle to a line, the distance from the center of an arc to a line, and the distance from the vertex of an included angle to a line.
[0159] The algorithm for measuring the distance between two points involves first calculating the coordinates of the two points, and then calculating the distance between them. The algorithm for measuring the distance from a point to a line involves first calculating the coordinates of the point and the coordinates of the two endpoints of the line segment, and then calculating the distance from the point to the line segment. The algorithm for measuring the distance between two line segments involves first calculating the coordinates of the endpoints of the two line segments, then calculating the distances from the two endpoints of one line segment to the other line segment, and finally adding the two distances together and taking the average value to obtain the distance between the two line segments.
[0160] In this embodiment, the measurement data of four basic elements—circle, line, arc, and angle—are displayed in real time. Specifically, the circle measurement type displays the center coordinates and radius value in real time; the line measurement type displays the tilt angle and length value; the arc measurement type displays the arc angle; and the angle measurement type displays the angle of inclination. Completing the above-mentioned circle, line, arc, and angle measurement tasks will yield the corresponding mask feature information.
[0161] like Figure 9 As shown, step 4.4, the extraction of test question template information, includes the following steps:
[0162] Step 4.6.1: Perform mean filtering on the template source image; in this embodiment, the mean filtering window size is 5*5; the template source image is the front and side images of the standard part obtained by the camera;
[0163] Step 4.6.2: Further thresholding processing is performed; thresholding processing sets the grayscale value of pixels greater than a set threshold to 0, and vice versa, it is set to 255; in this embodiment, the threshold is 100.
[0164] Step 4.6.3: Extract the outer contour points of the standard parts from the template source drawing;
[0165] Step 4.6.4: Find the smallest circumcircle of the outer contour and obtain the coordinates of the center and the radius;
[0166] Step 4.6.5: Extract the Region of Interest (ROI) based on the desired center coordinates and radius. This ROI is a rectangle with a side length equal to the diameter of the minimum circumcircle of the standard part in the template source image, its center at the center of the minimum circumcircle of the standard part, and its rotation angle is zero. The ROI represents the region of interest.
[0167] Step 4.6.6: Extract hierarchical contour information from the ROI. The hierarchical contour information includes outer contour information and inner contour information, and the outer contour and inner contour satisfy the parent-child hierarchical relationship. If the outer contour and inner contour satisfy the parent-child hierarchical relationship, then the outer contour is the parent contour and the inner contour is the child contour.
[0168] Step 4.6.7: Find the smallest bounding rectangle with zero rotation angle of its outer contour, obtain the length and width of the rectangle, and determine whether the length or width of this rectangle is greater than the set value; in this embodiment, it is expressed as whether the length is greater than the number of rows of the ROI minus 2, and whether the width is greater than the number of columns of the ROI minus 2.
[0169] Step 4.6.8: If the length or width of the rectangle is greater than the set value, the standard part goes out of bounds, and the process jumps to step 4.6.16;
[0170] Step 4.6.9: If the length or width of the rectangle is not greater than the set value, find the centroid of the outer contour and the smallest bounding rectangle to obtain the center coordinates, rotation angle, length, width and area of the rectangle; then determine whether there is an inner contour.
[0171] Step 4.6.10: If the inner contour does not exist, proceed to step 4.6.16;
[0172] Step 4.6.11: If an inner contour exists, then determine whether there is only one valid inner contour;
[0173] Step 4.6.12: If there is only one valid inner contour, then obtain the centroid, the coordinates of the center of the smallest bounding rectangle, the rotation angle, the length and width, and the area, and jump to step 4.6.16;
[0174] Step 4.6.13: If there are multiple valid inner contours, traverse all valid inner contours, find the maximum and minimum values of the area of the smallest bounding rectangle of the inner contour, and compare whether the difference between the maximum and minimum values is greater than a set value; in this embodiment, the set value is the sum of the squares of 10 pixels.
[0175] Step 4.6.14: If the difference between the maximum and minimum area of the minimum bounding rectangle is greater than the set value, it indicates that there is both a maximum inner contour and a minimum inner contour; calculate their centroid, coordinates of the center of the minimum bounding rectangle, rotation angle, length, width, and area respectively, and jump to step 4.6.16.
[0176] Step 4.6.15: If the difference between the maximum and minimum area of the minimum bounding rectangle is less than or equal to the set value, it indicates that the standard part has multiple valid maximum inner contours. Take any one of them and obtain the centroid, the center coordinates of the minimum bounding rectangle, the rotation angle, the length and width, and the area. Then jump to step 4.6.16.
[0177] Step 4.6.16: Based on the task editing information for circle, line, arc, and angle measurement types, extract the feature information for circle, line, arc, and angle measurement types;
[0178] Step 4.6.17: End the test template information extraction process.
[0179] like Figure 10 As shown, step 4.6.16, the process of extracting circle measurement type information from the template source image, includes the following steps:
[0180] Step 4.7.1: Based on the corresponding circle measurement type mask feature information obtained from the task editing, extract the circle measurement type ROI from the template source image;
[0181] Step 4.7.2: Filter the ROI grayscale image. The filtering process is Gaussian filtering. In this embodiment, the filtering window size for Gaussian filtering is 5*5, and the standard deviation is 2.
[0182] Step 4.7.3: Perform Hough circle finding on the filtered image to obtain several circles;
[0183] Step 4.7.4: Compare the circles obtained in step 4.7.3 with the center of the selected mask circle to determine whether the center offset is less than a set value; in this embodiment, the set value is 2mm.
[0184] Step 4.7.5: If the center offset is greater than or equal to the set value, change the Hough circle finding threshold parameter and jump to step 4.7.3; changing the Hough circle finding threshold parameter means reducing the threshold parameter, which is the same in subsequent processes and steps. This threshold parameter represents the cumulative threshold of the circle center in the detection stage of the Hough gradient method for circle finding. The smaller the Hough circle finding threshold parameter is, the more non-existent circles can be detected, while the larger the threshold is, the closer the detected circles are to perfect circles; in this embodiment, the range of the threshold is from 5 pixels to 1 / 5 of the circumference of the corresponding mask circle, and the value decreases by 5 pixels each time it is executed;
[0185] Step 4.7.6: If the center offset is less than the set value, select the Hough fitted circle with the smallest absolute difference between the template source image and the mask circle radius, and proceed to step 4.7.7;
[0186] Step 4.7.7: Compare with the radius of the mask circle to determine whether the absolute difference in radius is less than a set value; in this embodiment, the set value is 2mm.
[0187] Step 4.7.8: If the absolute difference in radius is greater than or equal to the set value, change the Hough circle finding threshold parameter threshold and jump to step 4.7.3;
[0188] Step 4.7.9: If the absolute difference in radius is less than the set value, then a suitable Hough fitted circle has been found;
[0189] Step 4.7.10: Apply the Canny operator to the grayscale image of the ROI for edge detection;
[0190] Step 4.7.11: Perform a bitwise AND operation between the Canny-processed ROI image and the masked ROI image; the AND algorithm refers to the process where edge points obtained from Canny edge detection in the ROI image that are within the white circle drawn in the masked ROI image are retained, while other points are discarded, such as... Figure 22 As shown;
[0191] Step 4.7.12: Extract the edge contour points to be measured from the image after image AND;
[0192] Step 4.7.13: Based on the distance from the contour points to the Hough fitted circle, select suitable contour points to form a new set of contour points;
[0193] Step 4.7.14: Apply the least squares method to fit a circle to the new contour point set to obtain the center and radius of the circle;
[0194] Step 4.7.15: End this process.
[0195] It should be noted that the process for extracting arc measurement type information from the template source image is the same as the process for extracting circle measurement type information from the template source image; the only difference is the ROI being extracted.
[0196] It should be noted that there may be multiple mask feature information for circle measurement types. The above measurement process is performed separately for each type of mask feature information for circle measurement. The measurement process is also performed separately for mask feature information for arc, line and corner measurement types.
[0197] like Figure 11 As shown, step 4.6.16, the process of extracting line measurement type information from the template source image, includes the following steps:
[0198] Step 4.8.1: Based on the corresponding line measurement type mask feature information obtained from the task editing, extract the line measurement type ROI from the template source image;
[0199] Step 4.8.2: Apply the Canny operator to the grayscale image of the ROI for edge detection;
[0200] Step 4.8.3: Perform Hough line finding on the image processed by Canny to obtain several line segments;
[0201] Step 4.8.4: Compare the tilt angle of the straight line segment obtained in step 4.8.3 with that of the mask straight line segment, and determine whether the tilt angle offset is less than a set value; in this embodiment, the set value is 7.5 degrees.
[0202] Step 4.8.5: If the tilt angle offset is greater than or equal to the set value, change the Hough line finding parameter threshold and jump to step 4.8.3. The Hough line finding parameters include the threshold parameter of the accumulating plane, the minimum line segment length, and the maximum line spacing. The threshold parameter of the accumulating plane represents the value that it must reach in the accumulating plane when identifying a certain part as a line in the figure. The maximum line spacing represents the maximum distance allowed to connect points in the same row. In this embodiment, the threshold expression of the accumulating plane threshold parameter is 160-2*M, the threshold expression of the minimum line segment length is 80-M, and the threshold expression of the maximum line spacing is 36-2*q, where 0≤M<71, 0≤Q<16, the initial value of M is 0, the initial value of Q is 0, and each time step c is executed, M is increased by 5 and Q is increased by 1.
[0203] Step 4.8.6: If the tilt angle offset is less than the set value, then select the longest straight line segment from the straight line segments that meet the tilt angle offset.
[0204] Step 4.8.7: Perform a bitwise AND operation between the Canny-processed ROI image and the masked ROI image;
[0205] Step 4.8.8: Extract the edge contour points to be measured from the image after image AND;
[0206] Step 4.8.9: Based on the distance from the contour point to the Hough fitted line segment, select suitable contour points to form a new contour point set;
[0207] Step 4.8.10: Apply the least squares method to fit a straight line to the new contour point set, and obtain the inclination angle and the coordinates of the two endpoints of the straight line segment;
[0208] Step 4.8.11: End this process.
[0209] like Figure 12 As shown, step 4.6.16, the process of extracting angle measurement type information from the template source image, includes the following steps:
[0210] Step 4.9.1: Based on the mask feature information of the corresponding angle measurement type obtained from the task editing, extract the ROI of the angle measurement type from the template source image;
[0211] Step 4.9.2: Apply the Canny operator to the grayscale image of the ROI in the template source image for edge detection;
[0212] Step 4.9.3: Perform Hough line finding on the image processed by Canny to obtain several line segments in the template source image;
[0213] Step 4.9.4: Based on the oblique angles of the two line segments forming an angle in the mask angle, including the oblique angles of the first and second line segments, select two sets of line segments from the several line segments obtained in Step 4.9.3, namely the first set of line segments and the second set of line segments. The absolute value of the difference between the oblique angle of the line segment in the first set of line segments and the oblique angle of the first line segment in the mask angle is less than a set value, which is 7.5 degrees in this embodiment. The absolute value of the difference between the oblique angle of the line segment in the second set of line segments and the oblique angle of the second line segment in the mask feature information is less than a set value, which is 7.5 degrees in this embodiment. If each set of line segments selected includes at least one line segment, the selection is successful; otherwise, the selection fails.
[0214] Step 4.9.5: If step 4.9.4 fails to filter, change the Hough line-finding parameters and jump to step 4.9.3 to execute;
[0215] Step 4.9.6: If the filtering in step 4.9.4 is successful, calculate the distance from the endpoint of any straight line segment in the mask angle to another straight line segment. This endpoint is the end furthest from the included angle. Two distance values are obtained, and the smaller distance value D is taken. Traverse the first group of straight line segments obtained in step 4.9.4, filtering out straight line segments whose distance to a set point is less than a set value, forming a new first group of straight line segments. This set point is the endpoint of the first straight line segment in the mask feature information furthest from the included angle. In this embodiment, if D / 5 > If the value is 70 pixels, then the set value is 70 pixels; otherwise, the set value is D / 5. Similarly, traverse the second group of line segments obtained in step 4.9.4, and filter out those line segments whose distance from the set point to the line segment is less than the set value to form a new second group of line segments. The set point is the endpoint of the second line segment in the mask feature information that is furthest from the included angle. The set value is the same as that of the first group of line segments. If both the new first group of line segments and the new second group of line segments satisfy the condition of including at least one line segment, then the filtering is successful; otherwise, the filtering fails.
[0216] Step 4.9.7: If the filtering is unsuccessful in step 4.9.6, change the Hough line-finding parameters and jump to step 4.9.3 to execute;
[0217] Step 4.9.8: If the filtering in step 4.9.6 is successful, traverse the new first group of line segments and the new second group of line segments to randomly select a group of line segments and filter out the longest line segment;
[0218] Step 4.9.9: Find the longest line segment obtained in Step 4.9.8 and the angle between each line segment in the other set of line segments;
[0219] Step 4.9.10: Compare the included angle obtained in step 4.9.9 with the mask included angle. If the difference between the included angle and the mask angle is less than the set value, filter out the line segments that meet the conditions in another set of line segments and determine whether the filtering is successful. If at least one line segment is filtered out in the other set of line segments, it indicates that the filtering is successful.
[0220] Step 4.9.11: If the filtering is unsuccessful in step 4.9.10, change the Hough line-finding parameter and jump to step 4.9.3 to execute;
[0221] Step 4.9.12: If the filtering in step 4.9.10 is successful, then select the longest line segment from the other group of line segments after completing the filtering in step 4.9.10.
[0222] Step 4.9.13: Obtain two line segments through steps 4.9.8 and 4.9.12, calculate the included angle between the two line segments, compare it with the mask angle, and determine whether the deviation is less than the set value; in this embodiment, the set value is 10 degrees.
[0223] Step 4.9.14: If the deviation is greater than or equal to the set value, the angle measurement type feature information fails to be retrieved, and the process jumps to step 4.9.19.
[0224] Step 4.9.15: If the deviation is less than the set value, find the outer contour of the image after Canny processing;
[0225] Step 4.9.16: Based on the distances from the contour points to the two line segments to be determined, select two sets of contour point sets;
[0226] Step 4.9.17: Apply the least squares method to fit straight lines to the two sets of contour points respectively, and obtain the coordinates of the two endpoints and the oblique angle;
[0227] Step 4.9.18: Further determine the included angle between the two line segments and the coordinates of the vertex;
[0228] Step 4.9.19: End this process.
[0229] Clicking the "Template Calibration" button will enter the template calibration interface. This interface allows for distortion correction and magnification calculation of the currently measured part. Distortion parameters and magnification are obtained through calibration, and these parameters are used for dimensional measurements in real-time. Clicking the "Front" or "Side" button in the template calibration interface will initiate the template calibration process, which includes the following steps:
[0230] Step 5.1: Place the calibration board at different positions within the field of view and acquire images of the calibration board respectively;
[0231] Step 5.2: After the calibration board image acquisition is completed, turn off camera acquisition and call the calibration algorithm to perform image calibration processing;
[0232] Step 5.3: After the calibration process is complete, update the calibration parameters to the latest calibration parameters;
[0233] Step 5.4: Exit the template calibration interface.
[0234] like Figure 13 , 14 As shown, the image calibration process in step 5.2 includes obtaining distortion parameters and obtaining magnification. Obtaining distortion parameters uses Zhang Zhengyou's distortion correction algorithm and includes the following steps:
[0235] Step 5.1.1: Read the acquired calibration image data and calibration parameters. In the calibration parameters, the number of horizontal points is the number of rows of the calibration board chessboard, the number of vertical points is the number of columns of the chessboard, and the unit spacing is the actual physical size of each small square of the chessboard.
[0236] Step 5.1.2: Extract corner information from each frame of the calibration image;
[0237] Step 5.1.3: Utilize the extracted corner information to further extract sub-pixel corner information;
[0238] Step 5.1.4: Initialize the spatial three-dimensional coordinate system of the corner points on the calibration board;
[0239] Step 5.1.5: Using the extracted sub-pixel corner information and the spatial three-dimensional coordinate system information of the corner points on the calibration board, perform camera calibration to obtain the distortion parameters, rotation vector, and translation vector of each frame of the image within the camera.
[0240] Step 5.1.6: Evaluate the calibration results; First, obtain the distortion parameters through camera calibration, then reproject the spatial three-dimensional coordinate points of each frame image to obtain new projection points. Calculate the error between the new projection points and the old projection points. 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 this process. If the error is greater than or equal to the set value of 0.15 pixels, it does not meet the requirements. End this process and prompt for re-acquiring calibration images.
[0241] The process of obtaining magnification includes the following steps:
[0242] Step 5.2.1: Use the calibration results to correct a single frame of the acquired calibration image;
[0243] Step 5.2.2: Extract corner information from the corrected image;
[0244] Step 5.2.3: Extract sub-pixel corner information;
[0245] Step 5.2.4: Traverse the columns of the correction image, calculate and save the spacing from the first row to the last row of each column;
[0246] Step 5.2.5: Sort the spacing stored in each column;
[0247] Step 5.2.6: Select several columns centered on the middle column, and sum the saved spacing of the selected columns;
[0248] Step 5.2.7: Calculate the mean based on the accumulated values;
[0249] Step 5.2.8: Calculate the magnification based on the mean, number of columns, and physical dimensions. The formula for calculating the magnification is: mean / (number of columns - 2) / physical dimensions.
[0250] Step 5.2.9: End this process.
[0251] The dimensional measurement process includes the following steps:
[0252] Step 6.1: Detect the part out of bounds based on the current real-time image to determine if the part being tested has exceeded the boundary. If it has exceeded the boundary, a prompt box will pop up to inform the user that the part being tested has exceeded the boundary. The user can close the prompt box and proceed to the next step. If it has not exceeded the boundary, proceed directly to the next step.
[0253] Step 6.2: Determine if the front or side template exists. If it exists, proceed to the next step. If it does not exist, prompt the user to create a template first, then take measurements, and end the process.
[0254] Step 6.3: Determine if an image has been acquired; if an image has been acquired, start the front / side dimension measurement processing thread and run the dimension measurement algorithm; if no image has been acquired, notify the user that no image has been obtained and end this process.
[0255] Step 6.4: Determine if the number of images processed has reached the processing threshold; if the processing threshold has not been reached, prompt "Please start the camera and continue to acquire n images", where n represents the number of missing images, and end this process; if the processing threshold has been reached, perform front / side data processing; data processing involves calculating the standard deviation of the processing results for each image, removing data based on the standard deviation, and then averaging the remaining data.
[0256] Step 6.5: After the data processing is complete, the measurement results of each dimension are displayed on the interface.
[0257] like Figure 15 As shown, the part out-of-bounds detection in step 6.1 includes the following steps:
[0258] Step 6.1.1: Read in the test drawing and template source drawing of the part to be tested;
[0259] Step 6.1.2: Perform differential processing on the image to be tested and the template source image of the part to be tested, and determine whether the two frames are consistent. If they are consistent, it indicates that the shape and displacement of the part to be tested have not changed, and the flag bit is set to 0. If they are inconsistent, it indicates that the shape or displacement of the part to be tested has changed, and the flag bit is set to 1.
[0260] Step 6.1.3: Filtering of the image under test; High-frequency noise is removed by median filtering while retaining contour edge information. In this embodiment, the median filtering window is 9 pixels * 9 pixels.
[0261] Step 6.1.4: Perform grayscale threshold binarization on the filtered image; where the grayscale value of pixels greater than the set threshold is set to 255, and vice versa, it is set to 0; in this embodiment, the threshold is set to 180.
[0262] Step 6.1.5: Find all closed-loop contours in the image; the closed-loop contour refers to the contour in which the distance between any two adjacent contour points is less than a set value, which is 2 pixels in this embodiment;
[0263] Step 6.1.6: Calculate the perimeter of the maximum closed-loop contour and determine if this perimeter meets the set conditions. The set conditions are that the perimeter of the maximum closed-loop contour is not less than 0.99 times the perimeter of the image and not greater than 1.01 times the perimeter of the image. If this perimeter does not meet the conditions, check the flag bit (Flag) and end this process. If this perimeter meets the conditions, proceed to step 6.1.7. Wherein, if Flag equals 0, it means that the detection result is that the part to be detected is out of bounds but the shape and displacement of the part to be detected have not changed. If Flag equals 1, it means that the detection result is that the part to be detected is out of bounds and the shape or displacement of the part to be detected has changed.
[0264] Step 6.1.7: Find the centroid of the largest closed-loop profile and determine whether this centroid satisfies the set conditions;
[0265] The set conditions are that the distance between the horizontal coordinate (X-axis coordinate) of the centroid and the horizontal coordinate of the image center point is not greater than a set value, which is 5 pixels in this embodiment; the distance between the vertical coordinate (Y-axis coordinate) of the centroid and the vertical coordinate of the image center point is also not greater than a set value, which is 5 pixels in this embodiment. If the centroid does not meet the set conditions, the flag bit is checked. If the flag is equal to 0, it means that the detection result is that the part to be detected is out of bounds but the shape and displacement of the part to be detected have not changed; if the flag is equal to 1, it means that the detection result is that the part to be detected is out of bounds and the shape or displacement of the part to be detected has changed; if the centroid meets the set conditions, it is then determined whether the total number of closed loop contours in the image is 1.
[0266] If the total number of closed loop contours in the image is 1, check the flag bit; if the flag is 0, the detection result is that the part to be detected is out of bounds but the shape and displacement of the part to be detected are unchanged; if the flag is 1, the detection result is that the part to be detected is out of bounds and the shape or displacement of the part to be detected has changed; if the total number of closed loop contours in the image is greater than 1, check the flag bit; if the flag is 0, the detection result is that the part to be detected is within bounds and the shape and displacement of the part to be detected are unchanged; if the flag is 1, the detection result is that the part to be detected is within bounds but the shape or displacement of the part to be detected has changed.
[0267] Step 6.1.8: End this process.
[0268] The specific implementation process of differential processing in step 6.1.2 is as follows: First, differential processing is performed between the image to be tested and the template source image. The gray values of all pixels in the two frames are compared. When the gray value is greater than a set value, the gray value statistics are incremented by 1. The initial gray value is 0, and in this embodiment, the set value is 80. After traversing all pixels, if the gray value statistics are greater than the set threshold, it indicates that the shape or displacement of the part to be detected has changed. Otherwise, it indicates that the shape and displacement of the part to be detected have not changed. In this embodiment, the set threshold is 99% of the total number of pixels.
[0269] like Figure 16 As shown, the dimension measurement algorithm in step 6.3 includes the following steps:
[0270] Step 6.2.1: Correct the real-time image to be read in using calibration parameters;
[0271] Step 6.2.2: Determine whether the shape and displacement of the part to be inspected have not changed;
[0272] Step 6.2.3: If the shape and displacement of the part to be inspected have not changed, then perform measurements of each measurement type based on the feature information extracted from the template source image;
[0273] Step 6.2.4: If the shape and / or displacement of the part to be detected changes, then perform object search and matching to determine whether the part to be detected matches the template source image;
[0274] Step 6.2.5: If the part to be inspected matches the template source image, perform measurements of circles, lines, arcs, and corners based on the feature information extracted from the template source image, and end this process;
[0275] Step 6.2.6: If the part to be inspected does not match the template source drawing, it means that the part to be inspected has not been found, and this process ends.
[0276] like Figure 17 As shown, in step 6.2.4, the object search and matching process includes the following steps:
[0277] Step 6.3.1: Perform mean filtering on the image to be tested; in this embodiment, the mean filtering window is 3 pixels * 3 pixels;
[0278] Step 6.3.2: Perform thresholding processing. Pixel grayscale values greater than the set threshold are set to 0, and vice versa. In this embodiment, the set threshold is 100.
[0279] Step 6.3.3: Extract the contour information of the part to be detected at the level to be detected; the contour information of the part to be detected at the level 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 hierarchy relationship, where the outer contour is the parent contour and the inner contour is the child contour.
[0280] Step 6.3.4: Determine whether the absolute value of the difference between the minimum bounding rectangle area of the outer contour of the part to be inspected and the minimum bounding rectangle area of the outer contour of the template source image is less than a set value; in this embodiment, the set value is 15% of the minimum bounding rectangle area of the outer contour of the template source image.
[0281] Step 6.3.5: If the absolute value of the difference between the minimum bounding rectangle area of the outer contour of the part to be inspected and the minimum bounding rectangle area of the outer contour of the template source image is greater than or equal to the set value, then the process ends.
[0282] Step 6.3.6: If the absolute value of the difference between the area of the minimum bounding rectangle of the outer contour of the part to be detected and the area of the minimum bounding rectangle of the outer contour of the template source image is less than a set value, then determine whether the absolute value of the difference between the aspect ratio of the minimum bounding rectangle of the outer contour of the part to be detected and the aspect ratio of the minimum bounding rectangle of the outer contour of the template source image is less than a set value; in this embodiment, the range of the set value is 10% of the aspect ratio of the minimum bounding rectangle of the outer contour of the template source image.
[0283] Step 6.3.7: If the absolute value of the difference between the aspect ratio of the minimum bounding rectangle of the outer contour of the part to be inspected and the aspect ratio of the minimum bounding rectangle of the outer contour of the template source drawing is greater than or equal to the set value, then the process ends.
[0284] Step 6.3.8: If the absolute value of the difference between the aspect ratio of the minimum bounding rectangle of the outer contour of the part to be inspected and the aspect ratio of the minimum bounding rectangle of the outer contour of the template source image is less than the set value, then find the minimum bounding circle of the outer contour and use its center as the rotation center.
[0285] Step 6.3.9: Determine whether the distance between the centroid of the outer contour of the template source image and the center of the minimum bounding rectangle of the outer contour of the template source image is greater than a set value; in this embodiment, the set value is 20 pixels.
[0286] Step 6.3.10: If the distance between the centroid of the outer contour of the template source image and the center of the minimum bounding rectangle of the outer contour of the template source image is less than or equal to the set value, then jump to step 6.3.18;
[0287] Step 6.3.11: If the distance between the centroid of the outer contour of the template source image and the center of the minimum bounding rectangle of the outer contour of the template source image is greater than the set value, then determine whether the absolute value of the difference between the centroid of the outer contour of the part to be tested and the center of its minimum bounding rectangle and the aspect ratio of the centroid of the outer contour of the template source image to its minimum bounding rectangle is less than the set value; in this embodiment, the set value is 10% of the aspect ratio of the centroid of the outer contour of the template source image to its minimum bounding rectangle.
[0288] Step 6.3.12: If the absolute value of the difference between the centroid of the outer contour of the part to be inspected and the center distance between its minimum bounding rectangle and the aspect ratio of the centroid of the outer contour of the template source image to its minimum bounding rectangle is greater than or equal to the set value, then jump to step 6.3.18.
[0289] Step 6.3.13: If the absolute value of the difference between the centroid of the outer contour of the part to be inspected and the center distance between its minimum bounding rectangle and the aspect ratio of the centroid of the outer contour of the template source image to its minimum bounding rectangle is less than the set value, then calculate the rotation angle of the part to be inspected relative to the template source image.
[0290] Step 6.3.14: Combining the center coordinates and angle information of the template source image, translate and rotate the image to be tested. That is, first extract the region of interest (ROI) of the part to be tested in the image to be tested; then create a blank image of the same size as the image to be tested, translate the part to be tested to the center of the blank image, and then rotate the part to be tested to the same angle as the template source image; in this embodiment, the ROI is a rectangle, the side length of which is the diameter of the smallest circumcircle of the template source image, and its center is the center of the smallest circumcircle of the part to be tested;
[0291] Step 6.3.15: Determine whether the vector angle from the centroid of the outer contour of the part to be inspected to the center of the minimum bounding rectangle of the part to be inspected is less than the vector angle from the centroid of the outer contour of the template source image to the center of the minimum bounding rectangle of the template source image. In this embodiment, the set value is 7.5 degrees.
[0292] Step 6.3.16: If the difference in vector angles in step 6.3.15 is less than the set value, it means that the object matching is successful and the process ends.
[0293] Step 6.3.17: If the difference in vector angles in step 6.3.15 is greater than or equal to the set value, then proceed to step 6.3.18;
[0294] Step 6.3.18: Determine whether an inner contour exists based on the area of the smallest bounding rectangle of the largest inner contour in the template source image; if not, the object matching is successful, calculate the rotation angle of the part to be detected relative to the template source image, combine the center coordinates and angle information of the template source image, translate and rotate the object, and end this process; if yes, determine whether the template source image has only one valid largest inner contour.
[0295] Step 6.3.19: If the template source image has only one valid maximum inner contour, then perform valid inner contour matching. Valid inner contour matching includes determining whether the area of the minimum bounding rectangle of the maximum inner contour of the part to be detected matches the area of the minimum bounding rectangle of the maximum inner contour of the template source image. Further, it sequentially determines whether the aspect ratio of the minimum bounding rectangle of the maximum inner contour matches, whether the center distance between the outer contour and the minimum bounding rectangle of the maximum inner contour matches, calculates the rotation angle of the part to be detected relative to the template source image, and combines the center coordinates and angle information of the template source image to rotate and translate the object. It then checks whether the vector angle between the center of the outer contour and the minimum bounding rectangle of the maximum inner contour matches to determine whether the matching is successful.
[0296] Step 6.3.20: If the template source image does not satisfy the condition of having only one valid maximum inner contour, then determine whether the template source image has multiple maximum inner contours or has both a maximum inner contour and a minimum outer contour.
[0297] Step 6.3.21: If the template source image has multiple maximum inner contours, then traverse all 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 yes, the object is successfully matched and this process ends; otherwise, the object is not successfully matched and this process ends.
[0298] Step 6.3.22: If the template source image has both a maximum inner contour and a minimum outer contour, first perform effective inner contour matching on the maximum inner contour; if the maximum inner contour is matched, the object matching is successful, and this process ends.
[0299] If the largest inner contour does not match, then perform effective inner contour matching on the smallest inner contour of the detected object; if the smallest inner contour matches, the object is successfully matched and the process ends; if the smallest inner contour does not match, the object is not successfully matched and the process ends.
[0300] like Figure 18 As shown, the measurement process for the circle measurement type of the drawing to be measured in step 6.2.5 includes the following steps:
[0301] Step 6.4.2: Extract the ROI of the circle measurement type from the image to be measured based on the feature information of the circle measurement type obtained from the template source image;
[0302] Step 6.4.3: Perform Gaussian filtering on the grayscale image of the ROI in the image to be tested;
[0303] Step 6.4.4: Perform Hough circle finding on the filtered image to obtain several circles in the image to be tested;
[0304] Step 6.4.5: Compare the center of the circle obtained in the image to be tested with the template source image to determine whether there is at least one circle in the image to be tested whose center is offset from the selected circle in the template source image within 2mm.
[0305] Step 6.4.6: If there is no circle on the image to be tested that satisfies step 6.4.5, change the Hough circle finding parameter threshold and jump to step 6.4.4;
[0306] Step 6.4.7: If there is a circle on the image to be tested that satisfies Step 6.4.5, then filter out the circle on the template source image and the circle on the image to be tested, so that the absolute difference between the radii of the two Hough fitted circles is minimized.
[0307] Step 6.4.8: Compare the radii of the circles selected in Step 6.4.7 and determine whether the absolute difference in radius is within 2mm;
[0308] Step 6.4.9: If the absolute difference in radius is not within 2mm, change the Hough circle finding parameter threshold and jump to step 6.4.4;
[0309] Step 6.4.9: If the absolute difference in radius is within 2mm, it means that a suitable Hough fitted circle has been found;
[0310] Step 6.4.20: Calculate the gradient of the Gaussian-filtered image;
[0311] Step 6.4.21: Calculate sub-pixel edge points; the edge point is defined as the maximum value of the difference between several adjacent gradient magnitudes. In this embodiment, the quadratic function interpolation of the gradient magnitudes at three adjacent points along the gradient direction is used, that is, three coordinate points (point A, point B, and point C) are used to fit a quadratic equation, and the compensation value η is obtained.
[0312]
[0313] Then the sub-pixel point at the edge is the middle point among three adjacent points with the compensation value added, where ||g(A)|| represents the gradient magnitude of point A, ||g(B)|| represents the gradient magnitude of point B, and ||g(C)|| represents the gradient magnitude of point C;
[0314] Step 6.4.22: Connect the sub-pixel edge points to form a contour;
[0315] Step 6.4.23: Filter contour points using dual thresholds;
[0316] Step 6.4.24: Based on the distance from the contour points to the found suitable Hough fitting circle, select suitable contour points to form a new set of contour points;
[0317] Step 6.4.25: Apply the least squares method to fit a circle to the new contour point set to obtain the center and radius;
[0318] Step 6.4.26: End this process.
[0319] In step 6.4.3, the Gaussian filtering process refers to using a discretized window sliding convolution. Gaussian filtering first requires calculating the Gaussian weight matrix. In this example, the coordinates of the center point are assumed to be (0,0). The coordinates of the eight points closest to it are as follows: Assuming a standard deviation σ = 1.5, the weight matrix with a filtering radius of 1 is as follows: The sum of the weights of these nine points equals 0.4787147. If only the weighted average of these nine points is calculated, their weights must be equal to 1. Therefore, the above nine values must be divided by 0.4787147 to obtain the final weight matrix. With the weight matrix, the center point and the surrounding n points can be calculated. Each point is multiplied by its own weight value, and these values are summed to obtain the Gaussian filtered value for the center point. This process is repeated for all points to obtain the Gaussian-filtered image.
[0320]
[0321]
[0322] In step 6.4.20, the gradient representation of the Gaussian filtered image is obtained, and the approximate image gradient and gradient magnitude are obtained using the central difference method. Specifically, the gradient of any pixel (x,y) in the image is divided into X component and Y component. The X component is the gray value of pixel (x+1,y) minus the gray value of pixel (x-1,y); the Y component is the gray value of pixel (x,y+1) minus the gray value of pixel (x,y-1); the gradient magnitude is the square root of the sum of the squares of the X component and the sum of the squares of the Y component.
[0323] In step 6.4.22, connecting sub-pixel edge points to form a contour representation involves grouping contour points belonging to the same edge together to form a link. Each contour point corresponds to a pixel. First, pixels grouped into the same link should have an approximate gradient direction. An approximate gradient direction means that the angle between adjacent pixels on the same link should be less than 90 degrees. Taking pixels A and B as an example, mathematically, this is expressed as: g(A).g(B)>0, where g(A) represents the gradient of point A and g(B) represents the gradient of point B. In addition, image contours can separate bright and dark regions, so continuous links need to divide dark regions to the same side of the curve. A simple method is to verify whether the vector from edge point A to point B is approximately orthogonal to one of the two possible gradient directions (X-axis direction or Y-axis direction) of point A.
[0324] In step 6.4.23, the dual-threshold screening of contour points refers to the contour points formed by screening through two set thresholds, a high threshold and a low threshold. Specifically, for each point in the link, first verify whether its gradient magnitude is greater than the set high threshold. In this embodiment, the high threshold is 4.3. If the gradient magnitude is greater than the set high threshold, then verify whether the gradient magnitude of the previous point linked to this point is greater than the set low threshold. In this embodiment, the low threshold is 0.8. If it is greater than the set low threshold, then the contour point is retained. If it is less than or equal to the set low threshold, then the contour point is marked as removed. Similarly, the case of the next contour point linked to this contour point is verified. Finally, after traversing all points, the contour points marked as removed are deleted, and the link is re-formed.
[0325] It should be noted that the original template image may contain feature information of multiple circle measurement types. The above measurement process is performed separately for each circle measurement type feature information; the measurement process is also performed separately for arc, line and angle measurement type feature information.
[0326] It should be noted that the measurement steps for arc measurement type and circle measurement type of the drawing to be measured are the same.
[0327] like Figure 19 As shown, the measurement process for the line measurement type of the diagram under test in step 6.2.5 includes the following steps:
[0328] Step 6.5.1: Extract the line measurement type ROI from the image to be measured based on the line measurement type feature information obtained from the template source image;
[0329] Step 6.5.2: Perform Canny edge detection processing on the grayscale image of the ROI in the image to be tested;
[0330] Step 6.5.3: Perform Hough line finding on the image after Canny processing to obtain several line segments in the image to be tested;
[0331] Step 6.5.4: Compare the angles of the line segments in the test image obtained in Step 6.5.3 with the line segments in the template source image to determine whether there is at least one line segment in the test image whose angle offset from at least one line segment in the template source image is less than a set value.
[0332] Step 6.5.5: If there is no straight line segment smaller than the set oblique angle offset value in the figure to be tested, jump to step 6.5.3;
[0333] Step 6.5.6: If there are straight line segments in the graph to be tested that are smaller than the set oblique angle offset value, then several Hough fitted straight line segments in the graph to be tested that satisfy the conditions in step 6.5.4 are obtained.
[0334] Step 6.5.7: Select the longest line segment from the line segments obtained in Step 6.5.6;
[0335] Step 6.5.8: Perform Gaussian filtering on the grayscale image of the ROI corresponding to the line segment obtained in Step 6.5.7;
[0336] Step 6.5.9: Calculate the gradient of the Gaussian-filtered image;
[0337] Step 6.5.10: Calculate sub-pixel edge points;
[0338] Step 6.5.11: Connect sub-pixel edge points to form an outline;
[0339] Step 6.5.12: Use dual thresholds to filter sub-pixel edge points and reassemble the contour point set;
[0340] Step 6.5.13: Based on the distance from the contour points to the selected line segments, select suitable contour points to form a new contour point set.
[0341] Step 6.5.14: Fit a straight line to the new contour point set using the least squares method to obtain the oblique angle and coordinates of the two endpoints;
[0342] Step 6.5.15: End this process.
[0343] like Figure 20 As shown, the measurement process for the angle measurement type of the drawing to be measured in step 6.2.5 includes the following steps:
[0344] Step 6.6.1: Extract the ROI of angle measurement type from the image to be measured based on the circle measurement type feature information obtained from the template source image;
[0345] Step 6.6.2: Perform Canny edge detection processing on the grayscale image of the ROI in the image to be tested;
[0346] Step 6.6.3: Perform Hough line finding on the image after Canny processing to obtain several line segments in the image to be tested;
[0347] Step 6.6.4: Based on the oblique angles of the two line segments forming the angle in the template source image, including the oblique angles of the first and second line segments, select two sets of line segments from the several line segments obtained in Step 6.6.3, namely the first set of line segments and the second set of line segments. The absolute value of the difference between the oblique angle of the line segments in the first set and the oblique angle of the first line segment in the mask feature information is less than a set value, which is 7.5 degrees in this embodiment. Similarly, the absolute value of the difference between the oblique angle of the line segments in the second set and the oblique angle of the second line segment in the mask feature information is less than a set value, which is 7.5 degrees in this embodiment. If each selected set of line segments includes at least one line segment, the selection is successful; otherwise, the selection fails.
[0348] Step 6.6.5: If the filtering in step 6.6.4 fails, change the parameters of Hough line finding and jump to step 6.6.3 to execute;
[0349] Step 6.6.6: If the filtering in step 6.6.4 is successful, calculate the distance from the endpoint of any one of the two line segments forming the included angle in the template source image to the other line segment. This endpoint is the end furthest from the included angle. Two distance values are obtained, and the smaller distance value D' is taken. Iterate through the first group of line segments obtained in step 6.6.4, filtering out line segments whose distance to a set point is less than a set value, forming a new first group of line segments. This set point is the endpoint of the first line segment in the template source image furthest from the included angle. In this embodiment... If D' / 5 > 70 pixels, then the set value is 70 pixels; otherwise, the set value is D' / 5. Similarly, traverse the second group of line segments obtained in step 6.6.4, and filter out those line segments whose distance from the set point to the line segment is less than the set value to form a new second group of line segments. The set point here is the endpoint of the second line segment in the template source image that is away from the included angle, and the set value is the same as that of the first group of line segments. If both the new first group of line segments and the new second group of line segments satisfy the condition of including at least one line segment, then the filtering is successful; otherwise, the filtering fails.
[0350] Step 6.6.7: If the filtering in step 6.6.6 fails, change the Hough line-finding parameters and jump to step 6.6.3;
[0351] Step 6.6.8: If the filtering in step 6.6.6 is successful, then traverse the new first group of line segments and the new second group of line segments in step 6.6.6, and select the longest line segment in the group.
[0352] Step 6.6.9: Find the angle between the line segment obtained in Step 6.6.8 and each line segment in the other set of line segments;
[0353] Step 6.6.10: Compare the included angle obtained in step 6.6.9 with the included angle selected in the template source image. If the difference in degree between the angle and the angle in the template source image is less than a set value, filter out the line segments that meet the conditions in another set of line segments and determine whether the filtering is successful. If at least one line segment is filtered out in the other set of line segments, it indicates that the filtering is successful.
[0354] Step 6.6.11: If the filtering in step 6.6.10 fails, change the Hough line-finding parameters and jump to step 6.6.3 to execute;
[0355] Step 6.6.12: If the filtering in step 6.6.10 is successful, then filter the longest line segment in another group of line segments;
[0356] Step 6.6.13: Obtain the longest line segment in each group of line segments, calculate the angle between the two line segments, compare it with the angle between the corresponding line segments in the template source image, and determine whether the deviation is less than the set value; in this embodiment, the set value is 10 degrees.
[0357] Step 6.6.14: If the deviation is greater than or equal to the set value, it indicates that the angle measurement type has failed, and the process will proceed to step 6.6.23.
[0358] Step 6.6.15: If the deviation is less than the set value, then perform Gaussian filtering on the ROI grayscale image;
[0359] Step 6.6.16: Calculate the gradient of the Gaussian-filtered image;
[0360] Step 6.6.17: Calculate sub-pixel edge points;
[0361] Step 6.6.18: Connect sub-pixel edge points to form an outline;
[0362] Step 6.6.19: Use dual thresholds to filter sub-pixel edge points and reassemble the contour point set;
[0363] Step 6.6.20: Based on the distances from the contour points to the two line segments to be determined, select two sets of contour points;
[0364] Step 6.6.21: Apply the least squares method to fit straight lines to the two sets of contour points respectively, and obtain the coordinates of the two endpoints and the oblique angle;
[0365] Step 6.6.22: Find the angle between the two line segments and the coordinates of the vertex;
[0366] Step 6.6.23: End this process.
[0367] The above description is merely a specific example of the present invention and does not constitute any limitation on the present invention. Obviously, those skilled in the art, after understanding the content and principles of the present invention, may make various modifications and changes in form and detail without departing from the principles and structure of the present invention; however, these modifications and changes based on the spirit of the present invention are still within the scope of protection of the claims of the present invention.
Claims
1. A method for adjusting a size measurement and scoring device, characterized in that, Includes the following steps: Step 1: Fix the camera and light source to the camera mounting plate and light source support plate respectively; set the bracket and the part to be tested on the carrier plate; turn on the light source, and adjust the vertical high-precision adjustment slide rail according to the clarity of the images continuously acquired by the camera to make the images clear; The upper surface of the carrier plate is provided with an enhanced reflective film; Step 2: Based on the data obtained by the laser sensor in the laser ranging device, continuously adjust the vertical high-precision adjustment slide rail to make the data obtained by the laser sensor equal and the camera fixing plate and the detection platform parallel. Step 3: Remove the bracket and the part to be tested from the testing table; adjust the horizontal and vertical adjustment rails on the slide rail adjustment device so that the standard flat crystal is facing the carrier plate at a set distance; turn off the light source; turn on the He-Ne laser and adjust the lower surface of the standard flat crystal to be parallel to the upper surface of the carrier plate. Step 4: Turn off the He-Ne laser, turn on the light source, and remove the standard flat crystal; place the support at the set position above the carrier plate, set a transparent checkerboard above the support, acquire images, calibrate the flat field, and calculate the image magnification. Step 5: Remove the transparent checkerboard grid, place the part to be inspected with the front side facing up, and use the camera to capture the image to complete the measurement of the front length, width, and internal dimensions of the parts. Step Six: Place the part to be inspected side up into the bracket groove, capture the image with the camera, complete the side height measurement, and end the step.
2. The adjustment and measurement method of the size measurement and scoring device according to claim 1, characterized in that, In step three, adjusting the lower surface of the standard flat crystal to be parallel to the upper surface of the carrier plate requires first ensuring that the light emitted by the He-Ne laser passes through the camera to obtain interference fringes. After processing, the information difference between adjacent interference fringes is obtained. Based on the difference, the four micro-adjustment knobs are continuously adjusted until the information difference between adjacent interference fringes is reduced to the set value, so that the interference fringes are approximately parallel and equally spaced.
3. The adjustment and measurement method of the size measurement and scoring device according to claim 1, characterized in that, The vertical high-precision adjustment slide rails are located at the four corners of the testing platform.
4. The adjustment and measurement method of the size measurement and scoring device according to claim 1, characterized in that, The standard optical flat maintains a set angle between its upper and lower surfaces, and the lower surface of the standard optical flat is provided with an enhanced transmission film.
5. The adjustment and measurement method of the size measurement and scoring device according to claim 1, characterized in that, The bracket is made of a transparent material and is used to fix the part to be tested.
6. The adjustment and measurement method of the size measurement and scoring device according to claim 1, characterized in that, The bracket is generally in the shape of a right quadrangular prism. A groove is provided in the middle part of the bracket. The top of the bracket allows the part to be inspected to be set horizontally, so that the camera can acquire a front image of the part to be inspected. The groove of the bracket allows the part to be inspected to be set vertically, so that the camera can acquire a side image of the part to be inspected.
7. The adjustment and measurement method of the size measurement and scoring device according to claim 1, characterized in that, In step five, the transparent checkerboard grid is positioned adjacent to the carrier plate.
Citation Information
Patent Citations
Laser-assisted calibration device for measuring sizes of parts with different heights
CN111156896A
Adjusting mount with image sensor part of measurement size
CN207540495U