Imaging recipe generation method, imaging apparatus, and electronic apparatus
By acquiring standard images and determining the target focal length, exposure, and color channel gain, an imaging recipe is generated, solving the problem of cross-device imaging parameter reproduction and consistency, and achieving efficient imaging effect consistency and accuracy.
Patent Information
- Application Number
- CN202611294204.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-25
- Publication Date
- 2026-11-20
AI Technical Summary
Existing technologies struggle to achieve rapid reproduction of imaging parameters and consistency of imaging effects during cross-device imaging processes. In particular, under factors such as changes in ambient lighting, differences in devices, assembly deviations, and material differences, imaging deviations can easily occur even with devices of the same model.
By acquiring standard images, the target focal length parameters, exposure parameters, and color channel gains are determined, and a target imaging recipe is generated to achieve joint configuration of focal length, exposure, and color channel gains, avoiding mutual interference caused by independent parameter adjustments.
It enables rapid reproduction of imaging parameters across devices, improves the consistency of imaging effects, and ensures the accuracy of image clarity, brightness, and color representation.
Smart Images

Figure CN123145484A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of industrial vision inspection technology, and in particular relates to an imaging recipe generation method, imaging equipment and electronic equipment. Background Technology
[0002] With the development of machine vision, image acquisition and image processing technologies, image-related equipment has been widely used in industrial inspection, security monitoring, medical imaging and automated recognition. Especially in the scenario of large-scale batch deployment across factories and production lines, the same model of equipment needs to maintain consistent imaging effects across different machines to ensure the consistency and stability of inspection standards.
[0003] In related technologies, manual adjustment, fixed gain settings, or correction based on empirical parameters are commonly used to adjust imaging equipment to improve problems such as image defocus, overexposure, color cast, and uneven brightness. Some related solutions also pre-set imaging parameters based on the calibration results at the time of equipment leaving the factory and use these parameter configurations in subsequent use.
[0004] However, during batch deployment and repeated application, due to factors such as changes in ambient light, differences in components, assembly deviations, differences in on-site environment, and differences in materials, the same model of equipment is prone to imaging deviations. The above solution is difficult to adapt to dynamic changes in different scenarios and is difficult to achieve rapid reproduction of imaging parameters across devices and consistency of imaging effects. Summary of the Invention
[0005] This invention aims to at least solve one of the technical problems existing in the prior art. To this end, this invention proposes an imaging recipe generation method, an imaging device, and an electronic device to achieve rapid reproduction of imaging parameters across devices and improve the consistency of imaging results.
[0006] In a first aspect, this application provides an imaging recipe generation method, the method comprising: Obtain a standard image; For the imaging device to be calibrated, images are acquired under different focal length parameters and the sharpness of each acquired image is determined. The target focal length parameter is then determined based on the sharpness. Under the target focal length parameter, images are acquired using different exposure parameters and the brightness deviation of each acquired image relative to the standard image is determined. The target exposure parameter is then determined based on the brightness deviation. The current image is acquired under the target focal length parameters and target exposure parameters. The color deviation of the current image relative to the standard image is determined. The color channel gain is iteratively adjusted according to the color deviation to obtain the target color channel gain. A target imaging recipe is generated based on the target focal length parameters, target exposure parameters, and target color channel gain; the target imaging recipe is used to configure the imaging device to be calibrated for image acquisition.
[0007] Secondly, this application provides an imaging device, which includes: Image acquisition device, used to acquire images; The processor is communicatively connected to the image acquisition device and is used to implement the imaging recipe generation method as described in the first aspect above.
[0008] Thirdly, this application provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the imaging recipe generation method as described in the first aspect above.
[0009] Fourthly, this application provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the imaging recipe generation method as described in the first aspect above.
[0010] Fifthly, this application provides a chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run programs or instructions to implement the imaging recipe generation method as described in the first aspect.
[0011] In a sixth aspect, this application provides a computer program product, including a computer program that, when executed by a processor, implements the imaging recipe generation method as described in the first aspect above.
[0012] The above-described one or more technical solutions in the embodiments of this application have at least one of the following technical effects: By having the imaging device under calibration acquire images at different focal lengths and determining the sharpness of each acquired image, and further determining the target focal length based on the sharpness, automatic optimization of the imaging focus position of the imaging device under calibration is achieved. This allows the imaging device under calibration to perform subsequent exposure and color calibration at focal lengths with satisfactory sharpness, effectively avoiding image blurring caused by inaccurate focal length and the resulting distortion of brightness and color evaluation results. Subsequently, at the target focal length, images are acquired using different exposure parameters, and the brightness deviation of each acquired image relative to the standard image is determined. The target exposure parameter is determined based on the brightness deviation, achieving exposure parameter matching based on sharp imaging. This allows the brightness of the images acquired by the imaging device under calibration to approach that of the standard image, effectively reducing the impact of underexposure or overexposure on image quality and subsequent color calibration accuracy. The system acquires the current image under target focal length and exposure parameters, determines the color deviation of the current image relative to the standard image, and iteratively adjusts the color channel gain based on the color deviation to obtain the target color channel gain. This achieves adaptive correction of the color channel under the condition that the focal length and exposure have been calibrated, thereby gradually bringing the color performance of the current image closer to the standard image and effectively improving the color consistency and imaging reproduction accuracy of the imaging device to be calibrated. Finally, based on the target focal length, target exposure, and target color channel gain, a target imaging recipe is generated. The target imaging recipe is then used to configure the imaging device to be calibrated for image acquisition. This effectively enables the joint configuration of focal length, exposure, and color gain parameters, avoiding mutual interference caused by independent adjustment of each imaging parameter. It can achieve rapid reproduction of imaging parameters across devices while effectively improving the consistency of imaging results.
[0013] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0014] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which: Figure 1 This is a flowchart illustrating the imaging recipe generation method provided in some embodiments of this application; Figure 2 This is a schematic diagram of the imaging recipe generation process provided in some other embodiments of this application; Figure 3 This is a schematic diagram of the color gain adjustment process provided in some embodiments of this application; Figure 4 This is a schematic diagram of the focus adjustment process in the first imaging scenario provided in some embodiments of this application; Figure 5This is a schematic diagram of the focus adjustment process in a batch re-running scenario provided in some embodiments of this application; Figure 6 This is a schematic diagram of the ideal sharpness evaluation curve provided in some embodiments of this application; Figure 7 This is a schematic diagram of the exposure parameter adjustment process in the first imaging scenario provided in some embodiments of this application; Figure 8 This is a schematic diagram of the exposure parameter adjustment process in a batch rerun scenario provided in some embodiments of this application; Figure 9 This is a schematic diagram of the imaging device structure provided in some embodiments of this application; Figure 10 This is a schematic diagram of the structure of an electronic device provided in some embodiments of this application. Detailed Implementation
[0015] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.
[0016] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0017] In image acquisition scenarios such as industrial inspection, sample recognition, and material analysis, imaging equipment is typically used to acquire images of target objects, and subsequent recognition, measurement, or analysis is performed based on the acquired images. To improve the accuracy of subsequent processing results, imaging equipment usually needs to undergo parameter calibration before formal use to ensure that it can obtain images with satisfactory clarity, brightness, and color performance under specified acquisition conditions.
[0018] In practical applications, the imaging effect of imaging devices is usually affected by multiple imaging parameters, such as focal length, exposure, and color channel gain. Among them, focal length directly affects the sharpness of the image; exposure affects the overall brightness of the image and the preservation of local details; and color channel gain affects the response ratio between different color channels, thus affecting the color reproduction effect of the image.
[0019] However, the above parameters are not independent of each other. For example, when the focal length is not accurately matched, the acquired image may be blurry, which will affect the accuracy of brightness evaluation and color evaluation. When the exposure parameters are not appropriate, the image may be overexposed or underexposed, which will affect the color deviation judgment and color channel gain adjustment.
[0020] In related technologies, the determination of imaging parameters typically relies on multiple test shots and adjustments based on human experience, or on independent calibration of parameters such as focal length, exposure, and color channel gain. Manual adjustment is not only time-consuming but also easily affected by differences in operator experience, making it difficult to achieve consistent calibration between different devices or batches of equipment. While independent calibration can obtain various parameters separately, it may not fully consider the impact of other parameters on image evaluation results when determining a particular parameter, leading to a final parameter combination that cannot consistently achieve the desired imaging effect.
[0021] In view of this, embodiments of this application provide an imaging recipe generation method, which aims to improve the accuracy of parameter calibration and the consistency of imaging effect of the imaging device to be calibrated. By determining the target focal length parameter based on image sharpness, determining the target exposure parameter based on the brightness deviation relative to the standard image, and obtaining the target color channel gain by iterative adjustment based on the color deviation relative to the standard image, the method can achieve rapid reproduction of imaging parameters across devices and improve the consistency of imaging effect.
[0022] The imaging recipe generation method, imaging device, and electronic device provided in this application will be described in detail below with reference to the accompanying drawings and through specific embodiments and application scenarios.
[0023] The imaging recipe generation method provided in this application can be executed by an electronic device or a functional module or entity within an electronic device capable of implementing the imaging recipe generation method. The electronic device mentioned in this application includes, but is not limited to, a terminal or a server.
[0024] The terminal includes, but is not limited to, one or more of various image acquisition devices, edge computing devices, embedded control devices, desktop computers, laptops, smartphones, or tablets. Image acquisition devices can be devices with functions such as image acquisition control, image processing, parameter configuration, recipe generation, and device calibration. Image acquisition devices include, but are not limited to, one or more of imaging detection devices, image analysis devices, automated detection devices, or their control hosts and processors used in industrial inspection, sample inspection, material analysis, or other image acquisition scenarios.
[0025] A server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, and big data and artificial intelligence platforms.
[0026] The imaging recipe generation method provided in this application embodiment will be described below, taking the processor of the imaging device as the execution subject as an example.
[0027] Figure 1 This is a schematic flowchart of an imaging recipe generation method provided in some embodiments of this application. For example... Figure 1 As shown, the imaging recipe generation method includes steps 110 to 150.
[0028] Step 110: Obtain the standard image.
[0029] Here, a standard image refers to an image that serves as a reference for the imaging effect of the imaging device to be calibrated. For example, a standard image can be used to characterize one or more imaging features such as brightness, color, sharpness, or contrast of the image that the imaging device to be calibrated is expected to obtain, or it can also serve as a reference for subsequently determining imaging parameters such as focal length, exposure parameters, and color channel gain of the imaging device to be calibrated.
[0030] In some implementations, the standard image can be a pre-acquired and stored reference image. For example, an image of the product or target to be inspected can be acquired using a calibrated standard imaging device under target light source, target shooting distance, target field of view, and target object being photographed, and the acquired image can be used as the standard image.
[0031] In other embodiments, the standard image may also be a target image pre-configured or generated according to the target imaging requirements. For example, a standard image may be generated based on one or more of the following: target brightness value, target color value, target grayscale distribution, target sharpness evaluation value, or image features of the target region.
[0032] In some other implementations, the standard image can be an image selected from multiple candidate images. For example, multiple candidate images can be evaluated using one or more of the following methods: brightness evaluation, color evaluation, sharpness evaluation, or noise evaluation, and the candidate image that meets the preset evaluation criteria can be determined as the standard image.
[0033] It should be noted that the imaging recipe generation method provided in this application embodiment can be applied to batch re-imaging scenarios or first-time imaging scenarios.
[0034] In batch calibration scenarios, a standard imaging device, standard imaging parameters, or standard imaging effect already exist, and one or more imaging devices to be calibrated need to reproduce this standard imaging effect. In this scenario, images acquired by the standard imaging device at the target object, target light source, target shooting distance, or target field of view can be used as standard images; alternatively, images acquired according to a validated imaging formula can be used as standard images. Based on this standard image, an imaging formula corresponding to the imaging device to be calibrated can be generated, ensuring that the images acquired by the imaging device to be calibrated meet preset consistency conditions with the standard image in terms of brightness, color, sharpness, contrast, and / or field of view.
[0035] In initial imaging scenarios, where there may be no directly reusable standard imaging equipment, standard imaging parameters, or standard imaging results, it is necessary to determine the imaging formula for the imaging equipment to be calibrated for the first time based on the target imaging requirements. In this scenario, a standard image can be determined or generated based on one or more of the following: target detection requirements, target object characteristics, target image quality requirements, or preset imaging evaluation indicators; alternatively, an image that meets preset imaging quality conditions can be selected as the standard image from multiple candidate images acquired by the imaging equipment to be calibrated under different imaging parameters.
[0036] Step 120: For the imaging device to be calibrated, acquire images under different focal length parameters and determine the sharpness of each acquired image, and determine the target focal length parameter based on the sharpness.
[0037] Here, the imaging device to be calibrated refers to an imaging device that needs parameter calibration to obtain an imaging effect that matches the reference image. For example, the imaging device to be calibrated may be an imaging device to be reproduced in a batch replication scenario, an imaging device to update a formula, or a production device to replicate the standard imaging effect; or it may be an imaging device to be initialized in a first imaging scenario, an imaging device to establish an initial imaging formula, or a device to determine the first set of imaging parameters.
[0038] Focal length parameters are parameters used to characterize the focusing position or magnification of the lens of an imaging device to be calibrated. For example, focal length parameters include, but are not limited to, one or more of the following: the focal length value of the lens, the focus position, the focusing step size, or focus control parameters related to image sharpness.
[0039] Sharpness refers to the clarity of the edges, textures, and details of an image. It is used to characterize the focus and sharpness of an image. Generally, the higher the sharpness, the closer the image is to the optimal focus state.
[0040] It should be noted that there is a correlation between focal length and sharpness. Specifically, when the imaging device to be calibrated acquires images at different focal lengths, the sharpness of the acquired image will vary with the focal length due to the varying degrees of matching between the imaging plane and the object's imaging position. When the focal length is within a suitable range or at the optimal focus position, the image sharpness is usually high. Based on this correlation, the processor can determine the target focal length parameter that will enable the image to achieve a preset sharpness by comparing the sharpness of images under different focal lengths.
[0041] The processor controls the imaging device to be calibrated to sequentially acquire images at multiple preset focal length parameters, and calculates the sharpness of each image. In some embodiments, the processor may first determine a search range for the focal length parameters, and then sequentially set multiple focal length parameters within the search range according to a preset step size, causing the imaging device to be calibrated to acquire images at each focal length parameter to obtain multiple candidate images. Subsequently, the processor determines the sharpness of each candidate image. Exemplarily, the sharpness may be obtained based on one or more of the following: image edge strength, gradient energy, Laplacian operator response, texture detail features, or other indicators characterizing image sharpness.
[0042] Subsequently, the processor can determine the focal length parameter with the smallest difference between the sharpness and the sharpness of the standard image as the target focal length parameter; in other embodiments, the processor can also determine the focal length parameter that meets the conditions as the target focal length parameter when the sharpness reaches a preset threshold and the corresponding image meets preset imaging quality conditions.
[0043] In feasible implementations, the processor controls the imaging device to be calibrated to perform segmented focusing and acquisition within the focal length parameter search range. Based on the sharpness variation trend of each acquired image, it determines the target focal length parameter using one or more methods such as peak search, iterative approximation, or interpolation fitting. In other feasible implementations, the processor can divide the focal length parameter search range into multiple continuous or non-continuous sub-intervals. Within each sub-interval, the focal length parameter is gradually adjusted and corresponding images are acquired to obtain the correspondence between the focal length parameter and sharpness. Then, based on the trend of sharpness variation with the focal length parameter, the processor can determine the interval where the sharpness peak is located and further narrow the search range. Acquisition and calculation are performed again within the narrowed search range until the focal length parameter corresponding to the maximum sharpness value is determined. In yet another feasible implementation, the processor can also establish a fitting curve between the focal length parameter and sharpness based on multiple preset discrete sampling points, and determine the target focal length parameter by finding the extreme value of the fitting curve.
[0044] Through the above steps, the processor can quickly filter out the optimal focal length parameter or the focal length parameter that is closest to the sharpness of the standard image from multiple focal length parameters, thereby improving the accuracy and stability of focal length parameter determination.
[0045] Step 130: Under the target focal length parameters, acquire images using different exposure parameters and determine the brightness deviation of each acquired image relative to the standard image, and determine the target exposure parameters based on the brightness deviation.
[0046] Exposure parameters refer to parameters that affect the amount of light entering the image or the brightness of the image when the imaging device to be calibrated acquires the image. For example, exposure parameters may include one or more of exposure time, gain value, aperture value, and ISO parameter; in some embodiments, exposure parameters may also be a group of exposure parameters formed by combining one or more parameters such as exposure time, gain value, and aperture value.
[0047] In feasible implementations, there is a direct correlation between exposure parameters and image brightness. For example, when the exposure time of the imaging device increases, the image sensor receives light signals for a longer period of time during a unit imaging process, thereby converting more light energy into electrical signals and increasing the brightness of the acquired image. Conversely, when the exposure time is shortened, the brightness of the acquired image decreases accordingly.
[0048] Brightness deviation refers to the degree of brightness difference between an image acquired by the imaging device under calibrated at any exposure parameter and a standard image. It characterizes the brightness deviation of the acquired image relative to the standard image under the current exposure parameters, such as whether it is too bright or too dark. In some implementations, brightness deviation can be determined based on one or more of the following: average grayscale difference between the acquired image and the standard image, average brightness difference, brightness histogram difference, target area brightness difference, or pixel brightness difference within a preset region of interest. The smaller the brightness deviation, the closer the brightness of the acquired image under the current exposure parameters is to the standard image; the larger the brightness deviation, the lower the degree of matching between the current exposure parameters and the standard image.
[0049] It's important to note that there's a correlation between exposure parameters and brightness. When other imaging conditions remain constant, increasing the exposure time, gain, or aperture will increase image brightness; conversely, decreasing the exposure time, gain, or aperture will decrease image brightness. Based on this relationship, by changing the exposure parameters at the target focal length and comparing the brightness deviation of each acquired image relative to a standard image, the target exposure parameters that best approximate the brightness of the standard image can be determined.
[0050] The processor first sets the focal length parameter of the imaging device to be calibrated to the target focal length parameter, thereby reducing the brightness evaluation error caused by defocus. Then, the processor determines the search range of exposure parameters and sets multiple candidate exposure parameters within this range, allowing the imaging device to acquire images under different candidate exposure parameters. For each acquired image, the processor compares its brightness with a standard image to obtain the corresponding brightness deviation, and determines the target exposure parameter based on the magnitude relationship of the multiple brightness deviations.
[0051] In some implementations, the processor controls the imaging device to be calibrated to sequentially acquire images using multiple preset exposure parameters under the target focal length parameter, and calculates the brightness deviation of each image relative to the standard image. Specifically, the processor can set multiple exposure times within a preset exposure time range according to a preset step size, or set multiple gain values within a preset gain range according to a preset step size, or simultaneously set multiple sets of combined parameters of exposure time and gain values, etc. After the imaging device to be calibrated acquires the corresponding image under each candidate exposure parameter, the processor calculates the brightness difference between the image and the standard image in the overall image area or a preset region of interest. Further, the processor can determine the exposure parameter with the smallest brightness deviation as the target exposure parameter; or, when the brightness deviation corresponding to a certain exposure parameter is less than a preset brightness deviation threshold, the exposure parameter is determined as the target exposure parameter.
[0052] In other implementations, the processor can iteratively adjust the exposure parameters based on the changing trend of the brightness deviation. Specifically, when the acquired image is darker than the standard image, the processor increases the exposure time, increases the gain value, and / or increases the aperture opening; when the acquired image is brighter than the standard image, the processor decreases the exposure time, decreases the gain value, and / or decreases the aperture opening. After each adjustment, the processor re-controls the imaging device to be calibrated to acquire an image and calculate the brightness deviation until the brightness deviation meets a preset condition or reaches a preset number of iterations. In this way, exposure parameters that are consistent with or substantially consistent with the brightness of the standard image can be gradually approached.
[0053] It should be noted that, in some embodiments, the order in which the target focal length parameter and the target exposure parameter of the imaging device to be calibrated are determined is not limited to the aforementioned implementation methods. That is, the processor can either determine the target focal length parameter first and then determine the target exposure parameter under the target focal length parameter, or it can determine the target exposure parameter first and then determine the target focal length parameter under the target exposure parameter.
[0054] The processor first controls the imaging device to be calibrated to acquire images under multiple candidate exposure parameters, and compares the brightness of each acquired image with a standard image to determine the brightness deviation corresponding to each candidate exposure parameter. Based on the brightness deviation corresponding to each candidate exposure parameter, the processor determines the target exposure parameter. Subsequently, the processor sets the exposure parameters of the imaging device to be calibrated to the target exposure parameter, and under this target exposure parameter, controls the imaging device to acquire images using multiple candidate focal length parameters, calculates the sharpness of each image, and thus determines the target focal length parameter.
[0055] In other embodiments, the order in which the target focal length parameter and the target exposure parameter are determined can be set according to actual calibration requirements, device control logic, ambient light stability, or imaging quality evaluation requirements.
[0056] Through the above steps, the processor can determine the target exposure parameters of the imaging device to be calibrated under the target focal length parameters, ensuring that the brightness of its acquired image is the same as or close to that of the standard image. This improves the brightness consistency and calibration accuracy of the imaging device to be calibrated.
[0057] Step 140: Acquire the current image under the target focal length parameters and target exposure parameters, determine the color deviation of the current image relative to the standard image, and iteratively adjust the color channel gain according to the color deviation to obtain the target color channel gain.
[0058] Color deviation refers to the color difference between the current image and the standard image in at least one color channel. In feasible implementations, a color channel can refer to a channel in a preset color space, such as the red (R), green (G), and blue (B) channels in the Red-Green-Blue (RGB) color space, or the hue (H), saturation (S), and lightness (V) channels in the Hue-Saturation-Value (HSV) color space. The processor can determine the color deviation of the current image relative to the standard image based on one or more of the pixel values, channel averages, or color distributions of one or more color channels.
[0059] Color channel gain refers to a parameter used to adjust the output intensity of the corresponding color channel. By adjusting the color channel gain, the color performance of the corresponding color channel in the image acquired by the imaging device to be calibrated can be changed.
[0060] The processor controls the imaging device to be calibrated to acquire the current image under the target focal length and exposure parameters, and determines the color deviation between the current image and the standard image in each color channel. If the color deviation does not meet the preset color deviation condition, the processor adjusts the gain of the corresponding color channel according to the color deviation, and re-acquires the image and recalculates the color deviation based on the adjusted color channel gain, until the color deviation meets the preset color deviation condition, and then determines the color channel gain at this time as the target color channel gain.
[0061] In some implementations, the processor may have a pre-set neural network model. After determining the color deviation between the current image and the standard image in each color channel, the processor inputs the color deviation in each color channel into the neural network model, which then outputs the gain adjustment amount or target gain value for the corresponding color channel. The processor can adjust the color channel gain of the corresponding color channel according to the gain adjustment amount, or directly use the target gain value as the updated color channel gain for the corresponding color channel.
[0062] In other implementations, the processor can determine the gain adjustment amount for the corresponding color channel based on the color deviation on each color channel and a preset gain adjustment rule. For example, the processor can query the gain adjustment amount for the corresponding color channel based on a preset mapping relationship between color deviation and gain adjustment amount; or, the processor can calculate the gain adjustment amount for the corresponding color channel based on the color deviation and a preset scaling factor. The processor updates the gain of the corresponding color channel based on the gain adjustment amount, and re-acquires the image and determines the color deviation under the updated color channel gain.
[0063] In some other implementations, the processor can determine the gain adjustment amount for a corresponding color channel using a Proportional-Integral-Differential (PID) control algorithm based on the color deviation on each color channel. For any given color channel, the processor can calculate the gain adjustment amount based on one or more of the following: the current color deviation, the cumulative value of historical color deviations, and the change between two adjacent color deviations. For example, the current color deviation corresponds to the proportional term, the cumulative value of historical color deviations corresponds to the integral term, and the change between two adjacent color deviations corresponds to the derivative term. The processor updates the gain of the color channel based on the obtained gain adjustment amount, and re-acquires the image and determines the color deviation under the updated color channel gain until the color deviation of each color channel meets a preset color deviation condition.
[0064] Through the above steps, the processor can iteratively adjust the gain of each color channel of the imaging device to be calibrated under the target focal length parameters and target exposure parameters, thereby completing the color gain calibration of the imaging device to be calibrated.
[0065] Step 150: Generate a target imaging recipe based on the target focal length parameters, target exposure parameters, and target color channel gain; the target imaging recipe is used to configure the imaging device to be calibrated for image acquisition.
[0066] The target imaging recipe refers to a set of data characterizing the combination of imaging parameters used by the imaging device to be calibrated when acquiring images. It is used to configure the imaging device to perform image acquisition, enabling it to execute imaging tasks according to the calibrated parameters. For example, the target imaging recipe may include one or more of the following: target focal length parameters, target exposure parameters, and target color channel gain; it may also include one or more of the following: light source parameters, white balance parameters, image format parameters, image resolution parameters, frame rate parameters, and trigger parameters.
[0067] The processor generates a target imaging recipe based on the target focal length parameters, target exposure parameters, and target color channel gain. This recipe is then configured into the imaging device to be calibrated, thereby calibrating the focal length, exposure, and color channel gain of the device and converting it into an imaging device. Consequently, when acquiring images based on the target imaging recipe, the imaging device can obtain images that match the reference image in terms of sharpness, brightness, and color performance, thus improving the consistency and accuracy of image acquisition in the target scene.
[0068] In some embodiments, the processor encapsulates the target focal length parameters, target exposure parameters, and target color channel gain according to a preset data format to generate a target imaging recipe. Exemplarily, the preset data format can be one or more of a table format, configuration file format, key-value pair format, script format, or database record format. The processor can also associate and store the target imaging recipe with one or more of the following: device identifier, lens identifier, application scenario identifier, calibration time, calibration environment parameters, etc., of the imaging device to be calibrated, for subsequent retrieval.
[0069] It should be noted that in the initial imaging scenario, the target imaging recipe may not include the target color channel gain, but only the target focal length and target exposure parameters, or the target color channel gain can be a default gain value. The processor can generate the target imaging recipe based on the target focal length and target exposure parameters, and configure this target imaging recipe to the imaging device to be calibrated, enabling the imaging device to acquire images based on the target focal length and target exposure parameters. After the initial imaging is completed, the processor can determine whether to further calibrate the color channel gain based on the color deviation between the actual acquired image and the standard image.
[0070] In some embodiments, during the initial imaging scenario, the processor can determine the optimal sharpness value for each of the multiple regions of interest (ROIs) and the target focal length parameter corresponding to the optimal sharpness value. Simultaneously, the processor determines the standard exposure parameter or the target exposure parameter combination, and based on the target focal length parameter and the target exposure parameter or the target exposure parameter combination, controls the imaging device to be calibrated to acquire images to generate multiple candidate images. According to a preset filtering rule, multiple preferred images are selected from the multiple candidate images and displayed on the display screen of the imaging device. The user can select the target image from the preferred images.
[0071] Furthermore, the processor can determine the corresponding target focal length and exposure parameters based on the target image selected by the user, and generate a target imaging recipe based on these parameters. This target imaging recipe is then configured onto the imaging device to be calibrated, thereby achieving automatic recommendation and rapid configuration of camera parameters in the initial imaging scenario, reducing the complexity of camera parameter tuning. In the initial imaging scenario, the target imaging recipe can include only the target focal length and exposure parameters; the target color channel gain can be excluded from parameter configuration or use a preset default value.
[0072] In other embodiments, when the imaging effect determined based on the preferred image does not meet the user's image expectations, the user can manually select a target ROI interactively. In response to the user's selection of the target ROI, the processor can adjust the focal length or exposure parameters of the imaging device to be calibrated for the target ROI and control the imaging device to acquire images. The processor can calculate the sharpness or brightness value corresponding to the target ROI based on the acquired image and compare the calculated sharpness or brightness with the sharpness and brightness of the reference image, respectively. Subsequently, the processor can determine the target focal length or target exposure parameters corresponding to the target ROI based on the comparison results and generate a corresponding target imaging formula based on the target focal length or target exposure parameters.
[0073] Figure 2 This is a schematic diagram of the imaging recipe generation process provided in other embodiments of this application. For example... Figure 2 As shown, the processor can first input a target / product image, using it as a reference image. Based on this image, the processor automatically adjusts the focal length of the imaging device to be calibrated to determine the target focal length parameter according to the image sharpness value under different focal length parameters. Subsequently, the processor can automatically adjust the exposure based on the target focal length parameter to determine the target exposure parameter based on the image brightness value under different exposure parameters. Further, the processor can automatically adjust the gain based on the target focal length parameter and the target exposure parameter to determine the target gain parameter. The processor can generate candidate imaging recipes based on the adjusted focal length parameter, exposure parameter, and gain parameter, and control the imaging device to be calibrated to acquire images based on the candidate imaging recipes to obtain candidate images. Afterward, the processor can recommend the optimal imaging quality Top map based on the imaging quality evaluation results of the candidate images. The user or processor can determine the optimal imaging formula based on the optimal imaging quality Top chart. If the determination result is yes, the corresponding focal length parameters, exposure parameters, and gain parameters are determined as the target imaging formula, and the process ends. If the determination result is no, the process can return to the steps of automatically adjusting the focal length, automatically adjusting the exposure, and / or automatically adjusting the gain, redetermine the candidate imaging formula, and recommend the optimal imaging quality Top chart again until the target imaging formula that meets the imaging requirements is determined and the process ends.
[0074] According to the imaging recipe generation method provided in this application, by having the imaging device to be calibrated acquire images under different focal length parameters and determining the sharpness of each acquired image, and further determining the target focal length parameter based on the sharpness, the automatic optimization of the imaging focus position of the imaging device to be calibrated is achieved. This enables the imaging device to be calibrated to perform subsequent exposure and color calibration under focal length parameters that meet the sharpness requirements, effectively avoiding image blurring caused by inaccurate focal length and the resulting distortion of brightness and color evaluation results. Subsequently, under the target focal length parameter, images are acquired using different exposure parameters and the brightness deviation of each acquired image relative to the standard image is determined. The target exposure parameter is determined based on the brightness deviation, achieving exposure parameter matching on the basis of sharp imaging. This makes the brightness of the image acquired by the imaging device to be calibrated approach that of the standard image, effectively reducing the impact of underexposure or overexposure on image quality and subsequent color calibration. The impact on accuracy is considered. Subsequently, the current image is acquired under target focal length and exposure parameters. The color deviation of the current image relative to the standard image is determined, and the color channel gain is iteratively adjusted based on the color deviation to obtain the target color channel gain. This achieves adaptive correction of the color channel under the condition that both focal length and exposure are calibrated, thereby gradually bringing the color performance of the current image closer to the standard image, effectively improving the color consistency and imaging reproduction accuracy of the imaging device to be calibrated. Finally, a target imaging recipe is generated based on the target focal length, target exposure, and target color channel gain. This target imaging recipe is then used to configure the imaging device to be calibrated for image acquisition. This effectively achieves joint configuration of focal length, exposure, and color gain parameters, avoiding mutual interference caused by independent adjustment of each imaging parameter. It enables rapid reproduction of imaging parameters across devices while effectively improving the consistency of imaging results.
[0075] In related technologies, color deviation in imaging is typically determined by comparing the overall color difference between the current image and a standard image. However, different regions in a product image or target image may differ in color, material, texture, reflectivity, and lighting conditions. Determining color deviation solely based on the average color value of the entire image can easily mask color anomalies in localized areas, leading to inaccurate color deviation assessments. For example, some areas in the current image may exhibit significant color cast, but because other areas show smaller color differences, the average color deviation of the entire image may still appear low, thus affecting the accuracy of image formulation adjustments.
[0076] Based on this, in some embodiments, determining the color deviation of the current image relative to the standard image specifically includes: determining multiple current image regions and multiple standard image regions in the current image and the standard image, respectively; the multiple current image regions and the multiple standard image regions are in one-to-one correspondence; for any pair of corresponding current image regions and standard image regions, determining the average color channel value of the current image region in multiple color channels and the average standard color channel value of the standard image region in multiple color channels, respectively; for each color channel, determining the color deviation of the current image region in the corresponding color channel based on the difference between the average color channel value of the current image region and the average standard color channel value of the standard image region; and determining the color deviation of each current image region in multiple color channels as the color deviation of the current image relative to the standard image.
[0077] The current image refers to the image acquired by the imaging device to be calibrated under the current imaging formula. The current image region is a local image region or ROI region that is pre-divided or selected from the current image. The standard image region refers to a local image region or ROI region that is pre-divided or selected from the standard image.
[0078] Furthermore, the one-to-one correspondence between multiple current image regions and multiple standard image regions means that each current image region has a corresponding standard image region in terms of its position, size, content, or target object.
[0079] A color channel refers to a different color channel in a color space. For example, it can be the R, G, and B channels in the RGB color space, or the H, S, and V channels in the HSV color space.
[0080] Color channel mean refers to the average pixel value of each pixel in the corresponding color channel within a given image region; standard color channel mean can represent the average pixel value of each pixel in the corresponding color channel within a standard image region; color deviation can be used to characterize the degree of color difference between the current image region and the corresponding standard image region across multiple color channels.
[0081] The processor can determine multiple current image regions and multiple standard image regions in the current image and standard image respectively, according to one or more of the following: preset grid, preset detection area, or target color block position, so that the two correspond one-to-one in terms of image position or target content. For each pair of corresponding image regions, the processor counts the pixel values of each pixel in the current image region and the standard image region in multiple color channels, and calculates the mean of each color channel. Subsequently, for each color channel, the processor calculates the difference between the mean of the color channel of the current image region and the mean of the standard color channel of the corresponding standard image region, and uses this difference as the color deviation of the current image region in the corresponding color channel. Thus, the color deviation of each current image region in multiple color channels can be obtained as the color deviation of the current image relative to the standard image.
[0082] For example, when the color channels are the R, G, and B channels in the RGB color space, the processor can calculate the average R, G, and B channels of the current image region, and then calculate the standard R, G, and B channels of the corresponding standard image region. Subsequently, the processor can determine the color deviation of the current image region in the R channel as the difference between the current image region's average R channel value and the standard R channel value; the color deviation of the current image region in the G channel as the difference between the current image region's average G channel value and the standard G channel value; and the color deviation of the current image region in the B channel as the difference between the current image region's average B channel value and the standard B channel value. In this way, the color deviation of the three RGB channels corresponding to each current image region can be obtained, thus reflecting the color cast of the current image relative to the standard image in different regions and different color channels.
[0083] In some feasible implementations, the processor can also register the current image and the standard image before region segmentation to make the positions of corresponding regions more consistent; or it can remove abnormal pixels, overexposed pixels, or noise pixels in each image region before calculating the color channel mean to reduce the impact of image offset or local noise on the color deviation calculation results. The above methods can be used individually or in combination to adapt to different imaging calibration scenarios.
[0084] In the above embodiments, by determining multiple one-to-one corresponding image regions in the current image and the standard image, and comparing the color channel averages of the corresponding regions in multiple color channels, color deviation can be determined from two dimensions: local region and color channel. This avoids the problem of the overall image average masking local color cast and improves the accuracy of the color deviation determination result.
[0085] In related technologies, when adjusting the color channel gain based on color deviation, the gain can usually be adjusted directly based on the overall color deviation of the currently acquired image. However, this method is easily affected by local color casts, image noise, or fluctuations in a single acquisition, leading to unstable gain adjustment; furthermore, if adjustment is made only based on the average deviation, some areas may still have significant color deviations.
[0086] In some embodiments, the target color channel gain is obtained by iteratively adjusting the color channel gain based on the color deviation. Specifically, this includes: for each color channel, determining the maximum color deviation from the color deviations of each current image region in the corresponding color channel, and using the maximum color deviation as the current error of the corresponding color channel; determining the control quantity corresponding to each color channel based on the current error of each color channel and the corresponding preset number of historical errors; adjusting the channel gain of the corresponding color channel based on the control quantity corresponding to each color channel, and controlling the imaging device to be calibrated to acquire new current images according to the adjusted channel gains; redetermining the color deviation of each current image region relative to the corresponding standard image region in the new current image; if the redetermined color deviation does not meet the deviation condition, returning to the step of determining the maximum color deviation from the color deviations of each current image region in the corresponding color channel and continuing execution until the redetermined color deviation meets the deviation condition; and determining the channel gain of each color channel when the deviation condition is met as the target color channel gain.
[0087] Color channel gain refers to the gain parameters of the imaging device under calibration in different color channels, such as R channel gain, G channel gain, and B channel gain. Maximum color deviation refers to the color deviation with the largest degree of deviation among all current image regions within the same color channel.
[0088] Current error refers to the color deviation of the corresponding color channel during the current iteration; while historical error refers to the color deviation determined in one or more iterations before the current iteration.
[0089] The control quantity refers to the adjustment amount determined based on the current error and historical error, used to adjust the gain of the corresponding color channel.
[0090] Deviation conditions refer to the conditions used to determine whether the color deviation of the current image relative to the standard image has met the calibration requirements.
[0091] For each color channel, the processor obtains the color deviation of each current image region on that color channel and determines the color deviation with the largest absolute value as the current error of that color channel. For example, for the R channel, the processor can determine the largest R channel color deviation from the R channel color deviations of multiple current image regions as the current error of the R channel; the same method can be used to determine the corresponding current errors for the G and B channels respectively.
[0092] Subsequently, the processor determines the control quantity for each color channel based on the current error of each color channel and the corresponding preset number of historical errors. For example, the processor can use proportional control, proportional-integral control, or proportional-integral-derivative control to determine the control quantity based on the current error and the previous one or more historical errors.
[0093] In a feasible implementation, the preset number of historical errors can be, for example, 5. The purpose of introducing historical errors is to ensure that the determination of the control quantity depends not only on the color deviation obtained from the current image acquisition but also on the changes in errors during previous iterations. This reduces the impact of image noise, slight fluctuations in the light source, or single acquisition anomalies on the gain adjustment results. By introducing historical errors, the processor can determine whether the color deviation is persistent, gradually decreasing, gradually increasing, or oscillating, and adjust the magnitude and direction of the control quantity accordingly. This avoids over-adjustment or repeated oscillations of the channel gain due to sudden changes in a single error, improving the stability and convergence of the color channel gain iterative adjustment process.
[0094] Taking the PID control algorithm as an example, the control quantity can be determined based on the current error, historical error, and the change between the current error and the previous historical error.
[0095] After determining the control values, the processor can adjust the channel gain of each color channel according to the control values for each color channel. For example, the processor can adjust the R channel gain according to the R channel control value, the G channel gain according to the G channel control value, and the B channel gain according to the B channel control value. After the adjustment is completed, the processor controls the imaging device to be calibrated to reacquire images according to the adjusted channel gains, obtain a new current image, and recalculate the color deviation of each current image region relative to the corresponding standard image region in each color channel.
[0096] If the recalculated color deviation does not meet the deviation condition, the processor can continue to determine the maximum color deviation from the color deviations of each current image region in the corresponding color channel, and repeat the process of determining the current error, calculating the control quantity, adjusting the channel gain, re-acquiring the image, and recalculating the color deviation until the recalculated color deviation meets the deviation condition. If the recalculated color deviation meets the deviation condition, the processor can determine the channel gain of each color channel at this time as the target color channel gain.
[0097] In some implementations, the deviation condition may be that the maximum color deviation of each color channel is less than or equal to the corresponding preset deviation threshold; in other implementations, the deviation condition may be that the color deviation of each current image region on multiple color channels is less than or equal to the preset deviation threshold; in still other implementations, the deviation condition may be that the color deviation meets the preset requirement after a preset number of consecutive iterations.
[0098] For example, the processor can employ an improved PID closed-loop control algorithm to determine the control input for each color channel based on the current error of each color channel and the corresponding preset number of historical errors. The PID closed-loop control algorithm integrates three control elements: proportional control (P), integral control (I), and derivative control (D).
[0099] Among them, proportional control is used to generate a control quantity proportional to the current error to quickly respond to the current color deviation and reduce the current deviation; integral control is used to generate a control quantity based on the cumulative result of the current error and historical error to eliminate the persistent steady-state error and improve the long-term calibration accuracy; derivative control is used to generate a control quantity based on the error change rate to predict the error change trend and make adjustments in advance, thereby reducing overshoot and oscillation during the gain adjustment process.
[0100] In a feasible implementation, the processor calculates the control quantity based on the most recent preset number of frame error samples. For example, the preset number can be 5. The processor can use the current error and the historical errors from the last 4 iterations to form an error sliding window, and calculate the PID control quantity based on this error sliding window.
[0101] Specifically, for any given color channel, the processor can determine the control quantity corresponding to that color channel using the following formula: (1) in, This indicates the PID output control quantity corresponding to this color channel in this iteration; This indicates the current error for that color channel; , , , These represent the historical errors of the color channel before the current iteration, and can be the errors determined in the last four iterations. This represents the proportional weight, used to control the degree of influence of the current error on the control quantity; This represents the integral weight, used to control the degree of influence of the accumulated error on the control quantity; This represents the differential weight, used to control the degree of influence of the error change trend on the control quantity.
[0102] In some implementations, the above , , The value range can be, for example, [0.0, 10.0]. In other embodiments, , , The initial values can be 1.0, 0.5, and 0.5. It is easy to understand that the above range and initial values are only examples, and in actual applications, they can be adjusted according to the response characteristics of the imaging device to be calibrated, the stability of the light source, the calibration accuracy requirements, etc.
[0103] When performing color difference calibration for the RGB three channels, the processor can execute the aforementioned PID control calculation process for the R, G, and B channels respectively. Specifically, the processor can first calculate the average color value of each current image region, i.e., each ROI region, in the R, G, and B channels, and determine the color deviation of that ROI region relative to the corresponding standard image region in the R, G, and B channels respectively. Subsequently, for each color channel, the processor can select the maximum color deviation from all ROI regions in that color channel as the current error for that color channel.
[0104] After determining the PID output control quantity corresponding to each color channel, the processor can update the channel gain of the corresponding color channel based on the corresponding control quantity. Specifically, for any color channel, the channel gain of that color channel can be updated according to the following formula: (2) in, This indicates the channel gain of the imaging device to be calibrated on this color channel in the next iteration; This indicates the channel gain of the imaging device to be calibrated on this color channel during the current iteration; This represents the control output of the PID algorithm. For the R, G, and B channels, the processor can calculate the corresponding values separately. And update the R channel gain, G channel gain and B channel gain respectively.
[0105] After completing the channel gain update, the processor can control the imaging device to be calibrated to reacquire the current image according to the updated R-channel gain, G-channel gain, and B-channel gain, and recalculate the color deviation of each ROI region in the new current image relative to the corresponding standard image region. If the recalculated color deviation does not meet the deviation condition, the process of error determination, PID control quantity calculation, channel gain update, and image reacquisition continues; if the recalculated color deviation meets the deviation condition, the current R-channel gain, G-channel gain, and B-channel gain are determined as the target color channel gain.
[0106] Figure 3 This is a schematic diagram of the color gain adjustment process provided in some embodiments of this application. For example... Figure 3 As shown, after inputting a target or product image, the processor sets the template RGB gain, small fluctuation range, and multiple ROI regions (i.e., image regions). Then, the processor controls the imaging device to be calibrated to capture an image, and processes the captured image to calculate the color deviation (i.e., color difference). The template RGB gain refers to the pre-determined color channel gain used as a reference for gain adjustment; the small fluctuation range refers to the range of changes in the gain parameter allowed for fine-tuning during gain adjustment, used to avoid significant color fluctuations caused by excessively large single adjustments. After calculating the color difference, the processor further determines whether the color difference meets the conditions. When the result is "yes," it means that the color adjustment result corresponding to the current RGB gain has met the preset requirements, and the process proceeds to successful gain adjustment. When the result is "no," it means that the color adjustment result corresponding to the current RGB gain has not yet met the preset requirements, and the processor adjusts the gain in small steps based on the current color difference result, or adjusts the gain according to the recommended adjustment method. Among them, small step gain adjustment refers to updating the gain of one or more color channels with a small adjustment range based on the current RGB gain; the recommended adjustment method can be the gain adjustment method determined by the processor based on the current color difference, historical color difference, preset adjustment rules or closed-loop control algorithm.
[0107] After adjusting the gain, the processor controls the imaging device to be calibrated to capture an image again, and repeats the process of calculating the color difference, determining whether the color difference meets the conditions, and continuing to adjust the gain if the conditions are not met, until the color difference meets the conditions. Through the above iterative process, the RGB gain of the imaging device to be calibrated can be gradually made closer to the target gain, thereby completing the color gain adjustment.
[0108] In the above embodiments, by selecting the maximum color deviation in multiple current image regions for each color channel as the current error, and combining it with a preset number of historical errors to determine the control quantity, and then iteratively adjusting the channel gain of each color channel based on the control quantity, it is possible to take into account both the local maximum color deviation and the error change trend, avoid the local color deviation being masked by the average deviation, and improve the stability and convergence of the gain adjustment, thereby obtaining the target color channel gain that meets the color deviation requirements more accurately.
[0109] In some embodiments, acquiring images under different focal length parameters and determining the sharpness of each acquired image, and determining the target focal length parameter based on the sharpness, specifically includes: obtaining a reference sharpness and determining an initial focal length parameter; acquiring images under the initial focal length parameter and determining the sharpness of the acquired images; comparing the sharpness with the reference sharpness, and if the sharpness is less than the reference sharpness and the difference between the sharpness and the reference sharpness is not less than a sharpness threshold, iteratively adjusting the initial focal length parameter according to a preset focal length step size, acquiring images after each adjustment and determining the sharpness of the acquired images; determining the focal length parameter corresponding to the sharpness extremum condition when the sharpness satisfies the sharpness extremum condition based on the relationship between multiple consecutive focal length parameters obtained during the iterative adjustment process and their corresponding sharpness; and determining the target focal length parameter based on the focal length parameter that satisfies the sharpness extremum condition.
[0110] The reference sharpness refers to the sharpness reference value used as a comparison benchmark. In some embodiments, the reference sharpness can be a pre-set sharpness threshold, the sharpness value corresponding to a standard image, or the sharpness value under the historical best focal length parameters. In other embodiments, the reference sharpness can also be the standard sharpness obtained by manual calibration or processor calibration.
[0111] The initial focal length parameter refers to the starting parameter used to begin the focal length search. The initial focal length parameter includes, but is not limited to, the preset focal length value, the previously saved focal length parameter, or the initial value determined based on the device's factory parameters, scene parameters, or empirical parameters.
[0112] The sharpness threshold is a threshold used to determine whether a change in sharpness meets the criteria for continued iterative adjustment. It is used to avoid invalid searches when the change in sharpness is too small.
[0113] The preset focal length step size refers to the increment or decrement used each time the focal length parameter is adjusted, which is used to control the granularity of the focal length search.
[0114] The sharpness extremum condition refers to the judgment condition corresponding to the sharpness reaching a local maximum, a global maximum, or satisfying the preset trend inflection point characteristics; the target focal length parameter refers to the focal length parameter used for imaging acquisition corresponding to the sharpness extremum condition.
[0115] In some implementations, the processor acquires an image at an initial focal length parameter and determines the sharpness of the acquired image. The methods for determining the sharpness of the acquired image include, but are not limited to, one or more of the following: image sharpness evaluation algorithms, gradient energy evaluation algorithms, edge strength evaluation algorithms, Laplacian operator evaluation algorithms, frequency domain high-frequency component evaluation algorithms, or other image sharpness evaluation algorithms. For example, the processor may perform grayscale processing on the acquired image, calculate the gradient magnitude, edge response value, or high-frequency component energy of the image, and use these as a sharpness indicator.
[0116] After the processor compares the sharpness with the reference sharpness, if the sharpness is less than the reference sharpness and the difference between the two is not less than the sharpness threshold, it indicates that the image sharpness obtained under the current initial focal length parameters deviates significantly from the reference sharpness. This means that the current focal length parameters have not yet reached an optimal state and need to be further adjusted. At this time, the processor iteratively adjusts the focal length parameters according to the preset focal length step size.
[0117] In feasible implementations, when the processor iteratively adjusts the initial focal length parameter according to a preset focal length step size, it can adjust along the direction of increasing focal length or along the direction of decreasing focal length. The specific adjustment direction can be determined based on one or more of the following: the trend of sharpness change, the result of comparing the sharpness of two consecutive images, historical focusing directions, or a preset search strategy. For example, if adjusting the focal length parameter in a certain direction improves the sharpness of the acquired image compared to before the adjustment, the adjustment can continue in that direction; if adjusting the focal length parameter in a certain direction decreases the sharpness of the acquired image compared to before the adjustment, the adjustment direction can be changed, or the focal length step size can be reduced before continuing the search.
[0118] In other feasible implementations, the processor iteratively adjusts the initial focal length parameter according to a preset focal length step size, which may include one or more of the following: unidirectional incremental adjustment, unidirectional decremental adjustment, bidirectional search adjustment, adaptive step size adjustment, and segmented adjustment. Specifically, unidirectional incremental adjustment refers to adjusting the focal length parameter in an increasing direction with a fixed step size each time; unidirectional decremental adjustment refers to adjusting the focal length parameter in a decreasing direction with a fixed step size each time; bidirectional search adjustment refers to searching along one direction first, and if no sharpness extreme point is found, switching directions to continue searching; adaptive step size adjustment refers to using a larger step size when sharpness changes rapidly, and decreasing the step size when approaching the sharpness extreme point; segmented adjustment refers to using a larger step size in the coarse adjustment stage and a smaller step size in the fine adjustment stage, thereby balancing focal length search efficiency and target focal length parameter determination accuracy.
[0119] After each adjustment of the focal length parameter, the processor re-controls the imaging device to acquire images and recalculates the sharpness of the acquired images, thereby obtaining multiple consecutive focal length parameters and their corresponding sharpness. The processor can determine the focal length parameter corresponding to the sharpness extremum condition based on the relationship between these multiple consecutive focal length parameters and sharpness. This relationship can include one or more of the following: sharpness initially increases and then decreases as the focal length parameter increases; it can also include an inflection point characteristic where sharpness reaches its peak and then begins to decline; or it can include a local maximum characteristic of the sharpness curve. Specifically, the processor can determine whether the sharpness has changed from increasing to decreasing, or vice versa, by comparing the sharpness corresponding to multiple adjacent focal length parameters. The processor can also fit multiple sampling points, for example, using curve fitting, interpolation fitting, quadratic function fitting, or cubic spline fitting, to solve for the extreme points of the sharpness curve, thus obtaining the focal length parameter that satisfies the sharpness extremum condition more accurately.
[0120] In some implementations, the focal length parameter corresponding to the sharpness extremum condition can be the focal length parameter with the highest sharpness among multiple consecutive focal length parameters, the focal length parameter corresponding to the peak obtained through fitting calculation, or the focal length parameter that simultaneously satisfies the condition of reaching a local maximum sharpness while the sharpness on both adjacent sides decreases. If multiple local extrema exist during the search process, the processor can further combine factors such as the magnitude of the sharpness value, the stability of the focal length parameter, the consistency of historical focal length parameters, or the priority of the imaging task to select one of the optimal focal length parameters as the target focal length parameter.
[0121] In some embodiments, when the processor determines the target focal length parameter based on the focal length parameter that satisfies the sharpness extreme value condition, it can directly use the focal length parameter as the target focal length parameter; it can also make fine adjustments based on the focal length parameter and use the finely adjusted focal length parameter as the final target focal length parameter; or it can combine factors such as system safety margin, lens mechanical error, and temperature drift compensation to correct the focal length parameter and use the corrected focal length parameter as the target focal length parameter.
[0122] In some implementations, the processor first sets initial focal length parameters, a focal length search range, and a region of interest (ROI). The initial focal length parameters can be the lens's default focal length parameters, the focal length search range defines the effective interval for focal length adjustment, and the ROI region defines the area for sharpness calculation. Subsequently, the processor controls the imaging device to acquire the current image based on the initial focal length parameters and performs sharpness calculations on the ROI region in the acquired image to obtain the sharpness value corresponding to the current focal length parameters. After obtaining the current sharpness value, the processor compares the current sharpness with a preset sharpness threshold to determine whether the current image meets further search conditions. If the current sharpness is greater than the preset sharpness threshold, the processor further determines whether the sharpness corresponding to the previous focus adjustment is an extreme point, i.e., whether the sharpness curve has reached a local maximum or whether there is an inflection point where it changes from increasing to decreasing. If the previous sharpness is determined to be an extreme value, the processor determines the focal length range before and after the extreme point and performs fine-tuning of the focal length parameters within this focal length range using small steps. Each time the focal length parameter is adjusted, the processor re-controls the imaging device to acquire images and recalculates the sharpness of the acquired images, thereby obtaining multiple consecutive focal length parameters and their corresponding sharpness values.
[0123] Following this, the processor determines whether the sharpness continues to increase based on the relationship between adjacent focal length parameters and sharpness. If the new sharpness is greater than the current maximum sharpness, the maximum sharpness and its corresponding focal length parameters are updated. If the sharpness does not continue to increase, it is determined that the sharpness peak has been reached, and the corresponding focal length parameter is set as the target focal length parameter. If the current sharpness is greater than the preset sharpness threshold but the previous sharpness was not an extreme value, the processor adjusts the focal length parameter with a large step size and continues to repeat the process of acquiring images and calculating sharpness until the focal length parameter corresponding to the sharpness extreme value condition is found. It should be noted that the above method can be applied to the focusing process in the first imaging scenario, especially suitable for situations where historical focus parameters or target focal length reference information have not yet been obtained. By combining large step size search with small step size fine search, the focal length parameter is determined, thereby improving the accuracy and stability of autofocus.
[0124] In some implementations, if the current sharpness is not greater than a preset sharpness threshold, the processor continues to adjust the focal length parameter according to a preset large step size, and re-acquires the image and recalculates the sharpness after each adjustment. It determines whether extreme value characteristics have appeared based on the changing trends of multiple consecutive focal length parameters and their corresponding sharpness. If the current focal length parameter exceeds the preset focal length range during the search process, the processor determines that autofocus has failed and outputs a failure message or executes a retry procedure. If it does not exceed the preset focal length range, the above search process continues until a focal length parameter that meets the sharpness extreme value condition is determined, and this focal length parameter is used as the target focal length parameter.
[0125] Figure 4 This is a schematic diagram illustrating the focus adjustment process in the initial imaging scenario provided in some embodiments of this application. For example... Figure 4 As shown, first, the target or product is placed, and the initial focal length, focal length search range, and ROI area are set. Then, the imaging device to be calibrated is controlled to capture images, and the sharpness of the acquired images is calculated. The processor determines whether the sharpness of the current image is greater than a preset threshold. If so, it further determines whether the previous sharpness was an extreme value. If the previous sharpness was an extreme value, the focal length range corresponding to the extreme point is obtained, and the focal length is adjusted in small steps within this focal length range. Then, the image is re-captured and the sharpness is recalculated. Then, it is determined whether the sharpness is greater than the maximum value. If so, the autofocus is considered successful; if not, the focal length is adjusted in small steps again. If the previous sharpness is not determined to be an extreme value, the focal length is adjusted in large steps, and it is determined whether it exceeds the focal length range. If it exceeds the focal length range, the autofocus is considered to have failed; if it does not exceed the focal length range, the image is captured and the sharpness is calculated again, and the next round of judgment is entered. If the initial sharpness is not greater than the preset threshold, the subsequent search is continued after adjusting the focal length in large steps until the autofocus success condition is met or the autofocus is considered to have failed.
[0126] In batch re-enhancing scenarios, the processor first acquires the target or product to be imaged and sets the baseline exposure parameters, focal length search range, and ROI region. The baseline exposure parameters serve as a reference for subsequent batch re-enhancing, the focal length search range defines the adjustment interval, and the ROI region defines the brightness calculation area to improve accuracy. Subsequently, the processor controls the imaging device to capture an image and calculates the brightness of the ROI region to obtain the current brightness value. After obtaining the current brightness value, the processor determines whether the brightness error is less than a preset threshold. If the brightness error is less than the preset threshold, the current exposure parameters are deemed to meet the requirements, and automatic exposure is successful. If the brightness error is not less than the preset threshold, the processor adjusts the exposure parameters in small steps, re-controls the imaging device to capture an image, recalculates the brightness, and repeats the above process until the brightness error meets the preset conditions, thus completing the exposure adjustment in the batch re-enhancing scenario.
[0127] It's easy to understand that batch re-enhancing scenarios and initial imaging scenarios may differ in parameter acquisition methods, adjustment strategies, and optimization objectives. Specifically, in initial imaging scenarios, the imaging conditions of the object to be imaged typically lack historical reference information, making it difficult for the processor to directly obtain the optimal parameters corresponding to the current target. Therefore, a large-scale search and iterative process are needed to coarsely and finely adjust the focal length or exposure parameters until the target parameters that meet the sharpness or brightness requirements are found. In contrast, in batch re-enhancing scenarios, the objects to be imaged usually have high consistency, and template exposure parameters, template focal length parameters, or corresponding reference imaging conditions can be obtained in advance. The processor can perform rapid correction based on existing templates, requiring only minor parameter adjustments within a small range to meet the re-enhancing requirements. Therefore, batch re-enhancing scenarios emphasize parameter reuse and rapid consistency control, while initial imaging scenarios emphasize completing parameter search and target parameter determination under conditions lacking prior information.
[0128] Figure 5 This is a schematic diagram of the focus adjustment process in a batch re-firing scenario provided in some embodiments of this application. For example... Figure 5 As shown, in a batch re-enhancing scenario, the processor first inputs the target or product image to be imaged and sets the template exposure parameters, small fluctuation range, and ROI region. The template exposure parameters provide basic imaging conditions for the initial imaging, the small fluctuation range limits the step size range for focus adjustment, and the ROI limits the area for sharpness calculation to improve the accuracy of focus determination. Subsequently, the processor controls the imaging device to capture the image and calculates the sharpness of the ROI region to obtain the current sharpness value. Next, the processor determines whether the current sharpness value has reached its maximum value or meets a preset extreme value condition. If so, the current focus parameter is determined to correspond to the optimal imaging state, and autofocus is successful. If not, the processor adjusts the focus in small steps, re-controls the imaging device to capture the image, recalculates the sharpness, and repeats the above process until the focus parameter corresponding to the maximum sharpness value is found, thus completing the focus adjustment in the batch re-enhancing scenario.
[0129] In the above embodiments, by obtaining a baseline sharpness and performing iterative search in combination with the initial focal length parameters, and then determining the focal length parameters corresponding to the sharpness extreme points based on the relationship between multiple consecutive focal length parameters and their corresponding sharpness, the errors caused by relying solely on a single sharpness judgment can be effectively avoided, improving the accuracy and stability of the target focal length parameter determination. At the same time, by setting a sharpness threshold and a preset focal length step size, the number of invalid searches can be reduced, improving the efficiency of focal length adjustment, thereby enhancing image sharpness and the robustness of autofocus.
[0130] Figure 6 This is a schematic diagram of the ideal sharpness evaluation curve provided in some embodiments of this application. For example... Figure 6 As shown, the ideal sharpness evaluation curve exhibits a single-peak distribution, with the horizontal axis representing the focal length parameter and the vertical axis representing the sharpness evaluation value. As the focal length parameter changes, the sharpness evaluation value first gradually increases to reach a peak, and then gradually decreases. Here, P is the maximum point of the evaluation function, corresponding to the system's focal position; P1 and P2 are the sharpness evaluation results at the in-focus and out-of-focus positions, respectively. Based on this ideal sharpness evaluation curve, the processor can compare the sharpness evaluation values under different focal length parameters to determine the focal length parameter corresponding to the maximum sharpness value, thereby achieving automatic focusing.
[0131] In related technologies, image sharpness evaluation methods are mostly based on gradient statistics, such as the Brenner gradient method and the energy gradient method.
[0132] Among them, the Brenner gradient method characterizes image sharpness by calculating the square of the gray-level difference between two pixels separated by a preset pixel distance. Let... For the image in The gradient response value at point A can be calculated using the following formula: (3) (4) (5) in, Indicates the image in The pixel grayscale value at that location; Represents the pixel coordinates in the image; Represents pixels exist The coordinates of the pixel located two pixels apart in the direction; Indicates the image in coordinates The pixel grayscale value at that location; Represents pixels The Brenner gradient response value at that location is used to characterize the intensity of grayscale changes at that location that are two pixels apart. This represents the total number of valid pixels involved in the calculation; This represents the mean of the gradient response values; This represents the variance of the gradient response value.
[0133] The energy gradient law is considered simultaneously direction and The gradient change in direction is characterized by the statistical result of the sum of squared bidirectional pixel differences to determine sharpness. Its calculation formula can be expressed as: (6) (7) (8) (9) (10) in, Represents pixels exist Gradient energy response value in the direction; Indicates the image in coordinates The pixel grayscale value at that location; Represents pixels exist The coordinates of adjacent pixels in the direction; Represents pixels exist Gradient energy response value in the direction; Indicates the image in coordinates The pixel grayscale value at that location; Represents pixels exist The coordinates of adjacent pixels in the direction; Represents pixels The comprehensive gradient energy response value at that point, i.e. Directional gradient energy response value and The sum of the directional gradient energy response values; This represents the total number of valid pixels involved in the calculation; This represents the mean of the overall gradient energy response values; This represents the variance of the overall gradient energy response value.
[0134] However, the aforementioned traditional sharpness evaluation methods have inherent limitations, namely, their evaluation values are usually difficult to normalize to a uniform value range of [0, 100]. For different targets, such as targets and workpieces, due to differences in edge features, texture complexity, and grayscale distribution, even within the same ROI area, the sharpness evaluation curves of different products will still exhibit significantly different value ranges. This makes it difficult for traditional methods to use a uniform threshold to determine the imaging sharpness of different products, and thus, in batch re-production scenarios, parameter adjustments often need to rely on manual experience.
[0135] In some embodiments, sharpness is obtained by: extracting the edge region of the acquired image and determining multiple valid pixels in the edge region; for any valid pixel, determining the neighborhood range of the valid pixel, and determining the grayscale information and gradient direction information of the valid pixel within the neighborhood range; determining the gradient change degree of the valid pixel based on the grayscale information and gradient direction information; and determining the sharpness of the acquired image based on the gradient change degree of multiple valid pixels.
[0136] Among them, the edge region refers to the region in the image where the gray level changes significantly and can reflect the outline or structural features of the target; the effective pixel refers to the pixel in the edge region that participates in the sharpness calculation, such as the pixel that meets the edge response condition, gradient magnitude condition or preset screening condition; the neighborhood range refers to the local pixel set within a preset size range centered on any effective pixel.
[0137] Furthermore, grayscale information refers to the grayscale value, grayscale difference, or grayscale distribution characteristics of pixels within the neighborhood; gradient direction information refers to the direction information corresponding to the direction of the fastest grayscale change of a pixel; gradient change degree refers to one or more of the following: grayscale change amplitude, gradient intensity, directional consistency change, or gradient difference with surrounding pixels, used to characterize the clarity of local edges.
[0138] In some implementations, extracting the edge region of the acquired image may include: converting the acquired image to grayscale and extracting the edge response region using the Sobel operator, Cannibal operator, Previtt operator, or other edge detection operators; further, pixels with edge response values greater than a preset edge threshold may be identified as valid pixels, and the number of valid pixels may be counted to obtain the total number of valid edge pixels.
[0139] In some embodiments, for any valid pixel The processor can determine a 3×3 neighborhood centered on the effective pixel, and based on the pixel gray-level differences in eight directions within the 3×3 neighborhood, determine the gray-level difference value along the gradient direction at the effective pixel. Specifically, the processor can calculate the gray-level differences in the horizontal, vertical, two diagonal, and other adjacent directions, and determine the positive and negative gray-level values corresponding to the gradient direction, denoted as the 3×3 neighborhood positive gray-level value and the 3×3 neighborhood negative gray-level value, respectively. The difference between the 3×3 neighborhood positive gray-level value and the 3×3 neighborhood negative gray-level value can be used to represent the local gray-level difference value along the gradient direction at the effective pixel (x, y), and reflect the intensity of short-distance edge changes near the effective pixel.
[0140] In some implementations, the processor can also be configured with effective pixels. Centered on the effective pixel, extend N pixels to both sides along the gradient direction to obtain the corresponding N×N neighborhood or the extended sampling range formed along the gradient direction. Within this range, determine the maximum and minimum gray values of the N×N neighborhood. The difference between the maximum and minimum gray values of the N×N neighborhood can represent the image at the effective pixel. The gray-level difference extreme range obtained after extending N pixels along the gradient direction is used to characterize the gray-level dynamic range in a large local area near the effective pixel. N can be a preset value, such as 3, 5, 7, 9, etc., or can be adaptively determined according to image resolution, edge width, target size, or actual detection accuracy requirements.
[0141] In some embodiments, the gradient change level of effective pixels can be determined based on grayscale information and gradient direction information using the following formula: (11) in, Indicates the image in The degree of gradient change after normalization, and its value range can be [0,1]. Indicates the image in The gray-level difference in the 3×3 neighborhood along the gradient direction; Indicates the image in The grayscale difference extreme range after extending N pixels along the gradient direction. By dividing the local gradient difference in the 3×3 neighborhood by the grayscale dynamic range within the range extended along the gradient direction, the gradient response under different brightness, texture, and ROI size conditions can be normalized, making the resulting gradient change more reflective of the relative sharpness at the real edge.
[0142] In some feasible implementations, when When the value is 0, or less than a preset grayscale difference threshold, the processor can discard the valid pixel and exclude it from the sharpness calculation; alternatively, the denominator can be set to a preset minimum value to avoid abnormal calculation results caused by division by zero or weak grayscale variation areas. Furthermore, it can... Perform truncation, amplitude limiting, or normalization corrections to stabilize it within the range of [0,1].
[0143] In some embodiments, determining the sharpness of the acquired image based on the gradient change of multiple valid pixels may include: assigning gradients to the corresponding values of multiple valid pixels. The mean value is calculated to obtain the normalized gradient change mean. As shown in the following formula: (12) in, This represents the total number of valid pixels at the edge. Furthermore, it can also be based on the number of valid pixels corresponding to... Calculate the normalized gradient variation variance As shown in the following formula: (13) Among them, the normalized gradient variation variance This represents the dispersion of the normalized gradient changes at multiple edge pixels. The processor can then calculate the mean of the normalized gradient changes. Variance can be used as a measure of the sharpness of the acquired image, or it can be used as the mean of the normalized gradient change. With normalized gradient variation variance The sharpness of the acquired image is obtained after weighted fusion. For example, when the overall edge sharpness is more important, the mean of the normalized gradient change can be used. Representational clarity; when it is necessary to distinguish between consistent edge changes and sharp local differences, normalized gradient variation variance can be used. Or normalized gradient change mean With normalized gradient variation variance The combination of characteristics represents clarity.
[0144] In some implementations, the processor can perform a global normalization mapping on the sharpness, uniformly mapping the sharpness evaluation results to a standard value range of [0, 100]. Specifically, the processor can perform linear normalization on the current sharpness based on a preset lower sharpness limit and a preset upper sharpness limit to obtain a standardized sharpness evaluation value.
[0145] In the above embodiments, by normalizing the local gray-level difference of effective edge pixels along the gradient direction and determining the image sharpness based on the normalized gradient change of multiple effective pixels, the influence of image area size, target texture differences and brightness changes on the evaluation results can be effectively reduced, improving the accuracy and stability of sharpness evaluation, thereby providing a more reliable basis for determining target focal length parameters.
[0146] In some embodiments, images are acquired using different exposure parameters and the brightness deviation of each acquired image relative to a standard image is determined. The target exposure parameter is then determined based on the brightness deviation. Specifically, this includes: acquiring a reference brightness and determining initial exposure parameters; acquiring images under the initial exposure parameters and determining the brightness of the acquired images; comparing the brightness with the reference brightness, and if the brightness is less than the reference brightness and the difference between the brightness and the reference brightness is not less than a brightness threshold, iteratively adjusting the initial exposure parameters according to a preset exposure step size, and acquiring images and determining the brightness of the acquired images after each adjustment; determining the exposure parameters corresponding to the brightness extremum condition based on the changes in brightness between multiple consecutive exposure parameters obtained during the iterative adjustment process and their corresponding brightness values; and determining the target exposure parameter based on the exposure parameters that satisfy the brightness extremum condition.
[0147] The reference brightness refers to the pre-set standard image brightness, including but not limited to one or more reference brightness values determined based on the target scene, historical images, user settings, or calibration results.
[0148] Initial exposure parameters refer to the initial exposure settings used when starting exposure adjustment, including but not limited to one or more of the following: default value, historical best value, preset lookup table, or output value of automatic exposure algorithm. Furthermore, brightness can be the overall brightness of the acquired image, or it can be the statistical brightness value of the target region, region of interest, or multiple regions in the image, such as one or more of the following: average grayscale value, average brightness, brightness histogram feature value, or brightness channel value.
[0149] A brightness threshold is a threshold used to determine whether the current brightness deviation has reached the level that requires further adjustment, so as to avoid ineffective adjustment due to small fluctuations. The preset exposure step size can be a fixed step size or a variable step size. Brightness extreme value conditions can include one or more of the following: brightness reaches a local maximum or local minimum, brightness change changes from increasing to decreasing or from decreasing to increasing, or brightness change amplitude meets the stability threshold requirements.
[0150] The processor acquires images using different exposure parameters and determines the brightness deviation of each acquired image relative to a standard image. Based on the brightness deviation, it determines the target exposure parameters. Specifically, this may include: acquiring a reference brightness and determining initial exposure parameters; acquiring images under the initial exposure parameters and determining the brightness of the acquired images; comparing the brightness with the reference brightness, and if the brightness is less than the reference brightness and the difference between the two is not less than a brightness threshold, iteratively adjusting the initial exposure parameters according to a preset exposure step size, and acquiring images and determining the brightness of the acquired images after each adjustment; determining the exposure parameters corresponding to the brightness extremum condition based on the changes in brightness between multiple consecutive exposure parameters obtained during the iterative adjustment process and their corresponding brightness; and determining the target exposure parameters based on the exposure parameters that satisfy the brightness extremum condition.
[0151] In some implementations, the reference brightness can be obtained by calculation based on a preset standard image, by statistics of the target area or the entire image area of the current scene, or by determination based on the optimal exposure result in historically acquired images, or by direct input from the user, host computer, or control module. The initial exposure parameters can be determined, for example, by using default exposure parameters, using the optimal exposure parameters corresponding to the previous frame image, by determining based on the average or median exposure parameters of similar historical scenes, or by determining them through an exposure parameter lookup table.
[0152] The methods for determining image brightness include, but are not limited to, one or more of the following: performing brightness statistics on the entire image, performing brightness statistics on the target area, or performing weighted statistics on multiple sub-regions.
[0153] The above methods can be used individually or in combination to adapt to the exposure adjustment needs in different scenarios.
[0154] After each exposure parameter adjustment, the processor re-acquires the image and recalculates the brightness, thus forming a continuous set of exposure parameters and their corresponding brightness sequences. Subsequently, based on the trend between the exposure parameter sequence and the brightness sequence, one or more methods, such as curve fitting, difference analysis, slope analysis, extreme value search, or threshold comparison, can be used to determine whether the current brightness meets the extreme brightness condition. If the brightness meets the extreme brightness condition, the corresponding exposure parameters can be determined as the target exposure parameters and used for exposure settings in subsequent image acquisition processes, thereby achieving automatic exposure parameter adjustment or dynamic exposure control.
[0155] In some implementations, during the initial imaging scenario, after detecting the target or product in place, the processor first sets the initial exposure parameters, exposure range, and ROI area, and then acquires an image and calculates the brightness under the initial exposure parameters. Subsequently, the brightness error corresponding to the current brightness is compared with a preset threshold: when the brightness error is not less than the threshold, the processor iteratively adjusts the exposure parameters according to a preset large step size, and re-acquires the image and calculates the brightness after each adjustment, while simultaneously determining whether the adjusted exposure parameters exceed the exposure range; if they do, automatic exposure is deemed a failure; if not, adjustment continues. When the brightness error is less than the threshold, the processor further determines whether the previous brightness was an extreme value; if it was an extreme value, the processor obtains the exposure range before and after the extreme point and adjusts the exposure within that range using small steps; if it is not an extreme value, the processor continues to adjust the exposure using large steps. Further, during the small step adjustment process, the processor continuously acquires images and calculates the brightness, determining whether the brightness error is minimized; if it is minimized, automatic exposure is deemed successful and the target exposure parameters are determined; otherwise, small step adjustments continue until the conditions for successful automatic exposure are met or the failure conditions are triggered.
[0156] Figure 7 This is a schematic diagram illustrating the exposure parameter adjustment process in the initial imaging scenario provided in some embodiments of this application. For example... Figure 7As shown, in the initial imaging scenario, after placing the target or product, the processor first sets the initial exposure parameters and exposure range, and determines the ROI region. Then, it acquires an image under the initial exposure parameters and calculates the brightness of the acquired image. Next, it compares the brightness error corresponding to the current brightness with a preset threshold. If the brightness error is less than the threshold, it further determines whether the previous brightness was an extreme value. If the previous brightness was an extreme value, it obtains the exposure range before and after the extreme point and performs small-step exposure adjustments within this range. If the previous brightness was not an extreme value, it performs large-step exposure adjustments. After performing large-step exposure adjustments, the processor determines whether the current exposure parameters exceed the exposure range. If they exceed the exposure range, automatic exposure is deemed a failure; if they do not exceed the exposure range, it switches to small-step exposure adjustments. Furthermore, after adjusting the exposure in small increments, the image is acquired again and the brightness is calculated. The brightness error is then checked to determine if it is minimized. If the brightness error is minimized, the automatic exposure is considered successful. If the brightness error is not minimized, the exposure is adjusted in small increments again, and the image acquisition, brightness calculation, and error judgment are repeated until the conditions for successful automatic exposure are met or the conditions for automatic exposure failure are triggered.
[0157] It is easy to understand that the way exposure parameters are determined in the first imaging scenario and the batch re-imaging scenario may be different. This is because when imaging for the first time, the processor usually has not yet obtained the historical best exposure parameters corresponding to the current target or product, and it usually needs to search and determine them starting from the initial exposure parameters. In the batch re-imaging scenario, the target exposure parameters corresponding to the previous target or product can usually be used as a reference, and the lighting and imaging conditions of the same batch of scenarios are relatively stable. Usually, only a small range of fine adjustments are needed based on the reference parameters.
[0158] In some implementations, in batch re-production scenarios, after the processor inputs a target or product image, it first sets the template exposure and small fluctuation range, as well as the ROI region for calculating brightness. Then, the processor controls the imaging component to capture images based on the initial exposure parameters and calculates the image brightness based on the ROI region, thereby obtaining the brightness error. Next, the processor determines whether the current brightness error is minimized. If so, automatic exposure is considered successful, and the current exposure parameters are determined as the target exposure parameters; otherwise, the exposure parameters are adjusted according to a preset small step size, and the image is re-captured and the brightness error is recalculated based on the adjusted exposure parameters, and the brightness error is determined again. The processor repeatedly executes the above process of capturing images, calculating brightness, determining brightness error, and adjusting exposure parameters until the brightness error is minimized, thereby completing automatic exposure and obtaining the target exposure parameters.
[0159] Figure 8 This is a schematic diagram illustrating the exposure parameter adjustment process in a batch re-run scenario provided in some embodiments of this application. For example... Figure 8As shown, in a batch re-production scenario, after the processor inputs the target or product image, it sets the template exposure, small fluctuation range, and ROI area. Then, it captures an image and calculates the brightness, determining if the brightness error is minimized. If the brightness error is minimized, automatic exposure is considered successful; if the brightness error is not minimized, the exposure is adjusted according to a preset small step size, and after adjustment, the image is recaptured, the brightness is calculated, and the brightness error is again determined to be minimized. This process is repeated until the brightness error is minimized and automatic exposure is completed.
[0160] In the above embodiments, by obtaining the reference brightness and comparing it with the current image brightness, the deviation between the current exposure state and the target exposure state can be determined first. At the same time, by iteratively adjusting the exposure parameters using a preset exposure step size when the brightness deviation meets the conditions, ineffective adjustments can be reduced and adjustment efficiency can be improved. Furthermore, the extreme point of brightness can be determined based on the relationship between multiple continuous exposure parameters and their corresponding brightness, which can avoid misjudgment caused by relying solely on a single brightness comparison, thereby finding the relatively optimal exposure parameters more accurately.
[0161] In some embodiments, brightness is obtained by: acquiring multiple image regions in the acquired image; determining the mean gray value of each image region and determining a reference gray value; determining the brightness deviation of each image region based on the absolute value of the difference between the mean gray value of each image region and the reference gray value; determining the brightness weight of each image region; and weighting and summing the brightness deviations of multiple image regions based on the brightness weight of each image region to obtain the brightness of the acquired image.
[0162] Here, an image region refers to multiple sub-regions in the acquired image, including but not limited to regions divided according to the structural features of the target object, ROI region, texture distribution, edge distribution, or preset rules. The grayscale mean of each image region can be obtained by averaging the grayscale values of each pixel within that image region; the reference grayscale value can be a preset target grayscale value, or the grayscale value of the corresponding region of the template image, a reference grayscale value under historical best exposure conditions, or a standard grayscale value obtained through calibration, or one or more of the following.
[0163] The brightness deviation of each image region is used to characterize the degree of deviation of the gray mean of the corresponding image region from the reference gray value. In some implementations, the brightness deviation can be expressed as the absolute value of the difference so as to uniformly evaluate the cases that are higher or lower than the reference gray value.
[0164] Furthermore, brightness weights are used to characterize the importance of different image regions in the overall brightness assessment. In feasible implementations, brightness weights can be preset or dynamically adjusted based on one or more of the following: the location and area of the image region, the importance of the target, historical stability, texture saliency, edge sensitivity, or other preset conditions. For example, a larger brightness weight can be set for the image region corresponding to the target subject region; a smaller brightness weight can be set for the background region or regions subject to greater interference.
[0165] The processor performs a weighted summation of the brightness deviations of multiple image regions based on brightness weights to obtain the brightness of the acquired image. In some implementations, the processor can also normalize the weighted summation result to further improve the consistency and stability of the brightness evaluation.
[0166] In some embodiments, determining the brightness weight of each image region specifically includes: for any image region, determining the foreground region and the background region of the image region; the foreground region and the background region each include multiple pixels; determining the brightness contrast of the image region based on the difference between the average pixel value of each pixel in the foreground region and the average pixel value of each pixel in the background region; and determining the brightness weight of the image region based on the brightness contrast.
[0167] The foreground region includes, but is not limited to, the region in the image region corresponding to the target object, product body, target pattern, detection feature, or target of interest; the background region includes, but is not limited to, the region in the image region other than the foreground region, or a reference region adjacent to the foreground region and used to highlight the foreground region.
[0168] Furthermore, the pixel mean can be the grayscale mean of multiple pixels within a region, or it can be one or more of the following: the brightness channel mean, the weighted average of the RGB channels, or other statistical values that can characterize the pixel brightness level.
[0169] Brightness contrast is used to characterize the degree of brightness difference between the foreground and background regions within the same image area; brightness weight is used to characterize the importance or reliability of the image area in the overall brightness evaluation.
[0170] For any given image region, the processor can first divide the image region into a foreground region and a background region. Specifically, the processor can determine the foreground region and the background region based on a preset template. For example, in a target detection scenario, the foreground region can be the target pattern region preset in the template, and the background region can be the blank area around the target pattern; in a product detection scenario, the foreground region can be the area containing product edges, markings, holes, solder joints, characters, or other key structures, and the background region can be the adjacent non-target region.
[0171] In other implementations, the processor may also determine the foreground and background regions of an image region based on an image segmentation algorithm. For example, the processor may divide the image region into foreground and background regions based on grayscale thresholding, edge detection, region growing, connected component analysis, semantic segmentation, object detection models, or background modeling algorithms.
[0172] In some other implementations, the processor can also determine the foreground and background regions based on ROI region information. For example, the region within the ROI region corresponding to the target subject can be determined as the foreground region, and the region within the ROI region other than the target subject can be determined as the background region; or the central region within the ROI region can be determined as the foreground region, and the edge regions within the ROI region can be determined as the background region; or, among multiple sub-ROI regions, sub-ROI regions with obvious target features can be determined as foreground regions, and sub-ROI regions with weak target features or that do not contain the target can be determined as background regions.
[0173] After determining the foreground and background regions, the processor calculates the average pixel value of each pixel in the foreground region and the average pixel value of each pixel in the background region, respectively. Specifically, the average pixel value of the foreground region can be obtained by summing the grayscale values of multiple pixels in the foreground region and dividing by the number of pixels in the foreground region; similarly, the average pixel value of the background region can be obtained by summing the grayscale values of multiple pixels in the background region and dividing by the number of pixels in the background region. In color image scenes, the processor can first convert the color image to a grayscale image and then calculate the average grayscale value of the corresponding region; alternatively, it can calculate the average pixel value based on the luminance channel, for example, by weighting the luminance values according to preset coefficients based on the three RGB color channels and then calculating the average pixel value.
[0174] In some embodiments, brightness evaluation is used to achieve automatic exposure and grayscale calibration. Using the expected grayscale or the average grayscale value of the ROI region in a standard prototype template image as a benchmark, the exposure parameters are automatically adjusted based on the deviation feedback between the current image and the benchmark. The expected grayscale includes, but is not limited to, pre-set target grayscale values for different imaging scenarios, such as 60, 128, or 180. Lower target grayscale values correspond to darker scenes, medium target grayscale values to moderate scenes, and higher target grayscale values to brighter scenes. Alternatively, the average grayscale value of the ROI region in a standard image can be used as the brightness benchmark to achieve exposure calibration based on the standard image.
[0175] In some implementations, brightness evaluation can employ either a global statistical approach or a weighted statistical approach. For the global statistical approach, the processor can calculate the average grayscale value across the entire image or within the region of interest (ROI). And compare the grayscale mean with the brightness reference value. By comparison, the brightness deviation was obtained. Specifically, it can be expressed as: (14) For weighted statistical methods, the processor can use Gaussian weighting to statistically analyze the grayscale values within an image region, weakening interference from edge regions and highlighting the brightness contribution of the central region to improve the robustness of brightness evaluation. Specifically, the processor can calculate the weighted grayscale mean of the entire image or ROI based on a preset Gaussian weight distribution. And the weighted grayscale mean and the brightness reference value are compared. By comparison, the brightness deviation was obtained. Specifically, it can be expressed as: (15) In other implementations, to further improve the anti-interference capability of brightness evaluation, an adaptive weight allocation mechanism for ROI regions can be introduced. Specifically, the processor weights the brightness contrast of different ROI regions, thereby giving higher weight to ROI regions that are more sensitive to exposure changes and have more obvious target features in the overall brightness evaluation, while assigning lower weight to ROI regions with greater interference, less obvious features, or poor stability, in order to improve the stability and accuracy of brightness evaluation.
[0176] In feasible implementations, brightness contrast is used to characterize the grayscale difference between the target area and the background area. A larger value indicates a more significant brightness difference between the target area and the background area, and a stronger ability to characterize exposure changes. Specifically, for any Region of Interest (ROI), the processor can first determine the foreground and background regions of the ROI, each containing multiple pixels. The methods for obtaining the foreground and background regions include traditional image segmentation methods or neural network-based image segmentation methods. For example, the processor can use traditional algorithms such as edge detection, region growing, and connected component analysis to determine the foreground and background regions; alternatively, it can use segmentation algorithms to identify the target foreground region and its corresponding background region.
[0177] In other feasible implementations, to avoid the influence of noise, abnormal pixels, or local extreme values on the grayscale statistics results, when calculating the grayscale mean of the foreground and background regions, only the statistical range of [missing information] can be used. The grayscale samples are calculated by removing the extreme values at both ends of the grayscale distribution before averaging. Specifically, the processor can first sort the pixel grayscale values in the foreground and background regions, remove the lowest 5% and highest 5% grayscale values, and then calculate the average of the remaining pixel grayscale values.
[0178] In some embodiments, the luminance contrast ratio can be calculated as follows: (16) Among them, adopt This approach avoids instability in weight calculations caused by excessively low or zero brightness contrast, thus ensuring the continuity and feasibility of subsequent weight allocation. In other words, even if the grayscale difference between the foreground and background regions is small, a base contrast value of at least 1 can still be assigned to prevent a particular ROI region from being completely ignored in subsequent calculations.
[0179] In some implementations, a If there are ROI regions, then the brightness weight of the i-th ROI region... Based on the brightness contrast of this area Determined, specifically, can be expressed as: (17) By using the above method, the brightness weights of each ROI region can be normalized, so that the sum of the weights of multiple ROI regions is 1. This facilitates the subsequent weighted summation of the brightness deviations of multiple ROI regions to obtain the overall brightness evaluation result of the image. Since ROI regions with higher brightness contrast correspond to larger weights, areas in the image that respond more significantly to exposure changes will have a greater impact on the final brightness evaluation result, thereby improving the sensitivity and accuracy of automatic exposure adjustment.
[0180] In some implementations, the foreground and background region segmentation results can be determined separately for different ROI regions, or dynamically updated based on template images, calibration images, or the currently acquired images. Brightness contrast and brightness weights can also be calculated in real-time after each frame is acquired, or predetermined based on a preset template during batch reprocessing, to meet the performance requirements of different devices and application scenarios. Furthermore, the brightness weights can be modified by incorporating factors such as the location, area, texture richness, edge saliency, and historical stability of the ROI region, thereby further enhancing the robustness of brightness evaluation.
[0181] In the above embodiments, by dividing the acquired image into multiple image regions, calculating the grayscale mean of each image region, and determining the brightness deviation by combining it with the baseline grayscale value, and then performing a weighted sum based on the brightness weights, the accuracy of brightness assessment can be improved, avoiding the overall average grayscale from masking local brightness anomalies, and making the brightness result more realistically reflect the image exposure state. At the same time, the absolute value of the difference and the weighting mechanism can reduce the impact of local anomalies such as bright reflections, shadow occlusion, and background interference on the overall brightness calculation, enhancing the robustness of brightness evaluation. Furthermore, the processor can adjust the exposure parameters based on more stable brightness feedback, reducing misjudgments and improving the success rate and stability of automatic exposure. In addition, by setting the brightness weights of different regions, it can also adapt to various application scenarios such as batch re-production, target imaging, and product inspection.
[0182] The imaging recipe generation method provided in this application can be executed by an imaging device. This application uses an imaging device executing the imaging recipe generation method as an example to illustrate the imaging device provided in this application.
[0183] Figure 9 This is a schematic diagram of the imaging device structure provided in some embodiments of this application. For example... Figure 9 As shown, the imaging device includes an image acquisition device 901 and a processor 902.
[0184] Image acquisition device 901 is used to acquire images.
[0185] Processor 902 is used to execute the above-described imaging recipe generation method.
[0186] According to the imaging device provided in this application embodiment, by having the imaging device to be calibrated acquire images under different focal length parameters and determining the sharpness of each acquired image, and further determining the target focal length parameter based on the sharpness, automatic optimization of the imaging focus position of the imaging device to be calibrated is achieved. This enables the imaging device to be calibrated to perform subsequent exposure and color calibration under focal length parameters that meet the sharpness requirements, effectively avoiding image blurring caused by inaccurate focal length and the resulting distortion of brightness and color evaluation results. Subsequently, under the target focal length parameter, images are acquired using different exposure parameters and the brightness deviation of each acquired image relative to the standard image is determined. The target exposure parameter is determined based on the brightness deviation, achieving exposure parameter matching on the basis of sharp imaging. This makes the brightness of the image acquired by the imaging device to be calibrated approach that of the standard image, effectively reducing the impact of underexposure or overexposure on image quality and subsequent color calibration accuracy. The process involves several steps: First, the current image is acquired under target focal length and exposure parameters. The color deviation of the current image relative to the standard image is determined, and the color channel gain is iteratively adjusted based on this deviation to obtain the target color channel gain. This achieves adaptive correction of the color channel under calibrated focal length and exposure conditions, gradually bringing the color performance of the current image closer to the standard image and effectively improving the color consistency and imaging accuracy of the imaging device to be calibrated. Finally, a target imaging recipe is generated based on the target focal length, exposure parameters, and color channel gain. This recipe is then used to configure the imaging device to be calibrated for image acquisition. This effectively enables joint configuration of focal length, exposure, and color gain parameters, avoiding mutual interference caused by independent adjustment of each imaging parameter. This allows for rapid reproduction of imaging parameters across devices while effectively improving the consistency of imaging results.
[0187] In some embodiments, the processor is further configured to determine a plurality of current image regions and a plurality of standard image regions in the current image and the standard image, respectively; the plurality of current image regions correspond one-to-one with the plurality of standard image regions; for any pair of corresponding current image regions and standard image regions, to determine the average color channel value of the current image region in the plurality of color channels and the average standard color channel value of the standard image region in the plurality of color channels, respectively; for each color channel, to determine the color deviation of the current image region in the corresponding color channel based on the difference between the average color channel value of the current image region and the average standard color channel value of the standard image region; and to determine the color deviation of each current image region in the plurality of color channels as the color deviation of the current image relative to the standard image.
[0188] In some embodiments, the processor is further configured to: determine the maximum color deviation from the color deviation of each current image region in the corresponding color channel for each color channel, and use the maximum color deviation as the current error of the corresponding color channel; determine the control quantity corresponding to each color channel based on the current error of each color channel and the corresponding preset number of historical errors; adjust the channel gain of the corresponding color channel based on the control quantity corresponding to each color channel, and control the imaging device to be calibrated to acquire a new current image according to the adjusted channel gain; redetermine the color deviation of each current image region in the new current image relative to the corresponding standard image region for each color channel; if the redetermined color deviation does not meet the deviation condition, return to the step of determining the maximum color deviation from the color deviation of each current image region in the corresponding color channel and continue execution until the redetermined color deviation meets the deviation condition; and determine the channel gain of each color channel when the deviation condition is met as the target color channel gain.
[0189] In some embodiments, the processor is further configured to: acquire a reference sharpness and determine an initial focal length parameter; acquire an image under the initial focal length parameter and determine the sharpness of the acquired image; compare the sharpness with the reference sharpness, and if the sharpness is less than the reference sharpness and the difference between the sharpness and the reference sharpness is not less than a sharpness threshold, iteratively adjust the initial focal length parameter according to a preset focal length step size, acquire an image after each adjustment and determine the sharpness of the acquired image; determine the focal length parameter corresponding to the sharpness extremum condition when the sharpness satisfies the sharpness extremum condition based on the relationship between the multiple consecutive focal length parameters obtained during the iterative adjustment process and their corresponding sharpness; and determine the target focal length parameter based on the focal length parameter that satisfies the sharpness extremum condition.
[0190] In some embodiments, the processor is further configured to extract edge regions of the acquired image and determine multiple valid pixels in the edge regions; for any valid pixel, determine the neighborhood range of the valid pixel and determine the grayscale information and gradient direction information of the valid pixel within the neighborhood range; determine the gradient change degree of the valid pixel based on the grayscale information and gradient direction information; and determine the sharpness of the acquired image based on the gradient change degree of multiple valid pixels.
[0191] In some embodiments, the processor is further configured to: acquire a reference brightness and determine initial exposure parameters; acquire an image under the initial exposure parameters and determine the brightness of the acquired image; compare the brightness with the reference brightness, and if the brightness is less than the reference brightness and the difference between the brightness and the reference brightness is not less than a brightness threshold, iteratively adjust the initial exposure parameters according to a preset exposure step size, and acquire an image and determine the brightness of the acquired image after each adjustment; determine the exposure parameters corresponding to the brightness extremum condition based on the changes in the brightness between multiple consecutive exposure parameters obtained during the iterative adjustment process and their corresponding brightness; and determine the target exposure parameters based on the exposure parameters that satisfy the brightness extremum condition.
[0192] In some embodiments, the processor is further configured to acquire multiple image regions in the acquired image; determine the mean gray level of each image region and determine a reference gray level; determine the brightness deviation of each image region based on the absolute value of the difference between the mean gray level of each image region and the reference gray level; determine the brightness weight of each image region; and perform a weighted summation of the brightness deviations of multiple image regions based on the brightness weight of each image region to obtain the brightness of the acquired image.
[0193] In some embodiments, the processor is further configured to, for any image region, determine a foreground region and a background region of the image region; the foreground region and the background region each include a plurality of pixels; determine the brightness contrast of the image region based on the difference between the average pixel value of each pixel in the foreground region and the average pixel value of each pixel in the background region; and determine the brightness weight of the image region based on the brightness contrast.
[0194] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0195] The imaging device in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal, such as a server.
[0196] The imaging device provided in this application embodiment can realize all the processes implemented in the above-described imaging recipe generation method embodiment, and will not be repeated here to avoid repetition.
[0197] In some embodiments, Figure 10 This is a schematic diagram of the structure of an electronic device provided in some embodiments of this application. For example... Figure 10 As shown, this application embodiment also provides an electronic device 1000, including a processor 1001, a memory 1002, and a computer program stored in the memory 1002 and executable on the processor 1001. When the program is executed by the processor 1001, it implements the various processes of the above-described imaging recipe generation method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0198] This application provides a non-transitory computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described imaging recipe generation method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0199] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable media, such as computer read-only memory (ROM), random-access memory (RAM), magnetic disks, or optical disks.
[0200] The computer-readable storage medium may include: read-only memory (ROM), random-access memory (RAM), magnetic disk or optical disk, etc.
[0201] This application provides a computer program product, including a computer program that, when executed by a processor, implements the above-described imaging recipe generation method.
[0202] This application provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above-described imaging recipe generation method embodiments and achieve the same technical effect. To avoid repetition, it will not be described again here.
[0203] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.
[0204] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0205] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the related technology, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0206] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
[0207] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0208] Although embodiments of this application have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of this application, the scope of which is defined by the claims and their equivalents.
Claims
1. A method for generating an imaging recipe, characterized in that, include: Obtain a standard image; For the imaging device to be calibrated, images are acquired under different focal length parameters and the sharpness of each acquired image is determined. The target focal length parameter is then determined based on the sharpness. Under the target focal length parameter, images are acquired using different exposure parameters and the brightness deviation of each acquired image relative to the standard image is determined. The target exposure parameter is then determined based on the brightness deviation. The current image is acquired under the target focal length parameters and the target exposure parameters, the color deviation of the current image relative to the standard image is determined, and the color channel gain is iteratively adjusted according to the color deviation to obtain the target color channel gain; A target imaging recipe is generated based on the target focal length parameters, the target exposure parameters, and the target color channel gain; the target imaging recipe is used to configure the imaging device to be calibrated for image acquisition.
2. The imaging recipe generation method according to claim 1, characterized in that, Determining the color deviation of the current image relative to the standard image includes: Multiple current image regions and multiple standard image regions are determined in the current image and the standard image, respectively; each of the multiple current image regions corresponds one-to-one with the multiple standard image regions. For any pair of corresponding current image regions and standard image regions, determine the average color channel value of the current image region in multiple color channels, and the average standard color channel value of the standard image region in multiple color channels. For each of the aforementioned color channels, the color deviation of the current image region in the corresponding color channel is determined based on the difference between the average color channel value corresponding to the current image region and the average standard color channel value corresponding to the standard image region. The color deviation of each current image region across multiple color channels is determined as the color deviation of the current image relative to the standard image.
3. The imaging recipe generation method according to claim 2, characterized in that, The step of iteratively adjusting the color channel gain based on the color deviation to obtain the target color channel gain includes: For each of the aforementioned color channels, the maximum color deviation is determined from the color deviation of each current image region in the corresponding color channel, and the maximum color deviation is used as the current error of the corresponding color channel; Based on the current error of each color channel and the corresponding preset number of historical errors, the control quantity corresponding to each color channel is determined respectively; The channel gain of each color channel is adjusted according to the control value corresponding to each color channel, and the imaging device to be calibrated is controlled to acquire a new current image according to the adjusted channel gain. Redetermine the color deviation of each color channel in each current image region relative to the corresponding standard image region in the new current image; If the redefined color deviation does not meet the deviation condition, the process returns to the step of determining the maximum color deviation from the color deviations of each current image region in the corresponding color channel, and continues until the redefined color deviation meets the deviation condition. The channel gain of each color channel when the deviation condition is met is determined as the target color channel gain.
4. The imaging recipe generation method according to claim 1, characterized in that, The process of acquiring images under different focal length parameters and determining the sharpness of each acquired image, and determining the target focal length parameter based on the sharpness, includes: Obtain the baseline sharpness and determine the initial focal length parameters; Images are acquired under the initial focal length parameters, and the sharpness of the acquired images is determined; The sharpness is compared with the reference sharpness. If the sharpness is less than the reference sharpness and the difference between the sharpness and the reference sharpness is not less than the sharpness threshold, the initial focal length parameter is iteratively adjusted according to the preset focal length step size. After each adjustment, an image is acquired and the sharpness of the acquired image is determined. Based on the relationship between multiple consecutive focal length parameters obtained during the iterative adjustment process and their corresponding sharpness, the focal length parameter corresponding to the sharpness extreme value condition is determined. The target focal length parameter is determined based on the focal length parameter that satisfies the aforementioned sharpness extreme condition.
5. The imaging recipe generation method according to claim 1 or 4, characterized in that, The clarity is obtained in the following way: Extract the edge regions of the acquired image and determine multiple valid pixels within the edge regions; For any valid pixel, determine the neighborhood range of the valid pixel, and within the neighborhood range, determine the grayscale information and gradient direction information of the valid pixel; Based on the grayscale information and gradient direction information, the gradient change degree of the effective pixel is determined; The sharpness of the acquired image is determined based on the gradient variation of multiple valid pixels.
6. The imaging recipe generation method according to claim 1, characterized in that, The process of acquiring images using different exposure parameters and determining the brightness deviation of each acquired image relative to the standard image, and determining the target exposure parameters based on the brightness deviation, includes: Obtain the reference brightness and determine the initial exposure parameters; An image is acquired under the initial exposure parameters, and the brightness of the acquired image is determined; The brightness is compared with the reference brightness. If the brightness is less than the reference brightness and the difference between the brightness and the reference brightness is not less than the brightness threshold, the initial exposure parameters are iteratively adjusted according to the preset exposure step size. After each adjustment, an image is acquired and the brightness of the acquired image is determined. Based on the relationship between multiple continuous exposure parameters obtained during the iterative adjustment process and their corresponding brightness changes, the exposure parameters corresponding to the brightness extreme value condition are determined. The target exposure parameters are determined based on the exposure parameters that satisfy the extreme brightness conditions.
7. The imaging recipe generation method according to claim 1 or 6, characterized in that, The brightness is obtained in the following way: Acquire multiple image regions from the acquired image; Determine the mean gray level of each image region and determine the baseline gray level; The brightness deviation of each image region is determined based on the absolute value of the difference between the mean gray value and the reference gray value of each image region. The brightness weight of each image region is determined, and the brightness deviation of multiple image regions is weighted and summed based on the brightness weight of each image region to obtain the brightness of the acquired image.
8. The imaging recipe generation method according to claim 7, characterized in that, Determining the brightness weight of each image region includes: For any image region, determine the foreground region and the background region of the image region; the foreground region and the background region each include multiple pixels; The brightness contrast of the image region is determined based on the difference between the average pixel value of each pixel in the foreground region and the average pixel value of each pixel in the background region. The brightness weight of the image region is determined based on the brightness contrast.
9. An imaging device, characterized in that, include: Image acquisition device, used to acquire images; The processor is communicatively connected to the image acquisition device and is used to execute the imaging recipe generation method as described in any one of claims 1-8.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the imaging recipe generation method as described in any one of claims 1-8.
