CN113624129A - Real-time measurement method of dimension measurement instrument - Google Patents

Real-time measurement method of dimension measurement instrument Download PDF

Info

Publication number
CN113624129A
CN113624129A CN202110356816.8A CN202110356816A CN113624129A CN 113624129 A CN113624129 A CN 113624129A CN 202110356816 A CN202110356816 A CN 202110356816A CN 113624129 A CN113624129 A CN 113624129A
Authority
CN
China
Prior art keywords
template
image
measurement
real
interface
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
CN202110356816.8A
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 CN202110356816.8A priority Critical patent/CN113624129A/en
Publication of CN113624129A publication Critical patent/CN113624129A/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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image

Abstract

The invention discloses a real-time measurement method of a dimension measuring instrument, which comprises the steps of 1) initializing, 2) measuring in real time and 3) matching; the invention provides a real-time measurement method of a dimension measurement instrument, which is high in compatibility, standardization, efficiency and real-time matching detection.

Description

Real-time measurement method of dimension measurement instrument
Technical Field
The invention relates to the field of size measurement, in particular to a real-time measurement method of a size measurement instrument.
Background
In an automatic production process, in order to ensure the product quality, a dimension measuring instrument is required to measure the dimension of a product.
Traditional size measuring apparatu is difficult to fine guarantees the measuring precision under the prerequisite of guaranteeing degree of automation, appears easily because measurement error is too big and the unqualified product that leads to occupies the proportion too big, has reduced work efficiency when increasing the cost, brings inconvenience for user's use.
Image size measuring instruments are therefore a trend, which is often used for measuring two-dimensional sizes. Are widely used in various precision industries. At present, the method is mainly used for measuring the sizes, angles and the like of parts which are difficult to measure or cannot be measured at all in calipers and angle gauges and play an important role in assembly, such as silica gel, creepage distance of a circuit board, clearance of electric appliances, lamp holes of a control panel, certain sizes of plastic parts and the like, and can also be used for shooting pictures of certain parts and components for analyzing bad reasons.
But current image size measuring apparatu still has more shortcoming when the in-service use, is difficult to accomplish full automated inspection at present, and the process of detection confoundly has not certain standard for final testing result also appears the deviation easily, makes work efficiency not high, to the detection of high accuracy product, greatly increased staff's intensity of labour on the contrary, is difficult to effectual help staff and reduces work load, improves work efficiency. Especially, in the real-time measurement process, the measurement of the picture is difficult to detect and judge under special conditions of reverse placement, movement and the like.
Disclosure of Invention
The invention overcomes the defects of the prior art and provides a real-time measurement method of the dimension measuring instrument, which is highly compatible, standardized, efficient and capable of matching and detecting in real time.
In order to solve the technical problems, the technical scheme of the invention is as follows:
a real-time measurement method of a dimension measurement instrument specifically comprises the following steps:
1) an initialization step: starting the measuring instrument, starting the operation software, entering a starting initialization interface, entering a template selection interface, and displaying data read from a database in the interface; when entering a template selection interface, selecting 'entering measurement' to enter a real-time measurement interface;
2) a real-time measurement step: when the real-time measurement module in the real-time measurement interface is executed, the real-time measurement module comprises the real-time size measurement of a single image, and the specific processing is as follows:
carrying out pixel combination on the image to be measured, and carrying out-of-bound detection on the image to be measured after the pixel combination; then judging whether the automatic focusing flag bit is effective, if so, calling the 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 the relevant measurement type according to the current frame mask information; if the mask information is invalid, directly carrying out size measurement of the relevant measurement type according to the mask information of the current frame;
if the out-of-range detection indicates that the out-of-range detection does not exist, pixel combination is carried out on the previous frame of image to be measured, inter-frame image comparison is carried out, whether an automatic focusing flag bit is effective or not is judged, if yes, the measurement type used for automatic focusing area selection is called, an automatic focusing definition evaluation function is measured in real time, a definition value is returned, and size measurement of the relevant measurement type is carried out according to the previous frame of mask information; if the frame mask information is invalid, directly carrying out size measurement of the related measurement type according to the previous frame mask information; if the two are inconsistent, the object to be detected is indicated to have moved, then all the checked template information is traversed, wherein the template information corresponding to the prior matching template number is firstly carried out, the corresponding template source images are subjected to pixel combination, the image to be detected and the template source images after the pixel combination are subjected to differential processing, if the two are consistent, the traversal is terminated, and the rotation translation of the current frame image is directly carried out according to the rotation translation result of the current template source image;
3) matching: executing the matching process of the object to be tested, if the object to be tested is not successfully matched, making a vertical axis through the center of the minimum circumscribed circle of the object to be tested, horizontally mirroring the image of the object to be tested by the axis to obtain a horizontal mirror image, using the horizontal mirror image as an input parameter, and jumping to the matching process of the object to be tested to execute; if the matching is successful, prompting the user to put the object to be tested reversely, and ending the process; if the matching is not successful, outputting that the object to be measured is not successfully matched, and finishing the real-time measurement of the single image.
Compared with the prior art, the invention has the advantages that:
the single image real-time size measurement of the invention provides high compatibility, standardization and high-efficiency real-time matching detection, and reasonable judgment is also carried out on the conditions of reverse placement, movement and the like under various special conditions, so that the judgment accuracy is greatly improved.
The temporary measurement function of the invention realizes the rapid template manufacture of the temporary measurement workpiece through temporary manufacture. The method can also realize the measurement of the workpiece with the super view field, and when the size of the workpiece to be measured is larger than the view field range of the camera, the position of the current workpiece is kept unchanged, the temporary template is manufactured and the size is measured, so that the size of the workpiece with the super view field can be quickly measured.
Drawings
FIG. 1 is a block diagram of the system of the present invention;
FIG. 2 is a flow chart of system initialization of the present invention;
FIG. 3 is a flow chart of database operation of the present invention;
FIG. 4 is a flow chart of the light source detection of the present invention;
FIG. 5 is a template selection interface diagram of the present invention;
FIG. 6 is a flow chart of template selection according to the present invention;
FIG. 7 is a template search flow diagram of the present invention;
FIG. 8 is a diagram of a real-time measurement interface of the present invention;
FIG. 9 is a parameter configuration interface diagram of the present invention;
FIG. 10 is a flow chart of parameter configuration according to the present invention;
FIG. 11 is a flowchart of rights management of the present invention;
FIG. 12 is a flow chart of the template operation of the present invention;
FIG. 13 is a flowchart of the template information extraction operation of the present invention;
FIG. 14 is a flow chart of an auto focus module of the present invention;
FIG. 15 is a flow chart of the present invention for real-time measurement of a single image;
FIG. 16 is a flow chart of the automatic frame skipping and frame rate adaptation of the present invention;
FIG. 17 is a flow chart of a continuous measurement of the present invention;
FIG. 18 is a flow chart of the automatic frame skipping and frame rate adaptation of the present invention;
FIG. 19 is a flow chart of the present invention for obtaining camera distortion parameters and an internal reference matrix;
FIG. 20 is a magnification acquisition flow chart of the present invention;
FIG. 21 is a schematic view showing the measurement results of the template making interface according to the present invention;
FIG. 22 is a flow chart of the automatic exposure adjustment of the present invention;
FIG. 23 is a schematic view of an apparatus of the present invention;
FIG. 24 is a schematic partial structure view of FIG. 23 in accordance with the present invention;
fig. 25 is a schematic view of the lift adjustment portion of fig. 23 of the present invention.
Detailed Description
The invention is further described with reference to the following figures and detailed description.
The first embodiment is as follows:
as shown in fig. 15, a real-time measurement method of a dimension measurement apparatus includes starting up the measurement apparatus, starting up operation software, entering a startup initialization interface, entering a template selection interface, and displaying data read from a database in the interface; when entering a template selection interface, selecting 'entering measurement' to enter a real-time measurement interface;
when the real-time measurement module in the real-time measurement interface is executed, the real-time measurement module comprises the real-time size measurement of a single image, and the specific processing is as follows:
firstly, carrying out pixel combination on a to-be-measured image, and then carrying out-of-bound detection on the to-be-measured image after the pixel combination; if the detection result is out of bounds, traversing all the selected template names, and judging whether temporary template names exist or not; if no temporary template name exists, outputting the object to be measured out of bounds, and ending the real-time measurement process of a single image; if the name of the temporary template exists, pixel combination is carried out on the temporary template source image, then differential processing is carried out on the image to be measured after the pixel combination and the temporary template source image after the pixel combination, if the image to be measured and the temporary template source image are not consistent, the output of the object to be measured is out of bounds, and the real-time measurement process of a single image is finished; if the template source images are consistent with the template source images, performing the rotational translation of the current frame image according to the rotational translation result of the temporary template source image;
then judging whether the automatic focusing flag bit is effective, if so, calling the 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 the relevant measurement type according to the current frame mask information; if the mask information is invalid, directly carrying out size measurement of the relevant measurement type according to the mask information of the current frame;
if the detection result is that the image is not out of range, pixel combination is carried out on the previous frame of image to be detected, then inter-frame image comparison is carried out, namely inter-frame differential processing is carried out on the image to be detected after the pixel combination and the previous frame of image to be detected after the pixel combination, if the two are consistent, the object to be detected is not moved, and then the rotation translation of the current frame image is directly carried out according to the rotation translation result of the previous frame; judging whether the automatic focusing flag bit is effective, if so, calling the 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 the relevant measurement type according to the previous frame of mask information; if the mask is invalid, directly carrying out size measurement of a related measurement type according to the mask information of the previous frame; if the two are not consistent, the object to be detected is indicated to move, then all the checked template information is traversed, wherein the template information corresponding to the template number which is preferentially matched is firstly carried out, the corresponding template source images are subjected to pixel combination, the image to be detected and the template source images after the pixel combination are subjected to differential processing, if the two are consistent, the traversal is terminated, and the rotation translation of the current frame image is directly carried out according to the rotation translation result of the current template source image. Judging whether the automatic focusing flag bit is effective, if so, calling the 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 the relevant measurement type according to the current frame mask information; if the mask information is invalid, directly carrying out size measurement of the relevant measurement type according to the mask information of the current frame; if the two are not consistent, reducing the characteristic information of the corresponding template source image according to the pixel merging coefficient, then executing the matching process of the object to be tested, if the object to be tested is successfully matched, terminating traversal, and converting the translation quantity of the object to be tested after the pixels are merged, which is obtained in the matching process of the object to be tested, into the translation quantity without the pixels being merged according to the pixel merging coefficient; judging whether the automatic focusing flag bit is effective, if so, calling the 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 the relevant measurement type according to the current frame mask information; if the mask information is invalid, directly carrying out size measurement of the relevant measurement type according to the mask information of the current frame; if the object to be detected is not successfully matched, making a vertical axis through the center of the minimum circumscribed circle of the object to be detected, horizontally mirroring the image of the object to be detected by the axis to obtain a horizontal mirror image, taking the horizontal mirror image as an input parameter, and skipping to the execution of the matching process of the object to be detected; if the matching is successful, prompting the user to put the object to be tested reversely, and ending the process; if the matching is not successful, outputting that the object to be measured is not successfully matched, and finishing the real-time measurement of a single image;
the pixel merging is to merge every four adjacent pixels in each row of pixels in the image into one pixel in sequence, the gray value of the pixel is averaged, after all rows are processed, every column of pixels is merged into one pixel in sequence by every four adjacent pixels, and the gray value of the pixel is averaged.
The out-of-range detection process is concretely as follows:
1: filtering the image to be detected after the pixels are combined; removing high-frequency noise points through median filtering processing, and keeping outline edge information, wherein a median filtering window in the embodiment is 9 pixels by 9 pixels;
2: carrying out grey threshold value binarization processing on the filtered image; wherein the gray value of the pixel greater than the set threshold is set to 255, otherwise, it is set to 0; in the embodiment, the set threshold value is 180;
3: searching all closed-loop contours in the image; the closed-loop contour means that the distance between any two adjacent contour points in the contour is smaller than a set value, and the set value of the embodiment is 2 pixels;
4: solving the maximum closed loop contour perimeter, and judging whether the perimeter meets the setting condition; setting conditions 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 perimeter meets the condition, the object to be detected is not out of bounds, and the process is ended; if the perimeter does not satisfy the condition, the object to be measured is out of bounds, and the process is ended.
Example two:
as shown in fig. 1, a dimension measuring instrument based on multi-template matching and auto-focusing functions, wherein the dimension measuring instrument is shown in fig. 23 to 25, the dimension measuring instrument comprises a lifting adjusting part and a supporting part, and the lifting adjusting part is arranged on the supporting part.
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) positioned on two sides of the objective table glass (13) are suitable for clamping parts which are inconvenient to place during measurement through special tool fixtures, and four knob screws (9) used for fixing and adjusting the levelness of the objective table glass (13).
The lifting adjusting part comprises a lifting vertical arm (21) arranged on a bearing plate (20), a vertical arm knob (7) for controlling the movement of the lifting vertical arm (21), a lens bracket (8) arranged on the lifting vertical arm (21), and a part arranged on the lens bracket (8), wherein the part comprises 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) with symmetrical two sides are used for fixing the annular light support (4) at a proper position on the lifting vertical arm shell (1), an annular light fixture (15) is arranged on the annular light support (4), and the annular light fixture (15) is fixed on the annular light fixture (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 wrapped by the lens cover (16) to protect internal instruments without exposing the structure.
In the lifting vertical arm (21), a rotary vertical arm knob (7) drives a gear (25) so as to transmit power to a rack (26) meshed with the gear, and thus drives a sliding block (24) provided with the rack (26) to move in the vertical direction. When the locking shifting piece (6) moves to a proper position, the locking shifting piece (6) is shifted down to the locking direction to drive the threads on the locking shaft (27) to drive the locking shaft to move inwards, and the locking rubber pad (28) arranged at the tail end of the locking shaft (27) can tightly abut against the rough belt (23) on the rack (26), so that the locking purpose is achieved.
The method comprises the steps of using a dimension measuring instrument, firstly placing a measured object on objective table glass (13), then enabling an industrial camera (17) and a lens (18) to reach proper positions by adjusting a vertical arm knob (7), pulling down a locking pull sheet (6) to a locking direction, then adjusting an annular light support (4) to reach proper positions, and pressing a key measuring button (12), so that the required corresponding dimension of a part to be measured can be displayed on an external touch screen.
The real-time measurement method of the dimension measuring instrument comprises the following specific operation steps:
1) an initialization step: starting the measuring instrument, and after the control software is started, operating the software to enter a starting initialization interface, and starting initialization is carried out in the interface; the startup initialization process mainly performs detection of system-related software and hardware, reading and setting of parameters, and the system-related software and hardware include: the system comprises a database, a camera, an annular light source and a backlight source, wherein the parameters mainly comprise camera configuration parameters, serial port configuration parameters, authority management parameters, size measurement related parameters and the like. Processing the detection result information of the related software and hardware, and judging whether the software and hardware abnormity that the system can not normally operate exists; if yes, waiting for the user to confirm the abnormal information and quitting the system; and if not, entering a template selection interface.
2) Template selection interface processing step: when entering a template selection interface, a template selected by a user before exiting the system last time is selected or selected by default (the template selected represents that the user selects a required template, the selected template is template information required to be checked by the user, generally the template selected by the user before exiting the system last time, but the template can be selected again), the user can select one or more workpiece templates required to be measured in the interface, if the template selection operation is carried out, a measurement result graph and measurement result information of the template can be displayed in the interface, only one template can be selected by the selection operation, and the user clicks a 'enter measurement' button to enter the next interface or clicks a 'exit system' button to exit the system after finishing the selection; at the moment, if the user selects the empty template, popping up an administrator password input dialog box, and entering a template operation interface after the user inputs a correct administrator password; and if the user selects other templates, entering a real-time measurement interface.
3) A real-time measurement step: performing real-time measurement of the size of the workpiece, system setting, temporary manufacturing and operation of quitting the system in the real-time measurement interface;
clicking a 'start measurement' button in a real-time measurement interface to enter a real-time size measurement process of a workpiece to be measured; judging whether measurement conditions are met or not, respectively judging whether the number of the check templates meets the constraint conditions or not and whether camera calibration result data exists or not, if the measurement conditions are met, judging whether an image is acquired or not, otherwise popping up an information prompt box prompt according to the measurement conditions which are not met, returning after information confirmation is carried out by a user, and waiting for user operation; if the image is collected, continuous measurement and judgment of one-key measurement version are carried out; if the image is a one-key measurement version, entering a one-key measurement version single-image real-time size measurement process, judging whether the number of processed images reaches a set value after the process is completed, if so, performing a multi-image data processing process, finishing the process, then, finishing the measurement, waiting for user operation, and if not, returning to judge whether the images are acquired; and if the image is a continuous measurement version, entering a single image real-time size measurement process of the continuous measurement version, entering a multi-image data processing process of the continuous measurement version after the process is finished, entering the next cycle after the process is finished, and judging whether the image is acquired.
And in the real-time size measurement process, judging whether the user clicks a 'stop measurement' button in real time, if so, ending the measurement, returning to wait for the operation of the user, and otherwise, continuously executing the real-time size measurement process.
The user can pop up an administrator password input box after clicking a system setting button, enter a system setting interface if the user inputs a correct management password, otherwise prompt the user that the password is input incorrectly, and close the administrator password input box or input the password again in the administrator password input box; clicking different buttons in the system setting interface can perform corresponding function operation, and the operation buttons specifically comprise: parameter configuration, template operation, template calibration, auxiliary focusing, authority management and return;
after clicking a 'parameter configuration' button, the system opens a parameter configuration interface, runs a parameter configuration module in the parameter configuration interface, simultaneously judges whether a user clicks a 'return' button, enters a parameter storage process if the user clicks the 'return' button, closes the parameter configuration interface after the completion, and returns to a system setting interface;
after clicking a 'template operation' button, the system opens a template operation interface, runs a template operation module in the template operation interface, and simultaneously judges whether a user clicks a 'return' button, if so, the template operation interface is closed, and the system setting interface is returned;
clicking a 'template calibration' button, entering a template calibration interface, operating a template calibration module in the template calibration interface, judging whether a user clicks a 'return' button or not, if so, closing the template calibration interface, and returning to a system setting interface;
clicking an auxiliary focusing button to enter an auxiliary focusing interface, operating an automatic focusing module in the auxiliary focusing interface, judging whether a user clicks a return button or not, if so, closing the auxiliary focusing interface, and returning to a system setting interface;
clicking an authority management button, entering an authority management interface, operating an authority management module in the authority management interface, judging whether a user clicks a return button or not, if so, closing the authority management interface, and returning to a system setting interface;
clicking temporary production on a 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; performing a temporary template making process in the template task editing interface, judging whether a user clicks a 'return' button or not, if so, closing the template task editing interface after generating a temporary template, and returning to a real-time measuring interface;
and after the system quitting is triggered, popping up a dialog box for confirming the system quitting, if the user selects and determines, quitting the system, and if not, closing the dialog box for quitting the system.
As shown in fig. 2, the initialization steps are 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 successfully connected or not according to the operation result; if the connection is unsuccessful, displaying a system quitting button, and waiting for the user to click the system quitting button to quit the system; the camera configuration parameters, the template information and the measurement result information are stored in the database, so that the operation can be continued only when the database and the camera are connected successfully; otherwise, carrying out maintenance, and waiting for the successful connection of the database and the camera; and carrying out the next process only after the database and the camera are successfully connected.
1.2) if the database and the camera are successfully connected, judging whether the serial port to IO module is successfully connected; if the connection is unsuccessful, displaying a system entering button and a system exiting button, and waiting for the user to perform button operation; if the connection is successful, entering a light source detection module; if the user clicks a 'enter system' button, judging whether the version is a one-key measurement version or a continuous measurement version according to the current version number, if the version is the one-key measurement version, entering a one-key measurement function, and if the version is the continuous measurement version, entering the continuous measurement version; if the user clicks the 'exit system' button, the user exits the system;
1.3) the light source detection module judges whether the annular light source and the backlight source can work normally; after the light source detection process is executed, judging whether the light sources are normal or not, if the light sources which can not normally work exist, displaying a 'enter system' button and a 'exit system' button, waiting for a user to perform button operation, and if the light sources can normally work, selecting a corresponding measurement function according to the current version number; 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 stored camera configuration parameters, automatic exposure adjustment parameters, camera calibration configuration parameters, camera calibration result data, camera automatic focusing parameters, user authority passwords, version numbers, data processing parameters, template information and real-time measurement result data; the database establishes a corresponding data table according to the stored data, wherein a template parameter general 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 parameter table cameraconfigureparamtertable: exposure, acquisition frame rate, processing frame rate, and pixel binning.
(2) Frame rate adaptation and frame skip parameter table framerateadaptappeandjumpparameterstable: the method comprises the following steps of counting pictures, processing data lower limit of standard deviation, standard deviation coefficient, frame rate self-adaptive proportion upper limit and frame skipping picture counting.
(3) Auto exposure adjustment parameter table: automatic exposure function selection, exposure adjustment target proportion value, target proportion value upper limit, target proportion value lower limit and exposure adjustment scale.
(4) Camera calibration configuration parameter table cameracalistriationparametertable: number of horizontal lattices, number of vertical lattices and unit length.
(5) Camera calibration results data table cameracalistrionresultparametertable: magnification, camera distortion parameters, camera intrinsic parameters matrix, and height values.
(6) Autofocus parameters table autofocusing parametertable: the device comprises an edge detection threshold, a focusing standard proportion value and a focusing lower limit proportion value.
(7) Serial port configuration parameter table SerialPortConfigureParameterTable: port number, baud rate.
(8) User rights table authorseparametertable: an administrator password, a technician password, and a system version number.
(9) Data processing parameter table DataProcessingParameterTable: the upper limit of the number of processing templates, the number of processed pictures, the standard deviation coefficient and the lower limit of the number of standard deviation processing data.
(10) Template information summary table template totaltable: template name, measurement template selection, display template selection, template source graph, measurement result graph, template source graph measurement information and template modification time.
(11) Template mask information table template maskmessagetable: template name, mask number, auto-focus selection, mask information, mask map, measurement results and measurement values corresponding to each mask.
(12) Measurement data table readmemeasureresulttable: template name, measurement value and measurement date and time.
As shown in fig. 3, the specific steps of the database operation module are as follows:
firstly, executing a database connection function according to the host address, the user name and the password of the database server, wherein the database connection result comprises database connection success, database connection abnormity and database connection failure; judging whether the database is successfully connected, if so, executing whether the database has a command 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 the corresponding commands of the database, if the database exists, sequentially executing whether the data table has the commands according to the name of the data table; if the corresponding data table exists, executing a data reading command, and setting the value of a corresponding variable according to the returned data of the reading command; if the corresponding data table does not exist, the data table is created, the data table is written with default parameter operation, the relevant dimension measurement parameter is set as a default value, finally, the corresponding data table does not exist in the database return information, wherein the camera calibration result data table, the template information summary table and the template mask information table are used for the whole time, if the corresponding data table does not exist, the default parameter operation does not need to be written, and the measurement result data table does not need to be traversed; if the database does not exist, firstly executing a database creating command to create the database, then creating each parameter table and writing default parameters, setting relevant dimension measurement parameters as default values, and simultaneously setting the database operation result as that the database does not exist;
and finally, displaying result information in the interface according to the database operation result and then finishing the database operation module.
The workpiece dimension measurement operation of the system depends on the collected images, and the images are collected by an industrial camera, so that the normal connection of the camera is required to be ensured when the system is started. The camera connection in software and hardware specifically comprises the following steps:
firstly, searching all Ethernet cameras and USB cameras connected in a system; if the camera is not detected, setting the camera connection operation result as the camera not detected, and writing the detection result into a log; if 1 camera is detected, executing camera opening operation; if 2 or more than 2 cameras are detected, displaying the detected camera names on an interface to wait for selection of a user, and opening the cameras after the user selects the cameras;
after the camera is opened, firstly creating an equipment object, then operating the equipment creating equipment on the equipment object according to the detected camera information, and finally executing the camera opening operation on the equipment, and if the camera is opened abnormally, returning corresponding abnormal information and finishing the camera operation;
if the camera is successfully opened, setting a camera image acquisition mode as a trigger mode, setting a camera callback function, simultaneously reading the size of the camera image acquisition as a judgment basis for whether a template is available, executing a corresponding camera configuration function according to camera configuration parameters, specifically, setting a camera image acquisition frame rate according to an acquisition frame rate variable, setting a camera pixel combination value according to a pixel combination variable, and setting a camera exposure amount according to an exposure variable;
and finally, finishing the confirmation of the camera connection after displaying result information in the interface according to the camera connection result.
The system controls the on-off of the annular light source and the backlight source through the IO signal output by the serial port IO module, and the light source illumination is a necessary condition for measuring the size of a workpiece, so that whether the serial port IO module is normally connected or not needs to be detected when the system is started. The specific steps of the serial port to IO module connection are as follows:
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 opening information, and ending the operation of opening the serial port; if the serial port is not opened, firstly adding a serial port receiving callback function for receiving serial port data, then opening the serial port function to open the serial port, finally returning serial port opening success information, and ending the operation of opening the serial port;
1.1.2) executing a serial port initialization step: step 1.1.1), executing initialization operation of a serial port to IO module, sending a command for reading an address of the serial port to IO module by a serial port, and waiting for data returned to the serial port by the serial port to IO module; if the serial port receives the return data and the data is data specified by a 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 connection of the serial port to IO module fails;
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 connection module is finished after result information is displayed in an interface according to a serial port to IO module connection result.
When the camera is connected and the serial port to IO module is normally connected, the light source detection can be performed by controlling the camera and the serial port to IO module, as shown in fig. 4, the light source detection is specifically processed as follows:
1.2.1) light source detection data acquisition step: firstly, turning on an annular light source through a serial port to IO module, delaying for 200mS to enable the illumination of the annular light source to be stable, and then collecting 1 image in a soft trigger mode through a control camera, and recording the image as bitmap 1; the annular light source is closed through the serial port to IO module, 200mS is delayed and waited, the camera is controlled to collect 1 image under the condition of no illumination, and the image is recorded as bitmap 2; turning on a backlight source through a serial port to IO module, delaying for 200mS to enable the backlight source to be stable in illumination, and collecting 1 image through a control camera, wherein the image is recorded as bitmap 3;
1.2.2) light source detection data processing step: calculating the image gray level mean values of bitmap1 and bitmap2 by calling a gray level mean algorithm, and calculating the ratio of the bitmap1 to the bitmap2 gray level mean values and recording as ratio 1; if the ratio1 is larger than the set threshold, setting the annular light source detection result as that the annular light source is normal, otherwise, setting the annular light source detection result as that the annular light source is abnormal; calculating the image gray level mean value of bitmap3 by calling a gray level mean value algorithm, and then calculating the ratio of the gray level mean values of bitmap3 and bitmap2, and recording as ratio 2; if the ratio2 is larger than the set threshold, setting the backlight source detection result as that the backlight source is normal, otherwise, setting the backlight source detection result as that the backlight source is abnormal;
1.2.3) light source detection data feedback step: and displaying the light source detection result in the interface, and finishing the light source detection.
And finishing the starting initialization process, and if the specified abnormal condition does not exist, entering a template selection interface by the system. And executing a template selection process on the template selection interface. The interface of template selection is shown in fig. 5, and the specific execution steps are shown in fig. 6:
2.1) interface display step: entering a template selection interface, firstly displaying in the interface according to data read by a database, and specifically displaying the following contents:
2.1.1) taking out a template source image, a template name, a measurement template selection and a display template selection in each template information, displaying the template source image, the template name, the measurement template selection and the display template selection in a display list on the left side of an interface, taking the template source image as a template icon, displaying the template name below the icon, selecting a selection frame in front of the template icon by the measurement template selection, selecting the template icon by the display template selection, and selecting only one template by the display template selection; the check frame can be selected more as the multi-template selection basis during multi-template measurement; only one icon can be selected in the template icon selection operation, and the template icon selection operation 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 templates, the rolling pull-down operation can be performed for selecting other templates; always displaying an empty template at the end of the display list, wherein the template icon is a blank picture and is used for directly entering a template making interface to perform related operations;
2.1.2) obtaining a measurement result graph and template source graph measurement information of the selected template according to the template name of the selected template, and displaying the measurement result graph of the selected template and the measurement result data of the template source graph on the right side of the interface; the user can judge whether the template mask manufacture meets the measurement requirements according to the measurement result of the template;
2.1.3) selecting to display the name of the current checking template at the lower left of the interface according to the measuring template in the template information, 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) displaying the system version number at the upper right of the interface;
2.2) a user operation judging step: judging whether the user clicks the template, if so, displaying the template name of the current clicked template at the left lower part of the interface, and when the user clicks the empty template, automatically canceling other clicked templates; judging whether the user cancels the checking of the template, and canceling the display of the template name of the template in the display at the left lower side of the interface; judging whether the information is input in the search template input frame to be modified, if so, searching the flow according to the entered template; 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 the measurement result graph and the measurement result data on the right side of the interface, and displaying the modification time of the currently selected template on the left lower side of the interface;
2.3) entering a measuring step: judging whether a user clicks an 'enter measurement' button, if so, firstly judging whether the user selects an empty template, and if so, popping up an 'enter template making' confirmation box; if the user clicks the confirm button of the confirmation box, popping up an operator password input box, and if the user clicks the cancel button of the confirmation box, re-judging the operation of the user on the interface; if the password input in the 'operator password' input box is the correct operator password, storing the currently selected template and the selected template into a database, wherein the currently selected template is an empty template, and entering a template making interface after starting camera image collection;
2.4) a step of empty template: if the user does not select the empty template, judging whether the number of the checked templates meets the constraint condition, 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, and if the number of the checked templates meets the constraint condition, traversing all the templates according to the template names of the checked templates to acquire template information of the checked templates, wherein the template information comprises a template source graph, a measurement result graph, measurement result data and mask information; judging whether the information of the check templates is complete according to the acquired information, if so, judging whether the template source graph of each check template is the same as the real-time graph acquired by the camera, and if the template source graphs of all the check templates are the same as the real-time graph, storing the currently checked template and the selected template into a database, starting the camera to acquire the graph and entering a template manufacturing interface;
if the number of the checked templates does not accord with the constraint, popping up a prompt box with abnormal number of the checked templates, displaying the current number of the checked templates and the constraint condition in the prompt box, closing the prompt box after the user clicks a 'confirm' button of the prompt box, and judging the operation of the user on the interface again; if the template information is incomplete, popping up a 'checking template' information exception prompt box, prompting the template name with incomplete information and the condition of missing information in the prompt box, closing the prompt box after a user clicks a 'confirm' button of the prompt box, and judging the operation of the user on the interface again; if the template source graph of the check template is different from the real-time graph in size, popping up a check template size abnormity prompt box, prompting the template name of the template different from the real-time graph in the prompt box, closing the prompt box after the user clicks a confirm button of the prompt box, and re-judging the operation of the user on the interface;
2.5) exiting the cancellation step: judging whether a user clicks a 'system exit' button or not, if the user clicks the button, popping up a 'system exit confirmation box', and if the user clicks a determined button in the confirmation box, closing the camera and exiting the system; and if the user clicks a cancel button, the operation of the user on the interface is judged again after the confirmation box is closed.
After entering the template selection interface, the user can input the template name in the template search input box to quickly search the appointed template. As shown in fig. 7, the specific 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 the input content is modified, firstly deleting all displayed templates in the template display list, matching the template names according to the input content, and if the input content is not modified, ending the template search process; the template name matching process compares the input content with all template names made by the current system, if the input content is the same as a sub-character string of the template name starting from the first character or is completely the same as the character string of the template name, the template name is considered to be matched, the template names made in the system can not be renamed, and capital and lower case letters are distinguished;
2.2.2) if the template name is matched, displaying the matched template in the display list, and simultaneously displaying a blank template in the display list for selecting the blank template; if the template name is not matched, ending the template searching process;
2.2.3) after the template names are matched, traversing the matched template names and the matched template names in a double-circulation mode, and judging whether the completely same template names exist or not; if the template with the same name exists, performing checking operation on the template with the same name in a currently displayed template list, and if the template with the same name does not exist, performing name matching on a selected template;
2.2.4) traversing the template names matched with the search templates in a single-cycle mode in the template name matching process, comparing the template names with the selected template names, judging whether the template names which are completely the same exist, if the template names which are completely the same exist, performing template selection operation in the currently displayed template list, and if the template names which are completely the same do not exist, ending the template search; the checking template and the selected template are the templates checked by the user before template searching, wherein only one selected template is selected, and the checking template can be selected more.
The real-time measurement module comprises the following steps of displaying a current measurement workpiece acquisition picture, displaying measurement result data and displaying an interface in a template selection frame area, wherein the specific functions are as follows:
when the 'start measurement' button is not pressed, a workpiece image acquired by a camera in real time and a template source image of a currently selected template are superposed according to a certain proportion and then displayed, and when the 'start measurement' button is pressed to measure a workpiece to be measured in real time, a measurement result image is displayed, and focusing definition and the name of the template matched currently are displayed;
in the real-time measurement process, measuring result data are displayed on the right side of the interface according to the measuring result of the current workpiece, and measuring numbers and measuring results are respectively displayed, wherein the measuring numbers correspond to the numbers displayed on a measuring result graph one by one; if the workpiece has the undetected dimension to be measured, displaying the serial number of the undetected dimension, and displaying the undetected dimension in a result column;
displaying a template selection frame in the middle position below the interface, and when real-time measurement is not performed, enabling a user to select a template in the selection frame; all templates manufactured by the system can be displayed in the selection frame, but no empty template is included, a user can select the template of the workpiece to be detected through the check frame in front of the check template icon in the selection frame, template selection operation can be performed by clicking the template icon, but template selection operation can only be performed in the check template, and the template source image of the selected template is displayed in the image display area after being overlapped with the real-time image. And when entering a real-time measurement interface, carrying out template checking operation according to the checking template variable, and default selecting the template to the template corresponding to the first variable in the checking template array variable. As shown in fig. 8, the interface includes four buttons of "system setup", "temporary creation", "start measurement/stop measurement", and "exit system", and different operations are performed by clicking different buttons.
Specifically, the implementation mode is as follows:
1. for the measured measurement type, a red line and a green letter M are marked with a serial number in the measurement result map, such as a circle M1 shown in fig. 21, based on the measurement data.
2. And for the unmeasured measurement types, performing or processing on the corresponding mask image 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 two mask images are subjected to OR processing corresponding to the gray value of each row and each column of pixel points to obtain a result image, if the two pixel points with the gray values of 255 and 255 are subjected to OR operation, the gray value of the pixel point at the corresponding position of the result image is 255, and similarly, if 255 and 0, the gray value is 255, and if 0 and 0, the gray value is 0.
3. If only one mask image is not detected, the final result image is obtained; and if the number of the mask patterns is more than two, performing the first two mask patterns in sequence to obtain an intermediate result pattern 1, performing the pressing or processing on the intermediate result pattern 1 and a third mask pattern which are not detected to obtain an intermediate result pattern 2, performing the pressing or processing on the intermediate result pattern 2 and a fourth mask pattern which are not detected to obtain an intermediate result pattern 3, and repeating the steps to obtain a final result pattern.
4. Through a double loop, the final result graph and the measurement result graph obtained in the previous step are traversed, and for a pixel with a gray scale value of 255 in the final result graph, the value of BGR of the corresponding pixel in the measurement result graph is set to be different from the measured mark color, in this embodiment, B is set to 0, G is set to 255, and R is set to 255, that is, yellow is displayed, for example, a circle M2 in fig. 21.
As shown in fig. 9, in the parameter setting interface, the user can set these parameters: camera configuration parameters, automatic exposure adjustment parameters, camera calibration configuration parameters, serial port configuration parameters, data processing parameters and automatic focusing parameters.
The camera configuration parameters comprise exposure, acquisition frame rate, processing frame rate and pixel combination;
the exposure amount represents the exposure amount of the camera, the exposure amount 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 images acquired by a camera, the variable is used for setting the image acquisition frame rate when real-time measurement is not carried out, the variable is floating point type data, the value range is 0.1-20, and the unit is Hz; the processing frame rate represents the frame rate of images acquired by a camera, the variable is used for setting the image acquisition frame rate when real-time measurement is carried out, the variable is floating point type 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 collection, the resolution of the collected 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, the lower limit of standard deviation processing data, a standard deviation coefficient, the upper limit of frame rate self-adaption proportion and the number of frame skipping images;
the image number represents the image number counted by the frame rate self-adaption function, the frame rate self-adaption function counts the processing time of a specified continuous image, the variable is used for setting the image number to be processed, the variable is integer data, and the value range is 1-10; the standard deviation processing data lower limit represents the data number lower limit for carrying out standard deviation processing on the processing time of continuous images, when the number of the set images is less 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 elimination coefficient when standard deviation data processing is carried out, the difference value of a data mean value and the coefficient multiplied by the standard deviation is used as a minimum value, the sum of the data mean value and the coefficient multiplied by the standard deviation is used as a maximum value, data between the maximum value and the minimum value is used as reserved data, the variable is floating point type data, and the value range is 0.1-5; the frame rate self-adaptive proportion upper limit represents the ratio upper limit of the image processing time average value and the image acquisition time, when the ratio exceeds (1+ frame rate self-adaptive proportion upper limit/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 number of the frame skipping images represents the number setting of the images subjected to frame skipping, when the image processing time exceeds the number of the collected images set by the variable, algorithm processing is not carried out on the newly collected images, the variable is integer data, and the value range is 1-10;
the automatic exposure adjusting parameters comprise automatic exposure selection, exposure adjusting target gray value, target gray value proportion lower limit, target gray value proportion upper limit and exposure adjusting scale;
the automatic exposure selection indicates whether an automatic exposure adjusting function is called or not, and the automatic exposure selection is set to be in a button selection form; the exposure adjustment target gray value represents the target gray 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 target gray value of automatic exposure adjustment, the lower limit of the target gray value of the exposure adjustment 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 target gray value proportion represents the upper limit of the proportion of the automatic exposure adjustment target gray value, the upper limit of the exposure adjustment target gray value 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 exposure quantity adjusting scale automatic exposure function adjusts the size of one-time exposure quantity, when the exposure is too large, the current exposure quantity minus the variable is the adjusted exposure quantity, when the exposure is too small, the current exposure quantity plus the variable is the adjusted exposure quantity, 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 process is as follows:
flag1 of 1 indicates a decrease in exposure amount, Flag1 of 2 indicates an increase in exposure amount; a Flag2 value of 1 indicates that the current cycle is subjected to the exposure amount reduction treatment, and a Flag2 value of 2 indicates that the current cycle is subjected to the exposure amount increase treatment; initialization: flag1 ═ 1; flag2 ═ 0;
2. extracting calibration board angular point information of a certain frame of calibration image;
3. further extracting sub-pixel corner information;
4. screening out sub-pixel angular points closest to a visual field;
5. respectively calculating the distances from the corner points to four nearest sub-pixel corners on the periphery;
6. comparing the four distances in pairs;
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 or not is judged; if yes, reducing the exposure of the camera, and skipping to the step 2 to execute, wherein Flag2 is 1; if not, increasing the exposure amount and setting Flag2 to be 2, and jumping to the step 2 for execution;
9. if not, further judging whether the first time is smaller than a set threshold value; if not, counting the stored exposure amount to obtain a proper range interval (taking the stored minimum exposure amount value as an interval lower limit value and the stored maximum exposure amount value as an interval upper limit value); if yes, further judge whether Flag2 equals 1; if the camera exposure is increased from the set value, the Flag1 is 2, and the step 2 is skipped to execute; if not, the camera exposure amount is reduced from the set value, Flag1 is equal to 1, and the process skips to step 2.
The camera calibration configuration parameters comprise the number of transverse grids, the number of longitudinal grids and unit length;
setting the number of transverse lattices of the checkerboard when the checkerboard is used for camera calibration, wherein the variable is integer data and the value range is 1-50; the longitudinal grid number is set by using the checkerboard longitudinal grid number when camera calibration is carried out on the checkerboard, the variable is integer data, and the value range is 1-50; setting the length of each checkerboard when the checkerboards are used for camera calibration 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 edge gray level threshold value setting when the focusing definition is judged, the variable is integer data, and the value range is 0-255; when the focusing standard proportion value indicates that the focusing definition is judged, the judgment is that the focusing is clear, when (the average gray value of a white area/(the average gray value of the white area + the average gray value of a black area) × 100) is greater than the variable, the focusing is considered to be clear, the variable is floating point type data, and the value range is 0-99; when the focusing lower limit proportional value indicates that focusing definition judgment is carried out, the judgment is the basis of focusing unsharpness, when (white region average gray value/(white region average gray value + black region average gray value) × 100) is smaller than the variable, the variable is floating point type data, the value range is 0-99, and the value of the variable is required to be smaller than the focusing standard proportional value;
the serial port configuration parameters comprise port numbers and baud rates;
the port number represents a serial port number of 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 processing data;
the upper limit of the number of the processing templates represents the number of the most selected matching templates in the workpiece dimension measurement, the variable is integer data, and the value range is 1-10; processing the number of pictures to represent the number of pictures for calculating an average measured value in the real-time size measurement process of the workpiece, and calculating a size average value when the number of the collected and processed single pictures reaches a set value, wherein the variable is an integer variable and has a value range of 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 size of the image, the variable is floating point type data, and the value range is 0.1-5; the lower limit of the number of standard deviation processed data represents the lower limit of the number of data when standard deviation processing is carried out on the measurement result data of the specified size of the image, the variable is integer data, and the value range is 1-10;
the user authority management comprises the authority setting of an operator, an administrator and a technician;
the authority of the operator is to perform template checking and automatic focusing operations, password modification operations are performed in a parameter setting interface, and if an operator button is clicked, the password modification operations of the operator are performed;
the administrator has the authority to perform parameter setting, template modification, deletion, new construction and template calibration operations, password modification operations are performed in a parameter setting interface, and if an administrator button is clicked, the administrator password modification operations are performed;
the authority of a technician is to perform one-key measurement and continuous measurement version switching, password modification and version switching operations are performed in a parameter setting interface, and if a 'technician' button is clicked, password modification and version selection operations of the technician are performed;
as shown in fig. 10, the specific implementation parameter configuration in the parameter configuration is as follows:
firstly, storing all parameters in the parameter configuration interface into a temporary storage variable; 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 an authority management button is clicked; if the format is correct, judging whether the input data of the input box conforms to the constraint range of the current parameters, if the format is incorrect, popping up a format error prompt box, and returning to the user operation judgment after the user clicks a 'confirm' button; if the input data is in the constraint range of the current parameters, modifying the current modification parameters into input data of an input box, simultaneously setting the states of all the input boxes into inputtable states, and setting all buttons of an interface into enabled states; if the input data is not in the constraint range of the current parameter, setting the unrelated parameter input box into an uninputable state, setting some parameters of the interface as related parameters, automatically focusing a focusing standard proportional value and a focusing lower limit proportional value in the parameters, setting all buttons in the interface into an incapacitating state, popping up a variable modification abnormal box, displaying the current input data and the constraint range in the abnormal box, and returning to the user operation judgment after a user clicks a 'confirm' button;
then, if the user clicks an authority management button, entering an authority management process, and returning to the user operation judgment after the authority management process is executed; if the user clicks a 'return' button, judging whether modified parameters exist or not; if the modified parameters exist, popping up a 'parameter storage' dialog box, and if the modified parameters do not exist, directly closing the interface and exiting the parameter configuration process; judging whether a user clicks a 'confirm' button or not in a 'save parameter' dialog box, if so, saving the modified parameters in a database, and if a user clicks a 'cancel' button, re-assigning all temporary storage parameters to all parameters in the interface to ensure that the parameters are consistent with the parameters entering the interface, and finally; and exiting the parameter configuration.
And after clicking an authority management button in the parameter setting interface, entering an authority management interface, and executing an authority management process in the interface. The authority management process mainly executes password modification of an administrator and a technician and switching of user versions. As shown in fig. 11, the specific process of rights management is as follows:
firstly, judging whether a 'manager password modification' button is clicked, 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, the administrator password input by the user is correct, an administrator password modification input box is popped up to wait for the user to modify the administrator password, if the administrator password input is incorrect, an administrator password input error prompt box is popped up to wait for the user to click a 'confirm' button to close the prompt box, and the user operation is returned to the judgment after the prompt box is closed; after the administrator password modification input box is opened, a user can input a new password, wait for the user to click the 'confirm' button, set the password input by the user newly as the administrator password after clicking the 'confirm' button, and write the administrator password into the database for storage; the password modification operation of the technician is the same as the password modification operation flow of the administrator;
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 the correct technician password is input or not after the user inputs the technician password, if so, popping up a version selection box, wherein the selection box comprises a 'one-key measurement' version selection button and a 'continuous measurement' version selection button, marking the current version, allowing the user to select to switch the version through the button, clicking a 'determination' button in the selection box after the selection is finished, setting the version according to the user selection modification, updating the version information and writing the version information into a database;
and finally, judging whether a 'return' button is clicked, if so, closing the authority management interface, and finishing the authority management.
And clicking a 'template operation' button in a system setting interface, entering a template operation interface, and executing a template operation process in the interface. In the interface, operations such as creating a template, modifying the template, deleting the template, copying the template, searching the template and the like can be performed, all manufactured templates of the current system are displayed on the interface in real time, the template of the workpiece to be measured can be selected in a template list through a check frame, the operation can be performed in a multi-selection mode, and a measurement result graph and measurement result information of the template are displayed by 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 or not, if so, popping up a new template name input box, and waiting for the user to input a 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 already existing in the system, and judging whether the template name newly input by the user already exists; otherwise, judging whether the user clicks a cancel button or not, if so, closing the newly-built template name input box; if the template name exists, popping up an information prompt box of which the template name exists, closing the information prompt box after the user clicks a 'confirm' button, and returning to judge the user operation; if the template does not exist, opening the camera to enable the camera to acquire images in real time, popping up a newly-built template confirmation frame, displaying the images acquired by the camera in real time in the confirmation frame, and enabling a user to confirm the current template through the real-time display of the acquired images; in the newly-built template confirmation frame, if a user clicks a 'confirm' button, recording the name of a template input by the user, closing the newly-built template confirmation frame, and opening a template task editing interface after closing a camera; if the user clicks a 'cancel' button, closing the newly-built template confirmation box and closing the camera, and returning to judge the user operation;
then, area editing of the current newly-built template and the newly-manufactured template to be measured in the template task editing interface is carried out; for example, editing areas such as circle, line, angle, arc and any two elements of the circle, line, angle, arc and the like, and the editing of each measurement task returns the mask map and area information thereof.
Judging whether a user clicks a 'return' button or not on 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 system manufactured template information list, and storing the template information in a template information summary table and a template mask information table in a database; closing the template task editing interface, returning to the template making interface, and updating the display information of the template making interface;
the update information is specifically as follows: firstly, adding a new template in a template display list, and checking and selecting a corresponding template; displaying a measurement result graph of corresponding template information and the measurement result information in an interface, wherein the template measurement result graph can be used for drawing and indicating the result according to the measurement result of the area to be measured; then, checking template information in the prompt message, adding the template, and displaying the selected template information as the name of the template;
then judging whether a user clicks a 'remaking' button or not on a template making interface, and popping up a template to make a confirmation frame again; judging whether a user clicks a 'confirm' button and a 'cancel' button in the confirmation frame, if the 'confirm' button is clicked, closing the template re-manufacturing confirmation frame, opening a template task editing interface and transmitting a currently selected template source image into the interface for template task editing, wherein the template task editing and quitting operation is the same as the operation of a newly-built template, wherein the difference is that the template exists in a template information list which is manufactured by a system, the information of the template in the template information list needs to be updated according to the template information acquired after re-manufacturing, and the database operation is also to update 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 perform 'confirm' button and 'cancel' button operations; if the 'confirm' button is clicked, deleting the template from the template information list which is already made by the system, deleting the template information in the database, and updating the template operation interface display information according to the current checking and the selected template state; if the 'cancel' button is clicked, the template deletion confirmation box is closed and then the user operation is returned to be judged;
judging whether a user right clicks in the template display list to select 'copying', if so, judging whether the user right clicks in the template display list to select 'pasting', if so, popping up a copying template confirmation frame, and waiting for the user to perform 'confirm' button or 'cancel' button operation; if the 'confirm' button is clicked, copying a selected template in the template display list, naming the selected template as a copy of the selected template name, copying template information of the selected template to the copy, adding the copy template to a system manufactured template information list, writing the copy template information into a database, closing a copy template confirmation frame after a copying flag bit is cleared, and simultaneously adding the copy template to the template display list in a template manufacturing interface; if the 'cancel' button is clicked, the copying flag bit is cleared and then a copying template confirmation box is closed, and the operation of the user is returned to be judged;
judging whether a user right-clicks a selected template in a template display list to select renaming, if so, popping up a template name input box, waiting for the user to input the template name, judging whether the user performs a 'confirm' button or a 'cancel' button operation in the input box, if the 'confirm' button is clicked, judging whether the template name input by the user exists in the system manufactured template, and if the 'cancel' button is clicked, closing the template input box and returning to judge the user operation; if the template name does not exist, the template name is modified, the template name in the template information in the database and the information related to the template in the template making interface are updated, then the template name input box is closed, if the template name exists, the information prompt box with the template name existing is popped up, the information prompt box is closed after the user clicks a 'confirm' button, and the operation of the user is returned to be judged;
judging whether a user clicks a 'return measurement' button or not, if so, traversing all the template checking templates in the template display list, and judging the integrity of the template information and the size of the template source graph; if the abnormal condition exists, popping up an abnormal information prompt box according to the abnormal condition, closing the abnormal information prompt box after the user clicks a 'confirm' button, and returning to judge the user operation; if no abnormity exists, storing the information of the current check template and the selected template into a corresponding template of the database, starting a camera for image acquisition and entering a real-time measurement interface;
judging that the user performs template checking, template checking canceling and template searching operations, wherein the processing process is the same as the operation in the template selecting process;
the new template, the deleted template, the remade template, the rename template, the deleted template and the copied template can be operated only by the authority of an administrator, so that an administrator password input frame is popped up before corresponding operation is carried out, and corresponding operation can be carried out only when a correct password is input; and performing administrator authority operation for many times in the template making interface, wherein the administrator password is input once, but only after returning to the real-time measurement interface, the administrator password magnetic energy needs to be input again to perform the administrator authority operation.
As shown in fig. 13, the specific steps of extracting the template information are as follows:
1: carrying out mean value filtering processing on the template source image; the template source image is an image of the front surface and the side surface of the standard part obtained by a camera;
2: carrying out thresholding treatment further; the pixel gradation value thresholded to be greater than the set threshold is set to 0, and otherwise, is set to 255;
3: extracting outer contour points of the standard part in the template source diagram;
4: solving the minimum circumscribed circle of the outer contour to obtain the coordinate and the radius of the circle center;
5: extracting ROI according to the coordinate and radius of the circle center; the ROI is a rectangle, the side length of the ROI is the diameter of the minimum circumscribed circle of the standard part in the template source image, the center of the ROI is the center of the minimum circumscribed circle of the standard part, and the rotation angle of the ROI is zero; the ROI represents a region of interest.
6: extracting hierarchical contour information from the ROI, wherein the hierarchical contour information comprises outer contour information and inner contour information, and the outer contour and the inner contour meet a parent-child hierarchical relationship; if the outer contour and the inner contour meet the hierarchical relationship of father and son, the outer contour is a father contour, and the inner contour is a son contour;
7: solving a minimum external rectangle with a zero rotation angle of the external outline to obtain the length and the width of the rectangle, and judging whether the length or the width of the rectangle is larger than a set value or not;
8: if the length or width of the rectangle is larger than a set value, the standard component is out of bounds, and the step 16 is skipped;
9: if the length or the width of the rectangle is not larger than a set value, solving the mass center and the minimum external rectangle of the outer contour to obtain the center coordinate, the rotation angle, the length and 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 step 16;
11: if the inner contour exists, judging whether only one effective inner contour exists;
12: if only one effective inner contour exists, the center of mass, the coordinate of the minimum circumscribed rectangle center, the rotation angle, the length, the width and the area 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 external rectangle 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 area of the minimum circumscribed rectangle is larger than a set value, the maximum inner contour and the minimum inner contour are indicated; respectively obtaining the center of mass, the coordinate of the minimum circumscribed rectangle center, the rotation angle, the length, the width and the area of the minimum circumscribed rectangle center, and jumping to the step 16;
15: if the difference value between the maximum value and the minimum value of the area of the minimum circumscribed rectangle is less than or equal to a set value, indicating that the standard part has a plurality of effective maximum inner contours, randomly selecting one of the effective maximum inner contours to obtain the center of mass, the center coordinate of the minimum circumscribed rectangle, the rotation angle, the length, the width and the area, and skipping to the step 16;
16: and ending the template information extraction process.
The automatic focusing module is used for continuously measuring the definition of a real-time image acquired by a camera; prompting whether the user is clear or not through the definition, and if not, enabling the user to adjust the height of the camera until the image is clear;
the real-time image of the camera is displayed on the left side of the interface of the automatic focusing module, and the area image framed and selected by a rectangular frame in the real-time image is displayed on the right side of the interface of the automatic focusing module; the progress bar of definition is shown to right image top, and the setting of parameter is carried out to right image below, and wherein the parameter of focusing includes: an edge detection threshold, a focusing standard proportion value and a focusing lower limit proportion threshold; the edge detection threshold is a threshold of 0-255 for black and white edge region segmentation, and is set as 100 by default; the focusing standard proportion threshold value is that the proportion of the set black and white area is 0-100, and the default is 90; the focusing lower limit proportion threshold is that the focusing unclear alarm threshold is 0-100, and the default is 70;
as shown in fig. 14, the specific process of the auto-focusing module is as follows:
firstly, judging whether a 'start focusing' button is clicked, if so, judging whether focusing area editing is performed on a real-time display image, if so, transmitting an X coordinate and a Y coordinate of the upper left corner of an editing rectangular frame, a length, a width, a real-time image and an edge detection threshold value to an algorithm, and executing an area definition calculation process; calculating a flow according to the definition of the region to obtain a definition evaluation value of the region, 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 acquired in real time is larger than the focusing standard proportion value, displaying the proportion value by the progress bar, and displaying green color to show that the definition of the current area is good without adjusting 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, 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, the definition of the current area is poor, the camera height adjustment is required to adjust the image definition, and otherwise, the accurate size measurement cannot be carried out;
the execution process of the regional definition calculation process judges whether a flag bit for stopping the definition calculation process is set or not in real time, if so, the execution of the process is stopped, and the operation of a user is returned to be judged;
after clicking the 'start focusing' button, starting to execute the definition calculation process, wherein the 'start focusing' button is changed into a 'stop focusing' button, and the 'stop focusing' button can be clicked by a user at the moment, so that a definition calculation process stop mark is set;
judging whether a user selects a focusing area on a real-time image display frame, if so, saving the coordinates of the upper left corner of the frame selection area and the length and width of the frame selection area; judging whether a user clicks an 'acquire height' button, if so, acquiring camera height information by controlling a height sensor, and then searching a table according to the camera height information to acquire camera calibration parameters to be used as parameters for real-time size measurement; and judging whether the user clicks a 'return to measurement' button, if so, closing the auxiliary focusing interface, and returning to the real-time measurement interface.
As shown in fig. 15, the real-time dimension measurement of a single image is as follows:
firstly, carrying out pixel combination on a to-be-measured image, and then carrying out-of-bound detection on the to-be-measured image after the pixel combination; if the detection result is out of bounds, traversing all the selected template names, and judging whether temporary template names exist or not; if no temporary template name exists, outputting the object to be measured out of bounds, and ending the real-time measurement process of a single image; if the name of the temporary template exists, pixel combination is carried out on the temporary template source image, then differential processing is carried out on the image to be measured after the pixel combination and the temporary template source image after the pixel combination, if the image to be measured and the temporary template source image are not consistent, the output of the object to be measured is out of bounds, and the real-time measurement process of a single image is finished; if the template source images are consistent with the template source images, performing the rotational translation of the current frame image according to the rotational translation result of the temporary template source image;
then judging whether the automatic focusing flag bit is effective, if so, calling the 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 the relevant measurement type according to the current frame mask information; if the mask information is invalid, directly carrying out size measurement of the relevant measurement type according to the mask information of the current frame;
if the detection result is that the image is not out of range, pixel combination is carried out on the previous frame of image to be detected, then inter-frame image comparison is carried out, namely inter-frame differential processing is carried out on the image to be detected after the pixel combination and the previous frame of image to be detected after the pixel combination, if the two are consistent, the object to be detected is not moved, and then the rotation translation of the current frame image is directly carried out according to the rotation translation result of the previous frame; judging whether the automatic focusing flag bit is effective, if so, calling the 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 the relevant measurement type according to the previous frame of mask information; if the mask is invalid, directly carrying out size measurement of a related measurement type according to the mask information of the previous frame; if the two are not consistent, the object to be detected is indicated to move, then all the checked template information is traversed, wherein the template information corresponding to the template number which is preferentially matched is firstly carried out, the corresponding template source images are subjected to pixel combination, the image to be detected and the template source images after the pixel combination are subjected to differential processing, if the two are consistent, the traversal is terminated, and the rotation translation of the current frame image is directly carried out according to the rotation translation result of the current template source image. Judging whether the automatic focusing flag bit is effective, if so, calling the 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 the relevant measurement type according to the current frame mask information; if the mask information is invalid, directly carrying out size measurement of the relevant measurement type according to the mask information of the current frame; if the two are not consistent, reducing the characteristic information of the corresponding template source image according to the pixel merging coefficient, then executing the matching process of the object to be tested, if the object to be tested is successfully matched, terminating traversal, and converting the translation quantity of the object to be tested after the pixels are merged, which is obtained in the matching process of the object to be tested, into the translation quantity without the pixels being merged according to the pixel merging coefficient; judging whether the automatic focusing flag bit is effective, if so, calling the 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 the relevant measurement type according to the current frame mask information; if the mask information is invalid, directly carrying out size measurement of the relevant measurement type according to the mask information of the current frame; if the object to be detected is not successfully matched, making a vertical axis through the center of the minimum circumscribed circle of the object to be detected, horizontally mirroring the image of the object to be detected by the axis to obtain a horizontal mirror image, taking the horizontal mirror image as an input parameter, and skipping to the execution of the matching process of the object to be detected; if the matching is successful, prompting the user to put the object to be tested reversely, and ending the process; if the matching is not successful, outputting that the object to be measured is not successfully matched, and finishing the real-time measurement of a single image;
the pixel merging is to merge every four adjacent pixels in each row of pixels in the image into one pixel in sequence, the gray value of the pixel is averaged, after all rows are processed, every column of pixels is merged into one pixel in sequence by every four adjacent pixels, and the gray value of the pixel is averaged.
The out-of-range detection process is concretely as follows:
1: filtering the image to be detected after the pixels are combined; removing high-frequency noise points through median filtering processing, and keeping outline edge information, wherein a median filtering window in the embodiment is 9 pixels by 9 pixels;
2: carrying out grey threshold value binarization processing on the filtered image; wherein the gray value of the pixel greater than the set threshold is set to 255, otherwise, it is set to 0; in the embodiment, the set threshold value is 180;
3: searching all closed-loop contours in the image; the closed-loop contour means that the distance between any two adjacent contour points in the contour is smaller than a set value, and the set value of the embodiment is 2 pixels;
4: solving the maximum closed loop contour perimeter, and judging whether the perimeter meets the setting condition; setting conditions 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 perimeter meets the condition, the object to be detected is not out of bounds, and the process is ended; if the perimeter does not meet the condition, the object to be detected is out of bounds, and the process is ended;
as shown in fig. 16, the matching process of the analyte is as follows:
1: carrying out mean value filtering processing on the image to be detected after the pixels are combined; the mean filtering window of the embodiment is 3 pixels by 3 pixels;
2: performing thresholding, and setting the gray value of the pixel larger than the set threshold value to be 0, otherwise, to be 255, wherein the set threshold value is 100 in the embodiment;
3: extracting outline information of a to-be-detected hierarchical part; the contour information of the to-be-detected hierarchical part comprises outer contour information and inner contour information of the to-be-detected hierarchical part, and the outer contour and the inner contour meet the parent-child hierarchical relationship, wherein the outer contour is a parent contour, and the inner contour is a child contour;
4: judging whether the absolute value of the difference between the minimum circumscribed rectangular area of the outer contour to be detected and the minimum circumscribed rectangular area of the outer contour of the template source diagram is smaller than a set value or not; the value range of the set value is 15% of the minimum circumscribed rectangle area of the outer contour of the template source diagram;
5: if the absolute value of the difference between the minimum circumscribed rectangular area of the outer contour to be detected and the minimum circumscribed rectangular area of the outer contour of the template source diagram is larger than or equal to a set value, the object is not successfully matched, and the process is ended;
6: if the absolute value of the difference between the minimum circumscribed rectangle area of the outer contour to be detected and the minimum circumscribed rectangle area of the outer contour of the template source diagram is smaller than the set value, judging whether the absolute value of the ratio difference between the length-width ratio of the minimum circumscribed rectangle of the outer contour of the part to be detected and the length-width ratio of the minimum circumscribed rectangle of the outer contour of the template source diagram is smaller than the set value or not; the value range of the set value is 10% of the length-width ratio of the minimum circumscribed rectangle of the outer contour of the template source diagram;
7: if the absolute value of the length-width ratio difference between the minimum external rectangle length-width ratio of the external outline to be detected and the minimum external rectangle length-width ratio of the external 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 execute;
8: if the absolute value of the length-width ratio difference between the minimum circumscribed rectangle of the outer contour to be detected and the length-width ratio difference between the minimum circumscribed rectangle of the outer contour of the template source diagram is smaller than a set value, solving a minimum circumscribed circle of the outer contour, and taking the circle center of the minimum circumscribed circle as a rotation center;
9: judging whether the distance between the centroid of the outer contour of the template source image and the center of the minimum circumscribed rectangle of the outer contour of the template source image is larger than a set value or not; the setting value in this embodiment is 20 pixels;
10: if the distance between the centroid of the outer contour of the template source image and the center of the minimum circumscribed rectangle of the outer contour of the template source image is smaller than or equal to a set value, jumping to step 18;
11: if the distance between the centroid of the outer contour of the template source image and the center of the minimum circumscribed rectangle of the outer contour of the template source image is larger than a set value, judging whether the absolute value of the difference between the distance between the centroid of the outer contour to be detected and the center of the minimum circumscribed rectangle of the outer contour of the template source image and the length-width ratio of the centroid of the outer contour to the minimum circumscribed rectangle of the outer contour of the template source image is smaller than the set value or not; the value range of the set value 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 distance between the center of the outer contour of the object to be detected and the center of the minimum circumscribed rectangle of the object to be detected and the length-width ratio between the center of the outer contour of the template source image and the minimum circumscribed rectangle of the outer contour of the template source image is larger than or equal to a set value, jumping to step 18;
13: if the absolute value of the difference between the distance between the center of mass of the outer contour to be detected and the minimum circumscribed rectangle center of the outer contour and the length-width ratio between the center of mass of the outer contour of the template source image and the minimum circumscribed rectangle length-width ratio of the outer contour of the template source image is smaller than a set value, calculating the rotation angle of the part to be detected relative to the template source image;
14: combining the central coordinates and the angle information of the template source image, translating and rotating the image to be measured, namely extracting a region of interest (ROI) of the object to be measured in the image to be measured; then, newly building a blank image equal to the image to be detected, translating the object to be detected to the center of the blank image, and rotating the object to be detected to the same angle of the template source image; in the embodiment, the ROI is a rectangle, the side length of the ROI is the diameter of the minimum circumscribed circle of the template source image, and the center of the ROI is the center of the minimum circumscribed circle of the object to be detected;
15: and judging whether the vector angle from the centroid of the outer contour to be detected to the minimum circumscribed rectangle center of the object to be detected is smaller than a set value or not by comparing the vector angle from the centroid of the outer contour of the template source image to the minimum circumscribed rectangle center of the template source image, wherein the set value is 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 finished;
17: if the difference value of the vector angles in the step 15 is larger than or equal to the set value, entering a step 18;
18: judging whether an inner contour exists according to the area of the minimum circumscribed rectangle of the maximum inner contour of the template source image; if not, the object matching is successful, the rotation angle of the object to be detected relative to the template source image is calculated, the rotating object is translated by combining the central coordinate and the angle information of the template source image, and the process is ended; if yes, judging whether the template source graph only has an effective maximum inner contour;
19: if the template source image only has one effective maximum inner contour, performing effective inner contour matching; the effective inner contour matching comprises the steps of judging whether the minimum external rectangle area of the maximum inner contour of a part to be detected is matched with the minimum external rectangle area of the maximum inner contour of the template source image, further sequentially judging whether the length-width ratio of the minimum external rectangle of the maximum inner contour is matched with the minimum external rectangle area of the maximum inner contour, whether the distance between the centers of the minimum external rectangle of the outer contour and the maximum inner contour is matched with the minimum external rectangle area of the template source image, calculating the rotation angle of the part to be detected relative to the template source image, rotating and translating the object by combining the central coordinate and the angle information of the template source image, and detecting whether the matching is successful or not by judging whether the vector angles of the minimum external rectangle centers of the outer contour and the maximum inner contour are matched with each other or not;
20: if the template source image does not meet the condition that only one effective maximum inner contour exists, judging whether the template source image has a plurality of maximum inner contours or both maximum inner contours and minimum outer contours;
21: if the template source image has a plurality of maximum inner contours, traversing all the inner contours in the part to be detected, performing effective inner contour matching on each inner contour, judging whether at least one inner contour is successfully matched, if so, successfully matching the object, and ending the process; if not, the object is not successfully matched, and the process is ended;
22: if the template source image has the maximum inner contour and the minimum outer contour; firstly, carrying out effective inner contour matching on the maximum inner contour; if the maximum inner contour 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 contour 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, the continuous measurement of real-time dimensions is performed in such a way that the number of check templates is smaller than the system set threshold variable and the camera calibration result data exists;
the control state settings in the interface performing continuous measurement of real-time dimensions are as follows: the template graph display is not overlapped in the real-time graph display; displaying and emptying the size measurement result data; the template display frame can only be rolled to check all templates made by the system and the currently selected template to be matched; the "system setup", "temporary make", and "quit system" buttons are disabled;
the specific execution flow of the real-time dimension of the continuous measurement version is as follows:
firstly, judging whether an image is acquired, if so, transmitting template information and a real-time image to a single image size measurement algorithm, and executing a single image real-time size measurement process; the parameters transmitted to the single image size measurement algorithm comprise an execution automatic focusing flag bit, an image acquired by a previous frame of camera, an image acquired by a current frame of camera, all checked template information, camera calibration parameters and a priority matching template number;
executing an automatic focusing flag bit, and determining whether the calculation of the definition evaluation function of the designated mask area is needed in the size measurement algorithm according to the flag bit; the previous frame of camera acquires an image, and is used for rapidly judging whether the workpiece moves or not after performing interframe difference processing on the image and the current frame of image; the frame camera collects images as images for size measurement; all the selected template information comprises a template source image, template source image ROI information, template source image characteristic information, the number of inner contours of the template source image, a template mask image, template mask characteristic information and template mask accurate characteristic information; preferentially matching template numbers, outputting the positions of successfully matched template pictures in a checking template list after the size measurement algorithm is executed when the real-time pictures are successfully matched with the template pictures, taking the position sequence as the preferentially matching template numbers, and transmitting the setting value to the size measurement algorithm when the camera acquires the images next time;
and then after executing the real-time size measurement process of the single image, judging whether the workpiece is out of bounds or not according to the return value of the single image, if not, judging whether the current measured workpiece is successfully matched with the template in the selected template, and if so, executing the following operations: firstly, storing the position number in the selected template sequence of the successfully matched template, and taking the position number as a prior matched template of the next acquired image for matching; if the algorithm executes definition calculation according to the automatic focusing marker bit, the automatic focusing marker bit is set according to the definition value returned by the algorithm and the definition calculation condition executed by the previous image; when the returned definition value is smaller than the focusing standard proportion value set by the system, setting an automatic focusing flag bit, executing definition calculation when an image execution algorithm is acquired next time, if the returned definition value is larger than the focusing standard proportion value set by the system, judging whether the number of acquired images is larger than the number of images at the definition calculation interval set by the system, if so, setting the automatic focusing flag bit, executing definition calculation when the image execution algorithm is acquired next time, otherwise, resetting the automatic focusing flag bit; finally, the size measurement result of the time is saved, and the specific numerical values of each measurement type are stored;
judging whether the number of the matched images reaches a set threshold value, if so, calculating the standard deviation of each measured mask type data, eliminating the standard deviation of the data in each mask type data array according to a system set standard deviation system, calculating the average value of the eliminated data, and numbering and displaying the obtained average value on a real-time measurement interface; if not, directly averaging the data of each measured mask type, and then displaying the serial number on the interface.
The template task interface is used for receiving a template selection interface, a template making interface or a real-time measurement interface, and a template selection interface, a template making interface or a real-time measurement interface is used for selecting a template; the temporary manufacturing can generate a temporary template, the template selection interface, the template manufacturing interface and the template display list of the real-time measurement interface are used for displaying, selecting and checking, and the original temporary template can be replaced after the temporary template is manufactured again, so that the system only has one temporary template at most; the user can rapidly manufacture the temporary template through the temporary measurement function, and then rapidly measure the temporary workpiece.
In the real-time measurement process, executing automatic frame skipping and frame rate self-adaptive flow according to the execution time of a size measurement algorithm and the time of a camera for acquiring an image frame rate; by executing the flow, the reasonable configuration of the image acquisition speed and the execution time of the size measurement algorithm is realized, and the system operation breakdown caused by too long execution time of the algorithm is prevented;
the automatic frame skipping aims at the processing of a single image, and when the processing time of the single image exceeds a system constraint condition, 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 solved;
the frame rate self-adaptation aims at the processing of a plurality of images, the average time of the processing of the plurality of images is calculated and 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 execution flow of automatic frame skipping and frame rate adaptation is as follows:
firstly, frame skipping processing flow is carried out: judging whether the camera collects images, if so, judging whether the number of the images collected by current measurement is greater than 1, if so, judging whether a specified image size measurement thread before the current image is finished, wherein the specified basis of the specified image thread is as follows: when a first image is acquired in the current measurement, designating the first image as a designated image; if not, the number of the images passing through the size measurement thread is added with 1, and meanwhile, the number of the images passing through the size measurement thread which is not processed between the designated image and the current image is also added with 1; if the processing is finished, selecting the image corresponding to the unprocessed size measurement thread established earliest between the current image and the designated image as the designated image, and adding 1 to the number of the images passing through all the processing threads between the designated image and the current image; judging whether the number of images passing through a designated image size measurement thread reaches a set threshold, if so, judging whether the execution time of the thread reaches the set threshold, if so, destroying the thread, and selecting the image corresponding to the unprocessed size measurement thread established earliest between the current image and the designated image as the designated image;
frame rate adaptive flow: firstly, after a camera collects an image and carries out frame skipping processing, a single image real-time size measurement process is executed on a current image creating thread; judging whether the size measurement process of a single image is finished, if so, judging whether the matching of the image template is successful, and if not, returning to judge whether the image is acquired; the purpose of judging the successful template matching is that the frame rate self-adaptation only carries out time statistics on images successfully matched with the templates, and because the running time of the successfully matched templates in the image processing algorithm is longer and can represent the time of the normal image processing algorithm, the time is selected as the adjustment basis of the frame rate self-adaptation;
if the template matching is successful, the running time of the image size measurement process is saved, whether the number of images successfully matched with the template is larger than a set threshold value or not is judged, if so, after standard deviation elimination processing is carried out on all processing time of the images successfully matched currently, 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;
and in the self-adaptive process of automatic frame skipping and the frame rate, judging whether a user clicks a 'stop measuring' button in real time, if so, clearing statistics such as the number of images, time and the like and then finishing the self-adaptive module of the automatic frame skipping and the frame rate.
Specifically, as shown in fig. 19 and 20, the template calibration process includes the following steps:
step 1: placing calibration plates at different positions in a view field, and respectively collecting calibration plate images;
step 2: after the calibration board image acquisition is finished, the camera acquisition is closed, and a calibration algorithm is called to perform image calibration processing;
and step 3: after the calibration processing is finished, updating the calibration parameters to the latest calibration parameters;
and 4, step 4: exiting the template calibration interface;
the image calibration processing in the step 2 comprises the steps of obtaining a camera distortion parameter, a camera internal parameter matrix and obtaining a magnification; the method for acquiring the distortion parameters and the internal reference matrix of the camera through a Zhang Zhengyou distortion correction algorithm comprises the following steps:
step 1.1: reading calibration image data and calibration parameters of the adopted images, wherein the number of transverse points in the calibration parameters refers to the number of rows of a checkerboard of the calibration plate, the number of longitudinal points refers to the number of columns of the checkerboard, and the unit interval refers to the real physical size of each small grid of the checkerboard;
step 1.2: extracting angular point 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 an angular point on a calibration plate;
step 1.5: calibrating the camera by using the extracted sub-pixel angular point information and the spatial three-dimensional coordinate system information of the angular point on the calibration plate to obtain distortion parameters participating in each frame of image in the camera and a rotation vector and a translation vector of each frame of image;
step 1.6: evaluating the calibration result; firstly, calibrating by a camera to obtain distortion parameters, carrying out re-projection calculation on spatial three-dimensional coordinate points of each frame of image to obtain new projection points, calculating the error between the new projection points and the old projection points, if the error is less than 0.15 pixel of a set value, meeting the requirements, storing calibration results and the distortion parameters, and ending the process; if the error is more than or equal to 0.15 pixel of the set value, the process is not qualified, and the process is ended and the calibration image is prompted to be collected again;
the process for obtaining the magnification comprises the following steps:
step 2.1: correcting a certain collected frame of calibration image by using a calibration result;
step 2.2: extracting corner information from the corrected image;
step 2.3: extracting sub-pixel angular point information;
step 2.4: traversing the number of the rows of the corrected image, and calculating and storing the distance from the first row of each row to the first last row;
step 2.5: sorting the distances stored in each column;
step 2.6: selecting a plurality of columns with the middle column as the center, and accumulating the saved distances of the selected columns;
step 2.7: according to the accumulated value, calculating an average value;
step 2.8: solving the magnification according to the mean value, the number of columns and the physical size, wherein the calculation formula of the magnification is mean value/(number of columns-2)/physical size;
step 2.9: the flow is ended.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, several modifications and decorations can be made without departing from the spirit of the present invention, and these modifications and decorations should also be regarded as being within the scope of the present invention.

Claims (7)

1. A real-time measurement method of a dimension measurement instrument is characterized by comprising the following steps:
1) an initialization step: starting the measuring instrument, starting the operation software, entering a starting initialization interface, entering a template selection interface, and displaying data read from a database in the interface; when entering a template selection interface, selecting 'entering measurement' to enter a real-time measurement interface;
2) a real-time measurement step: when the real-time measurement module in the real-time measurement interface is executed, the real-time measurement module comprises the real-time size measurement of a single image, and the specific processing is as follows:
carrying out pixel combination on the image to be measured, and carrying out-of-bound detection on the image to be measured after the pixel combination; then judging whether the automatic focusing flag bit is effective, if so, calling the 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 the relevant measurement type according to the current frame mask information; if the mask information is invalid, directly carrying out size measurement of the relevant measurement type according to the mask information of the current frame;
if the out-of-range detection indicates that the out-of-range detection does not exist, pixel combination is carried out on the previous frame of image to be measured, inter-frame image comparison is carried out, whether an automatic focusing flag bit is effective or not is judged, if yes, the measurement type used for automatic focusing area selection is called, an automatic focusing definition evaluation function is measured in real time, a definition value is returned, and size measurement of the relevant measurement type is carried out according to the previous frame of mask information; if the frame mask information is invalid, directly carrying out size measurement of the related measurement type according to the previous frame mask information; if the two are inconsistent, the object to be detected is indicated to have moved, then all the checked template information is traversed, wherein the template information corresponding to the prior matching template number is firstly carried out, the corresponding template source images are subjected to pixel combination, the image to be detected and the template source images after the pixel combination are subjected to differential processing, if the two are consistent, the traversal is terminated, and the rotation translation of the current frame image is directly carried out according to the rotation translation result of the current template source image;
3) matching: executing the matching process of the object to be tested, if the object to be tested is not successfully matched, making a vertical axis through the center of the minimum circumscribed circle of the object to be tested, horizontally mirroring the image of the object to be tested by the axis to obtain a horizontal mirror image, using the horizontal mirror image as an input parameter, and jumping to the matching process of the object to be tested to execute; if the matching is successful, prompting the user to put the object to be tested reversely, and ending the process; if the matching is not successful, outputting that the object to be measured is not successfully matched, and finishing the real-time measurement of the single image.
2. The real-time measurement method of the dimension measurement instrument according to claim 1, wherein the out-of-bounds detection in the step 2.1) is performed, if the detection result is out-of-bounds, all the checked template names are traversed, and whether the temporary template name exists is judged; if no temporary template name exists, outputting the object to be measured out of bounds, and ending the real-time measurement process of a single image; if the name of the temporary template exists, pixel combination is carried out on the temporary template source image, then differential processing is carried out on the image to be measured after the pixel combination and the temporary template source image after the pixel combination, if the image to be measured and the temporary template source image are not consistent, the output of the object to be measured is out of bounds, and the real-time measurement process of a single image is finished; and if the two images are consistent, performing the rotational translation of the current frame image according to the rotational translation result of the temporary template source image.
3. The real-time measurement method of a dimension measurement instrument according to claim 1, wherein in step 2.1), if the two are not identical, the corresponding template source map feature information is reduced according to the pixel combination coefficient, then the object matching process is performed, if the object matching is successful, the traversal is terminated, and the translation amount of the object to be measured after the pixel combination obtained in the object matching process is converted into the translation amount without the pixel combination according to the pixel combination coefficient.
4. The method as claimed in claim 1, wherein the pixel combination is to combine each row of pixels in the image into a pixel in turn by every four adjacent pixels, and the gray value is averaged, and after all rows are processed, each row of pixels is combined into a pixel in turn by every four adjacent pixels, and the gray value is averaged.
5. The real-time measurement method of the dimension measurement instrument according to claim 1, wherein the real-time measurement module in the real-time measurement interface includes a current measurement workpiece acquisition picture display, a measurement result data display and a template selection frame area, and the interface display and the specific functions are as follows:
when the 'start measurement' button is not pressed, a workpiece image acquired by a camera in real time and a template source image of a currently selected template are superposed according to a certain proportion and then displayed, and when the 'start measurement' button is pressed to measure a workpiece to be measured in real time, a measurement result image is displayed, and focusing definition and the name of the template matched currently are displayed;
in the real-time measurement process, measuring result data are displayed on the right side of the interface according to the measuring result of the current workpiece, and measuring numbers and measuring results are respectively displayed, wherein the measuring numbers correspond to the numbers displayed on a measuring result graph one by one; if the workpiece has the undetected dimension to be measured, displaying the serial number of the undetected dimension, and displaying the undetected dimension in a result column;
displaying a template selection frame in the middle position below the interface, and when real-time measurement is not performed, enabling a user to select a template in the selection frame; all templates manufactured by the system can be displayed in the selection frame, but no empty template is included, a user can select the template of the workpiece to be detected through the check frame in front of the check template icon in the selection frame, template selection operation can be performed by clicking the template icon, but template selection operation can only be performed in the check template, and the template source image of the selected template is displayed in the image display area after being overlapped with the real-time image. And when entering a real-time measurement interface, carrying out template checking operation according to the checking template variable, and default selecting the template to the template corresponding to the first variable in the checking template array variable.
6. The real-time measurement method of the dimension measurement instrument according to claim 1, wherein the real-time measurement module further comprises a temporary measurement module, a user can directly enter the template task interface to perform template fabrication by clicking a "temporary fabrication" button of the real-time measurement interface, a temporary template is generated after fabrication is completed, and dimension measurement of the selected temporary template is performed after the template selection interface, the template fabrication interface or the real-time measurement interface selects the temporary template; the temporary manufacturing can generate a temporary template, the template selection interface, the template manufacturing interface and the template display list of the real-time measurement interface are used for displaying, selecting and checking, and the original temporary template can be replaced after the temporary template is manufactured again, so that the system only has one temporary template at most; the user can rapidly manufacture the temporary template through the temporary measurement function, and then rapidly measure the temporary workpiece.
7. The real-time measurement method of the dimension measurement instrument as claimed in claim 1, wherein in the real-time measurement process, an automatic frame skipping and frame rate adaptive process is performed according to the execution time of the dimension measurement algorithm and the frame rate time of the image collected by the camera; by executing the flow, the image acquisition speed and the execution time of the size measurement algorithm are reasonably configured, and the system operation breakdown caused by too long execution time of the algorithm is prevented.
CN202110356816.8A 2021-04-01 2021-04-01 Real-time measurement method of dimension measurement instrument Pending CN113624129A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110356816.8A CN113624129A (en) 2021-04-01 2021-04-01 Real-time measurement method of dimension measurement instrument

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110356816.8A CN113624129A (en) 2021-04-01 2021-04-01 Real-time measurement method of dimension measurement instrument

Publications (1)

Publication Number Publication Date
CN113624129A true CN113624129A (en) 2021-11-09

Family

ID=78377877

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110356816.8A Pending CN113624129A (en) 2021-04-01 2021-04-01 Real-time measurement method of dimension measurement instrument

Country Status (1)

Country Link
CN (1) CN113624129A (en)

Cited By (1)

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

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6363167B1 (en) * 1998-03-03 2002-03-26 Kabushiki Kaisha Toshiba Method for measuring size of fine pattern
US20140193039A1 (en) * 2013-01-07 2014-07-10 Ronald M. Wexler System and method of measuring distances related to an object
CN110021006A (en) * 2018-09-06 2019-07-16 浙江大学台州研究院 A kind of device and method whether detection automobile parts are installed
CN112284250A (en) * 2020-10-15 2021-01-29 浙江大学台州研究院 Dimension measurement scoring system and measurement method based on machine vision

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6363167B1 (en) * 1998-03-03 2002-03-26 Kabushiki Kaisha Toshiba Method for measuring size of fine pattern
US20140193039A1 (en) * 2013-01-07 2014-07-10 Ronald M. Wexler System and method of measuring distances related to an object
CN110021006A (en) * 2018-09-06 2019-07-16 浙江大学台州研究院 A kind of device and method whether detection automobile parts are installed
CN112284250A (en) * 2020-10-15 2021-01-29 浙江大学台州研究院 Dimension measurement scoring system and measurement method based on machine vision

Cited By (1)

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

Similar Documents

Publication Publication Date Title
JP5228490B2 (en) Defect inspection equipment that performs defect inspection by image analysis
TWI519778B (en) A method for inspecting line width and/or positional errors of a pattern
CN111025701B (en) Curved surface liquid crystal screen detection method
JP7005930B2 (en) Sheet inspection equipment and inspection system
JP2011020455A (en) Method for automatically determining print quality of image printed on deformable carrier
JP2000057349A (en) Method for sorting defect, device therefor and method for generating data for instruction
CN113639630A (en) Dimension measuring instrument system based on multi-template matching and automatic focusing functions
CN110838149B (en) Camera light source automatic configuration method and system
JP2007285754A (en) Flaw detection method and flaw detector
JP2016145887A (en) Inspection device and method
CN113467664A (en) Size measuring instrument using method based on template matching
CN113624129A (en) Real-time measurement method of dimension measurement instrument
CN113645398A (en) Dimension measuring instrument system based on automatic focusing function
JPH08181178A (en) Wafer external appearance inspecting equipment and wafer external appearance inspecting method
JP4987323B2 (en) Color filter defect correcting apparatus and color filter defect correcting method
JP4880380B2 (en) Substrate defect correcting apparatus and substrate defect correcting method
JP3826146B2 (en) Wafer appearance inspection apparatus and wafer appearance inspection method
JP2016035542A (en) Position measurement method, method for creating map of positional deviation, and inspection system
JP4975472B2 (en) Color filter defect correcting apparatus and color filter defect correcting method
JP7380332B2 (en) Image processing device, control method and program for the image processing device
JPH01307645A (en) Inspecting method for sample
JP2005140655A (en) Method of detecting stain flaw, and stain flaw detector
JPH08159984A (en) Pattern irregularity inspecting apparatus
JPH06229737A (en) Method for inspecting surface defect of periodic pattern
JPH10300682A (en) Image-comparing device

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