CN116249001A - Dimension measuring instrument with automatic focusing function - Google Patents

Dimension measuring instrument with automatic focusing function Download PDF

Info

Publication number
CN116249001A
CN116249001A CN202310276991.5A CN202310276991A CN116249001A CN 116249001 A CN116249001 A CN 116249001A CN 202310276991 A CN202310276991 A CN 202310276991A CN 116249001 A CN116249001 A CN 116249001A
Authority
CN
China
Prior art keywords
template
focusing
image
definition
value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310276991.5A
Other languages
Chinese (zh)
Inventor
林建宇
陈浙泊
潘凌锋
叶雪旺
陈镇元
陈一信
余建安
陈龙威
吴荻苇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Research Institute of Zhejiang University Taizhou
Original Assignee
Research Institute of Zhejiang University Taizhou
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Research Institute of Zhejiang University Taizhou filed Critical Research Institute of Zhejiang University Taizhou
Priority to CN202310276991.5A priority Critical patent/CN116249001A/en
Publication of CN116249001A publication Critical patent/CN116249001A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G01MEASURING; TESTING
    • G01BMEASURING LENGTH, THICKNESS OR SIMILAR LINEAR DIMENSIONS; MEASURING ANGLES; MEASURING AREAS; MEASURING IRREGULARITIES OF SURFACES OR CONTOURS
    • G01B11/00Measuring arrangements characterised by the use of optical techniques
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Abstract

The invention discloses a size measuring instrument with an automatic focusing function, which comprises 1.1) an initializing step, 1.2) a focusing judging step and 1.3) a focusing interface information processing step; the invention provides the size measuring instrument with the automatic focusing function, which is easy to operate, simple in prompt and efficient in response.

Description

Dimension measuring instrument with automatic focusing function
The patent is a divisional application with the application number of 2021103568098 and the name of a dimension measuring instrument system based on an automatic focusing function
Technical Field
The invention relates to the field of size measurement, in particular to a size measuring instrument with an automatic focusing function.
Background
In an automated production process, in order to ensure the quality of the product, a dimension measuring apparatus is required to measure the dimension of the product.
The traditional size measuring instrument is difficult to ensure measuring accuracy well on the premise of ensuring the degree of automation, and the defect that the proportion of unqualified products is too large due to overlarge measuring errors is easy to occur, so that the cost is increased, the working efficiency is reduced, and inconvenience is brought to the use of users.
Image size measuring instruments are therefore a trend, which are commonly used for measuring two-dimensional dimensions. Is widely applied to various precise industries. The device is mainly used for measuring the sizes and angles of parts which are difficult to measure or not measured at all in calipers and angle gauges but play an important role in assembly at present, such as the creepage distance of silica gel and circuit boards, the clearance of electric appliances, the lamp holes of control panels, certain sizes of plastic parts and the like, and can also be used for shooting pictures of certain parts for analyzing bad reasons.
However, when the conventional image size measuring instrument is actually used, more defects still exist, the full-automatic detection is difficult to achieve at present, the detection process is not provided with certain standards, the final detection result is easy to deviate, the working efficiency is low, the labor intensity of workers is greatly increased for the detection of high-precision products, the workload is difficult to be effectively reduced by the workers, and the working efficiency is improved. Especially in the aspect of automatic focusing comparison, no corresponding system prompt exists at present, the whole structure of the full-automatic equipment is quite complex, and the manufacturing cost is high. In particular, the definition is not required to be too high, and the definition is only required to be within a certain range in the actual operation process in the field of dimension measurement.
Disclosure of Invention
The invention overcomes the defects of the prior art and provides the dimension measuring instrument with the automatic focusing function, which is easy to operate, simple in prompt and efficient in reaction.
In order to solve the technical problems, the technical scheme of the invention is as follows:
the automatic focusing module is used for continuously measuring the definition of real-time images acquired by a camera in the system; prompting a user whether the image is clear or not through the definition, and if the image is not clear, enabling the user to adjust the height of the camera until the image is clear; the method comprises the following specific steps:
1.1 Initializing: after the measuring instrument is started and the operation software is opened, the measuring instrument enters a startup initialization interface, the data read by a database is displayed in the interface, whether the equipment of the system is normal or not is judged, and the equipment enters a corresponding function after the equipment is normal;
1.2 A focusing judgment step: judging whether a focusing start button is clicked, if so, judging whether focusing region editing is performed on the real-time display diagram, if so, transmitting an X coordinate and a Y coordinate of the left upper corner of the editing rectangular frame, the length, the width, the real-time image and an edge detection threshold value to an algorithm, and executing a region definition calculation flow; obtaining a definition evaluation value of the region according to a region definition calculation flow, and displaying the definition evaluation value on an interface in real time;
displaying according to the focusing standard proportion value and the focusing lower limit proportion value, if the definition evaluation value obtained in real time is larger than the focusing standard proportion value, displaying the proportion value by the progress bar, displaying green color, and indicating that the definition of the current area is good, and not needing to adjust the height of the camera; if the definition evaluation value is smaller than the focusing standard proportion value and larger than the focusing lower limit proportion value, the progress bar displays yellow, which indicates that the definition of the current area is not good, and the height of the camera can be finely adjusted; if the definition evaluation value is smaller than the focusing lower limit proportion value, the progress bar displays red, which indicates that the definition of the current area is poor, and the camera height adjustment is needed to adjust the image definition, otherwise, the accurate size measurement cannot be performed;
The regional definition calculation flow execution process judges whether a zone bit of the definition calculation flow stopping process is set in real time, if so, the flow execution is stopped, and the user operation is returned to be judged;
1.3 Focusing interface information processing step: judging whether the user displays an upper frame selection focusing area on the real-time graph, if so, storing the left upper corner coordinates of the frame selection area and the length and width of the frame selection area; judging whether a user clicks a 'acquire height' button, if so, acquiring camera height information by controlling a height sensor, and acquiring camera calibration parameters according to the camera height information by looking up a table to be used as parameters of real-time dimension measurement; and judging whether the user clicks a 'measurement return' button, if so, closing the auxiliary focusing interface, and returning to the real-time measurement interface.
Compared with the prior art, the invention has the advantages that:
the automatic focusing function of the invention can acquire the definition of the image in real time and adjust the object distance of the camera in real time according to the definition. And (3) feeding back the image definition in real time in the process of adjusting the object distance of the camera, and realizing real-time adjustment of the image definition until the optimal (meeting the requirement) definition is reached.
The definition evaluation function execution flow returns the definition of the region to be evaluated through the definition evaluation function. Firstly, reading a to-be-measured image and ROI coordinate information (measurement type mask information for automatic focusing region selection or rectangular frame coordinate information edited by an auxiliary focusing interface) and setting a threshold value for a pixel gray value; extracting the ROI from the image to be detected according to the ROI coordinate information, and classifying black and white pixels according to a set threshold value to obtain a black pixel set and a white pixel set; respectively calculating the average gray value of the pixel points of the black-and-white set; calculating the percentage of the average gray value of the white set to the sum of the average gray values of the black and white sets, namely, the contrast; if the contrast is greater than or equal to the set threshold and less than 100%, the focusing definition value is returned for focusing definition, and the process is ended. If the focus resolution value is larger than 0 and smaller than the set threshold value, returning to the focus resolution value for focusing unclear, and ending the process. If the ROI is equal to 100 or 0, the extracted ROI area is either completely black or completely white, the need of re-extraction is prompted, and the focusing definition value is returned.
Drawings
FIG. 1 is a system block diagram of the present invention;
FIG. 2 is a system initialization flow chart of the present invention;
FIG. 3 is a flowchart of database operations of the present invention;
FIG. 4 is a flow chart of light source detection according to the present invention;
FIG. 5 is a template selection interface diagram of the present invention;
FIG. 6 is a template selection flowchart of the present invention;
FIG. 7 is a template search flow chart of the present invention;
FIG. 8 is a diagram of a real-time measurement interface of the present invention;
FIG. 9 is a diagram of a parameter configuration interface of the present invention;
FIG. 10 is a flow chart of the parameter configuration of the present invention;
FIG. 11 is a flow chart of rights management of the present invention;
FIG. 12 is a flowchart of the operation of the template of the present invention;
FIG. 13 is a flowchart illustrating a template information extraction operation according to the present invention;
FIG. 14 is a flowchart of an auto-focus module according to the present invention;
FIG. 15 is a flow chart of the real-time measurement of a single image in accordance with the present invention;
FIG. 16 is a flow chart of automatic frame skip and frame rate adaptation in accordance with the present invention;
FIG. 17 is a continuous measurement flow chart of the present invention;
FIG. 18 is a flow chart of automatic frame skip and frame rate adaptation in accordance with the present invention;
FIG. 19 is a flow chart of obtaining camera distortion parameters and internal reference matrices in accordance with the present invention;
FIG. 20 is a flowchart of the magnification acquisition process of the present invention;
FIG. 21 is a schematic diagram showing the measurement results of the template making interface of the present invention;
FIG. 22 is a flow chart of automatic exposure adjustment according to the present invention;
FIG. 23 is a schematic diagram of an apparatus of the present invention;
FIG. 24 is a schematic view of a portion of the structure of FIG. 23 in accordance with the present invention;
fig. 25 is a schematic view of the elevation adjustment portion of fig. 23 according to the present invention.
Detailed Description
The invention is further described below with reference to the drawings and the detailed description.
Embodiment one:
as shown in fig. 14, in a size measuring system with an auto-focusing function, an auto-focusing module continuously performs sharpness measurement on a real-time image collected by a camera; prompting a user whether the image is clear or not through the definition, and if the image is not clear, enabling the user to adjust the height of the camera until the image is clear;
displaying a real-time image of the camera on the left side in an interface of the automatic focusing module, and displaying an area image selected by a rectangular frame in the real-time image on the right side; and displaying a clear progress bar above the right image, and setting parameters below the right image, wherein the focusing parameters comprise: an edge detection threshold, a focusing standard proportion value and a focusing lower limit proportion threshold; the threshold value of the edge detection is 0-255 of the segmentation of the black-white edge region, and is set as 100 by default; the focusing standard proportion threshold value is set to be 0-100 in the black-white area proportion, and is set to be 90 by default; the focusing lower limit proportion threshold is 0-100, and is set as 70 by default; as shown in fig. 23 to 25, the dimension measuring instrument includes a lift adjusting portion, a supporting portion, and the lift adjusting portion is provided on the supporting portion.
The supporting part comprises a bearing plate (20) arranged on a base (11), a light source (19) arranged in the bearing plate (20), a key measuring button (12) is arranged in the base, external special fixture fixing hole belts (10) arranged on two sides of the objective table glass (13) are suitable for clamping parts inconvenient to put in measurement through special fixture fixtures, and four knob screws (9) are responsible for fixing and adjusting levelness of the objective table glass (13).
The lifting adjusting part comprises a lifting vertical arm (21) arranged on the bearing plate (20), a vertical arm knob (7) for controlling the lifting vertical arm (21) to move, a lens bracket (8) arranged on the lifting vertical arm (21) and components arranged on the lens bracket (8), wherein the components comprise a lens cover (16) and a displacement sensor bracket (3). The displacement sensor (5) is arranged on the displacement sensor bracket (3). The lifting vertical arm shell (1) wraps the lifting vertical arm (21), six rows of annular light support fixing holes (2) which are symmetrical on two sides are arranged on the lifting vertical arm shell (1) and are used for fixing the annular light support (4) at a proper position, an annular light clamp (15) is arranged on the annular light support (4), and annular light (14) is fixed on the annular light clamp (15). The industrial camera (16) is arranged on the lens bracket (8), the lens (18) is arranged on the industrial camera (17), and the industrial camera is covered by the lens cover (16) so as to prevent the structure from being exposed, thereby being convenient for protecting the internal instrument.
In the lifting vertical arm (21), the rotary vertical arm knob (7) drives the gear (25) to drive the rack (26) meshed with the gear, so as to drive the sliding block (24) provided with the rack (26) to move in the vertical direction. When the locking pulling piece (6) is pulled down to a locking direction when the locking pulling piece moves to a proper position, threads on the locking shaft (27) are driven to move inwards, and a locking rubber pad (28) arranged at the tail end of the locking shaft (27) can tightly prop against a rough belt (23) on the rack (26), so that the aim of locking is fulfilled.
The size measuring instrument is used, firstly, an object to be measured is placed on objective table glass (13), then an industrial camera (17) and a lens (18) reach proper positions by adjusting a vertical arm knob (7), a locking shifting piece (6) is shifted down in a locking direction, then a key measuring button (12) is pressed down when an annular light support (4) is adjusted to a proper position, and the corresponding size of a part to be measured can be displayed on an external contact screen.
The specific processing of the automatic focusing module is as follows:
firstly judging whether a focusing start button is clicked, if so, judging whether focusing region editing is performed on a real-time display diagram, if so, transmitting an X coordinate and a Y coordinate of the left upper corner of an editing rectangular frame, the length, the width, a real-time image and an edge detection threshold value to an algorithm, and executing a region definition calculation flow; obtaining a definition evaluation value of the region according to a region definition calculation flow, and displaying the definition evaluation value on an interface in real time; displaying according to the focusing standard proportion value and the focusing lower limit proportion value, if the definition evaluation value obtained in real time is larger than the focusing standard proportion value, displaying the proportion value by the progress bar, displaying green color, and indicating that the definition of the current area is good, and not needing to adjust the height of the camera; if the definition evaluation value is smaller than the focusing standard proportion value and larger than the focusing lower limit proportion value, the progress bar displays yellow, which indicates that the definition of the current area is not good, and the height of the camera can be finely adjusted; if the definition evaluation value is smaller than the focusing lower limit proportion value, the progress bar displays red, which indicates that the definition of the current area is poor, and the camera height adjustment is needed to adjust the image definition, otherwise, the accurate size measurement cannot be performed;
The regional definition calculation flow execution process judges whether a zone bit of the definition calculation flow stopping process is set in real time, if so, the flow execution is stopped, and the user operation is returned to be judged;
namely, after the focusing start button is clicked, the definition calculation flow is started to be executed, at the moment, the focusing start button is changed into the focusing stop button, at the moment, the focusing stop button can be clicked by a user, so that a definition calculation flow stopping mark is set;
judging whether the user displays an upper frame selection focusing area on the real-time graph, if so, storing the left upper corner coordinates of the frame selection area and the length and width of the frame selection area; judging whether a user clicks a 'acquire height' button, if so, acquiring camera height information by controlling a height sensor, and acquiring camera calibration parameters according to the camera height information by looking up a table to be used as parameters of real-time dimension measurement; and judging whether the user clicks a 'measurement return' button, if so, closing the auxiliary focusing interface, and returning to the real-time measurement interface.
Embodiment two:
as shown in fig. 1, the dimension measuring instrument system based on the multi-template matching and auto-focusing functions, in which the dimension measuring instrument includes a lift adjusting portion, a supporting portion, and the lift adjusting portion is provided on the supporting portion, as shown in fig. 23 to 25.
The supporting part comprises a bearing plate (20) arranged on a base (11), a light source (19) arranged in the bearing plate (20), a key measuring button (12) is arranged in the base, external special fixture fixing hole belts (10) arranged on two sides of the objective table glass (13) are suitable for clamping parts inconvenient to put in measurement through special fixture fixtures, and four knob screws (9) are responsible for fixing and adjusting levelness of the objective table glass (13).
The lifting adjusting part comprises a lifting vertical arm (21) arranged on the bearing plate (20), a vertical arm knob (7) for controlling the lifting vertical arm (21) to move, a lens bracket (8) arranged on the lifting vertical arm (21) and components arranged on the lens bracket (8), wherein the components comprise a lens cover (16) and a displacement sensor bracket (3). The displacement sensor (5) is arranged on the displacement sensor bracket (3). The lifting vertical arm shell (1) wraps the lifting vertical arm (21), six rows of annular light support fixing holes (2) which are symmetrical on two sides are arranged on the lifting vertical arm shell (1) and are used for fixing the annular light support (4) at a proper position, an annular light clamp (15) is arranged on the annular light support (4), and annular light (14) is fixed on the annular light clamp (15). The industrial camera (16) is arranged on the lens bracket (8), the lens (18) is arranged on the industrial camera (17), and the industrial camera is covered by the lens cover (16) so as to prevent the structure from being exposed, thereby being convenient for protecting the internal instrument.
In the lifting vertical arm (21), the rotary vertical arm knob (7) drives the gear (25) to drive the rack (26) meshed with the gear, so as to drive the sliding block (24) provided with the rack (26) to move in the vertical direction. When the locking pulling piece (6) is pulled down to a locking direction when the locking pulling piece moves to a proper position, threads on the locking shaft (27) are driven to move inwards, and a locking rubber pad (28) arranged at the tail end of the locking shaft (27) can tightly prop against a rough belt (23) on the rack (26), so that the aim of locking is fulfilled.
The size measuring instrument is used, firstly, an object to be measured is placed on objective table glass (13), then an industrial camera (17) and a lens (18) reach proper positions by adjusting a vertical arm knob (7), a locking shifting piece (6) is shifted down in a locking direction, then a key measuring button (12) is pressed down when an annular light support (4) is adjusted to a proper position, and the corresponding size of a part to be measured can be displayed on an external contact screen.
The specific operation steps of the dimension measuring instrument system based on the automatic focusing function are as follows:
1) Initializing: after the measuring instrument is started and the control software is opened, the operation software enters a startup initialization interface, and startup initialization is carried out in the interface; the startup initialization process mainly carries out detection of relevant software and hardware of the system and reading and setting of parameters, and the relevant software and hardware of the system comprise: the parameters mainly comprise camera configuration parameters, serial port configuration parameters, rights management parameters, dimension measurement related parameters and the like. Processing the detection result information of the related software and hardware, and judging whether the software and hardware abnormality exists in which the system cannot normally operate; if yes, waiting for the user to confirm the abnormal information and exiting the system; if not, entering a template selection interface.
2) Template selection interface processing step: when entering a template selection interface, defaulting to select or choosing a template selected by a user before exiting the system last time (selecting a template which represents the need of user selection and is selected as template information required to be checked by the user, typically, a template selected by the user before exiting the system last time but can be chosen again), wherein the user can select one or more workpiece templates required to be measured in the interface, if a template selection operation is performed, a measurement result graph and measurement result information of the template are displayed in the interface, the selection operation has and only one template can be selected, and after the user finishes selection, the user clicks a 'enter measurement' button to enter the next interface or clicks a 'exit system' button to exit the system; at this time, if the user selects an empty template, an administrator password input dialog box is popped up, and the user enters a template operation interface after inputting a correct administrator password; if the user selects other templates, the real-time measurement interface is entered.
3) And (3) measuring in real time: performing real-time measurement of the size of the workpiece, system setting, temporary manufacturing and operation of exiting the system in a real-time measurement interface;
clicking a button for starting measurement in a real-time measurement interface to enter a real-time dimension measurement flow of the measured workpiece; judging whether measurement conditions are met or not, judging whether the number of the checked templates accords with constraint conditions or not and whether camera calibration result data exist or not respectively, judging whether an image is acquired or not if the number of the checked templates accords with the measurement conditions, otherwise, popping up an information prompt box prompt according to the unsatisfied measurement conditions, waiting for a user to confirm information, returning, and waiting for the user to operate; if the image is acquired, judging continuous measurement and one-key measurement versions; if the image is in the one-key measurement version, entering a one-key measurement version single image real-time dimension measurement process, judging whether the number of processed images reaches a set value after finishing the process, if so, performing a plurality of image data processing processes, finishing the measurement after finishing the process, waiting for user operation, and if not, returning to judge whether the images are acquired; if the image is the continuous measurement version, entering a real-time dimension measurement process of a single image of the continuous measurement version, entering a data processing process of a plurality of images of the continuous measurement version after the completion of the real-time dimension measurement process, entering a next cycle after the completion of the data processing process, and judging whether the images are acquired or not.
In the real-time dimension measurement process, whether the user clicks a 'stop measurement' button is judged in real time, if yes, the measurement is ended, the user operation is waited for in a return mode, and otherwise, the real-time dimension measurement process is continuously executed.
After clicking the system setting button, the user pops up an administrator password input box, if the user inputs the correct management password, the user enters a system setting interface, otherwise, the user is prompted to input the password incorrectly, and the user can close the administrator password input box or re-input the password in the administrator password input box; clicking different buttons in the system setting interface can perform operation of corresponding functions, wherein the operation buttons specifically comprise: parameter configuration, template operation, template calibration, auxiliary focusing, authority management and return;
after clicking the 'parameter configuration' button, the system opens the parameter configuration interface, runs the parameter configuration module in the parameter configuration interface, and meanwhile judges whether the user clicks the 'return' button, if so, the system enters a parameter saving flow, closes the parameter configuration interface after finishing, and returns to the system setting interface;
after clicking the 'template operation' button, the system opens the template operation interface, operates the template operation module in the template operation interface, and simultaneously judges whether the user clicks the 'return' button, if so, closes the template operation interface, and returns to the system setting interface;
Clicking a 'template calibration' button, entering a template calibration interface, running a template calibration module in the template calibration interface, judging whether a user clicks a 'return' button, closing the template calibration interface if yes, and returning to a system setting interface;
clicking an auxiliary focusing button to enter an auxiliary focusing interface, running an automatic focusing module in the auxiliary focusing interface, judging whether a user clicks a return button, closing the auxiliary focusing interface if yes, and returning to a system setting interface;
clicking a right management button to enter a right management interface, running a right management module in the right management interface, judging whether a user clicks a return button, closing the right management interface if yes, and returning to a system setting interface;
clicking temporary production on the real-time measurement interface, popping up an administrator password input box after triggering, opening a template task editing interface if a user inputs a correct administrator password, otherwise prompting the user that the password is input incorrectly, and closing the administrator password input box or re-inputting the password in the administrator password input box by the user; carrying out a temporary template making process in the template task editing interface, judging whether a user clicks a return button, if so, closing the template task editing interface after generating a temporary template, and returning to the real-time measurement interface;
After the system is exited, a system exit dialog box is popped up for confirmation, if the user selects to confirm, the system is exited, and if the user does not select to confirm, the system exit dialog box is closed.
As shown in fig. 2, the initialization steps are specifically as follows:
1.1 Simultaneously starting a database operation flow, a camera connection operation flow and a serial port to IO module connection operation flow; judging whether the database and the camera are connected successfully according to the operation result; if the connection is unsuccessful, displaying a 'system exit' button, and waiting for a user to click the 'system exit' button and then exiting the system; because the database stores the camera configuration parameters, the template information and the measurement result information, the method can be continued only when the database and the camera are connected successfully; otherwise, overhauling, and connecting the database and the camera successfully; and after the database and the camera can be successfully connected, the next flow can be performed.
1.2 If the database and the camera are connected successfully, judging whether the serial port to IO module is connected successfully or not; if the connection is unsuccessful, buttons of entering the system and exiting the system are displayed, and the user waits for button operation; if the connection is successful, entering a light source detection module; if the user clicks the 'enter system' button, judging whether the current version number is a one-key measurement version or a continuous measurement version, entering a one-key measurement function if the current version number is the one-key measurement version, and entering the continuous measurement version if the current version number is the continuous measurement version; if the user clicks the 'exit system' button, the system is exited;
1.3 The light source detection module judges whether the annular light source and the backlight source can work normally or not; after the execution of the light source detection flow is finished, judging whether the light sources are normal, displaying buttons of entering the system and exiting the system if the light sources which cannot normally work exist, waiting for a user to perform button operation, and selecting corresponding measurement functions according to the current version number if the light sources can normally work; if the user clicks the 'enter system' button, selecting a corresponding measurement function according to the current version number; if the user clicks the "exit system" button, the system is exited.
The database comprises a camera configuration parameter, an automatic exposure adjustment parameter, a camera calibration configuration parameter, camera calibration result data, a camera automatic focusing parameter, a user permission password, a version number, a data processing parameter, template information and real-time measurement result data; the database establishes a corresponding data table according to the stored data, wherein a template parameter total table and a template mask information table are established according to the template information, and the data table and the stored data are as follows:
(1) Camera configuration parameters table cameraconfigurator parameters table: exposure, acquisition frame rate, processing frame rate, and pixel binning.
(2) Frame rate adaptation and frame skip parameter table framerateappteandjumppparamastertable: the number of pictures, the lower limit of standard deviation processing data, the standard deviation coefficient, the upper limit of frame rate self-adaptive proportion and the number of frame-skipping pictures.
(3) Automatic exposure adjustment parameter table autoexposurerelation parameter table: the automatic exposure function selects, exposes and adjusts the goal proportional value, goal proportional value upper limit, goal proportional value lower limit, exposure quantity adjusts the scale.
(4) Camera calibration configuration parameter table cameracaliationparametertable: the number of transverse lattices, the number of longitudinal lattices, and the unit length.
(5) Camera calibration result data table CameraCalibrationResultParameterTable: magnification, camera distortion parameters, camera internal parameters, and height values.
(6) Auto focus parameter table autofocusing parameter table: an edge detection threshold, a focus standard ratio value, and a focus lower limit ratio value.
(7) Serial port configuration parameter table serialport configuration parameter table: port number, baud rate.
(8) User rights table Authority ParameterTable: administrator password, technician password, and system version number.
(9) The data processing parameter table dataprocessarametertable: the upper limit of the number of the processing templates, the number of the processed pictures, the standard deviation coefficient and the lower limit of the number of the standard deviation processed data.
(10) Template information summary template message total table: template name, measurement template selection, display template selection, template source map, measurement result map, template source map measurement information and template modification time.
(11) Template mask information table template mask message table: template name, mask number, automatic focusing selection, mask information, mask diagram, measurement results and measurement values corresponding to each mask.
(12) Measurement results data table realtemeasureresulttable: template name, measurement value, and measurement date and time.
As shown in fig. 3, the database operation module specifically performs the following steps:
firstly, executing a database connection function according to a host address, a user name and a password of a database server, wherein a database connection result comprises a successful database connection, an abnormal database connection and a database connection failure; judging whether the database is successfully connected, if so, executing whether a command exists in the database according to the name of the database; if the database connection is abnormal or fails, writing the database connection result into a log and returning the connection result;
when executing corresponding commands of the database, if the database exists, sequentially executing whether commands exist in the data table according to the names of the data table; if the corresponding data table exists, executing a read data command, and setting the value of the corresponding variable according to the return data of the read command; if the corresponding data table does not exist, creating the data table, writing default parameter operation into the data table, setting related dimension measurement parameters as default values, and finally setting the corresponding data table to be not exist in the database return information, wherein the camera calibration result data table, the template information table and the template mask information table are traversed, if the corresponding data table does not exist, the default parameter operation is not required to be written, and the measurement result data table is not required to be traversed; if the database does not exist, executing a database creation command to create the database, creating each parameter table, writing default parameters, setting related dimension measurement parameters to be default values, and setting the database operation result to be that the database does not exist;
And finally, displaying result information in the interface according to the database operation result, and ending the database operation module.
The workpiece size measurement operation of the system is dependent on the acquired images, and the images are acquired through the industrial camera, so that the normal connection of the camera is ensured when the system is started. The camera connection in the software and hardware specifically comprises the following steps:
firstly, searching all Ethernet cameras and USB cameras which are connected in a system; if the camera is not detected, setting the camera connection operation result as the camera is not detected, and writing the detection result into a log; if 1 camera is detected, executing a camera opening operation; if 2 or more than 2 cameras are detected, displaying the detected camera names on an interface to wait for user selection, and performing camera opening operation after the user selects the cameras;
after the camera operation is started, firstly creating a device object, then creating a device for the device object operation according to the detected camera information, and finally executing the camera operation on the device, and returning corresponding abnormal information and ending the camera operation if the abnormality occurs in the camera opening process;
if the camera is successfully opened, setting a mode of collecting images by the camera as a trigger mode, setting a camera callback function, simultaneously reading the size of the collected images by the camera as a judging basis for judging whether a template is available or not, and executing a corresponding camera configuration function according to camera configuration parameters, specifically setting the frame rate of collecting images by the camera according to a collected frame rate variable, setting a pixel merging value of the camera according to a pixel merging variable, and setting the exposure of the camera according to an exposure variable;
And finally, displaying result information in the interface according to the camera connection result, and ending the confirmation of the camera connection.
The system outputs IO signals through the serial port-to-IO module to control the on-off of the annular light source and the backlight source, and the lighting of the light source is a necessary condition for the dimension measurement of the workpiece, so that whether the serial port-to-IO module is normally connected or not is detected during starting. The serial port-to-IO module connection comprises the following specific steps:
1.1.1 Opening the serial port: creating a serial port object according to the serial port number variable and the serial port baud rate variable; judging whether the serial port is opened or not for the serial port object, if so, returning serial port opened information, and ending serial port opening operation; if the serial port is not opened, adding a serial port receiving callback function for serial port data receiving, executing a serial port opening function to open the serial port, returning serial port opening success information, and ending serial port opening operation;
1.1.2 Executing a serial port initialization step: step 1.1.1), after the serial port-to-IO module initialization operation is executed, the serial port sends a command for reading the address of the serial port-to-IO module, and the serial port-to-IO module waits for returning data to the serial port; if the serial port receives the returned data and the data is the data specified by the communication protocol, the serial port-to-IO module is successfully connected; if the returned data received by the serial port is incorrect or the data is not received, the serial port-to-IO module fails to connect;
1.1.3 Serial port feedback step: and when the serial port-to-IO module is successfully connected, the serial port-to-IO module sends an IO signal to the serial port-to-IO module to turn off the annular light source and the backlight source, and the serial port-to-IO module connecting module is ended after the result information is displayed in the interface according to the connection result of the serial port-to-IO module.
When the camera connection and the serial port-to-IO module are normally connected, the camera and the serial port-to-IO module can be controlled to perform light source detection, as shown in FIG. 4, the specific processing of the light source detection is as follows:
1.2.1 Light source detection data acquisition step: firstly, turning on an annular light source through a serial port-IO module, delaying for 200mS to stabilize the illumination of the annular light source, and then acquiring 1 image through a soft triggering mode by controlling a camera, and marking as bitmap1; turning off the annular light source through the serial port-IO module, delaying for 200mS, and controlling the camera to acquire 1 image under the illumination-free condition, and marking as bitmap2; the backlight source is turned on through the serial port to IO module, the time delay is 200mS, the illumination of the backlight source is stable, and then 1 image is collected through the control camera and recorded as bitmap3;
1.2.2 Light source detection data processing step: calculating the image gray average value of the bitmap1 and the bitmap2 by calling a gray average value algorithm, and then calculating the ratio of the gray average values of the bitmap1 and the bitmap2, and marking as ratio1; if ratio1 is larger than the set threshold, setting the detection result of the annular light source as normal, otherwise setting the detection result of the annular light source as abnormal; calculating the image gray average value of the bitmap3 by calling a gray average value algorithm, and then calculating the ratio of the gray average values of the bitmap3 and the bitmap2, and marking the ratio as ratio2; if ratio2 is larger than the set threshold, setting the backlight source detection result as normal backlight source, otherwise setting the backlight source detection result as abnormal backlight source;
1.2.3 Light source detection data feedback step: and displaying the light source detection result in the interface, and ending the light source detection.
And finishing the startup initialization flow, and if the specified abnormal condition does not exist, entering a template selection interface by the system. The template selection procedure will be performed at the template selection interface. The interface of template selection is shown in fig. 5, and the specific implementation steps are shown in fig. 6:
2.1 Interface display step: entering a template selection interface, and displaying in the interface according to the data read by the database, wherein the following contents are specifically displayed:
2.1.1 Taking out the template source diagram, the template name, the measurement template selection and the display template selection in the template information, displaying the template source diagram as a template icon in a display list on the left side of the interface, displaying the template name below the icon, performing a checking operation on a checking frame in front of the measurement template selection template icon, performing a checking operation on the display template selection template icon, and displaying the template selection only to select one template; the selecting frame can be selected more and used as a multi-template selection basis during multi-template measurement; the operation of selecting the template icons can only select one icon, and is used for checking the measurement result and the modification time information of the currently selected template; the display list is provided with a rolling pull-down operation, and when the display list is full of the template number, the rolling pull-down operation can be carried out for selecting other templates; an empty template is always displayed at the end of the display list, and the template icon is a blank picture and is used for directly entering a template making interface to perform related operation;
2.1.2 Acquiring a measurement result graph of the template and measurement information of a template source graph according to the template name of the selected template, and displaying the measurement result graph of the selected template and measurement result data of the template source graph on the right side of the interface; the user can judge whether the template mask manufacturing meets the measurement requirement according to the measurement result of the template;
2.1.3 Selecting to display the name of the currently checked template at the lower left of the interface according to the measurement template in the template information, and selecting to read the template modification time of the display template according to the display template in the template information and displaying the template modification time at the lower left of the interface;
2.1.4 Display the system version number at the upper right of the interface;
2.2 User operation judgment step): judging whether a user selects a template, if so, displaying the template name of the currently selected template at the lower left of the interface, and if so, automatically canceling other selected templates; judging whether the user cancels the template to be checked, and canceling the template name of the template to be displayed in the lower left display of the interface; judging whether information modification is input in a search template input box, if so, entering a template search flow; judging whether a user switches the selected template, if so, acquiring a corresponding measurement result graph and measurement result data according to the template name of the selected template, displaying on the right side of the interface, and simultaneously displaying the modification time of the currently selected template on the lower left side of the interface;
2.3 A) entering a measurement step: judging whether a user clicks a 'enter measurement' button, if so, judging whether the user selects an empty template, and if so, popping up a 'enter template making' confirmation frame; if the user clicks the confirm box confirm button, the operator password input box is popped up, and if the user clicks the confirm box cancel button, the operation of the user on the interface is judged again; if the password input in the 'operator password' input box is the correct operator password, storing the currently checked template and the selected template into a database, wherein the currently checked template is an empty template, and entering a template making interface after the camera drawing is started;
2.4 Blank template step: if the user does not select an empty template, judging whether the number of the checked templates accords with the constraint, wherein the constraint condition is that the number of the checked templates is more than 0 and less than the upper limit variable value of the number of the processed templates, if the number of the checked templates accords with the constraint, traversing all the templates according to the template names of the checked templates, and acquiring template information of the checked templates, wherein the template information comprises a template source diagram, a measurement result diagram, measurement result data and mask information; judging whether the information of the checked templates is complete according to the acquired information, if so, judging whether the template source images of the checked templates are the same as the real-time images acquired by the cameras, if so, storing the currently checked templates and the checked templates into a database, starting the cameras to acquire the images, and entering a template manufacturing interface;
If the number of the checked templates does not accord with the constraint, popping up an abnormal prompting frame of the number of the checked templates, displaying the current number of the checked templates and constraint conditions in the prompting frame, closing the prompting frame after the user clicks a button of the prompting frame for determining, and re-judging the operation of the user on the interface; if the template information is incomplete, popping up an abnormal prompt box for checking the template information, prompting the incomplete template name and the missing information condition in the prompt box, closing the prompt box after the user clicks a button of the prompt box, and re-judging the operation of the user on the interface; if the template source diagram of the checked template is different from the real-time diagram in size, a template name of the template with the size different from the real-time diagram is prompted in a prompt frame by popping up a prompt frame with the size abnormal to the checked template, the prompt frame is closed after a user clicks a button of the prompt frame to determine, and the operation of the user on the interface is re-judged;
2.5 Exit cancel step): judging whether a user clicks a button for exiting the system, if the user clicks the button, popping up a confirmation frame for confirming exiting the system, and if the user clicks a confirmation button in the confirmation frame, closing the camera and exiting the system; if the user clicks the cancel button, the operation of the user on the interface is judged again after the confirmation frame is closed.
After entering the template selection interface, the user can enter a template name in the template search input box to perform quick search of the specified template. As shown in fig. 7, the specific execution steps of the template search are as follows:
2.2.1 Firstly judging whether the input content of the template search input box is modified, if so, firstly deleting all the displayed templates in the template display list, and then matching the template names according to the input content, and if not, ending the template search flow; the template name matching process compares the input content with all template names manufactured by the current system, and if the input content is identical to the substring of the template name from the first character or is identical to the character string of the template name, the input content is considered to be matched with the template name, the template names manufactured in the system cannot be renamed, and case letters are distinguished;
2.2.2 If the template name is matched, displaying the matched template in a display list, and displaying an empty template for selecting the empty template at the end of the display list; if the template name is not matched, ending the template searching process;
2.2.3 After the template name is matched, traversing the checked template name and the matched template name in a double-loop mode, and judging whether the identical template name exists or not; if the same name template exists, the same name template is checked in the current displayed template list, and if the same name template does not exist, the checked template name is matched;
2.2.4 The template name matching process traverses the template names matched by the search template in a single-cycle mode, compares the template names with the selected template names, judges whether identical template names exist, performs template selection operation in a currently displayed template list if the identical template names exist, and ends template search if the identical template names do not exist; the template selection and the template selection are the template selected by the user before the template search, wherein only one template is selected, and the template selection can be performed in a plurality of modes.
The real-time measurement module comprises the following steps of current measurement workpiece acquisition picture display, measurement result data display and template selection frame area interface display:
when the 'start measurement' button is not pressed, the workpiece image acquired by the camera in real time and the template source image of the currently selected template are overlapped according to a certain proportion and then displayed, when the 'start measurement' button is pressed to carry out real-time measurement on the workpiece to be measured, the measurement result image is displayed, and the focusing definition and the name of the currently matched template are displayed;
in the real-time measurement process, carrying out measurement result data display on the right side of the interface according to the measurement result of the current workpiece, and respectively displaying a measurement number and a measurement result, wherein the measurement number corresponds to the number displayed on the measurement result graph one by one; if the workpiece has the unmeasured dimension to be measured, displaying the number of the unmeasured dimension, and displaying the unmeasured dimension in a result column;
Displaying a template selection frame in the middle position below the interface, wherein a user can select a template in the selection frame when real-time measurement is not performed; all templates manufactured by the system are displayed in the selection frame, but the blank templates are not contained, a user can select the templates of the workpieces to be detected through the selection frame before the template icons are checked in the selection frame, the template selecting operation can be performed by clicking the template icons, but the template selecting operation can only be performed in the checked templates, and the template source diagram of the selected template is displayed in the picture display area after being used for being overlapped with the real-time diagram. And when the real-time measurement interface is entered, performing template checking operation according to the checked template variables, and simultaneously, checking the template to default to the template corresponding to the first variable in the checked template array variables. As shown in fig. 8, the interface includes four buttons of "system setup", "provisional production", "start measurement/stop measurement", and "exit system", and different operations are performed by clicking different buttons.
Specifically, the implementation mode is as follows:
1. the measured measurement type is marked by drawing red lines and green letters M in the measurement result map with serial numbers, for example, a circle M1 shown in fig. 21, based on the measurement data.
2. For the type of measurement which is not detected, the corresponding mask image is processed according to the gray value of the pixel point, wherein the mask image is a gray image, and the gray value of the pixel point is 255 or 0. The two images are processed as follows: and the gray values of the pixels corresponding to the positions of the two mask images are respectively processed according to or to obtain a result image, if the gray values are 255 and 255, the gray value of the pixel corresponding to the result image is 255, and similarly, if 255 and 0, the gray value of the pixel corresponding to the positions of the result image is 255, and if 0 and 0, the gray value of the pixel corresponding to the positions of the result image is 0.
3. If only one mask image is not detected, the mask image is the final result image; if there are two unmeasured mask patterns, they are pressed or processed to obtain the final result pattern, if there are more than two patterns, the first two patterns are pressed or processed in sequence to obtain the intermediate result pattern 1, then the intermediate result pattern 1 and the third unmeasured mask pattern are pressed or processed to obtain the intermediate result pattern 2, then the intermediate result pattern 2 and the fourth unmeasured mask pattern are pressed or processed to obtain the intermediate result pattern 3, and so on to obtain the final result pattern.
4. And (3) traversing the final result diagram and the measurement result diagram obtained in the previous step in a double-loop way, wherein for the pixel point with the gray value of 255 in the final result diagram, the corresponding pixel point BGR value of the corresponding measurement result diagram is set to be different from the measured mark color, and in the embodiment, the pixel point BGR value is set to be B= 0,G =255, and R=255, namely yellow is displayed, for example, a circle M2 in fig. 21.
As shown in fig. 9, in the parameter setting interface, the user can make settings of these parameters: camera configuration parameters, auto-exposure adjustment parameters, camera calibration configuration parameters, serial configuration parameters, data processing parameters, and auto-focus parameters.
The camera configuration parameters comprise exposure, acquisition frame rate, processing frame rate and pixel combination;
the exposure represents the exposure of the camera, the exposure of the camera can be set through the variable, the variable is integer data, the value range is 100-50000, and the unit is uS; the acquisition frame rate represents the frame rate of an image acquired by a camera, the variable is used for setting the image acquisition frame rate when real-time measurement is not performed, the variable is floating point data, the value range is 0.1-20, and the unit is Hz; the processing frame rate represents the frame rate of the image acquired by the camera, the variable is used for setting the image acquisition frame rate when real-time measurement is carried out, the variable is floating point data, the value range is 0.1-20, and the unit is Hz; the pixel combination represents the proportional relation between the image and the maximum size of the image during the acquisition, the resolution of the acquired image can be modified through the setting of the variable, the variable is integer data, and the value range is 1-4.
The frame rate self-adaption and frame skipping parameters comprise the number of images, a standard deviation processing data lower limit, a standard deviation coefficient, a frame rate self-adaption proportion upper limit and the number of frame skipping images;
The image number represents the image number counted by the frame rate self-adaptive function, the frame rate self-adaptive function carries out processing time statistics on the appointed continuous images, the variable is used for setting the processed image number, the variable is integer data, and the value range is 1-10; the lower limit of standard deviation processing data represents the lower limit of the number of data for carrying out standard deviation processing on continuous image processing time, when the number of images is set to be smaller than the variable, standard deviation eliminating processing is not carried out, the variable is integer data, and the value range is 1-10; the standard deviation coefficient represents a data rejection coefficient when standard deviation data processing is carried out, the difference value of the data mean value and the coefficient multiplied by the standard deviation is taken as a minimum value, the sum of the data mean value and the coefficient multiplied by the standard deviation is taken as a maximum value, the data between the maximum value and the minimum value is taken as reserved data, the variable is floating point data, and the value range is 0.1-5; the upper limit of the frame rate self-adaptive proportion represents the upper limit of the ratio of the image processing time average value to the image acquisition time, when the ratio exceeds (1+the upper limit of the frame rate self-adaptive proportion/100), the frame rate is adjusted according to the image processing time average value, the variable is integer data, and the value range is 1-500; the frame skipping image number represents the image number setting of frame skipping processing, when the image processing time exceeds the acquired image number set by the variable, no algorithm processing is carried out on the newly acquired image, the variable is integer data, and the value range is 1-10;
The automatic exposure adjustment parameters comprise automatic exposure selection, exposure adjustment target gray value, target gray value proportion lower limit, target gray value proportion upper limit and exposure adjustment scale;
the automatic exposure selection indicates whether an automatic exposure adjustment function is called, and the automatic exposure selection is set in a button selection form; the exposure adjustment target gray level value represents the target gray level value of automatic exposure adjustment, the variable is integer data, and the value range is 0-255; the lower limit of the target gray value proportion represents the lower limit of the proportion of the automatic exposure adjustment target gray value, the lower limit of the target gray value for adjusting exposure can be calculated according to the variable and the exposure adjustment gray value, the variable is integer data, and the value range is 0-20; the upper limit of the proportion of the target gray value represents the upper limit of the proportion of the automatic exposure adjustment target gray value, the upper limit of the target gray value for adjusting exposure can be calculated according to the variable and the exposure adjustment gray value, the variable is integer data, and the value range is 0-20; the automatic exposure function of the exposure adjustment scale adjusts the size of one exposure, when the exposure is too large, the current exposure minus the variable is the adjusted exposure, when the exposure is too small, the current exposure plus the variable is the adjusted exposure, the variable is integer data, the value range is 1-500, and the unit is uS;
Specifically, as shown in fig. 22, the automatic exposure amount adjustment flow is as follows:
flag1 is 1 to decrease exposure, flag1 is 2 to increase exposure; flag2 is 1 to indicate the exposure decreasing process in this cycle, flag2 is 2 to indicate the exposure increasing process in this cycle; initializing: flag1=1; flag2=0;
2. extracting the corner information of a calibration plate of a certain frame of calibration image;
3. further extracting sub-pixel corner information;
4. screening sub-pixel angular points closest to a field of view;
5. respectively solving the distances from the pixel to four nearest sub-pixel corner points around the pixel;
6. the four distances are compared in any pair;
7. whether the absolute value of the difference is smaller than a set value;
8. if yes, the exposure value is saved, and whether Flag1 is equal to 1 is judged; if yes, reducing the exposure of the camera, and performing jump to step 2, wherein flag2=1; if not, increasing the exposure and flag2=2, and jumping to the step 2 for execution;
9. if not, further judging whether the threshold value is smaller than the set threshold value for the first time; if not, counting the saved exposure to obtain a proper range section (taking the saved minimum exposure value as a section lower limit value and taking the saved maximum exposure value as a section upper limit value); if so, further judging whether Flag2 is equal to 1; if the camera exposure is increased from the set value, flag1=2, and jumping to the step 2 for execution; if not, the camera exposure is reduced from the set value, flag1=1, and the process goes to step 2.
The camera calibration configuration parameters comprise a transverse grid number, a longitudinal grid number and a unit length;
setting the transverse grid number of the checkerboard when the camera calibration is carried out by using the checkerboard, wherein the variable is integer data, and the value range is 1-50; setting the longitudinal grid number of the checkerboard when the camera calibration is carried out by using the checkerboard, wherein the variable is integer data, and the value range is 1-50; each checkerboard length setting when camera calibration is carried out by using the checkerboard in unit length, wherein the variable is floating point type data, the value range is 0.1-50, and the unit is mm;
the automatic focusing parameters comprise an edge detection threshold value, a focusing standard proportion value and a focusing lower limit proportion value;
the edge detection threshold value represents the setting of an edge gray level threshold value when the focusing definition judgment is carried out, the variable is integer data, and the value range is 0-255; when the focusing standard proportion value represents that the focusing definition is judged, the focusing definition is judged to be the basis of the focusing definition, and when the (white area average gray value/(white area average gray value+black area average gray value) 100) is larger than the variable, the focusing definition is considered to be the focusing definition, and the variable is floating point data, and the value range is 0-99; the lower limit proportion value of focusing represents that when the definition of focusing is judged, the basis of the definition of focusing is judged, when the (white area average gray value/(white area average gray value+black area average gray value) 100) is smaller than the variable, the focusing is considered to be unclear, the variable is floating point data, the value range is 0-99, and the value of the variable is required to be smaller than the standard proportion value of focusing;
The serial port configuration parameters comprise port numbers and baud rates;
the port number represents a serial port number connected with a serial port-to-IO module, and the variable is a character string variable; the baud rate represents the serial port bit rate of a serial port-to-IO module, the variable is integer data, the value range is 2400-115200, and the unit is bit/S;
the data processing parameters comprise an upper limit of the number of processing templates, the number of processed pictures, a standard deviation coefficient and a lower limit of the number of standard deviation processed data;
the upper limit of the processing template number represents the most selected matching template number in the measurement of the workpiece size, the variable is integer data, and the value range is 1-10; the number of processed pictures represents the number of pictures for calculating an average measured value in the real-time dimension measurement process of the workpiece, when the number of collected and processed single pictures reaches the set value, the dimension average value calculation can be carried out, the variable is an integer variable, and the value range is 1-10; the standard deviation coefficient represents a data rejection coefficient when standard deviation data processing is carried out on the measurement result data of the specified drawing size, the variable is floating point data, and the value range is 0.1-5; the lower limit of the number of the standard deviation processing data represents the lower limit of the number of the data when the standard deviation processing is carried out on the dimension measurement result data of the specified sheet, the variable is integer data, and the value range is 1-10;
The user authority management comprises operator, manager and technician authority setting;
the authority of the operator is to perform the checking and automatic focusing operation of the template, the password modifying operation is performed in the parameter setting interface, and if the operator button is clicked, the password modifying operation of the operator is performed;
the authority of the administrator is to perform parameter setting, template modification, deletion, new construction and template calibration operations, wherein the parameter setting interface is used for password modification operation, and if an administrator button is clicked, the administrator password modification operation is performed;
the technician's authority is to perform one-key measurement and continuous measurement version switching, the parameter setting interface is used for password modification and version switching operation, and if the "technician" button is clicked, the technician's password modification and version selection operation is performed;
as shown in fig. 10, the specific execution parameter configuration at the parameter configuration is as follows:
firstly, all parameters in the parameter configuration interface are stored into temporary storage variables; judging whether the content in each parameter input box is modified, if so, judging whether the input format is correct, and if not, judging whether to click a right management button; if the format is correct, judging whether the input data of the input box accords with the constraint range of the current parameter, if the format is incorrect, popping up a format error prompt box, waiting for a user to click a 'confirm' button, and returning to user operation judgment; if the input data is within the constraint range of the current parameter, modifying the current modification parameter into the input data of the input box, setting all input box states to an inputtable state, and setting all buttons of the interface to an enabling state; if the input data is not in the constraint range of the current parameter, setting an unassociated parameter input box to be in an unassociated state, wherein some parameters of the interface are associated parameters, a focusing standard proportion value and a focusing lower limit proportion value in the automatic focusing parameters are required to be smaller than the focusing standard proportion value, simultaneously setting all buttons in the interface to be in a disabled state, popping up a variable modification abnormal box, displaying the current input data and the constraint range in the abnormal box, waiting for a user to click a 'confirm' button, and returning to user operation judgment;
Then if the user clicks the 'rights management' button, entering a rights management flow, and returning to user operation judgment after the rights management flow is finished; if the user clicks the return button, judging whether the modified parameters exist or not; if the modified parameter exists, a dialog box for storing the parameter is popped up, if the modified parameter does not exist, the interface is directly closed, and the parameter configuration flow is exited; in a dialogue box for saving parameters, judging whether a user clicks a 'determination' button, if so, saving the modified parameters into a database, if the user clicks a 'cancel' button, reassigning all temporary storage parameters to all parameters in the interface, so that the parameters are consistent with the parameters when entering the interface, and finally; and (5) exiting the parameter configuration.
Clicking the "rights management" button in the parameter setting interface will enter the rights management interface where the rights management process will be executed. The rights management flow mainly performs password modification of an administrator and a technician and switching of user versions. As shown in fig. 11, the specific processing procedure of rights management is as follows:
firstly judging whether to click an 'manager password modification' button, if so, popping up a manager password input box to wait for a user to input a manager password; after the user inputs the administrator password, the administrator password is compared with the background administrator password, if the administrator password is completely consistent with the background administrator password, an administrator password modification input box is popped up to wait for the user to modify the administrator password, if the administrator password is not input correctly, an administrator password input error prompt box is popped up, the prompt box is closed after the user clicks a 'determination' button, and the user operation is returned to judge after the closing; after the administrator password modification input box is opened, a user can input a new password, wait for the user to click a 'determination' button, set the password newly input by the user as the administrator password after clicking the 'determination' button, and write the password into a database for storage; the modification operation of the technician password is the same as the modification operation flow of the administrator password;
Judging whether a user clicks a version switching button, if so, popping up a technician password input box to wait for the user to input a technician password, judging whether to input a correct technician password after the user inputs the technician password, if so, popping up a version selection box which comprises a one-key measurement version selection button and a continuous measurement version selection button and marks a current version, enabling the user to select the version switching button, clicking a determination button in the selection box after finishing the selection, modifying the version setting according to the user selection, and writing the version information into a database after updating the version information;
and finally judging whether to click a return button, if so, closing the rights management interface and ending the rights management.
After clicking a 'template operation' button in the system setting interface, entering a template operation interface, and executing a template operation flow in the interface. In the interface, operations such as newly-built template, modifying template, deleting template, copying template, searching template and the like can be performed, meanwhile, the interface displays all the manufactured templates of the current system in real time, the template of the workpiece to be tested can be selected in the template list through a checkbox, the operation can be selected more, and meanwhile, the measurement result graph and the measurement result information of the template can be displayed through clicking a template icon. As shown in fig. 12, the specific execution of the template operation is as follows:
Firstly judging whether a user clicks a new template button, if so, popping up a new template name input box, and waiting for the user to input the new template name; judging whether a user clicks a 'confirm' button in a newly built template name input box, if so, traversing all template names existing in the system, and judging whether the template name newly input by the user exists; otherwise, judging whether the user clicks a cancel button, if so, closing a new template name input box; if yes, popping up a template name existing information prompt box, waiting for a user to click a 'determination' button and closing the information prompt box, and returning to judge user operation; if the current template does not exist, the camera is opened to acquire the image in real time, a newly-built template confirmation frame is popped up, the image acquired by the camera is displayed in real time in the confirmation frame, and the user confirms the current template through the real-time display of the acquired image; in the new template confirmation frame, if a user clicks a 'confirm' button, recording the name of the template input by the user, closing the new template confirmation frame, closing a camera, and then opening a template task editing interface; if the user clicks a cancel button, closing the new template confirmation frame and closing the camera, and returning to judge the user operation;
Then, carrying out region editing of the size to be measured of the current newly-built template and the newly-manufactured template in a template task editing interface; if the editing of the areas such as the circle, the line, the angle, the arc and any two element combination is performed, the editing of each measurement task returns the mask diagram and the area information.
Judging whether a user clicks a return button or not at a template task editing interface, if so, executing a template information acquisition process to acquire template information, adding the template information of the newly-built template into a template information list which is already manufactured by the system, and storing the template information into a template information summary list and a template mask information list in a database; closing the template task editing interface, returning to the template making interface, and updating the template making interface display information;
the updated information is specifically as follows: firstly, adding a new template into a template display list, and selecting and checking a corresponding template; displaying a measurement result graph of corresponding template information and measurement result information in an interface, wherein the measurement result graph of the template can be subjected to result drawing illustration according to the measurement result of the area to be measured; then, selecting template information in the prompt information, adding the template, and displaying the selected template information as the template name;
Then judging whether the user clicks a 'remap' button or not at the template making interface, and popping up a template remap confirmation frame; judging whether a user clicks a 'determination' button and a 'cancel' button in the confirmation frame, if the user clicks the 'determination' button, closing the template to reproduce the confirmation frame, opening a template task editing interface, transmitting a currently selected template source diagram into the interface to edit a template task, wherein the template task editing and exiting operation is the same as that of a newly-built template, the difference is that the template exists in a template information list which is already produced by the system, the information of the template in the template information list is required to be updated according to template information obtained after reproduction, and the database operation is also updated according to the template information;
judging whether a user clicks a 'delete template' button, if so, popping up a template delete confirmation frame, and waiting for the user to operate a 'confirm' button and a 'cancel' button; if the 'confirm' button is clicked, deleting the template from the template information list which is manufactured by the system, deleting the template information in the database, and updating the template operation interface display information according to the current checked and selected template state; if the cancel button is clicked, closing the template deletion confirmation frame and returning to judge the user operation;
Judging whether the user right clicks in the template display list to select copy, if yes, judging whether the user right clicks in the template display list to select paste, if yes, popping up a copy template confirmation frame, and waiting for the user to perform a 'confirm' button or a 'cancel' button operation; if the 'confirm' button is clicked, the selected template in the template display list is copied, the selected template is named as a copy of the name of the selected template, the template information of the selected template is copied to the copy, the copy template is added to the template information list which is already manufactured by the system, the copy template information is written into the database, the copy template confirmation frame is closed after the copy flag bit is cleared, and meanwhile, the copy template is added to the template display list in the template manufacturing interface; if the cancel button is clicked, closing the copy template confirmation frame after resetting the copy flag bit, and returning to judge the user operation;
judging whether a user selects a template right click to select rename in a template display list, if yes, popping up a template name input frame, waiting for the user to input the template name, judging whether the user performs operation of a confirm button or a cancel button in the input frame, if yes, judging whether the user inputs the template name to exist in a system manufactured template, if yes, closing the template input frame, and returning to judge the user operation; if the template name does not exist, modifying the template name, updating the template name in the template information in the database and the information related to the template in the template making interface, closing a template name input box, if the template name exists, popping up a template name existing information prompt box, waiting for a user to click a 'confirm' button, closing the information prompt box, and returning to judge user operation;
Judging whether a user clicks a return measurement button, if so, traversing all checked templates in the template display list, and judging the integrity of template information and the size of a template source diagram; if the abnormal condition exists, popping up an abnormal information prompt box according to the abnormal condition, closing the abnormal information prompt box after waiting for a user to click a 'confirm' button, and returning to judge the user operation; if no abnormality exists, storing the current checking template and the information of the selected template into the corresponding template of the database, starting the camera to perform drawing, and entering a real-time measurement interface;
judging that the user performs template choosing, template choosing canceling and template searching operations, wherein the processing process is the same as the operation in the template choosing process;
the new template, the deleted template, the remade template, the renamed template, the deleted template and the copied template all need the authority of the administrator to operate, so that an administrator password input box is popped up before corresponding operation is performed, and corresponding operation can be performed only when a correct password is input again; the administrator authority operation is carried out for a plurality of times in the template making interface, and the administrator password is input once, but only the template making interface is re-entered after the real-time measuring interface is returned, the correct administrator password magnetic energy is required to be re-input for the administrator authority operation.
As shown in fig. 13, the specific steps of template information extraction are as follows:
1: carrying out mean value filtering treatment on the template source diagram; the template source image is an image of the front face and the side face of the standard component obtained by the camera;
2: further thresholding; the pixel gradation value thresholding to be larger than the set threshold is set to 0, otherwise, 255;
3: extracting outline points of a standard component in a template source diagram;
4: obtaining the minimum circumcircle of the outer contour to obtain the center coordinates and the radius;
5: extracting the ROI according to the calculated center coordinates and radius; the ROI is a rectangle, the side length of the rectangle is the diameter of the minimum circumscribing circle of the standard component in the template source diagram, the center of the rectangle is the center of the minimum circumscribing circle of the standard component, and the rotation angle of the rectangle is zero; the ROI represents a region of interest.
6: extracting hierarchy profile information from the ROI, wherein the hierarchy profile information comprises outer profile information and inner profile information, and the outer profile and the inner profile meet the parent-child hierarchy relationship; if the outer contour and the inner contour meet the relationship of father and son levels, the outer contour is a father contour, and the inner contour is a son contour;
7: obtaining the minimum circumscribed rectangle of the zero rotation angle of the outline of the rectangle, obtaining the length and width of the rectangle, and judging whether the length or width of the rectangle is larger than a set value;
8: if the length or width of the rectangle is larger than the set value, the standard component is out of limit, and the step 16 is skipped;
9: if the length or width of the rectangle is not larger than the set value, calculating the centroid and the minimum circumscribed rectangle of the outer contour to obtain the center coordinate, the rotation angle, the length, the width and the area of the rectangle; then judging whether an inner contour exists or not;
10: if the inner contour does not exist, jumping to the step 16;
11: if the inner contour exists, judging whether the inner contour has only one effective inner contour or not;
12: if only one effective inner contour exists, the center coordinates, the rotation angle, the length, the width and the area of the center of mass and the minimum circumscribed rectangle are obtained, and the step 16 is skipped;
13: if a plurality of effective inner contours exist, traversing all the effective inner contours, solving the maximum value and the minimum value of the minimum circumscribed rectangular area of the inner contours, and comparing whether the difference value between the maximum value and the minimum value is larger than a set value;
14: if the difference value between the maximum value and the minimum value of the minimum circumscribed rectangular area is larger than the set value, the maximum inner contour and the minimum inner contour are indicated; respectively obtaining the mass centers, the center coordinates of the minimum circumscribed rectangle, the rotation angle, the length, the width and the area of the mass centers, and jumping to the step 16;
15: if the difference value between the maximum value and the minimum value of the minimum circumscribed rectangular area is smaller than or equal to a set value, marking that a standard component has a plurality of effective maximum inner contours, and optionally taking one of the effective maximum inner contours to obtain center coordinates, rotation angles, length and width and area of the center of mass and the minimum circumscribed rectangular area, and jumping to the step 16;
16: and ending the template information extraction flow.
The automatic focusing module is used for continuously measuring the definition of the real-time image acquired by the camera; prompting a user whether the image is clear or not through the definition, and if the image is not clear, enabling the user to adjust the height of the camera until the image is clear;
displaying a real-time image of the camera on the left side in an interface of the automatic focusing module, and displaying an area image selected by a rectangular frame in the real-time image on the right side; and displaying a clear progress bar above the right image, and setting parameters below the right image, wherein the focusing parameters comprise: an edge detection threshold, a focusing standard proportion value and a focusing lower limit proportion threshold; the threshold value of the edge detection is 0-255 of the segmentation of the black-white edge region, and is set as 100 by default; the focusing standard proportion threshold value is set to be 0-100 in the black-white area proportion, and is set to be 90 by default; the focusing lower limit proportion threshold is 0-100, and is set as 70 by default;
as shown in fig. 14, the specific processing of the autofocus module is as follows:
firstly judging whether a focusing start button is clicked, if so, judging whether focusing region editing is performed on a real-time display diagram, if so, transmitting an X coordinate and a Y coordinate of the left upper corner of an editing rectangular frame, the length, the width, a real-time image and an edge detection threshold value to an algorithm, and executing a region definition calculation flow; obtaining a definition evaluation value of the region according to a region definition calculation flow, and displaying the definition evaluation value on an interface in real time; displaying according to the focusing standard proportion value and the focusing lower limit proportion value, if the definition evaluation value obtained in real time is larger than the focusing standard proportion value, displaying the proportion value by the progress bar, displaying green color, and indicating that the definition of the current area is good, and not needing to adjust the height of the camera; if the definition evaluation value is smaller than the focusing standard proportion value and larger than the focusing lower limit proportion value, the progress bar displays yellow, which indicates that the definition of the current area is not good, and the height of the camera can be finely adjusted; if the definition evaluation value is smaller than the focusing lower limit proportion value, the progress bar displays red, which indicates that the definition of the current area is poor, and the camera height adjustment is needed to adjust the image definition, otherwise, the accurate size measurement cannot be performed;
The regional definition calculation flow execution process judges whether a zone bit of the definition calculation flow stopping process is set in real time, if so, the flow execution is stopped, and the user operation is returned to be judged;
namely, after the focusing start button is clicked, the definition calculation flow is started to be executed, at the moment, the focusing start button is changed into the focusing stop button, at the moment, the focusing stop button can be clicked by a user, so that a definition calculation flow stopping mark is set;
judging whether the user displays an upper frame selection focusing area on the real-time graph, if so, storing the left upper corner coordinates of the frame selection area and the length and width of the frame selection area; judging whether a user clicks a 'acquire height' button, if so, acquiring camera height information by controlling a height sensor, and acquiring camera calibration parameters according to the camera height information by looking up a table to be used as parameters of real-time dimension measurement; and judging whether the user clicks a 'measurement return' button, if so, closing the auxiliary focusing interface, and returning to the real-time measurement interface.
As shown in fig. 15, the real-time size measurement of the single image is specifically as follows:
firstly, carrying out pixel combination on a to-be-detected image, and then carrying out-of-bounds detection on the to-be-detected image after the pixel combination; if the detection result is out of bounds, traversing all the checked template names, and judging whether temporary template names exist or not; if the temporary template name does not exist, outputting the object to be detected to go out of the boundary, and ending the real-time measurement flow of the single image; if the temporary template name exists, carrying out pixel combination on the temporary template source diagram, carrying out differential processing on the to-be-detected diagram after the pixel combination and the temporary template source diagram after the pixel combination, if the to-be-detected diagram is inconsistent, outputting an object to be detected out of bounds, and ending the real-time measurement flow of the single image; if the images are consistent, carrying out rotation translation on the current frame image according to the rotation translation result of the temporary template source image;
Judging whether the automatic focusing zone bit is effective or not, if so, calling a measurement type for automatic focusing area selection, executing a real-time measurement automatic focusing definition evaluation function, returning a definition value, and then carrying out size measurement of a related measurement type according to the mask information of the current frame; if not, directly carrying out the size measurement of the related measurement type according to the mask information of the current frame;
if the detection result is that the image is not out of the boundary, carrying out pixel combination on the image to be detected of the previous frame, and then carrying out inter-frame image comparison, namely carrying out inter-frame difference processing on the image to be detected after the pixel combination and the image to be detected of the previous frame after the pixel combination, and if the two images are consistent, indicating that the object to be detected is not moved, carrying out rotation translation on the image of the current frame directly according to the rotation translation result of the previous frame; judging whether the automatic focusing zone bit is effective, if so, calling a measurement type for automatic focusing area selection, executing a real-time measurement automatic focusing definition evaluation function, returning a definition value, and then carrying out size measurement of a related measurement type according to the mask information of the previous frame; if not, directly carrying out the size measurement of the related measurement type according to the mask information of the previous frame; if the two template source images are inconsistent, indicating that the object to be detected moves, traversing all the checked template information, wherein the template information corresponding to the template number is preferentially matched, carrying out pixel combination on the corresponding template source images, carrying out differential processing on the to-be-detected image and the template source image after the pixel combination, and if the two template source images are consistent, stopping traversing, and directly carrying out rotary translation on the current frame image according to the rotary translation result of the current template source image. Judging whether the automatic focusing zone bit is effective, if so, calling a measurement type for automatic focusing area selection, executing a real-time measurement automatic focusing definition evaluation function, returning a definition value, and then carrying out size measurement of a related measurement type according to the mask information of the current frame; if not, directly carrying out the size measurement of the related measurement type according to the mask information of the current frame; if the two are inconsistent, firstly reducing the corresponding template source diagram characteristic information according to the pixel merging coefficient, then executing the matching flow of the object to be detected, if the object to be detected is successfully matched, stopping traversing, and converting the translation amount of the object to be detected after the pixel merging obtained in the matching flow of the object to be detected into the translation amount without the pixel merging according to the pixel merging coefficient; judging whether the automatic focusing zone bit is effective, if so, calling a measurement type for automatic focusing area selection, executing a real-time measurement automatic focusing definition evaluation function, returning a definition value, and then carrying out size measurement of a related measurement type according to the mask information of the current frame; if not, directly carrying out the size measurement of the related measurement type according to the mask information of the current frame; if the object to be detected is not successfully matched, the center of the smallest circumcircle of the object to be detected is used as a vertical axis, the axis is used for horizontally mirroring the image of the object to be detected, a horizontal mirror image is obtained and is used as an input parameter, and the matching process of the object to be detected is jumped to be executed; if the matching is successful, prompting the user that the object to be detected is put reversely, and ending the flow; if the matching is unsuccessful, outputting that the object to be detected is unsuccessful, and ending the real-time measurement of the single image;
The pixel merging is to sequentially merge each row of pixel points in the image into a pixel point by every four adjacent pixel points, the gray value of the pixel point is taken as an average value, and after all rows are processed, each column of pixel points is sequentially merged into a pixel point by every four adjacent pixel points, and the gray value of the pixel point is taken as an average value.
The out-of-bounds detection flow is specifically as follows:
1: filtering the to-be-detected image after the pixels are combined; removing high-frequency noise points through median filtering processing, and reserving contour edge information, wherein a median filtering window is 9 pixels by 9 pixels in the embodiment;
2: performing gray threshold binarization processing on the filtered image; wherein the pixel gray value greater than the set threshold is set to 255, and conversely, to 0; the present embodiment sets a threshold value of 180;
3: searching all closed loop contours in the image; the closed-loop profile means that the distance between any two adjacent profile points in the profile is smaller than a set value, and the set value of the embodiment takes 2 pixels;
4: solving the perimeter of the maximum closed-loop outline, and judging whether the perimeter meets the setting condition or not; setting the condition that the maximum closed-loop contour perimeter is not less than 0.99 times and not more than 1.01 times of the image perimeter; if the circumference meets the condition, the object to be detected is not out of limit, and the process is ended; if the circumference does not meet the condition, the object to be detected is out of limit, and the process is ended;
As shown in fig. 16, the matching flow of the object to be measured is specifically as follows:
1: carrying out mean value filtering treatment on the to-be-detected image after the pixels are combined; the mean filter window in this embodiment is 3 pixels by 3 pixels;
2: performing thresholding processing, setting the gray value of the pixel larger than the set threshold to 0, otherwise setting the gray value to 255, and setting the set threshold to 100 in the embodiment;
3: extracting outline information of the hierarchical part to be detected; the outline information of the to-be-detected hierarchical part comprises outline information and inner outline information of the to-be-detected part, wherein the outline and the inner outline meet the parent-child hierarchical relationship, the outer outline is a parent outline, and the inner outline is a child outline;
4: judging whether the absolute value of the difference between the minimum circumscribed rectangular area of the outline of the object to be detected and the minimum circumscribed rectangular area of the outline of the template source diagram is smaller than a set value; in the embodiment, the value range of the set value is 15% of the minimum circumscribed rectangular area of the outline of the template source diagram;
5: if the absolute value of the difference between the minimum circumscribed rectangular area of the outline of the object to be detected and the minimum circumscribed rectangular area of the outline of the template source diagram is larger than or equal to a set value, the object is not successfully matched, and the flow is ended;
6: if the absolute value of the difference between the minimum circumscribed rectangular area of the outer contour of the object to be detected and the minimum circumscribed rectangular area of the outer contour of the template source diagram is smaller than a set value, judging whether the absolute value of the difference between the minimum circumscribed rectangular length-width ratio of the outer contour of the part to be detected and the minimum circumscribed rectangular length-width ratio of the outer contour of the template source diagram is smaller than the set value or not; the value range of the set value in the embodiment is 10% of the minimum circumscribed rectangular length-width ratio of the outline of the template source diagram;
7: if the absolute value of the minimum external rectangular length-width ratio of the outline of the object to be detected and the minimum external rectangular length-width ratio difference of the outline of the template source diagram is larger than or equal to a set value, the object is not successfully matched, and the step 4 is skipped to be executed;
8: if the absolute value of the difference between the minimum external rectangular length-width ratio of the outline of the object to be detected and the minimum external rectangular length-width ratio of the outline of the template source diagram is smaller than a set value, solving a minimum external circle of the outline, and taking the circle center as a rotation center;
9: judging whether the distance between the outline centroid of the template source diagram and the minimum circumscribed rectangle center of the outline of the template source diagram is larger than a set value or not; the set value in this embodiment is 20 pixels;
10: if the distance between the outline centroid of the template source diagram and the minimum circumscribed rectangle center of the outline of the template source diagram is smaller than or equal to a set value, jumping to the step 18;
11: if the distance between the outline centroid of the template source diagram and the minimum circumscribed rectangle center of the outline of the template source diagram is larger than a set value, judging whether the absolute value of the difference between the outline centroid of the object to be detected and the minimum circumscribed rectangle center of the outline centroid of the template source diagram and the aspect ratio of the outline centroid of the template source diagram to the minimum circumscribed rectangle is smaller than the set value; the value range of the set value in the embodiment is 10% of the length-width ratio from the outline centroid of the template source diagram to the minimum circumscribed rectangle of the outline;
12: if the absolute value of the difference between the center distance between the outline centroid of the object to be detected and the minimum circumscribed rectangle and the aspect ratio between the outline centroid of the template source diagram and the minimum circumscribed rectangle of the outline thereof is greater than or equal to a set value, jumping to the step 18;
13: if the absolute value of the difference between the center distance between the outline centroid of the object to be detected and the minimum circumscribed rectangle and the length-width ratio between the outline centroid of the template source diagram and the minimum circumscribed rectangle of the outline centroid of the object to be detected is smaller than a set value, the rotation angle of the part to be detected relative to the template source diagram is calculated;
14: combining the center coordinates and angle information of the template source diagram, and translating and rotating the diagram to be detected, namely firstly extracting a region of interest (ROI) of the object to be detected from the diagram to be detected; then creating a blank diagram with the same size as the diagram to be detected, translating the object to be detected to the center of the blank diagram, and rotating the object to be detected to the same angle as the template source diagram; in the embodiment, the ROI is a rectangle, the side length of the rectangle is the diameter of the smallest circumscribed circle of the template source diagram, and the center of the rectangle is the center of the smallest circumscribed circle of the object to be detected;
15: judging whether the vector angle from the outline centroid of the object to be detected to the minimum circumscribed rectangle center of the object to be detected is smaller than a set value or not compared with the vector angle from the outline centroid of the template source diagram to the minimum circumscribed rectangle center of the template source diagram, wherein the set value in the embodiment takes 7.5 degrees.
16: if the difference value of the vector angles in the step 15 is smaller than the set value, the object matching is successful, and the step 2 is ended;
17: if the vector angle difference value in the step 15 is greater than or equal to the set value, the step 18 is entered;
18: judging whether an inner contour exists according to the minimum circumscribed rectangular area of the maximum inner contour of the template source diagram; if not, the object matching is successful, the rotation angle of the object to be detected relative to the template source diagram is calculated, and the object is translated and rotated by combining the center coordinate and the angle information of the template source diagram, so that the process is finished; if yes, judging whether the template source diagram has only one effective maximum inner contour;
19: if the template source diagram has only one effective maximum inner contour, effective inner contour matching is performed; the effective inner contour matching comprises the steps of judging whether the minimum circumscribed rectangular area of the maximum inner contour of the part to be detected is matched with the minimum circumscribed rectangular area of the maximum inner contour of the template source diagram, further judging whether the aspect ratio of the minimum circumscribed rectangular area of the maximum inner contour is matched in sequence, judging whether the center distances of the minimum circumscribed rectangular areas of the outer contour and the maximum inner contour are matched, solving the rotation angle of the part to be detected relative to the template source diagram, combining the center coordinates and angle information of the template source diagram, rotating and translating an object, and judging whether the vector angles of the centers of the minimum circumscribed rectangular areas of the outer contour and the maximum inner contour are matched or not to detect whether the matching is successful;
20: if the template source diagram does not meet the condition that only one effective maximum inner contour exists, judging whether the template source diagram has a plurality of maximum inner contours or has both a maximum inner contour and a minimum outer contour;
21: if the template source diagram has a plurality of maximum inner contours, traversing all inner contours in the part to be detected, carrying out effective inner contour matching on each inner contour, judging whether at least one inner contour matching is successful, if so, successfully matching the object, and ending the flow; if not, the object is not successfully matched, and the process is ended;
22: if the template source diagram has a maximum inner contour and a minimum outer contour; firstly, carrying out effective inner contour matching on the maximum inner contour; if the maximum inner outline is matched, the object is successfully matched, and the process is ended;
23: if the maximum inner contour is not matched, then carrying out effective inner contour matching on the minimum inner contour detection object; if the minimum inner outline is matched, the object is successfully matched, and the process is ended; if the minimum inner contour is not matched, the object is not successfully matched, and the process is ended;
as shown in fig. 17, performing continuous measurement of real-time size is required to satisfy that the number of the check templates is smaller than the system setting threshold variable and that camera calibration result data exists;
the control state in the interface performing continuous measurement of real-time dimensions is set as follows: the template diagram display is not overlapped in the real-time diagram display; displaying and clearing the size measurement result data; only the display frame can be subjected to rolling operation in the template display frame, and all templates manufactured by the system and the currently hooked templates to be matched are checked; the "system setup", "temporary make" and "exit system" buttons fail;
The specific execution flow of the continuous measurement version real-time size is as follows:
firstly judging whether an image is acquired or not, if the image is acquired, transmitting template information and a real-time image to a single image size measurement algorithm, and executing a single image real-time size measurement flow; parameters transferred to the single image size measurement algorithm comprise an automatic focusing zone bit, a last frame of camera collected image, a current frame of camera collected image, all checked template information, camera calibration parameters and a priority matching template number;
executing an automatic focusing zone bit, and determining whether a definition evaluation function calculation of a designated mask region is required in a dimension measurement algorithm according to the zone bit; the last frame of camera acquires an image and is used for quickly judging whether a workpiece moves or not after carrying out inter-frame difference processing with the image of the previous frame; the frame camera collects images to be used as images for size measurement; all the checked template information comprises template source diagram, template source diagram ROI information, template source diagram feature information, template source diagram inner contour number, template mask diagram, template mask feature information and template mask accurate feature information; the template numbers are preferentially matched, when the real-time image and the template image are successfully matched, the size measurement algorithm outputs the position of the template image which is successfully matched in the checking template list after the execution is completed, the position sequence is used as the template numbers which are preferentially matched, and the setting value is transmitted to the size measurement algorithm when the camera acquires the image next time;
And then after executing the real-time dimension measurement flow of the single image, judging whether the workpiece is out of range according to the return value, if not, judging whether the currently measured workpiece is successfully matched with the template in the selected template, and if so, executing the following operations: firstly, saving the position number in the checked template sequence of the successfully matched template, and taking the position number as a preferential matching template of the next acquired image for matching; if the algorithm executes definition calculation according to the automatic focusing zone bit, setting the automatic focusing zone bit according to a definition value returned by the algorithm and the previous image executing definition calculation condition; setting an automatic focusing zone bit when the returned definition value is smaller than a focusing standard proportion value set by a system, executing definition calculation when an image execution algorithm is acquired next time, judging whether the number of acquired images is larger than the number of images at intervals of definition calculation set by the system if the returned definition value is larger than the focusing standard proportion value set by the system, setting the automatic focusing zone bit if the number of acquired images is larger than the number of images at intervals of definition calculation set by the system, executing definition calculation when the image execution algorithm is acquired next time, and otherwise clearing the automatic focusing zone bit; finally, the measurement result of the current size is saved, and specific numerical values of specific measurement types are obtained;
Judging whether the number of the matched images reaches a set threshold value, if so, calculating standard deviation of each piece of measured mask type data, carrying out standard deviation elimination on the data in each mask type data array according to a standard deviation system set by the system, calculating an average value of the eliminated data, and numbering and displaying the obtained average value on a real-time measurement interface; if not, the mask type data of each measurement are directly averaged, and then the serial numbers are displayed on the interface.
The system comprises a template task interface, a template selecting interface, a template manufacturing interface and a real-time measuring interface, wherein the template task interface is used for carrying out template manufacturing, the template manufacturing interface is used for carrying out template manufacturing, and the template selecting interface is used for carrying out template size measurement; temporary manufacturing can generate a temporary template, display, selection and check operations are carried out in a template display list of a template selection interface, a template manufacturing interface and a real-time measurement interface, and the original temporary template can be replaced after the temporary manufacturing is carried out again, so that at most one temporary template exists in the system; the user can quickly manufacture the temporary template through the temporary measurement function, so that quick measurement of the temporary workpiece is performed.
In the real-time measurement process, executing an automatic frame skipping and frame rate self-adaption flow according to the execution time of a size measurement algorithm and the time of the camera to acquire the image frame rate; by executing the flow, reasonable configuration of the image acquisition speed and the execution time of the size measurement algorithm is realized, and system operation breakdown caused by too long algorithm execution time is prevented;
the automatic frame skipping is carried out for processing the single image, when the processing time of the single image exceeds the constraint condition of the system, the automatic frame skipping is carried out or the processing of the single image is finished, so that the problem of system breakdown caused by overlong processing time of the single image is prevented;
the frame rate self-adaption calculates the average time of processing a plurality of images aiming at the processing of the images, and the average time is used as a basis for adjusting the frame rate, so that the frame rate of image acquisition can meet the processing requirements of most images in real-time image processing, and when the processing time of individual images is too long, automatic frame skipping is adopted;
as shown in fig. 18, the specific implementation flow of automatic frame skip and frame rate adaptation is as follows:
firstly, performing a frame skipping processing flow: judging whether the camera collects images, if so, judging whether the number of the images collected by current measurement is more than 1, and if so, judging whether a specified image size measuring thread before the current image is finished, wherein the specified basis of the specified image thread is as follows: when the first image is acquired by current measurement, designating the first image as a designated image; if not, the number of the images passing through the specified image size measuring thread is increased by 1, and meanwhile, the number of the images passing through the size measuring thread which is not processed between the specified image and the current image is also increased by 1; if so, selecting an image corresponding to the unprocessed size measurement thread which is established earliest between the current image and the designated image as the designated image, and adding 1 to the number of images which are processed by all the processing threads between the designated image and the current image; judging whether the number of images passed by a specified image size measuring thread reaches a set threshold value, if so, judging whether the execution time of the thread reaches the set threshold value, if so, destroying the thread, and selecting an image corresponding to the unprocessed size measuring thread which is established earliest between the current image and the specified image as the specified image;
Frame rate adaptation flow: firstly, after the camera collects the image and carries out frame skipping processing, executing a real-time dimension measurement flow of a single image on a current image creation thread; judging whether the single image size measurement flow is finished, if so, judging whether the image template matching is successful, otherwise, returning to judging whether the image is acquired; the purpose of judging that the template matching is successful is that the frame rate self-adaption only carries out time statistics on the image successfully matched by the template, and the time is selected as the self-adaption adjustment basis of the frame rate because the running time of the template matching is longer in the image processing algorithm and can represent the time of the normal image processing algorithm;
if the template matching is successful, the running time of the image size measurement flow is saved, whether the number of images successfully matched by the template is larger than a set threshold value is judged, if so, standard deviation elimination processing is carried out on all processing time of the images successfully matched currently, and then average value operation is carried out on the rest time to obtain average time; judging whether the average time is greater than a frame rate time threshold, wherein the frame rate time threshold is the product of the time corresponding to the image acquisition frame rate and a frame rate self-adaptive upper limit proportion threshold, and if so, adjusting the camera acquisition frame rate to be the frame rate corresponding to the average time;
In the automatic frame skipping and frame rate self-adaption process, whether a user clicks a 'stop measurement' button or not is judged in real time, if yes, statistics such as the number of images, time and the like are cleared, and then the automatic frame skipping and frame rate self-adaption module is finished.
As shown in fig. 19 and 20, the template calibration procedure includes the following steps:
step 1: the calibration plate is placed at different positions in the view field, and the images of the calibration plate are respectively acquired;
step 2: after the image acquisition of the calibration plate is completed, closing the camera acquisition, and calling a calibration algorithm to perform image calibration processing;
step 3: after the calibration process is completed, updating the calibration parameters to the latest calibration parameters;
step 4: exiting the template calibration interface;
the image calibration processing in the step 2 comprises the steps of obtaining camera distortion parameters, camera internal parameter matrixes and obtaining magnification; the method for obtaining the camera distortion parameters and the internal reference matrix through the Zhengyou distortion correction algorithm comprises the following steps:
step 1.1: reading calibration image data and calibration parameters of the acquired image, wherein the transverse points in the calibration parameters are the number of rows of the checkerboard of the index calibration plate, the longitudinal points are the number of columns of the checkerboard, and the unit interval is the real physical size of each cell of the checkerboard;
Step 1.2: extracting corner information from each frame of calibration image;
step 1.3: further extracting sub-pixel corner information by using the extracted corner information;
step 1.4: initializing a space three-dimensional coordinate system of the corner points on the calibration plate;
step 1.5: carrying out camera calibration by using the extracted sub-pixel angular point information and the spatial three-dimensional coordinate system information of the angular points on the calibration plate to obtain distortion parameters participating in each frame of image in the camera, and rotation vectors and translation vectors of each frame of image;
step 1.6: evaluating the calibration result; firstly, obtaining distortion parameters through camera calibration, carrying out reprojection calculation on a space three-dimensional coordinate point of each frame of image to obtain a new projection point, calculating the error between the new projection point and an old projection point, if the error is smaller than a set value of 0.15 pixels, conforming to the requirements, storing a calibration result and the distortion parameters, and ending the process; if the error is greater than or equal to 0.15 pixel of the set value, the process is ended and the calibration image is prompted to be collected again if the error is not required;
the amplification factor acquisition process comprises the following steps:
step 2.1: correcting the acquired calibration image of a certain frame by using the calibration result;
step 2.2: extracting corner information from the corrected image;
Step 2.3: extracting sub-pixel corner information;
step 2.4: traversing the corrected image column number, and calculating and storing the distance from the first row to the first row of each column;
step 2.5: sorting the saved intervals of each column;
step 2.6: selecting a plurality of columns with the middle column as a center, and accumulating the saved intervals of the selected columns;
step 2.7: according to the accumulated value, calculating an average value;
step 2.8: according to the average value, the column number and the physical size, the amplification rate is calculated, and the calculation formula of the amplification rate is the average value/(column number-2)/the physical size;
step 2.9: the present flow is ended.
The foregoing is merely a preferred embodiment of the present invention, and it should be noted that modifications and adaptations to those skilled in the art may be made without departing from the concept of the present invention, and such modifications and adaptations are intended to be comprehended within the scope of the present invention.

Claims (3)

1. The size measuring instrument with the automatic focusing function is characterized by comprising a lifting adjusting part and a supporting part, wherein the lifting adjusting part is arranged on the supporting part; the supporting part comprises a bearing plate arranged on the base;
the lifting adjusting part comprises a lifting vertical arm arranged on the bearing plate, a vertical arm knob for controlling the movement of the lifting vertical arm, a lens bracket arranged on the lifting vertical arm and a component arranged on the lens bracket, wherein the component comprises a lens cover and a displacement sensor bracket; the displacement sensor is arranged on the displacement sensor bracket; the lifting vertical arm shell wraps the lifting vertical arm, six rows of symmetrical annular light support fixing holes are formed in the lifting vertical arm shell and used for fixing an annular light support at a proper position, an annular light clamp is arranged on the annular light support, and annular light is fixed on the annular light clamp; the industrial camera is arranged on the lens bracket, and the lens is arranged on the industrial camera and is covered by the lens cover so as not to expose the structure;
In the lifting vertical arm, the rotary vertical arm knob drives the gear to drive the rack meshed with the gear, so as to drive the sliding block provided with the rack to move in the vertical direction; when the locking poking piece moves to a proper position, the locking poking piece is poked down in the locking direction, the threads on the locking shaft are driven to move inwards, and the locking rubber pad arranged at the tail end of the locking shaft can tightly prop against the rough belt on the rack;
the automatic focusing module is used for continuously measuring the definition of real-time images acquired by cameras in the system; prompting a user whether the image is clear or not through the definition, and if the image is not clear, enabling the user to adjust the height of the camera until the image is clear; the method comprises the following specific steps:
1.1 Initializing: after the measuring instrument is started and the operation software is opened, the measuring instrument enters a startup initialization interface, the data read by a database is displayed in the interface, whether the equipment of the system is normal or not is judged, and the equipment enters a corresponding function after the equipment is normal;
1.2 A focusing judgment step: judging whether a focusing start button is clicked, if so, judging whether focusing region editing is performed on the real-time display diagram, if so, transmitting an X coordinate and a Y coordinate of the left upper corner of the editing rectangular frame, the length, the width, the real-time image and an edge detection threshold value to an algorithm, and executing a region definition calculation flow; obtaining a definition evaluation value of the region according to a region definition calculation flow, and displaying the definition evaluation value on an interface in real time;
Displaying according to the focusing standard proportion value and the focusing lower limit proportion value, if the definition evaluation value obtained in real time is larger than the focusing standard proportion value, displaying the proportion value by the progress bar, displaying green color, and indicating that the definition of the current area is good, and not needing to adjust the height of the camera; if the definition evaluation value is smaller than the focusing standard proportion value and larger than the focusing lower limit proportion value, the progress bar displays yellow, which indicates that the definition of the current area is not good, and the height of the camera can be finely adjusted; if the definition evaluation value is smaller than the focusing lower limit proportion value, the progress bar displays red, which indicates that the definition of the current area is poor, and the camera height adjustment is needed to adjust the image definition, otherwise, the accurate size measurement cannot be performed;
the regional definition calculation flow execution process judges whether a zone bit of the definition calculation flow stopping process is set in real time, if so, the flow execution is stopped, and the user operation is returned to be judged;
1.3 Focusing interface information processing step: judging whether the user displays an upper frame selection focusing area on the real-time graph, if so, storing the left upper corner coordinates of the frame selection area and the length and width of the frame selection area; judging whether a user clicks a 'acquire height' button, if so, acquiring camera height information by controlling a height sensor, and acquiring camera calibration parameters according to the camera height information by looking up a table to be used as parameters of real-time dimension measurement; and judging whether the user clicks a 'measurement return' button, if so, closing the auxiliary focusing interface, and returning to the real-time measurement interface.
2. The size measuring instrument with an auto-focusing function according to claim 1, wherein a real-time image of the camera is displayed on the left side in the interface of the auto-focusing module, and an area image selected by a rectangular frame in the real-time image is displayed on the right side; and displaying a clear progress bar above the right image, and setting parameters below the right image.
3. The automatic focusing size measuring instrument according to claim 1, wherein in the step 1.2), after the "start focusing" button is clicked, the definition calculating process is started to be executed, at this time, the "start focusing" button is changed to the "stop focusing" button, at this time, the user can click the "stop focusing" button, so as to set the stop definition calculating process flag.
CN202310276991.5A 2021-04-01 2021-04-01 Dimension measuring instrument with automatic focusing function Pending CN116249001A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310276991.5A CN116249001A (en) 2021-04-01 2021-04-01 Dimension measuring instrument with automatic focusing function

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202310276991.5A CN116249001A (en) 2021-04-01 2021-04-01 Dimension measuring instrument with automatic focusing function
CN202110356809.8A CN113645398B (en) 2021-04-01 2021-04-01 Dimension measuring instrument system based on automatic focusing function

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN202110356809.8A Division CN113645398B (en) 2021-04-01 2021-04-01 Dimension measuring instrument system based on automatic focusing function

Publications (1)

Publication Number Publication Date
CN116249001A true CN116249001A (en) 2023-06-09

Family

ID=78415745

Family Applications (3)

Application Number Title Priority Date Filing Date
CN202110356809.8A Active CN113645398B (en) 2021-04-01 2021-04-01 Dimension measuring instrument system based on automatic focusing function
CN202310276991.5A Pending CN116249001A (en) 2021-04-01 2021-04-01 Dimension measuring instrument with automatic focusing function
CN202310282111.5A Pending CN116249002A (en) 2021-04-01 2021-04-01 Automatic focusing method of size measuring instrument

Family Applications Before (1)

Application Number Title Priority Date Filing Date
CN202110356809.8A Active CN113645398B (en) 2021-04-01 2021-04-01 Dimension measuring instrument system based on automatic focusing function

Family Applications After (1)

Application Number Title Priority Date Filing Date
CN202310282111.5A Pending CN116249002A (en) 2021-04-01 2021-04-01 Automatic focusing method of size measuring instrument

Country Status (1)

Country Link
CN (3) CN113645398B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113639630A (en) * 2021-04-01 2021-11-12 浙江大学台州研究院 Dimension measuring instrument system based on multi-template matching and automatic focusing functions

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CH321135A (en) * 1953-04-30 1957-04-30 Agfa Camera Werk Aktiengesells Optical copier with focus indicator
CN103575742B (en) * 2013-11-13 2015-11-18 成都术有科技有限公司 One-touch optical measuring instrument

Also Published As

Publication number Publication date
CN113645398B (en) 2023-05-09
CN113645398A (en) 2021-11-12
CN116249002A (en) 2023-06-09

Similar Documents

Publication Publication Date Title
TWI519778B (en) A method for inspecting line width and/or positional errors of a pattern
JPWO2007074770A1 (en) Defect inspection equipment that performs defect inspection by image analysis
JP2011020455A (en) Method for automatically determining print quality of image printed on deformable carrier
WO2022206022A1 (en) Size measuring instrument system based on multi-template matching and automatic focusing functions
CN113645398B (en) Dimension measuring instrument system based on automatic focusing function
JPH11231507A (en) Method and device for inspecting mask
CN113467664A (en) Size measuring instrument using method based on template matching
CN113624129A (en) Real-time measurement method of dimension measurement instrument
US7970238B2 (en) Method and apparatus for acquiring image of internal structure, and computer product
JP4987323B2 (en) Color filter defect correcting apparatus and color filter defect correcting method
CN111242939B (en) Method for identifying state of pressing plate
CN110658215B (en) PCB automatic splicing detection method and device based on machine vision
JP4880380B2 (en) Substrate defect correcting apparatus and substrate defect correcting method
JP2016035542A (en) Position measurement method, method for creating map of positional deviation, and inspection system
JP7380332B2 (en) Image processing device, control method and program for the image processing device
JP4975472B2 (en) Color filter defect correcting apparatus and color filter defect correcting method
CN114612427A (en) Nameplate defect detection method and device, electronic equipment and storage medium
JP2005140655A (en) Method of detecting stain flaw, and stain flaw detector
CN113379692A (en) Method and device for calibrating OM and SEM coordinate relation, equipment and storage medium
JPH08181053A (en) Position detecting method
JP5099689B2 (en) Color filter defect correcting apparatus and color filter defect correcting method
JP3017839B2 (en) Defect inspection method and inspection device
JPS6048683B2 (en) Object surface condition inspection method and inspection device
KR20070023979A (en) Method of preventing error of mask pattern check
JPH08159984A (en) Pattern irregularity inspecting apparatus

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination