Method and device for determining optimal shooting distance of fixed depth-of-field camera

By keeping the content of the area of interest unchanged during the camera propulsion process, dynamically adjusting the area parameters, and using a multi-scale gradient fusion method, the problem of determining the optimal shooting distance of the fixed depth of field camera is solved, and the accurate evaluation of image sharpness and determination of the optimal shooting distance is achieved.

CN120302155AActive Publication Date: 2025-07-11SHENZHEN XINRUN FULIAN DIGITAL TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510776741.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-11
Publication Date
2025-07-11
Estimated Expiration
2045-06-11

AI Technical Summary

Technical Problem

In the prior art, when a fixed depth of field camera determines the optimal shooting distance, it cannot accurately reflect the objective relationship between image sharpness and imaging quality, resulting in the inability to find the optimal shooting distance.

Method used

By keeping the content of the area of interest unchanged during the camera advancement, dynamically adjusting the area parameters, combining the multi-scale gradient fusion method, recording the correspondence between clarity and shooting distance, and selecting the distance with the highest clarity as the optimal shooting distance.

Benefits of technology

准确确定固定景深相机的最佳拍摄距离,确保图像清晰度的准确性和一致性,避免了因成像大小变化导致的区域不一致问题。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120302155A_ABST
    Figure CN120302155A_ABST
Patent Text Reader

Abstract

The invention relates to a method and device for determining the optimal shooting distance of a fixed depth-of-field camera, and the method comprises the steps: determining an initial focusing region of interest of the fixed depth-of-field camera, and determining a first region parameter of the initial region of interest; according to the initial shooting distance between the camera and the shooting object before advancing and the current shooting distance between the camera and the shooting object after advancing, the image scaling generated before and after advancing of the camera is determined; adjusting the first region parameter according to the image scaling to obtain a second region parameter after the camera is propelled, and determining a current region of interest corresponding to the second region parameter; fusing the multi-scale gradient of the shot image in the current region of interest to obtain the image definition, and recording the corresponding relation between the definition and the current shooting distance; and after the camera is propelled, selecting the shooting distance with the highest definition as the optimal shooting distance according to the corresponding relation. The method can accurately determine the optimal shooting distance of the camera.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data processing, and particularly to a method and device for determining the optimal shooting distance of a fixed-depth-of-field camera. Background Art

[0002] When using a fixed-depth-of-field camera to photograph an object, finding the optimal shooting distance between the camera and the shooting area is the key to obtaining a clear image. Traditional methods mainly determine this optimal distance by comparing the sharpness of images taken by the camera at different positions. However, during the actual process of adjusting the shooting distance, the size of the object's image changes due to the variation in the distance between the camera and the object.

[0003] If a fixed region of interest (ROI) is adopted, at different shooting distances, there will be significant differences in the part of the object selected by the ROI. For example, when the camera approaches the object, the object's image becomes larger, and the original fixed ROI may only select partial details of the object, while losing key overall features; when the camera moves away from the object, the image becomes smaller, and a large amount of background content may be mixed into the ROI, reducing the proportion of effective object information.

[0004] When the content of the ROI cannot be kept consistent at different shooting distances, the sharpness of the image calculated based on the fixed ROI will be interfered by the differences in the image content. This interference causes the sharpness of the image not to truly reflect the objective relationship between the shooting distance and the imaging quality. There may be situations where the sharpness is overestimated during close-range shooting due to the clarity of local details, and underestimated during long-range shooting due to the mixture of the background. The inability to accurately determine the sharpness means losing a reliable standard for measuring the imaging quality at different shooting distances. At this time, no matter how the sharpness of images taken at different positions is compared, it is impossible to accurately find the shooting distance that can make the imaging quality of the entire object optimal. Summary of the Invention

[0005] This application provides a method and device for determining the optimal shooting distance of a fixed-depth-of-field camera to solve the problem of being unable to accurately find the optimal shooting distance.

[0006] In a first aspect, this application provides a method for determining the optimal shooting distance of a fixed-depth-of-field camera, the method including: Determine an initial region of interest for the focus of the fixed-depth-of-field camera, and determine a first region parameter of the initial region of interest, where the camera takes one image for every fixed distance advanced towards the shooting object; Determine the image scaling ratio generated before and after the camera advances according to the initial shooting distance between the camera and the shooting object before the advance and the current shooting distance between the camera and the shooting object after the advance; Adjust the first region parameters according to the image scaling ratio to obtain the second region parameters after the camera advances, and determine the current region of interest corresponding to the second region parameters, where the captured content of the region of interest is scaled proportionally during the camera advancement; Fuse the multi-scale gradients of the captured image in the current region of interest to obtain the image sharpness, and record the corresponding relationship between the sharpness and the current shooting distance; After the camera advancement ends, select the shooting distance with the highest sharpness as the optimal shooting distance according to the corresponding relationship.

[0007] Optionally, the first region parameters include the first abscissa, the first ordinate, the first width, and the first height of the corner points of the initial region of interest. Adjusting the first region parameters according to the image scaling ratio to obtain the second region parameters after the camera advances includes: Determine the central abscissa and the central ordinate of the center point of the overall image, where the overall image is the entire image captured by the camera; Determine the second abscissa according to the central abscissa, the image scaling ratio, and the first abscissa; Determine the second ordinate according to the central ordinate, the image scaling ratio, and the first ordinate; Determine the second width according to the first width and the image scaling ratio; Determine the second height according to the first height and the image scaling ratio; Construct the second region parameters according to the second abscissa, the second ordinate, the second width, and the second height.

[0008] Optionally, fusing the multi-scale gradients of the captured image in the current region of interest to obtain the image sharpness includes: Generate multi-scale images by downsampling the captured image in the current region of interest; Generate a target image with an initial sharpness score through dynamically assigning weights to each scale image and multi-scale gradient fusion; Select the blurred sub-blocks from multiple candidate sub-blocks according to the gradient mean of each candidate sub-block in the target image, where there is image blurring in the local image region corresponding to the blurred sub-blocks; Obtain the sharpness of the captured image by deducting the blurred region score corresponding to the blurred sub-blocks from the initial sharpness score.

[0009] Optionally, generating a target image with an initial sharpness score through dynamically assigning weights to each scale image and multi-scale gradient fusion includes: Determine the gradient magnitude of each pixel in the images of each scale, and determine the gradient magnitude variance and gradient magnitude mean of the scale image according to the gradient magnitudes of multiple pixels, wherein the gradient magnitude variance is used to indicate the texture density of the scale image; Assign weights to the scale images corresponding to each scale image according to the texture density of each scale image, wherein the weight has a positive relationship with the richness of the texture density; Obtain a target image with an initial clarity score according to the weighted average of the gradient magnitude mean and the weight of each scale image.

[0010] Optionally, selecting the blurred sub-blocks among the multiple candidate sub-blocks according to the gradient mean of each candidate sub-block in the target image includes: Divide the target image into multiple candidate sub-blocks, and determine the gradient mean of each candidate sub-block; Determine a scoring threshold according to a preset threshold coefficient and the initial clarity score; If the absolute value of the difference between the gradient mean of the candidate sub-block and the initial clarity score exceeds the scoring threshold, determine that the candidate sub-block is a blurred sub-block.

[0011] Optionally, obtaining the clarity of the captured image by deducting the blurred area score corresponding to the blurred sub-block from the initial clarity score includes: Determine the blurred area score according to the number of the blurred sub-blocks, the number of the candidate sub-blocks, and a preset penalty coefficient, wherein the preset penalty coefficient is used to indicate the influence degree of local blur on the overall clarity of the image; Obtain a final clarity score according to the difference between the initial clarity score and the blurred area score, and use the final clarity score as the clarity of the captured image.

[0012] Optionally, the fixed distance for the camera to advance is determined according to the first advancement step length and a preset number of advancement steps. After determining the optimal shooting distance, the method further includes: Determine a shooting distance range according to the difference and sum value between the optimal shooting distance and the first advancement step length, and use the shooting distance range as the initial shooting distance between the camera and the shooting object; Redetermine the advancement distance of the camera each time according to the second advancement step length and the preset number of advancement steps, wherein the second advancement step length is less than the first advancement step length; Redetermine the current shooting distance according to the updated initial shooting distance and the updated advancement distance, and perform multiple advancements and then select the shooting distance with the highest clarity as the optimal shooting distance.

[0013] Second aspect, the present application provides an apparatus for determining the optimal shooting distance of a fixed-depth-of-field camera, the apparatus comprising: A first determination module, configured to determine an initial region of interest for the focus of a fixed-depth-of-field camera, and determine a first region parameter of the initial region of interest, wherein the camera takes an image every time it advances a fixed distance towards the subject; A second determination module, configured to determine an image scaling ratio generated before and after the camera advances according to an initial shooting distance between the camera and the subject before the advance and a current shooting distance between the camera and the subject after the advance; An adjustment module, configured to adjust the first region parameter according to the image scaling ratio to obtain a second region parameter after the camera advances, and determine a current region of interest corresponding to the second region parameter, wherein the shooting content of the region of interest scales proportionally during the camera's advance; A third determination module, configured to obtain image sharpness by fusing multi-scale gradients of the captured images in the current region of interest, and record the corresponding relationship between the sharpness and the current shooting distance; A selection module, configured to, after the camera's advance ends, select the shooting distance with the highest sharpness as the optimal shooting distance according to the corresponding relationship.

[0014] Third aspect, the present application provides an electronic device, comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus.

[0015] Fourth aspect, the present application further provides a computer storage medium, storing computer-executable instructions, the computer-executable instructions being used to execute the method for determining the optimal shooting distance of a fixed-depth-of-field camera according to any one of the above of the present application.

[0016] The above technical solutions provided by the embodiments of the present application have the following advantages compared with the prior art: The camera takes an image every time it advances a fixed distance. During the advancement process, the image scaling ratios before and after the advancement are determined according to the change in the shooting distance, and then the region parameters of the region of interest are dynamically adjusted according to the image scaling ratios to ensure that the region of interest is always scaled proportionally. Regardless of how the shooting distance changes, the content of the shooting object remains the same. Then, the clarity of the image in the region of interest is determined by using the multi-scale gradient fusion method, comprehensively evaluating the details and edge information of the image from multiple scales, accurately reflecting the image clarity, and recording the corresponding relationship between the shooting distance and the image clarity each time. After the camera completes all advancements, the optimal shooting distance that makes the image captured by the fixed-depth-of-field camera the clearest is found. The present application accurately determines the optimal shooting distance of the camera through a dynamic region of interest. Description of the Drawings

[0017] The drawings herein are incorporated into the specification and form a part of this specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.

[0018] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0019] One or more embodiments are exemplarily illustrated by the pictures in the corresponding drawings. These exemplary illustrations do not limit the embodiments. Elements with the same reference numerals in the drawings represent similar elements. Unless otherwise stated, the drawings in the figures do not constitute a proportional limitation.

[0020] Figure 1 It is a flowchart of a method for determining the optimal shooting distance of a fixed-depth-of-field camera provided by an embodiment of the present application; Figure 2 It is a schematic diagram of the overall process for determining the optimal shooting distance of a fixed-depth-of-field camera provided by an embodiment of the present application; Figure 3 It is a schematic diagram of the device structure for determining the optimal shooting distance of a fixed-depth-of-field camera provided by an embodiment of the present application; Figure 4 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Detailed Embodiments

[0021] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the following will clearly and completely describe the technical solutions in the embodiments of this application with reference to the accompanying drawings in the embodiments of this application. Apparently, the described embodiments are some, but not all, of the embodiments of this application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this application without creative efforts shall fall within the scope of protection of this application.

[0022] The following disclosure provides many different embodiments or examples for implementing different structures of this application. To simplify the disclosure of this application, components and settings of specific examples are described below. Of course, they are only examples and are not intended to limit this application. In addition, this application may repeat reference numerals and / or letters in different examples. This repetition is for the purpose of simplification and clarity and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0023] To solve the problem of being unable to accurately determine the optimal shooting distance of a camera mentioned in the background art, the embodiments of this application provide an accurate clarity by keeping the content of the shooting object in the region of interest unchanged during the camera's advancement process, thereby providing an accurate basis for determining the optimal shooting distance.

[0024] The embodiments of this application are applied to the field of camera shooting, and specific application scenarios include but are not limited to: monitoring industrial production, intelligent monitoring, pathological section diagnosis, or cell growth recording.

[0025] The following will, in combination with specific implementation manners, provide a detailed description of a method for determining the optimal shooting distance of a fixed-depth-of-field camera provided by the embodiments of this application. Taking a fixed-depth-of-field camera as an example, as Figure 1 shown, the specific steps are as follows: Step 101: Determine the initial region of interest for the focus of a fixed-depth-of-field camera, and determine the first region parameters of the initial region of interest, where one image is taken each time the camera advances a fixed distance towards the shooting object; Step 102: Determine the image scaling ratios generated before and after the camera's advancement based on the initial shooting distance between the camera and the shooting object before the advancement and the current shooting distance between the camera and the shooting object after the advancement; Step 103: Adjust the first region parameters according to the image scaling ratio to obtain the second region parameters after the camera's advancement, and determine the current region of interest corresponding to the second region parameters, where the shooting content of the region of interest scales proportionally during the camera's advancement; Step 104: Obtain the image clarity by fusing the multi-scale gradients of the captured images in the current region of interest, and record the corresponding relationship between the clarity and the current shooting distance; Step 105: After the camera advancement ends, select the shooting distance with the highest clarity as the optimal shooting distance according to the corresponding relationship.

[0026] First, explanations are given for the nouns used in the embodiments of the present application, including the following content.

[0027] Fixed depth-of-field camera: The depth-of-field range of the camera is fixed. Objects are in focus within a certain distance range, and become blurred beyond this range. It is necessary to find the appropriate shooting distance to ensure that the target is clear.

[0028] Initial region of interest: Before the start of shooting, a specific region in the image selected manually or by an algorithm, which contains the object that one wants to focus on shooting or analyzing.

[0029] First region parameters: Parameters used to describe the characteristics of the initial region of interest, including the coordinates of a certain corner point of the region, the width and height of the region, etc., which determine the position and size of the region in the image.

[0030] Image scaling ratio: Before and after the camera advancement, due to the change in shooting distance, the size of the object imaged in the image will change, and the image scaling ratio reflects the degree of this size change.

[0031] Second region parameters: Parameters obtained by adjusting the first region parameters according to the image scaling ratio, which are used to determine the new region of interest after the camera advancement.

[0032] Multi-scale gradient fusion: Comprehensive processing of the gradient information of the image at different scales (such as reducing to 1 / 2, 1 / 4, etc. of the original image), and evaluating the image clarity by fusing this information, which can more comprehensively reflect the details and quality of the image.

[0033] In step 101, before the formal shooting, the primary task is to clarify the core target of the shooting, and based on this, select the region of interest (ROI). This selection process has various implementation methods. It can either be that the operator manually frames the region containing the key object or details in the camera's viewfinder according to the shooting requirements, or the target object can be automatically detected by an image recognition algorithm and the region range can be accurately delimited. For example, when shooting precision mechanical parts, the algorithm can quickly identify the part contour and set it as the region of interest.

[0034] The initial region of interest mentioned in the embodiments of the present application is the region of interest before each advancement of the camera. After determining the initial region of interest, the system will obtain its first region parameters, and the region parameters include the precise coordinates of the region corner points, as well as the width and height of the region itself. Through these parameters, the specific position and size range of the region of interest in the entire image can be clarified.

[0035] In addition, it is also necessary to set a fixed distance for the camera to advance towards the subject each time. This distance determines the rhythm of the camera gradually approaching the subject. Subsequently, the camera will approach the subject according to this preset distance, and each time a propulsion action is completed, the shooting function will be triggered to record the image at the current position. Among them, the distance of each propulsion is determined by the product of the first propulsion step length S and the preset number of propulsion steps i.

[0036] In step 102, during the process of the camera performing the propulsion operation, the change in the shooting distance before and after each propulsion will directly cause a change in the imaging size of the object in the image. Therefore, the initial shooting distance D between the camera and the subject will be recorded before each propulsion of the camera; when the camera completes one propulsion, the current shooting distance between the camera and the subject will be recorded again. By comparing these two distance data, the scaling ratio of the image generated before and after the camera propulsion can be determined. The image scaling ratio reflects how much the imaging size of the object in the image has specifically changed due to the change in the shooting distance.

[0037] The calculation formula for the image scaling ratio is: , where R is the image scaling ratio, D is the initial shooting distance, i is the preset number of propulsion steps, S is the first propulsion step length, is the current shooting distance.

[0038] In step 103, after obtaining the image scaling ratio, the camera will accurately adjust the first region parameters according to this ratio. Specifically, the camera will perform operations on the corner coordinates, width, height, and other parameters of the initial region of interest respectively with the scaling ratio according to established rules and algorithms. Through such calculations, the adjusted second region parameters are obtained. These new parameters redefine the position and size of the region of interest. Based on the second region parameters, the camera can accurately determine the current region of interest. In this way, during the continuous propulsion of the camera, the region of interest will be scaled accordingly with the change in the imaging size of the object. Regardless of how the distance between the camera and the subject changes, it can ensure that the shooting content within the region of interest always changes in the same proportion, so that each shooting targets the same part of the subject, avoiding the problem of inconsistent analysis regions caused by changes in the imaging size.

[0039] In step 104, for the captured image within the current region of interest, in order to comprehensively and accurately evaluate its sharpness, the camera adopts a multi-scale gradient fusion method. First, the captured image is processed at multiple different scales, and multiple images of different sizes are generated through technical means, such as being reduced to scales of 1 / 2, 1 / 4, etc. of the original image. Then, at different scales, the details and features presented by the image are different. The small-scale image can show the overall contour, while the large-scale image retains more local details. Next, the gradient information of the image at each scale is calculated separately. The gradient information reflects the degree of intensity of pixel changes in the image, and the places where pixel changes are intense often correspond to the edges and detail parts of the image. Then, these gradient information from different scales are organically fused. Through comprehensive analysis and processing, a value that can comprehensively represent the sharpness of the image is finally obtained. This value is not a one-sided evaluation at a single scale, but a comprehensive result after fusing multi-scale information. Finally, the camera associates and records this sharpness value with the current shooting distance, forming a set of corresponding relationship data.

[0040] In step 105, when the camera completes all the advancing operations according to the pre-set advancing distance, a set of different shooting distances and their corresponding image sharpness data have been accumulated at this time. These data form a complete data set, reflecting the quality of the images at different shooting distances. The camera will find the highest sharpness value by comparing each sharpness value one by one. The shooting distance corresponding to this highest sharpness value is the best shooting distance that can enable the fixed-depth-of-field camera to capture the clearest image during this shooting process.

[0041] Exemplarily, a fixed-depth-of-field camera is used to photograph an antique ornament with an irregular shape. Before the shooting starts, the operator manually frames the antique ornament as the region of interest through the camera operation interface, and obtains that the coordinates of the upper left corner of this region in the image are (100, 100), the width of the region is 200 pixels, and the height is 150 pixels. It is set that the camera advances 2 cm towards the ornament each time, and takes one image each time it advances. The camera starts advancing from a distance of 30 cm from the ornament. After the first advance, the current shooting distance becomes 28 cm. By comparing the initial shooting distance and the current shooting distance, the image scaling ratio is determined. The initial region-of-interest parameters are adjusted according to the scaling ratio to obtain a new region of interest, ensuring that the antique ornament is always completely within the region of interest. For the image of the region of interest captured each time, multi-scale gradient fusion processing is performed to obtain the image sharpness value, and the corresponding relationship between this value and the current shooting distance is recorded. When the camera advances to a distance of 20 cm from the ornament, all the advancing operations are completed. Finally, by comparing all the recorded shooting distances and sharpness values, it is found that the sharpness of the captured image is the highest when the distance from the ornament is 24 cm. Therefore, 24 cm is determined as the best shooting distance for this shooting.

[0042] In this application, the camera takes an image every time it advances a fixed distance. During the advancement process, the image scaling ratios before and after the advancement are determined based on the change in the shooting distance, and then the region parameters of the region of interest are dynamically adjusted according to the image scaling ratios, ensuring that the region of interest is always scaled proportionally. Regardless of how the shooting distance changes, the content of the shooting object remains the same. Then, the clarity of the image in the region of interest is determined by using the multi-scale gradient fusion method. The details and edge information of the image are comprehensively evaluated from multiple scales, accurately reflecting the image clarity, and the corresponding relationship between each shooting distance and the image clarity is recorded. After the camera completes all advancements, the optimal shooting distance that makes the image captured by the fixed-depth-of-field camera the clearest is found. This application accurately determines the optimal shooting distance of the camera through the dynamic region of interest.

[0043] As an alternative implementation, in step 103, adjusting the first region parameter according to the image scaling ratio to obtain the second region parameter after the camera advancement includes the following content.

[0044] Step S11: Determine the central abscissa and central ordinate of the center point of the overall image, where the overall image is the entire image captured by the camera; Step S12: Determine the second abscissa according to the central abscissa, the image scaling ratio, and the first abscissa; Step S13: Determine the second ordinate according to the central ordinate, the image scaling ratio, and the first ordinate; Step S14: Determine the second width according to the first width and the image scaling ratio; Step S15: Determine the second height according to the first height and the image scaling ratio; Step S16: Construct the second region parameter according to the second abscissa, the second ordinate, the second width, and the second height.

[0045] The first region parameter includes the first abscissa and the first ordinate (X, Y) of the corner point of the initial region of interest, the first width Width, and the first height Height. The center point coordinates of the overall image are , which is a fixed value.

[0046] The calculation formula for the second region parameter is as follows.

[0047]

[0048] Among them, is the corner point coordinates of the current region of interest, is the second width of the current region of interest, is the second height of the current region of interest.

[0049] As an optional implementation, in step 104, obtaining the image clarity by fusing the multi-scale gradients of the captured image in the current region of interest includes the following contents.

[0050] Step S21: generating a multi-scale image by downsampling the captured image in the current region of interest; Step S22: Generate a target image with an initial clarity score by dynamically assigning weights to each scale image and fusing multi-scale gradients; Step S23: selecting a blurred sub-block from among the plurality of candidate sub-blocks according to the gradient mean of each candidate sub-block in the target image, wherein the local image region corresponding to the blurred sub-block has image blur; Step S24: The clarity of the captured image is obtained by deducting the blur region score corresponding to the blur sub-block from the initial clarity score.

[0051] In step S21, when the camera processes the captured image in the current area of ​​interest, it generates image versions of different scales by downsampling, such as 1 / 2, 1 / 4 of the original image, to build a multi-scale structure of the image. Images of different scales carry differentiated feature information of objects. Large-scale images focus on retaining the details and edges of objects, and can capture subtle textures and local changes; small-scale images focus on the overall outline and macroscopic form of objects, showing their structural layout. Multi-scale analysis can break through the information limitations of a single scale by integrating these different levels of features, and conduct a comprehensive and multi-level analysis of image content.

[0052] In step S22, for each scale image generated, its gradient amplitude is first extracted. This amplitude reflects the drastic degree of pixel change in the image. The drastic pixel change corresponds to the edge and detail information of the image, which is a key factor in measuring image clarity. Since there are differences in texture richness between images of different scales, in order to more accurately evaluate image clarity, weights are dynamically assigned according to the texture density of each scale image. The texture-rich area has a greater impact on the image clarity perceived by the human eye. Therefore, the denser the texture, the higher the weight assigned to the scale image. By weighted summing the gradient mean of each scale image according to the assigned weights, the information of different scales is fused, and finally a score that can comprehensively reflect the overall clarity of the image is obtained, and a target image containing an initial clarity score is generated. This method integrates multi-scale information to make the initial clarity score more accurate.

[0053] In step S23, the camera divides the target image containing the initial sharpness score into multiple candidate sub-blocks of the same size and independent of each other, and then calculates the gradient mean of the pixels within each candidate sub-block. This mean reflects the richness of image details and edges within the candidate sub-block. In a clear image region, the gradient mean of the sub-block is usually close to the initial sharpness score of the overall image, while for a sub-block with a blurring problem, its gradient mean will be significantly lower than the overall score. Based on this characteristic, by comparing the gradient mean of each candidate sub-block with the overall initial sharpness score, the local regions in the image with blurring phenomena, i.e., blurred sub-blocks, can be accurately identified, laying a foundation for subsequent correction of the initial sharpness score.

[0054] In step S24, based on the detected multiple blurred sub-blocks, the camera comprehensively evaluates their influence on the overall quality of the image and calculates the corresponding blurred region score. Since local blurring reduces the subjective perception of the overall sharpness of the image by people, the blurred region score is deducted from the previously obtained initial sharpness score of the overall image to correct the initial sharpness score. This method can eliminate the interference of local blurring on the overall score, making the finally obtained initial sharpness score of the captured image more truly reflect the sharpness of the image in people's eyes and improving the accuracy and reliability of sharpness evaluation.

[0055] In this application, first, the image of the region of interest is downsampled at multiple scales to capture image features from multiple dimensions from the global contour to local details, breaking through the limitations of single-scale analysis; second, weights are dynamically assigned based on texture density and multi-scale gradient information is fused to simulate the sensitivity of the human eye to regions with rich textures, making the initial sharpness score more accurate; then, the blurred region is accurately located through the sub-block gradient mean to avoid the interference of local blurring on the overall evaluation; finally, the blurred region score is deducted to correct the image sharpness to ensure that the score truly reflects the image quality. By comprehensively analyzing image features and accurately excluding interference factors, a more reliable sharpness evaluation result is finally provided for the fixed-depth-of-field camera, so as to accurately find the best shooting distance.

[0056] As an alternative implementation, in step S22, generating the target image with the initial sharpness score through dynamic weight assignment and multi-scale gradient fusion for each scale image includes the following content.

[0057] Step S221: Determine the gradient amplitude of each pixel in each scale image, and determine the gradient amplitude variance and gradient amplitude mean of the scale image according to the gradient amplitudes of multiple pixels. Among them, the gradient amplitude variance is used to indicate the texture density of the scale image; Step S222: Assign weights to the corresponding scale images according to the texture density of each scale image, where the weight has a positive relationship with the richness of the texture density; Step S223: Obtain a target image with an initial clarity score according to the weighted addition of the gradient amplitude mean and weight of each scale image.

[0058] In step S221, after the multi-scale image generation is completed, the camera uses a gradient operator (such as a Scharr operator or a Sobel operator) to calculate the gradient amplitude of each pixel in each scale image. The gradient amplitude represents the intensity of the grayscale change of the pixel in the scale image in the horizontal and vertical directions. The more obvious the grayscale change is (such as the edge of the object, the texture details), the greater the gradient amplitude of the pixel.

[0059] The calculation formula of the gradient amplitude of a pixel is: ,in, is the gradient magnitude of the pixel, I represents the scale image, represents the convolution operation, represents the convolution kernel in the horizontal direction, represents the convolution kernel in the vertical direction, .

[0060] For example, .

[0061] After calculating the gradient amplitude of all pixels, the camera performs statistical analysis on the gradient amplitude of all pixels in the scale image and obtains two key indicators: the mean gradient amplitude and the variance gradient amplitude. The mean gradient amplitude reflects the overall grayscale change of the scale image, while the variance gradient amplitude is used to measure the discreteness of the pixel gradient amplitude in the image. The larger the variance, the more drastic the grayscale change of the pixels in the image, that is, the richer the texture, which can be used as an important basis for judging the texture density of the image.

[0062] In step S222, the camera assigns weights to each scale image based on the gradient amplitude variance (i.e., texture density index) of each scale image. Since the human eye is more sensitive to the clarity of texture-rich areas in an image, an allocation strategy in which the weight is positively correlated with the richness of the texture density is adopted. Specifically, a scale image with a high texture density (large gradient amplitude variance) will be assigned a higher weight, which means that the scale image will account for a larger proportion in the final clarity assessment; while a scale image with a low texture density will be assigned a lower weight. By linking the weight to the image texture density, the impact of texture-rich areas on clarity assessment is prioritized, so that the initial clarity score generated by the algorithm is highly consistent with the human eye's subjective perception of image clarity.

[0063] This dynamic weight allocation mechanism enables the algorithm to automatically adjust the weights of images at different scales according to the differences in image content, and the algorithm can adaptively determine the importance of each scale layer. Thus, it can adaptively adjust the contribution degree of images at different scales to clarity evaluation, improving the accuracy of clarity evaluation.

[0064] The calculation formula for the weight is: , where is the weight of the i-th scale image, n is the total number of scales, j is the j-th scale, is the variance of the gradient amplitude of the i-th scale image, is the variance of the gradient amplitude of the j-th scale image.

[0065] In step S223, after determining the weights of images at each scale, the camera performs a weighted operation on the mean value of the gradient amplitude of each scale image and the corresponding weight. Specifically, it multiplies the mean value of the gradient amplitude of each scale image by the corresponding weight, and then sums up the weighted results of all scale layers to finally obtain a comprehensive value, which is the initial clarity score of the target image. This initial clarity score integrates the information of images at different scales and is weighted according to the texture importance of each scale image, and can comprehensively and accurately reflect the overall clarity of the image.

[0066] The calculation formula for the initial clarity score is: , where is the initial clarity score of the target image, n is the total number of scales, i is the i-th scale, is the mean value of the gradient amplitude of the i-th scale image, is the weight of the i-th scale image.

[0067] In the embodiments of the present application, by performing weighted fusion on images at each scale, the information contained in images at different scales is fully utilized. The large-scale layer captures the details and edges of the image, and the small-scale layer shows the overall structure of the image, avoiding information loss or misjudgment that may be caused by relying only on a single-scale image for clarity evaluation, obtaining a more comprehensive and accurate initial clarity score, and providing a more reliable basis for determining the best shooting distance.

[0068] Through gradient feature analysis, adaptive weight allocation, and multi-scale fusion, this application achieves precise quantitative evaluation of image sharpness. First, by calculating the pixel gradient magnitude, variance, and mean of images at each scale, the texture features of the images are transformed into measurable numerical indicators. Then, weights are dynamically allocated to each scale layer according to the texture density, enabling regions with rich texture and greater impact on human perception of sharpness to carry higher weights in the evaluation, thus conforming to human visual characteristics. Finally, by weighted-fusing the gradient means of each scale layer and integrating image information at different resolutions, the limitations of single-scale analysis are avoided. This process solves problems in traditional methods such as inconsistent sharpness evaluation with human perception and inability to adapt to complex scenarios, improving the accuracy and reliability of the initial sharpness score, and thus determining the optimal shooting distance.

[0069] As an alternative implementation, in step S23, selecting the blurred sub-blocks from multiple candidate sub-blocks according to the gradient mean of each candidate sub-block in the target image includes the following content.

[0070] Step S231: Segment the target image into multiple candidate sub-blocks and determine the gradient mean of each candidate sub-block. Step S232: Determine the scoring threshold according to a preset threshold coefficient and the initial sharpness score. Step S233: If the absolute value of the difference between the gradient mean of the candidate sub-block and the initial sharpness score exceeds the scoring threshold, determine the candidate sub-block as a blurred sub-block.

[0071] In step S231, the camera divides the target image obtained by multi-scale gradient fusion into multiple candidate sub-blocks of the same size and non-overlapping according to a preset rule. These sub-blocks, like the basic units of the image, jointly constitute a refined analysis unit for the local features of the image. After segmentation, for each candidate sub-block, the gradient magnitude of all pixels inside it is calculated one by one. The gradient magnitude reflects the intensity of pixel gray-level change and represents the richness of image edges and details. Subsequently, the gradient magnitudes of all pixels in the candidate sub-block are arithmetically averaged to obtain the gradient mean of the candidate sub-block. This mean serves as a quantitative indicator for measuring the sharpness of the sub-block. The higher the value, the richer the image details and the clearer the edges within the sub-block; conversely, it means that the sub-block may be blurred. By subdividing the target image into sub-blocks and analyzing them one by one, the specific regions with blurred phenomena in the image can be accurately located, that is, the blurred sub-blocks in the background can be quickly identified, avoiding misjudgment of the overall image quality due to local blurring.

[0072] In step S232, the camera calculates a scoring threshold based on a preset threshold coefficient and the initial clarity score of the target image. The threshold coefficient can be an adjustment parameter set by humans, and its value reflects the strictness of the algorithm's determination of blurred areas. This threshold coefficient can also be dynamically adjusted according to the clarity level of the image itself. Multiply the threshold coefficient by the initial clarity score to obtain the specific scoring threshold. This scoring threshold serves as a criterion for judging whether a sub-block is blurred. It comprehensively considers the overall clarity level of the image and provides a unified quantification standard for the subsequent screening of blurred sub-blocks.

[0073] By combining the overall initial clarity score of the image with the dynamically calculated scoring threshold, the algorithm can adaptively adapt to the image characteristics in different scenarios. Whether it is an image with complex textures (such as a fabric with rich textures) or a relatively smooth image (such as a portrait on a solid-color background), it can set a reasonable determination threshold based on its own clarity level, effectively avoiding misjudgments caused by a fixed threshold and improving the reliability of the evaluation results.

[0074] In step S233, the camera compares the gradient mean of each candidate sub-block with the initial clarity score of the target image and calculates the absolute value of the difference between the two. If this absolute value exceeds the scoring threshold determined in step S232, it indicates that the clarity of this candidate sub-block is lower than the overall level of the image, and thus this sub-block is determined to be a blurred sub-block.

[0075] The calculation formula for judging a blurred sub-block is: , where is the gradient mean of the candidate sub-block, is the initial clarity score, is the threshold coefficient.

[0076] After the camera identifies and marks the blurred sub-blocks, the subsequent overall initial clarity score can be corrected by deducting their influence, making the scoring result more in line with the subjective feeling of the human eye. Exemplarily, in a landscape photo with some areas blurred due to jitter, the algorithm first locates the blurred sub-blocks and then deducts the negative influence of these sub-blocks from the initial clarity score. The final obtained score can truly reflect the quality of the clear areas of the image and provide a more reliable basis for determining the best shooting distance.

[0077] As an optional implementation manner, in step S24, obtaining the clarity of the captured image by deducting the blurred area score corresponding to the blurred sub-blocks from the initial clarity score includes the following contents.

[0078] Step S241: Determine the blurred area score according to the number of blurred sub-blocks, the number of candidate sub-blocks, and a preset penalty coefficient, where the preset penalty coefficient is used to indicate the influence degree of local blurring on the overall clarity of the image; Step S242: Obtain the final clarity score based on the difference between the initial clarity score and the blurred area score, and use the final clarity score as the clarity of the captured image.

[0079] First, the camera counts the number M of all blurred sub-blocks and the total number of candidate sub-blocks , and then determines the proportion of the blurred area in the entire image through the ratio . This proportion reflects the coverage of the blurring phenomenon. Then, a preset penalty coefficient is set as an adjustment factor, and its value depends on the sensitivity of the application scenario to local blurring. Finally, multiply the blurred proportion by the penalty coefficient to obtain the blurred area score . The blurred area score quantifies the degree of weakening of the overall clarity caused by local blurring.

[0080] Based on the initial clarity score and the blurred area score , the final clarity score of the final image is obtained through subtraction. The final clarity score is the clarity of the captured image. This subtraction operation essentially deducts the quality loss caused by local blurring from the initial clarity score, making the final score closer to the subjective perception of the image clarity by the human eye.

[0081] The calculation formula for the final clarity score is: , where is the final clarity score.

[0082] As an optional implementation manner, the fixed distance advanced by the camera is determined according to the first advancement step length and the preset number of advancement steps. After determining the optimal shooting distance, the method further includes: Determine the shooting distance range based on the difference and sum between the optimal shooting distance and the first advancement step length, and use the shooting distance range as the initial shooting distance between the camera and the shooting object; Redetermine the advancement distance of the camera each time according to the second advancement step length and the preset number of advancement steps, where the second advancement step length is less than the first advancement step length; Redetermine the current shooting distance according to the updated initial shooting distance and the updated advancement distance, and perform multiple advancements and then select the shooting distance with the highest clarity as the optimal shooting distance.

[0083] Preferably, the present application adopts hierarchical search. Through a strategy of first rough and then refined, a relatively large first advancing step size is used to quickly determine the approximate range of the best shooting distance, significantly reducing the search time and improving the search efficiency. Then, a relatively small second advancing step size is used to conduct a detailed search within the precise range, improving the accuracy of determining the best shooting distance. The steps of the rough search stage and the refined search stage are as follows respectively.

[0084] Rough search stage.

[0085] First, set a relatively large first advancing step size, such as 5 cm, and at the same time determine the total number of times the camera advances. Subsequently, starting from the initial position, the camera approaches the object to be photographed by the first advancing step size each time, and takes an image each time it advances. During this process, for each captured image, methods such as multi-scale gradient fusion and correction of blurred areas are used to calculate the clarity score of the image. Finally, by comparing the clarity scores corresponding to all shooting distances, an initial best shooting distance H is determined. This step quickly narrows the range of finding the best shooting distance through a relatively large step size.

[0086] Refined search stage.

[0087] First, based on the best shooting distance H and the first advancing step size S determined in the previous step, delimit a new shooting distance range [H - S, H + S]. This range will serve as the starting interval for a new round of shooting, and this range will be used as the initial shooting distance between the camera and the object to be photographed. Compared with the shooting in the rough search stage, this range is closer to the actual best distance, effectively narrowing the search space.

[0088] Next, set a second advancing step size that is significantly smaller than the first advancing step size, such as 1 cm. The camera advances and shoots again within the new distance range by the second advancing step size, and still calculates the image clarity each time it advances. By using a smaller step size for refined search under the same number of advancing steps, and making fine adjustments within the range determined by the rough search, the positioning accuracy of the best shooting distance is improved, avoiding missing the true best distance due to an overly large step size.

[0089] Finally, the camera advances multiple times according to the new setting, takes an image each time it advances, and establishes the corresponding relationship between the clarity and the current shooting distance by calculating the image clarity. After completing all advancing operations, select the shooting distance with the highest clarity from the corresponding relationship again, and use it as the final shooting distance to achieve fine adjustment of the shooting distance.

[0090] In this application, the final shooting distance determined by the method of first rough and then fine can ensure that the clarity of the images captured by the camera reaches the optimal level. The rough search reduces unnecessary shootings and calculations, and the fine search focuses on a small range, which overall reduces the number of camera movements and the amount of image calculations. In long-term shooting tasks, it can reduce the mechanical wear of the camera, save computing resources, extend the service life of the device, and reduce operating costs.

[0091] This application provides a schematic diagram of the overall process for determining the best shooting distance of a fixed-depth-of-field camera, as Figure 2 shown, including the following steps.

[0092] Step 1: Initial parameter setting.

[0093] Step 1.1: Set the first advancement step length S of the camera, which is a relatively large distance value, such as 5 cm, for quickly searching the approximate range of the best shooting distance. Also set the preset advancement step length i of the camera.

[0094] Step 1.2: Set the regional parameters of the initial region of interest, such as the corner coordinates (X, Y), width Width, and height Height.

[0095] Step 1.3: Determine the total number of camera advancements, which will be used in the subsequent rough search and fine search phases.

[0096] Step 1.4: Set the initial position of the camera, and use this position as the starting point of the shooting distance.

[0097] Step 2: Rough search phase (rapid positioning in a large range).

[0098] Step 2.1: The camera starts from the initial position and moves towards the shooting object according to the first advancement step length, and takes an image each time it moves. Repeat this process until the preset total number of advancements is reached.

[0099] Step 2.2: During the advancement process, determine the image scaling ratio according to the ratio of the shooting distances before and after each advancement.

[0100] Step 2.3: Process the regional parameters of the region of interest before advancement using the image scaling ratio to obtain the regional parameters after advancement, and determine the corresponding region of interest. The shooting content of the region of interest during the camera advancement is scaled proportionally.

[0101] Step 2.4: Determine the captured image in the region of interest after the camera advancement.

[0102] Step 2.5: Downsample the captured image to generate images of different scales, such as 1 / 2, 1 / 4 of the original image size, etc.

[0103] Step 2.6: Calculate the gradient magnitude, gradient magnitude variance, and gradient magnitude mean of each scale image.

[0104] Step 2.7: Assign weights to each scale image according to the gradient magnitude variance. The gradient magnitude variance can reflect the texture density of the image. Weights are assigned to each scale image based on the texture density, and regions with richer textures receive higher weights.

[0105] Step 2.8: Fuse the gradient magnitude means of different scale images, comprehensively consider the weights of each region, generate an initial sharpness score, and obtain the target image.

[0106] Step 2.9: Divide the target image into multiple small sub - blocks, and calculate the gradient mean of each sub - block. Identify the blurred sub - blocks with blurred situations through the gradient mean of the sub - blocks and the initial sharpness score of the overall image.

[0107] Step 2.10: Deduct the blurred region score of the blurred sub - blocks from the initial sharpness score to obtain the sharpness of the captured image.

[0108] Step 2.11: Compare the sharpness corresponding to all shooting distances, and find the shooting distance with the highest sharpness score as the optimal shooting distance H.

[0109] Step 3: Fine - search stage (fine - tuning in a small range).

[0110] Step 3.1: Determine a new shooting distance range [H - S, H + S] according to the initial optimal shooting distance H and the first step size S.

[0111] Step 3.2: Set a second step size, which should be significantly smaller than the first step size, such as 1 cm, for a more refined search within the newly determined small range.

[0112] Step 3.3: The camera moves within the new shooting distance range, starting from the minimum value of the shooting distance range, and moves towards the object according to the second step size. Take an image each time it moves, and repeat this until the preset total number of moves.

[0113] Step 3.4: For each image taken in the fine - search stage, repeat the image - processing process in steps 2.2 - 2.10, and calculate the corrected sharpness score corresponding to each shooting distance.

[0114] Step 4: Determine the final result.

[0115] Step 4.1: Select the shooting distance with the highest score from all the sharpness scores obtained in the fine - search stage, and take it as the finally determined optimal shooting distance.

[0116] Step 4.2: The camera moves to the finally determined optimal shooting distance position for formal shooting, thereby obtaining an image with the optimal clarity.

[0117] Based on the same technical concept, the present application provides a device for determining the optimal shooting distance of a fixed-depth-of-field camera, as Figure 3 shown. The device includes: A first determination module 301, configured to determine an initial region of interest for focusing of a fixed-depth-of-field camera and determine first region parameters of the initial region of interest, where an image is captured every time the camera advances a fixed distance towards the object to be photographed; A second determination module 302, configured to determine the image scaling ratios generated before and after the camera advances according to the initial shooting distance between the camera and the object to be photographed before the advance and the current shooting distance between the camera and the object to be photographed after the advance; An adjustment module 303, configured to adjust the first region parameters according to the image scaling ratio to obtain second region parameters after the camera advances, and determine the current region of interest corresponding to the second region parameters, where the shooting content of the region of interest is scaled proportionally during the camera advance; A third determination module 304, configured to obtain image clarity by fusing multi-scale gradients of the captured images in the current region of interest and record the corresponding relationship between the clarity and the current shooting distance; A selection module 305, configured to select the shooting distance with the highest clarity as the optimal shooting distance according to the corresponding relationship after the camera advance ends.

[0118] Optionally, the first region parameters include the first abscissa, the first ordinate, the first width, and the first height of the corner points of the initial region of interest. The adjustment module 303 is configured to: Determine the central abscissa and the central ordinate of the center point of the overall image, where the overall image is the entire image captured by the camera; Determine the second abscissa according to the central abscissa, the image scaling ratio, and the first abscissa; Determine the second ordinate according to the central ordinate, the image scaling ratio, and the first ordinate; Determine the second width according to the first width and the image scaling ratio; Determine the second height according to the first height and the image scaling ratio; Constitute the second region parameters according to the second abscissa, the second ordinate, the second width, and the second height.

[0119] Optionally, the third determination module 304 is configured to: Generate multi-scale images by downsampling the captured images in the current region of interest; Generate a target image with an initial clarity score by dynamically assigning weights to images at each scale and fusing multi-scale gradients. Select blurred sub-blocks from multiple candidate sub-blocks according to the mean gradient of each candidate sub-block in the target image, where there is image blurring in the local image area corresponding to the blurred sub-block. Obtain the clarity of the captured image by deducting the score of the blurred area corresponding to the blurred sub-block from the initial clarity score.

[0120] Optionally, the third determination module 304 is specifically configured to: Determine the gradient amplitude of each pixel in the images at each scale, and determine the gradient amplitude variance and gradient amplitude mean of the scale image according to the gradient amplitudes of multiple pixels, where the gradient amplitude variance is used to indicate the texture density of the scale image. Assign weights to the scale images according to the texture density of the scale images, where the weights are in a positive relationship with the richness of the texture density. Obtain a target image with an initial clarity score according to the weighted gradient amplitude mean and weights of the scale images.

[0121] Optionally, the third determination module 304 is specifically configured to: Segment the target image into multiple candidate sub-blocks and determine the mean gradient of each candidate sub-block. Determine a score threshold according to a preset threshold coefficient and the initial clarity score. If the absolute value of the difference between the mean gradient of the candidate sub-block and the initial clarity score exceeds the score threshold, determine the candidate sub-block as a blurred sub-block.

[0122] Optionally, the third determination module 304 is specifically configured to: Determine a blurred area score according to the number of blurred sub-blocks, the number of candidate sub-blocks, and a preset penalty coefficient, where the preset penalty coefficient is used to indicate the degree of influence of local blurring on the overall clarity of the image. Obtain a final clarity score according to the difference between the initial clarity score and the blurred area score, and use the final clarity score as the clarity of the captured image.

[0123] Optionally, the device is further configured to: Determine a shooting distance range according to the difference and sum value between the optimal shooting distance and the first advancement step size, and use the shooting distance range as the initial shooting distance between the camera and the shooting object. Redetermine the advancement distance of the camera each time according to the second advancement step size and a preset number of advancement steps, where the second advancement step size is smaller than the first advancement step size. According to the updated initial shooting distance and the updated advancing distance, re-determine the current shooting distance, and perform multiple advancements and then select the shooting distance with the highest clarity as the optimal shooting distance.

[0124] As Figure 4 shown, an embodiment of the present application provides an electronic device, including a processor 401, a communication interface 402, a memory 403, and a communication bus 404. Among them, the processor 401, the communication interface 402, and the memory 403 complete mutual communication through the communication bus 404.

[0125] The memory 403 is used to store computer programs.

[0126] In an embodiment of the present application, when the processor 401 executes the program stored on the memory 403, it implements the method for determining the optimal shooting distance of a fixed-depth-of-field camera provided in any one of the foregoing method embodiments.

[0127] An embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the steps of the method for determining the optimal shooting distance of a fixed-depth-of-field camera provided in any one of the foregoing method embodiments.

[0128] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0129] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the above technical solution, in essence, or the part that contributes to the related technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disc, etc., including several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiments.

[0130] It should be understood that the terms used herein are for the purpose of describing particular example embodiments only and are not intended to be limiting. Unless the context clearly dictates otherwise, the singular forms "a", "an", and "the" as used herein may also include the plural forms. The terms "comprising", "including", "containing", and "having" are inclusive and thus specify the presence of stated features, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, steps, operations, elements, components, and / or combinations thereof. The method steps, processes, and operations described herein are not to be construed as necessarily requiring their performance in the particular order described or illustrated, unless an execution order is explicitly stated. It should also be understood that additional or alternative steps may be used.

[0131] The above are only specific embodiments of the present application, enabling those skilled in the art to understand or implement the present application. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to these embodiments shown herein, but rather will be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for determining the optimal shooting distance of a fixed depth-of-field camera, characterized in that, The method includes: Determine an initial region of interest for the camera focus with a fixed depth of field, and determine a first region parameter of the initial region of interest, where the camera captures an image every time it advances a fixed distance towards the subject; Determine the image scaling ratios before and after the camera advancement based on the initial shooting distance between the camera and the subject before the advancement and the current shooting distance between the camera and the subject after the advancement; Adjust the first region parameter according to the image scaling ratio to obtain a second region parameter after the camera advancement, and determine the current region of interest corresponding to the second region parameter, where the captured content of the region of interest scales proportionally during the camera advancement; Obtain the image sharpness by fusing the multi-scale gradients of the captured images in the current region of interest, and record the corresponding relationship between the sharpness and the current shooting distance; After the camera advancement ends, select the shooting distance with the highest sharpness as the optimal shooting distance according to the corresponding relationship.

2. The method according to claim 1, characterized in that, The first region parameter includes the first abscissa, the first ordinate, the first width, and the first height of the corner points of the initial region of interest. Adjusting the first region parameter according to the image scaling ratio to obtain the second region parameter after the camera advancement includes: Determine the central abscissa and the central ordinate of the center point of the overall image, where the overall image is the entire image captured by the camera; Determine the second abscissa according to the central abscissa, the image scaling ratio, and the first abscissa; Determine the second ordinate according to the central ordinate, the image scaling ratio, and the first ordinate; Determine the second width according to the first width and the image scaling ratio; Determine the second height according to the first height and the image scaling ratio; Construct the second region parameter according to the second abscissa, the second ordinate, the second width, and the second height.

3. The method according to claim 1, wherein Obtaining the image sharpness by fusing the multi-scale gradients of the captured images in the current region of interest includes: Generate multi-scale images by downsampling the captured images in the current region of interest; Generate a target image with an initial sharpness score through dynamically assigning weights to each scale image and fusing multi-scale gradients; Select the blurred sub-blocks from multiple candidate sub-blocks according to the gradient mean of each candidate sub-block in the target image, where the local image region corresponding to the blurred sub-block has an image blurring situation; Obtain the sharpness of the captured image by deducting the blurred region score corresponding to the blurred sub-block from the initial sharpness score.

4. The method according to claim 3, wherein Generating a target image with an initial sharpness score through dynamically assigning weights to each scale image and fusing multi-scale gradients includes: Determine the gradient amplitude of each pixel in each scale image, and determine the gradient amplitude variance and the gradient amplitude mean of the scale image according to the gradient amplitudes of multiple pixels, where the gradient amplitude variance is used to indicate the texture density of the scale image; Assign weights to the images at each scale according to the texture density of the images at each scale, where the weights are in a positive relationship with the richness of the texture density; Obtain a target image with an initial clarity score based on the weighted average of the gradient magnitudes and weights of the images at each scale.

5. The method according to claim 3, characterized in that, Selecting blurry sub-blocks from multiple candidate sub-blocks according to the gradient mean of each candidate sub-block in the target image includes: Segment the target image into multiple candidate sub-blocks and determine the gradient mean of each candidate sub-block; Determine a score threshold according to a preset threshold coefficient and the initial clarity score; If the absolute value of the difference between the gradient mean of the candidate sub-block and the initial clarity score exceeds the score threshold, determine that the candidate sub-block is a blurry sub-block.

6. The method according to claim 3, wherein Obtain the clarity of the captured image by deducting the blurry area score corresponding to the blurry sub-block from the initial clarity score, including: Determine the blurry area score according to the number of blurry sub-blocks, the number of candidate sub-blocks, and a preset penalty coefficient, where the preset penalty coefficient is used to indicate the influence degree of local blurriness on the overall clarity of the image; Obtain a final clarity score according to the difference between the initial clarity score and the blurry area score, and use the final clarity score as the clarity of the captured image.

7. The method according to claim 1, characterized in that The fixed distance of the camera advancement is determined according to a first advancement step length and a preset number of advancement steps. After determining the optimal shooting distance, the method further includes: Determine a shooting distance range according to the difference and sum value between the optimal shooting distance and the first advancement step length, and use the shooting distance range as the initial shooting distance between the camera and the shooting object; Redetermine the advancement distance of the camera each time according to a second advancement step length and the preset number of advancement steps, where the second advancement step length is less than the first advancement step length; Redetermine the current shooting distance according to the updated initial shooting distance and the updated advancement distance, and perform multiple advancements and then select the shooting distance with the highest clarity as the optimal shooting distance.

8. An apparatus for determining the optimal shooting distance of a fixed depth-of-field camera, characterized in that, The device includes: A first determination module, configured to determine an initial region of interest for the camera focus with a fixed depth of field, and determine a first region parameter of the initial region of interest, where the camera captures an image every time it advances a fixed distance towards the shooting object; A second determination module, configured to determine the image scaling ratio generated before and after the camera advancement according to the initial shooting distance between the camera and the shooting object before the advancement and the current shooting distance between the camera and the shooting object after the advancement; An adjustment module, configured to adjust the first region parameter according to the image scaling ratio to obtain a second region parameter after the camera advancement, and determine the current region of interest corresponding to the second region parameter, where the captured content of the region of interest is scaled proportionally during the camera advancement; A third determination module, configured to obtain the image clarity by fusing the multi-scale gradients of the captured image in the current region of interest, and record the corresponding relationship between the clarity and the current shooting distance; A selection module, configured to select, after the camera advancement ends, the shooting distance with the highest clarity as the optimal shooting distance according to the corresponding relationship.

9. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete mutual communication through the communication bus; The memory is used to store computer programs; The processor is configured to implement the method according to any one of claims 1-7 when executing the program stored on the memory.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the method according to any one of claims 1-7 is implemented.

Citation Information

Patent Citations

  • Image photographing method and equipment and computer readable storage medium

    CN108171743A

  • Automatic focusing method, system and equipment for medium-format inspection camera and storage medium

    CN117939293A

  • Photographing control method and apparatus, computer device and storage medium

    US20240114246A1

  • Image photographing method and related apparatus

    WO2021136050A1