Camera focusing method, medium, electronic equipment and visual positioning instrument
By determining the camera's focal plane depth and image quality judgment, combined with the allowable confusion circle constraint and pixel ambiguity, the problem of uneven image quality in the target workspace is solved, and a fast and accurate focusing effect is achieved.
Patent Information
- Application Number
- CN202511196450.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-25
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2045-08-25
AI Technical Summary
In the existing technology, the way the camera focuses in the target workspace leads to large differences in image quality, affecting positioning accuracy and low efficiency, making it difficult to meet the accuracy requirements of the entire target workspace.
By determining the focal plane depth of the camera's target workspace, capturing the image of the object being measured and adjusting the focus based on the image quality, and combining the allowable confusion circle constraint and pixel ambiguity judgment, the camera can be quickly focused.
The camera can quickly focus in the target workspace, meeting the accuracy requirements of the entire space and improving positioning accuracy and focusing efficiency.
Smart Images

Figure CN120711287A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of visual positioning technology, and in particular to a camera focusing method, medium, electronic equipment and visual positioning instrument. Background Art
[0002] Cameras are widely used in visual positioning technology. To ensure optimal imaging within the target workspace for precise positioning, cameras are typically focused directly at the center of the target workspace. This results in significant variations in image quality at different locations within the target workspace, compromising positioning accuracy. Furthermore, this approach is prone to focus failures and is inefficient, resulting in the camera's depth of field failing to meet the required accuracy across the entire target workspace. Summary of the Invention
[0003] The present invention provides a camera focusing method, medium, electronic equipment and visual positioning instrument to achieve rapid focusing of the camera and meet the accuracy requirements of the entire target working space of the camera.
[0004] In a first aspect, an embodiment of the present invention proposes a camera focusing method, comprising: determining a focal plane depth based on a target working space of the camera; using the camera to capture a first image of an object to be measured placed at the first target position, wherein the first target position is determined based on the focal plane depth; and focusing the camera based on the quality of the first image.
[0005] In some embodiments, determining the focal plane depth based on the target workspace of the camera includes: determining an allowable confusion circle constraint corresponding to the target workspace, and obtaining the focal plane depth based on the allowable confusion circle constraint; wherein the allowable confusion circle constraint represents a mapping relationship between a first allowable confusion circle size and a second allowable confusion circle size, the first allowable confusion circle being the allowable confusion circle corresponding to the camera's foreground depth of field corresponding to the closest distance of the target workspace, and the second allowable confusion circle being the allowable confusion circle corresponding to the camera's backfield depth of field corresponding to the farthest distance of the target workspace.
[0006] In some embodiments, the allowed circle of confusion constraint is obtained by the following formula:
[0007] in, represents the allowed circle of confusion constraint, 、 Respectively represent the farthest distance and the closest distance, 、 They respectively represent the pixel offsets corresponding to the farthest distance and the closest distance.
[0008] In some embodiments, the focal plane depth is obtained by the following formula:
[0009] in, represents the focal plane depth, Indicates the aperture value of the camera. represents the focal length of the camera, Indicates the size of the second allowable circle of confusion.
[0010] In some embodiments, focusing the camera according to the quality of the first image includes: determining the blur condition of the target pixel in the first image; when the blur condition does not meet the preset condition, adjusting the focus ring of the camera until the blur condition meets the preset condition.
[0011] In some embodiments, the object to be measured is a chessboard, and the target pixel point is a corner point of the chessboard; determining the blur condition of the target pixel point in the first image includes: selecting a target pixel area with the target pixel point as the center; calculating each pixel point in the target pixel area with a preset operator in a first direction, and adding up the calculation results to obtain a first blur degree; calculating each pixel point in the target pixel area with a preset operator in a second direction, and adding up the calculation results to obtain a second blur degree; wherein the second direction is perpendicular to the first direction, and the blur condition includes the first blur degree and the second blur degree.
[0012] In some embodiments, the preset conditions include: in the first direction, the number of target pixel points whose first blurriness is greater than a first blurriness threshold is greater than a first number threshold, and in the second direction, the number of target pixel points whose second blurriness is greater than a second blurriness threshold is greater than a second number threshold.
[0013] In some embodiments, after focusing is completed according to the quality of the first image, the method further includes: using the camera to capture a second image of the object to be measured placed at the second target position, wherein the second target position is determined according to the closest distance of the target workspace; determining whether the focusing result meets the target requirement based on the quality of the second image; if not, returning to the step of using the camera to capture the first image of the object to be measured placed at the first target position.
[0014] In some embodiments, after focusing is completed according to the quality of the second image, the method further includes: using the camera to capture a third image of the object to be measured placed at the third target position, wherein the third target position is determined according to the farthest distance of the target workspace; determining whether the focusing result meets the target requirement based on the quality of the third image; if not, returning to the step of using the camera to capture the first image of the object to be measured placed at the first target position.
[0015] In some embodiments, the first target position is within a first preset distance range before and after the focal plane depth, and / or the second target position is within a second preset distance range before and after the closest distance, and / or the third target position is within a third preset distance range before and after the farthest distance.
[0016] In a second aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the camera focusing method described in the embodiment of the first aspect is implemented.
[0017] In a third aspect, an embodiment of the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory. When the processor processes the computer program, it implements the camera focusing method described in the embodiment of the first aspect.
[0018] In a fourth aspect, an embodiment of the present invention provides a visual positioning device, comprising: a camera and the electronic device described in the embodiment of the third aspect.
[0019] The camera focusing method, medium, electronic device and visual positioning instrument of the embodiments of the present invention first determine the focal plane of the camera, then use the camera to capture a first image of the object to be measured placed at a first target position determined according to the focal plane, and focus the camera according to the quality of the first image. This can achieve rapid focusing of the camera, and the focusing result can meet the accuracy requirements of the camera's target workspace.
[0020] Additional aspects and advantages of the present invention will be set forth in part in the description which follows and, in part, will be obvious from the description which follows, or may be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 is a flow chart of a camera focusing method according to an embodiment of the present invention; FIG2( a ) is a schematic diagram of a target workspace according to an example of the present invention; FIG2( b ) is a schematic diagram of a target workspace according to another example of the present invention; FIG2( c ) is a schematic diagram of a checkerboard calibration plate according to an example of the present invention; FIG2( d ) is a schematic diagram of the placement angle of a checkerboard calibration plate according to an example of the present invention; Figure 3 is a flowchart of a camera focusing method according to another embodiment of the present invention; Figure 4 is a flow chart of a camera focusing method according to another embodiment of the present invention; Figure 5 is a schematic diagram of the depth of field according to an embodiment of the present invention; Figure 6 is a schematic diagram of a target pixel area according to an example of the present invention; Figure 7 is a structural block diagram of an electronic device according to an embodiment of the present invention; Figure 8 4 is a structural block diagram of a visual positioning device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0022] The following describes embodiments of the present invention in detail, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and are not to be construed as limiting the present invention.
[0023] The following describes a camera focusing method, a medium, an electronic device, and a vision positioning device according to embodiments of the present invention with reference to the accompanying drawings.
[0024] In an embodiment of the present invention, the following description can be made using a binocular camera in a surgical navigation system as an example. The surgical navigation system may include a navigator equipped with a binocular camera, a main control trolley for control, calculation, and display, and a robotic arm, etc. The main control trolley can be used to perform focusing calculations on the binocular camera of the navigator.
[0025] Figure 1 The figure is a flow chart of a camera focusing method according to an embodiment of the present invention.
[0026] like Figure 1 As shown, the camera focusing method includes: S11, determining the focus plane depth according to the target working space of the camera.
[0027] In embodiments of the present invention, the camera may be a monocular camera, a binocular camera, or multiple cameras. Taking the binocular camera in a surgical navigation system as an example, the surgical navigation system may include a navigator equipped with the binocular camera, a main control trolley for control, calculation, and display, and a robotic arm. The main control trolley can be used to perform focus calculations on the navigator's binocular camera.
[0028] The target workspace is the actual working space of the camera, referring to the physical range within which the camera lens can meet the actual working requirements for clear imaging. It can be pre-set as needed. For example, for a monocular camera, its target workspace is shown in Figure 2(a); for a binocular camera, its target workspace is shown in Figure 2(b). Referring to Figures 2(a) and 2(b), the closest distance, farthest distance, and working distance can be determined based on this target workspace: working distance = farthest distance - closest distance, where γ is the maximum acquisition angle of the camera. For a monocular camera, the target workspace is within the spatial range defined by γ; for a binocular camera, the target workspace is within the shared spatial range defined by the two γs.
[0029] For example, when the camera is imaging, the imaging within a certain depth of field range on both sides of the focal plane is relatively clearer. During the research and development work, it was found that when the middle position of the target workspace is used as the position corresponding to the focus plane depth, the camera has smaller system disturbances at the closest distance to the target workspace than at the farthest distance, resulting in a large difference in positioning errors. By balancing the errors at the closest and farthest distances of the camera's target workspace, the focus plane depth can be determined between the middle position of the target workspace and one-quarter of the working distance toward the farthest distance, or the focus plane depth can be obtained by theoretical calculation, so that when the camera is quickly focused based on the focus plane depth, the accuracy requirements of the camera in the target workspace can be met. Among them, the focus plane depth is determined from the above-mentioned one-quarter range, and the focus plane depth can be determined in sequence from near to far, from far to near, or from the middle to both ends, and then the multiple determined focus plane depths are traversed, and focus debugging is performed in sequence through the embodiment of the present invention until the focus is completed.
[0030] For cameras in the same batch, once the focal plane depth is determined for one camera, the focal plane depth can be used for focusing other cameras.
[0031] S12: using a camera to capture a first image of the object to be measured placed at a first target position, wherein the first target position is determined according to a depth of a focal plane.
[0032] For example, the first target position can be at a position corresponding to the depth of the focal plane, or can be within a first preset distance (which can be within a range of 5 to 15 mm) before or after the depth of the focal plane, such as within 10 mm before or after the depth of the focal plane. The measured object is a calibration object, such as a checkerboard calibration plate or a dot array calibration plate.
[0033] In one embodiment, the first target position is determined by a surgical navigation and positioning system executing the method of the present invention based on the focal plane depth. For example, after determining the focal plane depth, the surgical navigation and positioning system may determine the first target position based on the focal plane depth and provide the first target position to a staff member so that the staff member can place the object to be measured at the first target position.
[0034] In another embodiment, the first target position is determined by a staff member. For example, after determining the focal plane depth, the surgical navigation positioning system provides the focal plane depth to the staff member, who then determines the first target position based on the focal plane depth and places the object to be measured at the first target position.
[0035] For example, the display of the surgical navigation and positioning system can display the navigator, the target workspace corresponding to the navigator, i.e., the actual workspace of the aforementioned camera, and the previously determined depth of focus in real time. The operator can use an input module such as a mouse or keyboard to select or input the determined first target position on the reference display, place the object under test in the target workspace, and move the object under test until the display shows the object at the first target position.
[0036] As another embodiment, after determining the depth of the focal plane and determining the first target position according to the depth of the focal plane, the surgical navigation and positioning system further places the object to be measured at the first target position through a robotic arm.
[0037] In the above embodiment, to avoid or reduce aberrations introduced by angles (i.e., the deviation between ideal imaging and actual imaging), when determining the first target position, for a monocular camera, the line connecting the first target position and the camera position can be parallel to the camera optical axis; for a binocular camera, the line connecting the first target position and the binocular midpoint can be parallel to the symmetry axis of the binocular camera's baseline.
[0038] As shown in Figure 2 (c), taking the object to be measured as a checkerboard calibration plate as an example, the checkerboard calibration plate is placed at the first target position, and the distance between the first target position and the initial focal plane does not exceed a first preset distance, such as 10mm. In other words, the checkerboard calibration plate can be placed Within the range of ±10mm, is the distance between the camera and the initial focal plane, i.e., the depth of the focal plane. After placing the checkerboard calibration plate at the first target position, rotate the checkerboard calibration plate to ensure that the horizontal and vertical grid lines on the checkerboard calibration plate remain substantially parallel to the camera's X-axis and Y-axis, respectively, with an angular tilt error θ of no more than 5 degrees, as shown in Figure 2(d). At this point, the checkerboard calibration plate is confirmed to be placed, and the camera can capture the first image.
[0039] S13: Adjust the focus of the camera according to the quality of the first image.
[0040] The quality of the first image may be blurriness, clarity, etc. During the focusing process, the first image may be clear and not blurry as a condition for terminating the focusing.
[0041] In this embodiment, the focal plane depth is first determined according to the target workspace of the camera, and then the camera is used to capture a first image of the object to be measured placed at the first target position determined according to the focal plane depth. The camera is focused according to the quality of the first image to adjust the focal plane of the camera to near the focal plane depth. This can achieve rapid focusing of the camera, and the focusing result can meet the accuracy requirements of the camera's target workspace.
[0042] Figure 3 The figure is a flow chart of a camera focusing method according to another embodiment of the present invention.
[0043] S31, determining the focus plane depth according to the target working space of the camera.
[0044] S32: Using a camera to capture a first image of the object to be measured placed at a first target position, wherein the first target position is determined according to a depth of the focus plane.
[0045] S33: Adjust the focus of the camera according to the quality of the first image.
[0046] S34, using a camera to capture a second image of the object to be measured placed at a second target position, wherein the second target position is determined according to the shortest distance of the target workspace.
[0047] The second target position can be the closest distance to the target workspace. Similarly to the first target position, the second target position can be located within a second preset distance (which can be between 5 and 15 mm) before and after the closest distance to the camera's target workspace. For example, the second target position can be located within 10 mm before and after the closest distance. This second target position can be determined by the surgical navigation system based on the closest distance or by the operator.
[0048] S35: Determine whether the focusing result meets the target requirement according to the quality of the second image.
[0049] If not, the process returns to step S32 , which is the step of using a camera to capture a first image of the object to be measured placed at the first target position.
[0050] Figure 3 The embodiment shown and Figure 1 The difference between the illustrated embodiments is that, after performing the first focus adjustment using the quality of the first image, the quality of the second image is also used to determine whether the first focus adjustment result meets the target requirements. Specifically, whether the quality of the image captured at the closest distance to the target workspace meets the target requirements. If so, the result is considered qualified. Otherwise, the process returns to step S32 for a second focus adjustment, which can be a fine adjustment. Step S35 can be used to verify the focus adjustment results based on the depth of the focus plane to ensure the usability and reliability of the focus adjustment results for the entire target workspace.
[0051] Figure 4 The figure is a flow chart of a camera focusing method according to another embodiment of the present invention.
[0052] S41, determining the focus plane depth according to the target working space of the camera.
[0053] S42: Using a camera to capture a first image of the object to be measured placed at a first target position, wherein the first target position is determined according to a depth of the focus plane.
[0054] S43: Adjust the focus of the camera according to the quality of the first image.
[0055] S44, using a camera to capture a second image of the object to be measured placed at a second target position, wherein the second target position is determined according to the shortest distance of the target workspace.
[0056] S45: Determine, based on the quality of the second image, whether the focusing result meets the target requirement.
[0057] S46 , using a camera to capture a third image of the object to be measured placed at a third target position, wherein the third target position is determined according to the farthest distance of the target workspace.
[0058] The third target position can be the farthest distance from the target workspace. Similarly to the first target position, the third target position can be determined within a third preset distance (which can be within a range of 5-15 mm) before or after the farthest distance from the target workspace. For example, the third target position can be within 10 mm before or after the farthest distance. This third target position can be determined by the surgical navigation and positioning system based on the farthest distance, or by the staff based on the farthest distance.
[0059] S47: Determine whether the focusing result meets the target requirement according to the quality of the third image.
[0060] If not, the process returns to step S42 , which is the step of using a camera to capture a first image of the object to be measured placed at the first target position.
[0061] Figure 4 The embodiment shown and Figure 3 The difference between the illustrated embodiments is that after using the quality of the second image to verify that the focusing result meets the target requirements, the quality of the third image is also used to verify again whether the focusing result meets the target requirements, so as to better ensure the availability and reliability of the focusing on the target workspace.
[0062] Optionally, the focusing result may be verified first according to the quality of the third image, and after confirming that the target requirement is met, the focusing result may be verified again according to the quality of the second image.
[0063] In some embodiments of the present invention, determining the focal plane depth based on the target workspace of the camera includes: determining an allowable confusion circle constraint corresponding to the target workspace, and obtaining the focal plane depth based on the allowable confusion circle constraint. The allowable confusion circle constraint represents a mapping relationship (such as a ratio, product, etc.) between the size of a first allowable confusion circle and the size of a second allowable confusion circle. The first allowable confusion circle is the allowable confusion circle corresponding to the foreground depth of field of the camera corresponding to the closest distance to the target workspace, and the second allowable confusion circle is the allowable confusion circle corresponding to the back depth of field of the camera corresponding to the farthest distance to the target workspace. , depth of field Depth of focus The relative position relationship between Figure 5 shown.
[0064] This allowable circle of confusion constraint can be used to adjust the camera's imaging quality at the closest and farthest distances from the target workspace, thereby ensuring that the depth of field that meets imaging requirements covers the camera's target workspace. As an implementation, cameras from the same batch can achieve consistent product quality. After focusing using other methods, a second image at the closest distance and a third image at the farthest distance of the target workspace, after adjusting the focus, can be obtained. A first allowable circle of confusion size is then determined based on the quality of the second image, and a second allowable circle of confusion size is then determined based on the quality of the third image. A mapping relationship between the first and second allowable circle of confusion sizes is then determined to obtain an allowable circle of confusion constraint. This constraint can then be used for focusing in systems such as surgical navigation and positioning systems.
[0065] As another embodiment, the allowable circle of confusion constraint is a ratio of the first allowable circle of confusion size to the second allowable circle of confusion size. The allowable circle of confusion constraint is obtained by the following formula (1): (1) in, represents the allowed circle of confusion constraint, 、 Represents the farthest distance and the closest distance respectively. 、 They represent the pixel offset corresponding to the farthest distance and the closest distance respectively (referring to the position change of the imaging target on the image plane). So if the size of the second allowable confusion circle is , then the size of the first allowable circle of confusion can be expressed as .
[0066] It should be noted that the allowable confusion circle constraint determined by this method constrains and balances the errors between the nearest distance and the farthest distance of the target workspace. Compared with the allowable confusion circle constraint determined based on the second image quality and the third image quality after focusing is completed, it has a higher accuracy rate, is more accurate for the focal plane determined subsequently, can achieve faster and more accurate focusing, and can meet the positioning accuracy requirements of the camera target workspace.
[0067] In one embodiment, the ratio between the first allowable confusion circle size and the second allowable confusion circle size can be used as the ratio of the distance from the first position to the closest point of the target workspace to the distance from the focal plane depth position to the farthest point of the target workspace, thereby determining the first position, and determining the focal plane depth between the first position and the middle position of the target workspace.
[0068] In this case, according to an embodiment of the present invention, precise focusing can be achieved by traversing different focus plane depths.
[0069] In one embodiment, the ratio between the first allowable circle of confusion and the second allowable circle of confusion can be multiplied by the theoretical ratio of the foreground depth of field to the background depth of field (the range of the theoretical ratio is determined when the target working space depth, the aperture value of the camera, the focal length of the camera, and the allowable circle of confusion are selected. For example, if the target working space depth is within the range of 1-2.4 m, is 4, The product of the distance from the focal plane depth position to the closest point of the target workspace and the distance from the focal plane depth position to the farthest point of the target workspace is obtained by multiplying the distance by 1.5. If the product is 1.5, the focal plane depth can be determined based on this.
[0070] For example, in another embodiment, the depth of the focal plane is obtained by the following formula (2): (2) in, represents the focal plane depth, Indicates the aperture value of the camera. represents the focal length of the camera, Indicates the size of the second allowable circle of confusion.
[0071] exist is 2.88, is 4, When the focal plane depth is 10 mm, the focal plane depth is calculated based on formula (2): It is 1764mm.
[0072] This invention balances the errors between the closest and farthest distances of the target workspace by constraining the allowable circle of confusion at the closest and farthest points, combined with the focusing process. This can meet the positioning accuracy requirements of the camera's target workspace. By calculating the precise focal plane, subsequent focusing can be performed quickly.
[0073] In some embodiments of the present invention, focusing the camera according to the quality of the first image includes: determining the blur condition of the target pixel in the first image; when the blur condition does not meet the preset condition, adjusting the focus ring of the camera until the blur condition meets the preset condition.
[0074] In the embodiment, the purpose of focusing is to make the image clear and not blurry, and the blur condition can be used to characterize whether the image is blurry. If the blur condition does not meet the preset conditions, it is determined that the image is blurry and a focusing operation is required.
[0075] As an implementation method, the object to be measured is a checkerboard, and the target pixel point is a corner point of the checkerboard; determining the blur condition of the target pixel point in the first image includes: selecting a target pixel area with the target pixel point as the center; calculating each pixel point in the target pixel area with a preset operator in a first direction in turn, and adding up the calculation results to obtain a first blur degree; calculating each pixel point in the target pixel area with a preset operator in a second direction in turn, and adding up the calculation results to obtain a second blur degree, wherein the second direction is perpendicular to the first direction, and the blur condition includes the first blur degree and the second blur degree.
[0076] Take the target pixel area size of 11×11, the first direction is the X-axis direction, the second direction is the Y-axis direction, and the preset operator is the Sobel operator as an example. Find all the checkerboard corner points in the image. For each corner point, set the corresponding coordinates after rounding to (x, y). Select the [x-5, x+5] area in the X-axis direction and the [y-5, y+5] area in the Y-axis direction to form an 11×11 square area. Use the Sobel operator [3, 1, -3] in the X-axis direction to calculate one by one and take the absolute value and add it up. Use the Sobel operator [3; 1; -3] in the Y-axis direction to calculate one by one and take the absolute value and add it up. The edge position without pixel areas is filled with the nearest pixel value. For the corner point with a pixel value of 104, its target pixel area is as follows Figure 6 As shown, the pixel point with a value of 98 above it is calculated with the Sobel operator of [3,1,-3] in the X-axis direction to obtain |48×3+98×1+158×(-3)|=232, and the pixel point with a value of 98 above it is calculated with the Sobel operator of [3;1;-3] in the Y-axis direction to obtain |104×3+98×1+104×(-3)|=98. Similarly, Figure 6Calculate the other pixel points shown, add up the calculated values of all pixel points in the X-axis direction to obtain the first blur of the corner point; add up the calculated values of all pixel points in the Y-axis direction to obtain the second blur of the corner point.
[0077] Exemplarily, the preset conditions include: in the first direction, the number of target pixel points whose first blurriness is greater than the first blurriness threshold is greater than the first number threshold, and in the second direction, the number of target pixel points whose second blurriness is greater than the second blurriness threshold is greater than the second number threshold.
[0078] The first ambiguity threshold and the second ambiguity threshold may be equal and determined according to the position of the object being measured. Assume that the first ambiguity threshold and the second ambiguity threshold at the first target position are , the first ambiguity threshold and the second ambiguity threshold at the second target position are , the first ambiguity threshold and the second ambiguity threshold at the third target position are The fuzziness threshold and the inverse of the allowed confusion circle size are positively correlated and almost linear, combined with the allowed confusion circle size corresponding to the foreground depth corresponding to the nearest distance of the target workspace The size of the allowable circle of confusion corresponding to the depth of field at the farthest distance from the target workspace , there is a style When determining the fuzziness threshold, we can first determine , The value can be taken from small to large, and it is guaranteed to satisfy 、 The critical value of Not less than 1.5 times The first quantity threshold and the second quantity threshold may be determined based on a checkerboard calibration plate. For example, for a square checkerboard calibration plate, the first quantity threshold and the second quantity threshold may be equal, such as 8. For a rectangular checkerboard calibration plate, the first quantity threshold and the second quantity threshold may be different, such as 10 and 8, respectively.
[0079] If the number of target pixels in the first direction with a first blurriness greater than the first blurriness threshold is greater than the first threshold, the image quality in the first direction is determined to be acceptable. If the number of target pixels in the second direction with a second blurriness greater than the second blurriness threshold is greater than the second threshold, the image quality in the second direction is determined to be acceptable. If the image quality in either direction is unacceptable, the focus ring can be manually or automatically rotated in the direction that results in a clear image, and the image captured again and quality assessed. This process is repeated until the image quality in both the first and second directions is acceptable.
[0080] Optionally, to reduce the amount of calculation, only the first ambiguity may be calculated for judgment, or only the second ambiguity may be calculated for judgment.
[0081] Based on the camera focusing method of the above embodiment, the present invention proposes a computer-readable storage medium.
[0082] In this embodiment, a computer program is stored on a computer-readable storage medium. When the computer program is executed by a processor, the camera focusing method of the above embodiment is implemented.
[0083] Figure 7 It is a structural block diagram of an electronic device according to an embodiment of the present invention.
[0084] like Figure 7 As shown, electronic device 700 includes: a processor 701 and a memory 703. Processor 701 and memory 703 are connected, for example, via a bus 702. Optionally, electronic device 700 may further include a transceiver 704. It should be noted that in actual applications, the number of transceivers 704 is not limited to one, and the structure of electronic device 700 does not constitute a limitation on the embodiments of the present invention.
[0085] Processor 701 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic device, transistor logic device, hardware component, or any combination thereof. It may implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the present disclosure. Processor 701 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.
[0086] Bus 702 may include a path for transmitting information between the above components. Bus 702 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. Bus 702 may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, Figure 7 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.
[0087] The memory 703 is used to store a computer program corresponding to the camera focusing method of the above embodiment of the present invention, and the computer program is controlled and executed by the processor 701. The processor 701 is used to execute the computer program stored in the memory 703 to implement the content shown in the above method embodiment. Figure 7 The electronic device 700 shown is merely an example and should not limit the functions and scope of use of the embodiments of the present invention.
[0088] Figure 8 4 is a structural block diagram of a visual positioning device according to an embodiment of the present invention.
[0089] like Figure 8 As shown, the visual positioning instrument 800 includes: a camera 100 and the electronic device 700 of the above embodiment.
[0090] In summary, the camera focusing method, medium, electronic device and vision positioning device of the embodiments of the present invention can achieve rapid focusing of the camera and meet the accuracy requirements of the entire target workspace of the camera.
[0091] It should be noted that the logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing the logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device). For purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic device), a portable computer disk cartridge (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and programmable read-only memory (EPROM or flash memory), fiber optic devices, and a portable compact disc read-only memory (CDROM). Furthermore, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing it in another suitable manner if necessary, and then storing it in a computer memory.
[0092] It should be understood that various components of the present invention may be implemented using hardware, software, firmware, or a combination thereof. In the above-described embodiments, multiple steps or methods may be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented using hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof may be used: a discrete logic circuit having logic gate circuits for implementing logic functions on data signals, an application-specific integrated circuit having suitable combinational logic gate circuits, a programmable gate array (PGA), a field-programmable gate array (FPGA), etc.
[0093] Throughout this specification, reference to terms such as "one embodiment," "some embodiments," "examples," "specific examples," or "some examples" means that a specific feature, structure, material, or characteristic described in conjunction with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, schematic representations 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 any one or more embodiments or examples.
[0094] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", "axial", "radial", "circumferential" and the like to indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the present invention.
[0095] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of the technical features being referred to. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present invention, "plurality" means at least two, such as two, three, etc., unless otherwise specifically defined.
[0096] In the present invention, unless otherwise specified or limited, the terms "installed," "connected," "connect," "fixed," etc. should be understood in a broad sense. For example, they can refer to fixed connection, detachable connection, or integration; mechanical connection, electrical connection; direct connection, or indirect connection through an intermediate medium; internal communication between two components, or interaction between two components, unless otherwise specified. Those skilled in the art will understand the specific meanings of the above terms in the present invention based on specific circumstances.
[0097] In the present invention, unless otherwise expressly specified or limited, when a first feature is "above" or "below" a second feature, it may mean that the first and second features are in direct contact, or that the first and second features are in indirect contact through an intermediary. Furthermore, when a first feature is "above," "above," or "above" a second feature, it may mean that the first feature is directly above or diagonally above the second feature, or simply means that the first feature is at a higher level than the second feature. When a first feature is "below," "below," or "below" a second feature, it may mean that the first feature is directly below or diagonally below the second feature, or simply means that the first feature is at a lower level than the second feature.
[0098] Although the embodiments of the present invention have been shown and described above, it will be understood that the above embodiments are illustrative and are not to be construed as limitations on the present invention. A person skilled in the art may change, modify, replace and modify the above embodiments within the scope of the present invention.
Claims
1. A camera focusing method, characterized in that: include: Determine the depth of the focal plane based on the target working space of the camera; capturing, using a camera, a first image of the object under test placed at a first target position, wherein the first target position is determined according to the depth of the focal plane; The camera is focused according to the quality of the first image.
2. The camera focusing method according to claim 1, wherein: Determining the focal plane depth according to the target working space of the camera includes: Determining an allowable circle of confusion constraint corresponding to the target workspace, and obtaining the focal plane depth according to the allowable circle of confusion constraint; Among them, the allowable confusion circle constraint represents the mapping relationship between the size of a first allowable confusion circle and the size of a second allowable confusion circle, the first allowable confusion circle is the allowable confusion circle corresponding to the foreground depth of field of the camera corresponding to the closest distance of the target workspace, and the second allowable confusion circle is the allowable confusion circle corresponding to the back depth of field of the camera corresponding to the farthest distance of the target workspace.
3. The camera focusing method according to claim 2, wherein: The allowed circle of confusion constraint is obtained by the following formula: in, represents the allowed circle of confusion constraint, 、 Respectively represent the farthest distance and the closest distance, 、 They respectively represent the pixel offsets corresponding to the farthest distance and the closest distance.
4. The camera focusing method according to claim 3, wherein: The focal plane depth is obtained by the following formula: in, represents the focal plane depth, Indicates the aperture value of the camera. represents the focal length of the camera, Indicates the size of the second allowable circle of confusion.
5. The camera focusing method according to claim 1, wherein: The focusing of the camera according to the quality of the first image includes: Determining a blur condition of a target pixel in the first image; When the blur condition does not meet the preset condition, the focus ring of the camera is adjusted until the blur condition meets the preset condition.
6. The camera focusing method according to claim 5, characterized in that: The object to be measured is a checkerboard, and the target pixel point is a corner point of the checkerboard; and determining the blur condition of the target pixel point in the first image includes: Taking the target pixel point as the center, selecting a target pixel area; Calculating each pixel point in the target pixel area with a preset operator in sequence in a first direction, and summing the calculation results to obtain a first blurriness; Calculating each pixel point in the target pixel area with a preset operator in sequence in the second direction, and summing the calculation results to obtain a second blurriness; The second direction is perpendicular to the first direction, and the blur condition includes the first blur degree and the second blur degree.
7. The camera focusing method according to claim 6, wherein: The preset conditions include: In the first direction, the number of target pixel points whose first blurriness is greater than a first blurriness threshold is greater than a first number threshold, and in the second direction, the number of target pixel points whose second blurriness is greater than a second blurriness threshold is greater than a second number threshold.
8. The camera focusing method according to claim 1, wherein: After focusing is completed according to the quality of the first image, the method further includes: capturing, using the camera, a second image of the object under test placed at a second target position, wherein the second target position is determined according to a minimum distance of the target workspace; determining whether a focusing result meets a target requirement according to the quality of the second image; If not, the process returns to the step of using a camera to capture a first image of the object to be measured placed at the first target position.
9. The camera focusing method according to claim 8, wherein: After focusing is completed according to the quality of the second image, the method further includes: using the camera to capture a third image of the object under test placed at a third target position, wherein the third target position is determined according to the farthest distance of the target workspace; determining whether a focusing result meets the target requirement according to the quality of the third image; If not, the process returns to the step of using a camera to capture a first image of the object to be measured placed at the first target position.
10. The camera focusing method according to claim 9, wherein: The first target position is within a first preset distance range before and after the focal plane depth, and / or the second target position is within a second preset distance range before and after the closest distance, and / or the third target position is within a third preset distance range before and after the farthest distance.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the camera focusing method according to any one of claims 1 to 10 is implemented.
12. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that: When the processor processes the computer program, the camera focusing method according to any one of claims 1 to 10 is implemented.
13. A visual positioning device, characterized in that: include: A camera and an electronic device as claimed in claim 12.
Citation Information
Patent Citations
Light field display control method and device, and light field display equipment
CN106375694A
Fast snapshot method, device and system
CN109922251A
Focusing method and electronic equipment
CN111083375A
Depth-of-field judgment method and device, electronic equipment and storage medium
CN113570650A
Shooting method and electronic equipment
CN113747028A