An Automatic Adjustment Method for Gain Value and Exposure Value of an Industrial Camera
By adopting screening strategies for a variety of image quality evaluation indicators in industrial cameras, and automatically adjusting exposure and gain, the problems of complex methods and single evaluation indicators in the prior art are solved, and image quality and stability are improved.
Patent Information
- Application Number
- CN202211375802.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-04
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2042-11-04
AI Technical Summary
When the prior art automatically adjusts exposure and gain in industrial cameras, the method is complex and the evaluation indicators are single, making it difficult to obtain the best parameters in complex environments, resulting in poor image quality.
Design an industrial camera parameter screening strategy based on multiple image quality evaluation indicators. Through three levels of screening, the best exposure and gain values are obtained, and the parameters of industrial cameras are self-adjusted.
It realizes high contrast, good clarity and high stability of images collected by industrial cameras, and is suitable for normal use in complex environments.
Smart Images

Figure CN115714858B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of parameter setting, and particularly to a method for automatically adjusting the gain value and exposure value of an industrial camera. Background Art
[0002] In the field of visual inspection, the quality of the imaging directly affects the accuracy of the inspection results. In order to obtain an ideal image, it is usually necessary to first adjust the parameters of the industrial camera: gain and exposure. If the parameter settings are unreasonable, the image will have poor brightness contrast and lack of details. Generally, the gain adjustment usually relies on preset empirical values and is only adjusted when the signal is weak but the exposure time does not want to be increased. Therefore, most of the existing parameter automatic adjustment methods only target the exposure parameter, and the method for jointly adjusting exposure and gain is relatively lacking. When adjusting both at the same time, the gain value is usually fixed first, and an optimal exposure value is found. The adjustment range of the exposure value is determined by selecting adjacent values of the optimal exposure value. The gain value is changed within the adjustment range to adjust a set of parameter data. During this adjustment process, the quality of the industrial camera parameters is easily interfered by subjective factors. At the same time, since it is only adjusted within the adjacent interval range of the optimal exposure value, it is easy to fall into a local optimal solution and unable to adjust the best parameters. After searching the patent literature, CN113992863A provides an automatic exposure method, device, electronic device and computer-readable storage medium. Although it adjusts exposure and gain at the same time, its adjustment process is complex and requires judging various situations and selecting a suitable mode to adjust the gain or exposure. At the same time, the evaluation index for evaluating the quality of the exposure parameter adjustment is too single, and only the brightness average value is used as the evaluation parameter, lacking evaluation dimensions. In addition, the problem of a single evaluation index is also reflected in the patent literature CN113382143A. This literature proposes an automatic exposure adjustment method for an industrial camera used in the binocular vision of a fire-fighting robot. When evaluating the exposure value, it also only evaluates the adjustment quality based on the image gray information (average brightness). The parameters adjusted in this way may lead to problems such as poor edge sharpness, poor contrast, and lack of detail information in the captured image, and cannot meet the normal use of the industrial camera in complex environments (such as large contrast, low-light environment, and bright-dark alternating environment). Summary of the Invention
[0003] In order to solve the above technical problems, the present invention provides a method for automatically adjusting the gain value and exposure value of an industrial camera. This method designs a parameter screening strategy for an industrial camera based on multiple image quality evaluation indicators. Through three levels of screening, the optimal exposure and gain values are obtained to complete the self-adjustment of the industrial camera parameters. After adjustment, the industrial camera has high contrast, good clarity, and high stability in the captured image.
[0004] The technical solution is as follows:
[0005] An automatic adjustment method for the gain value and exposure value of an industrial camera, which selects three groups of evaluation parameters from the image quality evaluation parameters, and respectively records them as the first evaluation index, the second evaluation index, and the third evaluation index; a single group of evaluation parameters is a single evaluation parameter or a comprehensive evaluation parameter formed by combining multiple evaluation parameters;
[0006] Preset the exposure value adjustment range and the gain value adjustment range; Denote any one of the exposure / gain as parameter A, and the other parameter as parameter B; Select a value within the adjustment range of parameter A as the initial value of parameter A;
[0007] Adjust the gain value and exposure value of the industrial camera through the following steps:
[0008] Step 1: Fix the value of parameter A, and gradually increase the value of parameter B from the minimum value within the adjustment range according to the preset step size. Each time it increases, the industrial camera collects the image of the measured object at the same position, performs image processing, and uses the first evaluation index to judge the image quality;
[0009] Compare the quality of the images collected under different conditions of parameter B, and denote the value of parameter B corresponding to the image with the best quality as the upper limit value; Store the values of parameter B and the corresponding images between the minimum value of the adjustment range of parameter B and the upper limit value in the preliminary set;
[0010] Use the second evaluation index to judge the quality of each image in the preliminary set, find the value of parameter B corresponding to the image with the best quality, and store this value and the value of parameter A as a group of alternative parameters;
[0011] Step 2: Select another value within the adjustment range of parameter A, assign it to parameter A, and execute Step 1 again until all the values within the adjustment range of parameter A are traversed, obtaining multiple groups of alternative parameters;
[0012] Step 3: Use the third evaluation index to judge the quality of the images corresponding to each group of alternative parameters, denote the group of alternative parameters corresponding to the image with the best quality as the best parameters, and use the best parameters to set the gain value and exposure value of the industrial camera respectively to complete the automatic adjustment of the industrial camera.
[0013] Furthermore, the image quality evaluation parameters include image contrast, foreground gray change amount, image gray variance, edge gradient consistency, image information entropy, edge gradient mean, edge length, and edge smoothness.
[0014] Preferably, the first evaluation index is image contrast or foreground gray change amount;
[0015] The second evaluation index and the third evaluation index are respectively one or more of edge smoothness, edge gradient consistency, image information entropy, edge gradient mean, edge length, and image gray variance;
[0016] When multiple evaluation parameters are included in the second evaluation index and / or the third evaluation index, the image processing results of each evaluation parameter are multiplied by their respective corresponding proportionality coefficients, and then the products are accumulated and summed to form a comprehensive evaluation parameter.
[0017] Preferably, the first evaluation index is image contrast or foreground gray change amount;
[0018] The second evaluation index is one or more of edge smoothness and edge gradient consistency;
[0019] The third evaluation index is one or more of image information entropy, edge gradient mean, edge length, and image gray variance;
[0020] Or:
[0021] The first evaluation index is image contrast or foreground gray change amount;
[0022] The second evaluation index is one or more of image information entropy, edge gradient mean, edge length, and image gray variance;
[0023] The third evaluation index is one or more of edge smoothness and edge gradient consistency;
[0024] When multiple evaluation parameters are included in the second evaluation index and / or the third evaluation index, the image processing results of each evaluation parameter are multiplied by their respective corresponding proportionality coefficients, and then the products are accumulated and summed to form a comprehensive evaluation parameter.
[0025] Furthermore, according to different evaluation parameters, the method for judging image quality is any of the following situations:
[0026] Situation 1:
[0027] Taking the image contrast as the evaluation parameter, the method for judging image quality using the image contrast is as follows:
[0028] Segment the image to obtain the foreground region and the background region;
[0029] Calculate the average gray levels of the foreground region and the background region respectively, take the difference, and use the difference as the image contrast; or, randomly sample N sub-regions from the foreground region and the background region respectively, calculate the gray level means of each sub-region; calculate the differences between the gray level means of the sub-regions sampled from the foreground region and the sub-regions sampled from the background region in pairs; take the average value of each difference as the image contrast;
[0030] The larger the numerical value of the image contrast, the better the image quality;
[0031] Case Two:
[0032] Taking the foreground gray-scale change amount as the evaluation parameter, the method for judging the image quality using the foreground gray-scale change amount is as follows:
[0033] Segment the image to obtain the foreground region and the background region; calculate the average gray-scale of the foreground region. If this is the first image, record the foreground gray-scale change amount as 0. Otherwise, subtract the average gray-scale of the foreground region of the previous image from the average gray-scale of the foreground region of this image, and record the difference as the foreground gray-scale change amount; the larger the numerical value of the foreground gray-scale change amount, the better the image quality;
[0034] Case Three:
[0035] Taking the edge smoothness as the evaluation parameter, the method for judging the image quality using the edge smoothness is as follows:
[0036] Extract the edges of the image; fit lines using the edge points, calculate the distances from each edge point to the fitted line, and take the average of these distance values as the evaluation value of the edge smoothness. The larger the numerical value, the better the image quality;
[0037] Case Four:
[0038] Taking the edge gradient consistency as the evaluation parameter, the method for judging the image quality using the edge gradient consistency is as follows:
[0039] Extract the edges of the image, and make the following judgment for each edge point: obtain the gradient directions of the current edge point and multiple neighboring points within its neighborhood range, record the gradient direction with the highest frequency as the main direction, and if the gradient direction of the current edge point is the same as the main direction, retain this edge point;
[0040] Count the number of retained edge points, and record the ratio of it to the total number of edge points as the edge gradient consistency. The larger the numerical value, the better the image quality;
[0041] Case Five:
[0042] Taking the image information entropy as the evaluation parameter, the method for judging the image quality using the image information entropy is as follows:
[0043] Calculate the image information entropy, and take the entropy value as the evaluation value of the image quality. The larger the numerical value, the better the image quality;
[0044] Case Six:
[0045] Taking the average edge gradient as the evaluation parameter, the method for judging the image quality using the average edge gradient is as follows:
[0046] Extract the edges of the image; calculate the average gradient of each pixel point on the edge line and use it as the evaluation value of the image quality; the gradient is the horizontal gradient, vertical gradient, or gradient in a specific direction; the larger the average gradient, the better the image quality.
[0047] Case Seven:
[0048] Take the edge length as the evaluation parameter, and the method for judging the image quality using the edge length is as follows:
[0049] Extract the edges of the image; calculate the edge line length, accumulate and average the length values as the edge length; the larger the edge length value, the better the image quality.
[0050] Case Eight:
[0051] Take the image gray variance as the evaluation parameter, and the method for judging the image quality using the image gray variance is as follows:
[0052] Calculate the sum of the squares of the difference between the gray value of each pixel point in the image and the average gray value of the image, and then divide by the total number of pixel points to obtain the gray variance; the larger the value of the gray variance, the better the image quality.
[0053] Preferably, the preset step size for adjusting the exposure value ranges from 50 to 200, and the preset step size for adjusting the gain value ranges from 1 to 10.
[0054] Furthermore, the method for pre-setting the exposure value adjustment range and the gain value adjustment range is as follows:
[0055] Set the rated adjustment range of the exposure value and the gain value as the adjustment range;
[0056] Or, select local ranges from the rated adjustment ranges of the exposure value and the gain value respectively according to empirical values and set them as the adjustment ranges.
[0057] Preferably, use the following method to determine whether the industrial camera parameters need to be automatically adjusted:
[0058] Obtain one or more frames of images collected during the normal operation of the industrial camera;
[0059] Use one or more of the first evaluation index, the second evaluation index, and the third evaluation index to judge the quality of the image;
[0060] When the image quality meets the preset requirements, maintain the current industrial camera parameters; otherwise, perform steps one to three on the industrial camera to automatically adjust the industrial camera parameters.
[0061] Preferably, when there are multiple evaluation parameters for judging image quality, the image processing results of each evaluation parameter are first normalized, then multiplied by their respective proportionality coefficients, and the products are accumulated and summed to form a comprehensive evaluation parameter as the image quality score. It is judged whether the image quality score is greater than the threshold. If so, the current industrial camera parameters are maintained; otherwise, the industrial camera is subjected to steps 1 to 3 to automatically adjust the industrial camera parameters.
[0062] This method designs an industrial camera parameter screening strategy based on multiple image quality evaluation indicators. Through three levels of screening, the optimal exposure and gain values are obtained, and the parameter self-adjustment of the industrial camera is completed. The adjusted industrial camera has high contrast, good clarity, and high stability in the collected images.
[0063] More specifically, the screening strategy sets three image quality dimensions, namely:
[0064] 1) Contrast index: including image contrast or foreground gray change amount;
[0065] 2) Feature stability index: including edge smoothness and edge gradient consistency;
[0066] 3) Edge sharpness index: including image information entropy, average edge gradient, edge length, and image gray variance.
[0067] This method not only adjusts the exposure parameters but also takes into account the gain parameters, and performs global search through collaborative adjustment to avoid local optimal solutions. It has the characteristics of fast adjustment speed, strong robustness, and high accuracy. Brief Description of the Drawings
[0068] Figure 1a For adjusting the industrial camera to collect the image of the first object to be measured by using the method of the present invention in the specific embodiment;
[0069] Figure 1b For adjusting the industrial camera to collect the image of the first object to be measured by using the existing method in the specific embodiment;
[0070] Figure 2a For adjusting the industrial camera to collect the image of the second object to be measured by using the method of the present invention in the specific embodiment;
[0071] Figure 2b For adjusting the industrial camera to collect the image of the second object to be measured by using the existing method in the specific embodiment. Detailed Description of the Invention
[0072] The technical solutions of the present invention will be described in detail below in conjunction with the drawings and specific embodiments.
[0073] An automatic adjustment method for the gain value and exposure value of an industrial camera, which selects three groups of evaluation parameters from the image quality evaluation parameters, and respectively records them as the first evaluation index, the second evaluation index, and the third evaluation index; a single group of evaluation parameters is a single evaluation parameter or a comprehensive evaluation parameter formed by combining multiple evaluation parameters.
[0074] Preset an exposure value adjustment range and a gain value adjustment range; denote any one of the exposure / gain as parameter A, and the other parameter as parameter B; select a value within the adjustment range of parameter A as the initial value of parameter A.
[0075] Adjust the gain value and exposure value of the industrial camera through the following steps:
[0076] Step 1: Fix the value of parameter A, and gradually increase the value of parameter B from the minimum value within the adjustment range according to the preset step size. Each time it increases, the industrial camera collects an image of the measured object at the same position, performs image processing, and uses the first evaluation index to judge the image quality.
[0077] Compare the image quality collected under different parameter B conditions, and record the value of parameter B corresponding to the image with the best quality as the upper limit value; store the parameter B values and the corresponding images between the minimum value of the adjustment range of parameter B and the upper limit value into the preliminary set.
[0078] Use the second evaluation index to judge the quality of each image in the preliminary set, find the value of parameter B corresponding to the image with the best quality, and store this value and the value of parameter A as a group of alternative parameters.
[0079] Step 2: Select another value within the adjustment range of parameter A and assign it to parameter A, and then execute Step 1 again until all the values within the adjustment range of parameter A are traversed to obtain multiple groups of alternative parameters.
[0080] Step 3: Use the third evaluation index to judge the quality of the images corresponding to each group of alternative parameters, record the group of alternative parameters corresponding to the image with the best quality as the best parameters, and use the best parameters to set the gain value and exposure value of the industrial camera respectively to complete the automatic adjustment of the industrial camera.
[0081] The above adjustment process can be carried out when the camera is first used, or can be adjusted as needed during the use of the camera. Specifically, the specific method for judging whether the parameters of the industrial camera need to be automatically adjusted is as follows:
[0082] Obtain one or more frames of images collected during the normal operation of the industrial camera;
[0083] Use one or more of the first evaluation index, the second evaluation index, and the third evaluation index to judge the quality of the images;
[0084] When the image quality meets the preset requirements, maintain the current industrial camera parameters; otherwise, perform Steps 1 to 3 on the industrial camera to automatically adjust the industrial camera parameters.
[0085] Preferably, when there are multiple evaluation parameters for judging the image quality, first perform normalization processing on the image processing results of each evaluation parameter, then multiply by their respective corresponding proportionality coefficients, sum the products, and combine them to form a comprehensive evaluation parameter as the image quality score. Determine whether the image quality score is greater than the threshold. If so, maintain the current industrial camera parameters; otherwise, perform Steps 1 to 3 on the industrial camera to automatically adjust the industrial camera parameters.
[0086] Specifically, the image quality evaluation parameters include image contrast, foreground gray level change amount, image gray level variance, edge gradient consistency, image information entropy, edge gradient mean, edge length, and edge smoothness.
[0087] More specifically, the first evaluation index is image contrast or foreground gray level change amount;
[0088] The second evaluation index and the third evaluation index are respectively one or more of edge smoothness, edge gradient consistency, image information entropy, edge gradient mean, edge length, and image gray level variance;
[0089] When the second evaluation index and / or the third evaluation index contain multiple evaluation parameters, multiply the image processing results of each evaluation parameter by their respective corresponding proportionality coefficients, and then sum the products to combine and form a comprehensive evaluation parameter.
[0090] For example, the third evaluation index S c contains the edge gradient mean S 1 and the image information entropy S 2 two evaluation parameters:
[0091] S c =W 1 ×S 1 +W 2 ×S 2
[0092] wherein, S c represents the comprehensive evaluation parameter (the third evaluation index) formed by combining the image processing results of each evaluation parameter, and W 1 , W 2 are the corresponding weights respectively, and W 1 +W 2 =1. In specific implementation, the weight values can be set according to actual needs. For example, W 1 takes values such as 0.5, 0.3, 0.8, etc.
[0093] In this embodiment, the image quality evaluation parameters involve three dimensions:
[0094] Contrast index: including image contrast or foreground gray-scale change amount;
[0095] Feature stability index: including edge smoothness and edge gradient consistency;
[0096] Edge sharpness index: including image information entropy, average edge gradient, edge length, and image gray-scale variance.
[0097] Among them, the first evaluation index is image contrast or foreground gray-scale change amount; it is used to evaluate the contrast of the image;
[0098] The second evaluation index is one or more of edge smoothness and edge gradient consistency; it is used to evaluate the feature stability of the image;
[0099] The third evaluation index is one or more of image information entropy, average edge gradient, edge length, and image gray-scale variance; it is used to evaluate the edge sharpness of the image;
[0100] Or:
[0101] The first evaluation index is image contrast or foreground gray-scale change amount; it is used to evaluate the contrast of the image;
[0102] The second evaluation index is one or more of image information entropy, average edge gradient, edge length, and image gray-scale variance; it is used to evaluate the edge sharpness of the image;
[0103] The third evaluation index is one or more of edge smoothness and edge gradient consistency; it is used to evaluate the feature stability of the image;
[0104] When the second evaluation index and / or the third evaluation index contains multiple evaluation parameters, multiply the image processing results of each evaluation parameter by their respective proportionality coefficients, and then accumulate and sum the products to form a comprehensive evaluation parameter.
[0105] Among them, according to the different evaluation parameters, the method for judging the image quality is any of the following situations:
[0106] Situation 1:
[0107] Taking the image contrast as the evaluation parameter, the method for judging the image quality using the image contrast is as follows:
[0108] Segment the image to obtain the foreground region and the background region;
[0109] Calculate the average grayscale of the foreground region and the background region respectively, take the difference, and use the difference as the image contrast; alternatively, randomly sample N sub-regions from the foreground region and the background region respectively, and calculate the grayscale mean of each sub-region; calculate the difference between the grayscale means of the sub-regions sampled from the foreground region and the sub-regions sampled from the background region pairwise; take the average of each difference as the image contrast;
[0110] The larger the value of the image contrast, the better the image quality;
[0111] Case Two:
[0112] Use the foreground grayscale change amount as an evaluation parameter, and the method for judging the image quality using the foreground grayscale change amount is as follows:
[0113] Segment the image to obtain the foreground region and the background region; calculate the average grayscale of the foreground region. If this is the first image, record the foreground grayscale change amount as 0. Otherwise, take the difference between the average grayscale of the foreground region of this image and the average grayscale of the foreground region of the previous image, and record the difference as the foreground grayscale change amount; the larger the value of the foreground grayscale change amount, the better the image quality;
[0114] Case Three:
[0115] Use the edge smoothness as an evaluation parameter, and the method for judging the image quality using the edge smoothness is as follows:
[0116] Perform edge extraction on the image; use the edge points to fit a line, calculate the distance from each edge point to the fitted line, and take the average of each distance value as the evaluation value of the edge smoothness. The larger the value, the better the image quality;
[0117] Case Four:
[0118] Use the edge gradient consistency as an evaluation parameter, and the method for judging the image quality using the edge gradient consistency is as follows:
[0119] Perform edge extraction on the image, and make the following judgment for each edge point: Obtain the gradient directions of the current edge point and multiple neighborhood points within its neighborhood range, and record the gradient direction with the most occurrences as the main direction. If the gradient direction of the current edge point is consistent with the main direction, retain the edge point;
[0120] Count the number of retained edge points, and record the ratio of it to the total number of edge points as the edge gradient consistency. The larger the value, the better the image quality;
[0121] Case Five:
[0122] Use the image information entropy as an evaluation parameter, and the method for judging the image quality using the image information entropy is as follows:
[0123] Calculate the information entropy of the image, and use the entropy value as the evaluation value of the image quality. The larger the value, the better the image quality.
[0124] Case Six:
[0125] Use the average edge gradient as the evaluation parameter. The method for judging the image quality using the average edge gradient is as follows:
[0126] Perform edge extraction on the image; calculate the average gradient of each pixel point on the edge line, and use it as the evaluation value of the image quality; the gradient is the horizontal gradient, vertical gradient, or specific direction gradient; the larger the average gradient, the better the image quality.
[0127] Case Seven:
[0128] Use the edge length as the evaluation parameter. The method for judging the image quality using the edge length is as follows:
[0129] Perform edge extraction on the image; calculate the edge line length, accumulate and take the average of the length values as the edge length; the larger the edge length value, the better the image quality.
[0130] Case Eight:
[0131] Use the image gray variance as the evaluation parameter. The method for judging the image quality using the image gray variance is as follows:
[0132] Calculate the sum of the squares of the difference between the gray value of each pixel point in the image and the average gray value of the image, and then divide by the total number of pixel points to obtain the gray variance; the larger the value of the gray variance, the better the image quality.
[0133] Preferably, the preset step size for adjusting the exposure value ranges from 50 to 200, and the preset step size for adjusting the gain value ranges from 1 to 10.
[0134] When specifically implemented, the method for presetting the exposure value adjustment range and the gain value adjustment range is as follows:
[0135] Set the rated adjustment range of the exposure value and the gain value as the adjustment range;
[0136] Alternatively, select local ranges from the rated adjustment ranges of the exposure value and the gain value respectively according to empirical values, and set them as the adjustment ranges.
[0137] Taking the example of an industrial camera collecting images of outdoor objects to be measured, the method of the present invention will be described exemplarily as follows:
[0138] Among them, the first evaluation index is the image contrast;
[0139] The second evaluation index is the average edge gradient;
[0140] The third evaluation index is the edge gradient consistency;
[0141] The specific adjustment steps for the object to be tested (characteristic hole) are as follows:
[0142] After the camera is installed and before officially starting image acquisition, perform the following parameter automatic adjustment steps:
[0143] A method for automatically adjusting the gain value and exposure value of an industrial camera, wherein the exposure value adjustment interval [1000, 8000] and the gain value adjustment interval [1, 15] are pre-set according to empirical values; the gain is recorded as parameter A, and the exposure is recorded as parameter B; a value is randomly selected within the adjustment interval of parameter A (gain) as the initial value of parameter A;
[0144] Use the following steps to adjust the gain and exposure values of the industrial camera:
[0145] Step 1: The value of parameter A is fixed, and the value of parameter B is gradually increased from the minimum value (50) in the adjustment range according to a preset step length of 50. Each time the value increases, the industrial camera collects an image of the object under test at the same position, performs image processing, and uses the first evaluation index (image contrast) to judge the image quality.
[0146] Compare the quality of the images collected under different parameter B conditions, and record the value of parameter B (5000) corresponding to the image with the best quality as the upper limit value; store the parameter B values and corresponding images between the minimum value and the upper limit value of the adjustment interval of parameter B into the preliminary set;
[0147] Using the second evaluation index (edge gradient mean) to judge the quality of each image in the preliminary set, find the parameter B value corresponding to the image with the best quality, and store the value and the parameter A value as a set of candidate parameters;
[0148] Step 2: Select another value within the adjustment range of parameter A, assign it to parameter A, and execute step 1 again until all values within the adjustment range of parameter A are traversed to obtain multiple sets of candidate parameters;
[0149] Multiple groups of optional parameters are shown in the following table:
[0150] Number of iterations Gain value Exposure value 1 1 6350 2 2 3650 3 3 2300 4 4 1500 5 5 1300 6 6 1250 7 7 1150 8 8 1500 9 9 1050 10 10 1100 11 11 1150 12 12 1250 13 13 1300 14 14 1050 15 15 1050
[0151] Step 3: Use the third evaluation index (edge gradient consistency) to judge the quality of the images corresponding to each candidate parameter. Record the set of candidate parameters corresponding to the image with the best quality as the optimal parameters (gain value 4, exposure value 1500). Use the optimal parameter settings to set the gain value and exposure value of the industrial camera respectively to complete the automatic adjustment of the industrial camera.
[0152] Perform normal operations with the adjusted camera.
[0153] Since in this embodiment, the industrial camera is outdoors with a complex environment and is vulnerable to external interference, during the normal operation of the camera, the camera parameters are adjusted in real time:
[0154] Obtain one or more frames of images of the object to be measured collected by the industrial camera;
[0155] Use the second evaluation index (mean edge gradient) and the third evaluation index (edge gradient consistency) to judge the quality of the image and obtain the image quality score A;
[0156] A = a×H 1 +b×H 2
[0157] where a and b are the corresponding weights respectively, a + b = 1, and the weight values can be set according to actual needs during specific implementation, such as ch taking 0.5, 0.3, 0.8, etc.; H 1 represents the value after normalizing the image processing result of the mean edge gradient, H 2 represents the value after normalizing the image processing result of the edge gradient consistency.
[0158] Exemplarily, the image processing result of the mean edge gradient is normalized as follows:
[0159]
[0160]
[0161] H 1 = 0.5×H 水平 +0.5×H 垂直
[0162] where M represents the total number of pixel points included in the edge line, G represents the maximum value of the image gradient, C k 、D k represent the gradient values of the edge pixel points in the horizontal and vertical directions.
[0163] Judge whether the image quality score A is greater than the threshold. If so, maintain the current industrial camera parameters; otherwise, perform steps one to three on the industrial camera to automatically adjust the industrial camera parameters.
[0164] To verify the effectiveness of the method of the present invention, the following comparative experiments are carried out:
[0165] Comparative experiment one:
[0166] An industrial camera captures images of the first object to be measured (a plate with characteristic holes) outdoors. The gain value and exposure value of the industrial camera are set using the optimal parameters adjusted by the method of the present invention and the camera parameters adjusted by the prior art method (judging the image quality only by the average gray level of the whole image and obtaining the industrial camera parameters), respectively. Then, the industrial camera after adjustment is used to capture images of the object to be measured:
[0167] The optimal parameters obtained according to the method of the present invention are: gain value 4, exposure value 1500. Using these to adjust the gain value and exposure value of the industrial camera and capture images of the first object to be measured, the results are as Figure 1a shown;
[0168] The camera parameters obtained according to the prior art method are: gain value 10, exposure value 1700. Using these to set the gain value and exposure value of the industrial camera and capture images of the first object to be measured, the results are as Figure 1b shown;
[0169] Using Figure 1a and Figure 1b respectively, the quality of the images is judged using the second evaluation index (mean edge gradient (H 1 )) and the third evaluation index (edge gradient consistency (H 2 )) to obtain the image quality score A:
[0170] Figure 1a : A = a×H 1 +b×H 2 = 0.5×0.92 + 0.5×0.77 = 0.85
[0171] Figure 1b : A = a×H 1 +b×H 2 = 0.5×0.41 + 0.5×0.67 = 0.54
[0172] By comparing the quality scores of the two images, it can be seen that Figure 1a has a higher score, its overall image contrast is higher, the clarity is better, there are fewer burrs on the edges of the characteristic holes, and the details are richer. The image captured by the industrial camera after adjusting the exposure value and gain value obtained by the method of the present invention has better quality.
[0173] Comparative experiment two:
[0174] An industrial camera captures images of the second object to be measured (a flat plate) outdoors. The gain value and exposure value of the industrial camera are set using the optimal parameters adjusted by the method of the present invention and the camera parameters adjusted by the prior art method (judging the image quality only by the average gray level of the whole image and obtaining the industrial camera parameters), respectively. Then, the industrial camera after adjustment is used to capture images of the object to be measured:
[0175] The optimal parameters obtained by the method of the present invention are: gain value 5, exposure value 2300. Using these to adjust the gain value and exposure value of the industrial camera and acquire the image of the second object to be measured, the result is as Figure 2a shown;
[0176] The camera parameters obtained by the prior art method are: gain value 7, exposure value 4000. Using these to set the gain value and exposure value of the industrial camera and acquire the image of the second object to be measured, the result is as Figure 2b shown;
[0177] Using Figure 2a and Figure 2b respectively to judge the quality of the images by using the second evaluation index (mean edge gradient (H 1 )) and the third evaluation index (edge gradient consistency (H 2 )) to obtain the image quality score A:
[0178] Figure 2a : A = a×H 1 +b×H 2 = 0.5×0.89 + 0.5×0.97 = 0.93
[0179] Figure 2b : A = a×H 1 +b×H 2 = 0.5×0.54 + 0.5×0.81 = 0.68
[0180] By comparing the quality scores of the two images, it can be seen that Figure 2a has a higher score, its image has a higher contrast, less reflection and better clarity. The image acquisition quality of the industrial camera after adjusting the exposure value and gain value obtained by the method of the present invention is better.
[0181] The foregoing description of the specific exemplary embodiments of the present invention has been presented for purposes of illustration and description. The foregoing description is not intended to be exhaustive nor to limit the invention to the precise form disclosed, and obviously many modifications and variations are possible in light of the above teaching. The exemplary embodiments were chosen and described in order to explain the particular principles of the invention and its practical application to enable others skilled in the art to make and utilize various exemplary embodiments of the invention and their various alternative forms and modifications. The scope of the invention is intended to be defined by the appended claims and their equivalents.
Claims
1. An automatic adjustment method for the gain value and exposure value of an industrial camera, characterized in that, select three groups of evaluation parameters from the image quality evaluation parameters, and denote them as the first evaluation index, the second evaluation index, and the third evaluation index respectively; a single group of evaluation parameters is a single evaluation parameter or a comprehensive evaluation parameter formed by combining multiple evaluation parameters; preset an exposure value adjustment range and a gain value adjustment range; denote any one of exposure / gain as parameter A, and the other parameter as parameter B; select a value within the adjustment range of parameter A as the initial value of parameter A; adjust the gain value and exposure value of the industrial camera through the following steps: Step 1: Fix the value of parameter A, and increase the value of parameter B step by step from the minimum value within the adjustment range according to the preset step size. Each time it is increased, the industrial camera collects an image of the object to be measured at the same position, performs image processing, and uses the first evaluation index to judge the image quality; Compare the quality of the images collected under different parameter B conditions, and denote the value of parameter B corresponding to the image with the best quality as the upper limit value; Store the parameter B values and the corresponding images between the minimum value of the adjustment range of parameter B and the upper limit value into the preliminary set; Use the second evaluation index to judge the quality of each image in the preliminary set, find the value of parameter B corresponding to the image with the best quality, and store this value and the value of parameter A as a group of alternative parameters; Step 2: Select another value within the adjustment range of parameter A, assign it to parameter A, and execute Step 1 again until all the values within the adjustment range of parameter A are traversed to obtain multiple groups of alternative parameters; Step 3: Use the third evaluation index to judge the quality of the images corresponding to each group of alternative parameters, denote the group of alternative parameters corresponding to the image with the best quality as the best parameters, and use the best parameters to set the gain value and exposure value of the industrial camera respectively to complete the automatic adjustment of the industrial camera.
2. The automatic adjustment method for the gain value and exposure value of the industrial camera according to claim 1, characterized in that: The image quality evaluation parameters include image contrast, foreground gray change amount, image gray variance, edge gradient consistency, image information entropy, edge gradient mean, edge length, and edge smoothness.
3. The automatic adjustment method for the gain value and exposure value of the industrial camera according to claim 1, characterized in that: The first evaluation index is image contrast or foreground gray change amount; The second evaluation index and the third evaluation index are respectively one or more of edge smoothness, edge gradient consistency, image information entropy, edge gradient mean, edge length, and image gray variance; When the second evaluation index and / or the third evaluation index contain multiple evaluation parameters, multiply the image processing results of each evaluation parameter by their respective proportional coefficients, and then sum the products to form a comprehensive evaluation parameter.
4. The automatic adjustment method for the gain value and exposure value of the industrial camera according to claim 1, characterized in that: The first evaluation index is image contrast or foreground gray change amount; The second evaluation index is one or more of edge smoothness and edge gradient consistency; The third evaluation index is one or more of image information entropy, average edge gradient, edge length, and image gray variance; Or: The first evaluation index is image contrast or foreground gray change amount; The second evaluation index is one or more of image information entropy, average edge gradient, edge length, and image gray variance; The third evaluation index is one or more of edge smoothness and edge gradient consistency; When the second evaluation index and / or the third evaluation index contain multiple evaluation parameters, the image processing results of each evaluation parameter are multiplied by their respective proportionality coefficients, and then the products are accumulated and summed to form a comprehensive evaluation parameter.
5. The method for automatically adjusting the gain value and exposure value of the industrial camera according to claim 1 or 2, Characterized in that: According to different evaluation parameters, the method for judging the image quality is any of the following situations: Situation 1: Taking the image contrast as the evaluation parameter, the method for judging the image quality using the image contrast is as follows: Segment the image to obtain the foreground region and the background region; Calculate the average gray levels of the foreground region and the background region respectively, take the difference, and use the difference as the image contrast; or, randomly sample N sub-regions from the foreground region and the background region respectively, and calculate the average gray levels of each sub-region; calculate the difference between the average gray levels of the sub-regions sampled from the foreground region and the sub-regions sampled from the background region in pairs; take the average value of each difference as the image contrast; The larger the value of the image contrast, the better the image quality; Situation 2: Taking the foreground gray change amount as the evaluation parameter, the method for judging the image quality using the foreground gray change amount is as follows: Segment the image to obtain the foreground region and the background region; Calculate the average gray level of the foreground region. If this is the first image, record the foreground gray change amount as 0. Otherwise, take the difference between the average gray level of the foreground region of this image and the average gray level of the foreground region of the previous image, and record the difference as the foreground gray change amount; The larger the value of the foreground gray change amount, the better the image quality; Situation 3: Taking the edge smoothness as the evaluation parameter, the method for judging the image quality using the edge smoothness is as follows: Extract the edges of the image; fit a line using the edge points, calculate the distance from each edge point to the fitted line, and take the average value of each distance value as the evaluation value of the edge smoothness. The larger the value, the better the image quality; Situation 4: Taking the edge gradient consistency as the evaluation parameter, the method for judging the image quality using the edge gradient consistency is as follows: Extract the edges of the image, and make the following judgment for each edge point: Obtain the gradient directions of the current edge point and multiple neighboring points within its neighborhood range, and record the gradient direction with the most occurrences as the main direction. If the gradient direction of the current edge point is consistent with the main direction, retain the edge point; Count the number of retained edge points, and record the ratio of it to the total number of edge points as the edge gradient consistency. The larger the value, the better the image quality; Situation 5: Taking the image information entropy as the evaluation parameter, the method for judging the image quality using the image information entropy is as follows: Calculate the image information entropy, and use the entropy value as the evaluation value of the image quality. The larger the value, the better the image quality; Case Six: Using the mean edge gradient as the evaluation parameter, the method for judging image quality using the mean edge gradient is as follows: Perform edge extraction on the image; calculate the mean gradient of each pixel point on the edge line and use it as the evaluation value of the image quality; the gradient is the horizontal gradient, vertical gradient, or gradient in a specific direction; the larger the mean gradient, the better the image quality. Case Seven: Using the edge length as the evaluation parameter, the method for judging image quality using the edge length is as follows: Perform edge extraction on the image; calculate the edge line length, accumulate and take the mean of the length values as the edge length; the larger the edge length value, the better the image quality. Case Eight: Using the image gray variance as the evaluation parameter, the method for judging image quality using the image gray variance is as follows: Calculate the sum of the squares of the differences between the gray values of each pixel point in the image and the average gray value of the image, and then divide by the total number of pixel points to obtain the gray variance; the larger the value of the gray variance, the better the image quality.
6. The method for automatically adjusting the gain value and exposure value of the industrial camera according to claim 1 or 2, characterized in that: The preset step size for adjusting the exposure value ranges from 50 to 200, and the preset step size for adjusting the gain value ranges from 1 to 10.
7. The method for automatically adjusting the gain value and exposure value of the industrial camera according to claim 1 or 2, characterized in that: The method for presetting the exposure value adjustment range and gain value adjustment range is as follows: Set the rated adjustment ranges of the exposure value and gain value as the adjustment ranges; Alternatively, select local ranges from the rated adjustment ranges of the exposure value and gain value respectively according to empirical values and set them as the adjustment ranges.
8. The method for automatically adjusting the gain value and exposure value of the industrial camera according to claim 1 or 2, characterized in that: Use the following method to judge whether the parameters of the industrial camera need to be automatically adjusted: Obtain one or more frames of images collected during the normal operation of the industrial camera; Judge the quality of the image using one or more of the first evaluation index, second evaluation index, and third evaluation index; When the image quality meets the preset requirements, maintain the current industrial camera parameters; otherwise, perform steps one to three on the industrial camera to automatically adjust the industrial camera parameters.
9. The method for automatically adjusting the gain value and exposure value of the industrial camera according to claim 8, characterized in that: When there are multiple evaluation parameters for judging the image quality, first perform normalization processing on the image processing results of each evaluation parameter, then multiply by their respective proportionality coefficients, sum the products, and combine them to form a comprehensive evaluation parameter as the image quality score. Judge whether the image quality score is greater than the threshold. If so, maintain the current industrial camera parameters; otherwise, perform steps one to three on the industrial camera to automatically adjust the industrial camera parameters.
Citation Information
Patent Citations
Automatic exposure adjusting method for binocular camera of fire-fighting robot
CN113382143A
Automatic exposure method and device, electronic equipment and computer readable storage medium
CN113992863A
Automatic exposure method and device
CN103888681A
Bar code image exposure judgment system and method based on CMOS
CN107124561A