Methods and systems for camera focusing, storage medium

CN122845934APending Publication Date: 2026-09-29CONTEMPORARY AMPEREX TECHNOLOGY CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510368838.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-26
Publication Date
2026-09-29

AI Technical Summary

Technical Problem

[0002]在锂电池生产过程中,需要使用各类外观检测设备对电芯表面缺陷进行外观检测,但是目前,在切拉换型中,这类设备需要人工介入调试成像,调试过程中要考虑角度、距离,光源共线度等多个因素

Benefits of technology

[0021]在上述方案中,通过获取多个对焦图像,获取用于表征每个对焦图像的清晰度的评价指标,基于多个候选拍摄位置所对应的对焦图像的评价指标,确定目标拍摄位置,用于相机对焦进行拍摄,实现相机自动对焦,减少人工干预,极大减少电池检测现场调试时间,提高了运维便捷性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122845934A_ABST
    Figure CN122845934A_ABST
Patent Text Reader

Abstract

The application discloses a camera focusing method and system, and a storage medium. The camera focusing method comprises the following steps: acquiring a plurality of focus images, wherein the plurality of focus images are obtained by respectively moving a camera to a plurality of candidate shooting positions relative to a calibration battery, and shooting a calibration pattern on the calibration battery; acquiring an evaluation index for characterizing the sharpness of each focus image; and determining a target shooting position based on the evaluation index of the focus image corresponding to the plurality of candidate shooting positions, wherein the target shooting position is used for camera focusing. According to the above scheme, the camera automatic focusing is realized through the calibration pattern on the calibration battery, manual intervention is reduced, on-site debugging time is greatly reduced, and operation and maintenance convenience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of battery testing technology, and in particular to a method and system for camera focusing, and a storage medium. Background Technology

[0002] In the lithium battery production process, various appearance inspection equipment is needed to visually inspect the surface defects of the cells. However, currently, during the cutting and changing process, these devices require manual intervention to adjust the imaging. During the adjustment process, multiple factors such as angle, distance, and collinearity of the light source must be considered. With the increasing frequency of cutting and changing, the manual adjustment cycle is long and the cost is high, making it increasingly unable to meet the production line's requirement for one-click changing of equipment during cutting and changing. Summary of the Invention

[0003] This application provides at least one method and system for camera focusing, and a storage medium.

[0004] This application provides a method for camera focusing, comprising: acquiring a plurality of focus images, wherein the plurality of focus images are obtained by moving the camera relative to a calibration battery to a plurality of candidate shooting positions and taking pictures of a calibration pattern on the calibration battery; acquiring an evaluation index for characterizing the sharpness of each focus image; and determining a target shooting position based on the evaluation index of the focus images corresponding to the plurality of candidate shooting positions, wherein the target shooting position is used for camera focusing.

[0005] In the above scheme, multiple focus images are acquired, and an evaluation index is obtained to characterize the sharpness of each focus image. Based on the evaluation index of the focus images corresponding to multiple candidate shooting positions, the target shooting position is determined for camera focusing. Automatic camera focusing is achieved by calibrating the calibration pattern on the calibration battery, reducing manual intervention, greatly reducing on-site debugging time, and improving the convenience of operation and maintenance.

[0006] In some embodiments, the calibration pattern has a first color block and a second color block arranged adjacent to each other; obtaining an evaluation index for characterizing the sharpness of each focused image includes: extracting a region of interest from the focused image, wherein the region of interest includes the boundary line between the first color block and the second color block; counting the number of transition pixels within the region of interest; obtaining a first evaluation index for characterizing the sharpness based on the proportion of transition pixels in the region of interest, wherein the smaller the proportion of transition pixels in the region of interest, the greater the sharpness. In the above scheme, fast, accurate, and quantifiable sharpness is achieved, thereby enabling automatic camera focusing through the region of interest in the calibration pattern, reducing manual intervention, greatly reducing on-site debugging time, and improving maintenance convenience.

[0007] In some embodiments, the number of regions of interest extracted from each focused image is multiple; obtaining the evaluation index for characterizing the sharpness of each focused image includes: averaging a first evaluation index of multiple regions of interest in the same focused image to obtain a second evaluation index. In the above scheme, it is less affected by local dirt or blurriness in the focused image, achieving fast, accurate, and quantifiable sharpness. This allows for automatic camera focusing by calibrating the regions of interest in the pattern, reducing manual intervention, significantly decreasing on-site debugging time, and improving maintenance convenience.

[0008] In some embodiments, the region of interest is rectangular, with two opposite edges along its length or width direction located within adjacent first and second color blocks on either side of the boundary line. The region of interest covers at least four rows or four columns of pixels in both the first and second color blocks along its length or width direction. This approach facilitates the determination of sharpness evaluation metrics for the focused image, enabling rapid, accurate, and quantifiable sharpness assessment.

[0009] In some embodiments, the first color block includes a border color block, and the second color block is disposed inside the border color block; the step of extracting the region of interest from the focused image includes:

[0010] A local image is extracted from the focused image based on the outer contour of the border color block; the region of interest is extracted within the local image, wherein the number of regions of interest is at least one, and at least a portion of the regions of interest includes the boundary line between the border color block and the second color block inside it. This approach achieves fast, accurate, and quantifiable sharpness.

[0011] In some embodiments, the first color block further includes an inner color block, which is disposed inside the border color block and spaced apart from the border color block by the second color block. The number of regions of interest (ROIs) is multiple, and some of the ROIs include the boundary line between the inner color block and the second color block. This approach provides more options for ROI detection, strong compatibility, and achieves fast, accurate, and quantifiable clarity.

[0012] In some embodiments, the border color block is arranged in a ring with an angle; the step of extracting a local image from the focused image based on the outer contour of the border color block includes: determining a reference point in the focused image based on the angle; setting an extraction region in the focused image based on the reference point; and extracting the local image from the extraction region. In the above scheme, it is easier to quickly and accurately locate the image, effectively reducing the impact of manually misaligned calibration patterns.

[0013] In some embodiments, determining a reference point in the focused image based on the oblique angle includes using the intersection of the extensions of the two right-angled sides connected by the oblique angle as the reference point. This approach allows for faster and more accurate positioning, effectively reducing the impact of manually misaligned calibration patterns.

[0014] In some embodiments, setting the extraction region based on the reference point includes determining the extraction region based on multiple reference points having a predetermined relative positional relationship with the reference point. In the above scheme, it is easier to quickly and accurately locate the region, effectively reducing the impact of manually misaligned calibration patterns.

[0015] In some embodiments, before extracting the local image from the focused image based on the outer contour of the border color block, the method further includes: performing rotation correction on the focused image based on the oblique angle. In the above scheme, focusing image correction is achieved, making it easier to quickly and accurately locate the image and effectively reducing the impact of manually misaligned calibration patterns.

[0016] In some embodiments, determining the target shooting position based on the evaluation index of the focused images corresponding to the plurality of candidate shooting positions includes: determining the focused image with the highest sharpness from the plurality of focused images, and using the candidate shooting position corresponding to the focused image with the highest sharpness as the target shooting position; or, in response to the sharpness of the currently acquired focused image meeting a preset sharpness requirement, using the candidate shooting position corresponding to the currently acquired focused image as the target shooting position, and stopping the acquisition of subsequent focused images. In the above scheme, the camera focusing meets the debugging requirements, thereby achieving automatic camera focusing, reducing manual intervention, greatly reducing on-site debugging time, and improving maintenance convenience.

[0017] In some embodiments, the camera focusing method is performed in a cyclic manner, wherein in each cycle, the camera moves relative to the calibration battery from a starting position to one of the plurality of candidate shooting positions by a preset step size. The starting position of the next cycle is the target shooting position of the previous cycle, and the step size of the next cycle is smaller than that of the previous cycle. This scheme achieves accurate determination of the target shooting position for camera focusing, thereby enabling automatic camera focusing, reducing manual intervention, significantly reducing on-site debugging time, and improving maintenance convenience.

[0018] In some embodiments, the method further includes: generating an alarm signal in response to an evaluation index of the sharpness of the focused image corresponding to the target shooting position being greater than a preset evaluation index value. In the above scheme, rapid switching and resizing are achieved, reducing manual intervention.

[0019] This application provides a camera focusing system, which includes a camera, a transmission module, a controller, and a host computer, wherein: the camera is used to photograph a calibration battery and a calibration pattern thereon; the transmission module is used to drive the camera to move; the controller is used to control the transmission module to drive the camera to move, control the camera to photograph the calibration battery and the calibration pattern thereon, and acquire the image captured by the camera; the host computer is used to execute the camera focusing method as described above.

[0020] This application provides a computer-readable storage medium having program instructions stored thereon, which, when executed by a processor, implement any of the above-described camera focusing methods.

[0021] In the above solution, by acquiring multiple focus images, an evaluation index is obtained to characterize the sharpness of each focus image. Based on the evaluation index of the focus images corresponding to multiple candidate shooting positions, the target shooting position is determined for camera focusing and shooting, thereby realizing automatic camera focusing, reducing manual intervention, greatly reducing on-site debugging time for battery testing, and improving the convenience of operation and maintenance.

[0022] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this application. Attached Figure Description

[0023] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with this application and, together with the specification, serve to explain the technical solutions of this application.

[0024] Figure 1 This is a schematic flowchart of a camera focusing method provided in some embodiments of this application;

[0025] Figure 2 This is a partial structural schematic diagram of a camera focusing system provided in some embodiments of this application;

[0026] Figure 3 This is a schematic diagram illustrating the acquisition of a focused image provided in some embodiments of this application;

[0027] Figure 4 This is a schematic diagram illustrating the extraction of regions of interest from a focused image according to some embodiments of this application;

[0028] Figure 5 This is a schematic diagram illustrating the extraction of regions of interest from a focused image according to some embodiments of this application;

[0029] Figure 6 This is a schematic diagram illustrating the extraction of regions of interest from a focused image according to some embodiments of this application;

[0030] Figure 7 This is a schematic diagram illustrating the extraction of regions of interest from a focused image according to some embodiments of this application;

[0031] Figure 8 This is a schematic diagram of the structure of a camera focusing system according to some embodiments of this application;

[0032] Figure 9 This is a schematic diagram illustrating the extraction of regions of interest from a focused image according to some embodiments of this application;

[0033] Figure 10 This is a schematic flowchart of the camera focusing process in some embodiments of this application;

[0034] Figure 11 This is a schematic diagram of the structure of a camera focusing system according to some embodiments of this application;

[0035] Figure 12 These are schematic diagrams of the structure of electronic devices provided in some embodiments of this application;

[0036] Figure 13 This is a schematic diagram of the structure of a computer-readable storage medium provided in some embodiments of this application. Detailed Implementation

[0037] The embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0038] In the following description, specific details such as particular system architectures, interfaces, and technologies are presented for illustrative purposes rather than for limiting purposes, in order to provide a thorough understanding of this application.

[0039] In this document, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, "many" in this document means two or more. Moreover, the term "at least one" in this document means any combination of at least two of any one or more of a plurality of objects. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.

[0040] Currently, when appearance inspection equipment performs appearance inspection on the surface of battery cells, the frequent cutting and changing of shapes leads to long manual adjustment cycles and high costs, which cannot meet the production line's requirement for one-click changing of shapes for equipment cutting and changing of shapes.

[0041] To this end, this application acquires multiple focus images, obtains evaluation indicators to characterize the sharpness of each focus image, determines the target shooting position based on the evaluation indicators of the focus images corresponding to multiple candidate shooting positions, and uses them for camera focusing. Automatic camera focusing is achieved by calibrating the calibration pattern on the calibration battery, reducing manual intervention, greatly reducing on-site debugging time, and improving the convenience of operation and maintenance.

[0042] Please see Figure 1 , Figure 1 This is a flowchart illustrating a camera focusing method provided in some embodiments of this application. The method includes: Step S11: Acquiring multiple focus images, wherein the multiple focus images are obtained by moving the camera relative to a calibration battery to multiple candidate shooting positions and capturing images of a calibration pattern on the calibration battery. Step S12: Acquiring an evaluation index characterizing the sharpness of each focus image. Step S13: Determining a target shooting position based on the evaluation index of the focus images corresponding to the multiple candidate shooting positions, wherein the target shooting position is used for camera focusing.

[0043] like Figure 2 The diagram shown is a partial structural schematic of a camera focusing system provided in some embodiments of this application. The camera focusing system 200 includes a camera 210 and a transmission module 220, wherein the camera 210 is disposed on the transmission module 220, the camera 210 is used to take pictures of the calibration battery 230, and the transmission module 220 is used to drive the camera 210 to move, so that the camera 210 is aligned with the calibration battery 230.

[0044] The camera focusing system 200 is used for focusing the camera 210. After focusing the camera 210, it can also be used for battery testing, such as battery appearance inspection. The calibration battery 230 is provided with a calibration pattern 240. For example, the calibration pattern 240 can be provided on a calibration plate, which is attached to the calibration battery 230.

[0045] The control drive module 220 moves the camera 210 relative to the calibration battery 230, for example, by moving it to multiple candidate shooting positions in preset steps.

[0046] Camera 210 photographs the calibration pattern 240 on the calibration battery 230. Alternatively, camera 210 can photograph the surface of the calibration battery 230 containing the calibration pattern 240. Figure 3 As shown, a battery image a1 is obtained. Subsequently, the portion corresponding to the calibration pattern 240 is cropped from the battery image a1, which is the focused image a2. The specific pattern of the calibration pattern 240 is not limited, so it is not shown. The camera 210 takes a picture of the calibration pattern 240 on the calibration battery 230, or the camera 210 can directly take a picture of the area corresponding to the calibration pattern 240 to obtain the focused image.

[0047] The sharpness of a focused image can be represented by the number of pixels within a specific brightness range in the focused image. Therefore, the corresponding evaluation metric can be determined based on the number of pixels within that specific brightness range. At each candidate shooting position, a focused image and its sharpness evaluation metric are obtained. Multiple candidate shooting positions result in multiple focused images and thus multiple evaluation metrics. Based on these multiple evaluation metrics, one of them is determined, and the candidate shooting position corresponding to that evaluation metric is then identified as the target shooting position.

[0048] In this embodiment, by acquiring multiple focused images, an evaluation index is obtained to characterize the sharpness of each focused image. Based on the evaluation index of the focused images corresponding to multiple candidate shooting positions, the target shooting position is determined for camera focusing. Automatic camera focusing is achieved by calibrating the calibration pattern on the calibration battery, reducing manual intervention, greatly reducing on-site debugging time, and improving the convenience of operation and maintenance.

[0049] In some embodiments, the calibration pattern has a first color block and a second color block arranged adjacent to each other; obtaining an evaluation index for characterizing the sharpness of each focused image includes: extracting a region of interest from the focused image, wherein the region of interest includes the boundary line between the first color block and the second color block; counting the number of transition pixels in the region of interest; obtaining a first evaluation index for characterizing sharpness based on the proportion of transition pixels in the region of interest, wherein the smaller the proportion of transition pixels in the region of interest, the greater the sharpness.

[0050] like Figure 4 The diagram illustrates the extraction of regions of interest from a focused image according to some embodiments of this application. In the focused image 400, the calibration pattern 410 includes a first color block 411 and a second color block 412 arranged adjacent to each other. The first color block 411 has a first expected brightness within the focused image 400, for example, the first color block 411 is a black color block. The second color block 412 has a second expected brightness within the focused image 400, for example, the second color block 412 is a white color block. Transition pixels are pixels whose brightness is within a preset brightness range, which is between the first expected brightness and the second expected brightness. The expected brightness can be a specific value or a specific range value, referring to the brightness that a specific color block should present when the focused image 400 is sufficiently clear, and can be set empirically. For example, the expected brightness of a black color block is 0-50, and the expected brightness of a white color block is 220-255. In this case, the brightness range of the transition pixels is set to 50-220.

[0051] A region of interest (ROI) 413 is extracted from the focused image 400. ROI 413 includes the boundary line 414 between the first color patch 411 and the second color patch 412. In other words, ROI 413 includes a portion of the first color patch 411, a portion of the second color patch 412, and the boundary line 414 between the first and second color patches 411 and 412. Assuming the number of transition pixels within ROI 413 is W, and the total number of pixels within ROI 413 is S, a first evaluation metric for characterizing sharpness can be determined based on W / S. For example, the first evaluation metric is W / S. The smaller the W / S, i.e., the smaller the first evaluation metric, the smaller the number of transition pixels, and thus the greater the sharpness.

[0052] It should be noted that, although Figure 4 The focused image 400 and calibration pattern 410 are shown as rectangles, but the focused image 400 and calibration pattern 410 in this application can also be other shapes, such as squares. Additionally, Figure 4 The first color block 411 is a circular color block, and the second color block 412 is a rectangular color block. Of course, the first color block 411 and the second color block 412 can also be color blocks of other shapes. For example, the first color block 411 can also be a rectangular color block, and the second color block 412 can also be a rectangular color block located on the rectangular color block of the first color block 411.

[0053] In this embodiment, by extracting the region of interest (ROI) from the focused image, including the boundary line between the first and second color blocks in the calibration pattern, counting the number of transition pixels within the ROI, and obtaining a first evaluation index to characterize sharpness based on the proportion of transition pixels in the ROI, a fast, accurate, and quantifiable sharpness is achieved. Thus, automatic camera focusing is realized through the ROI in the calibration pattern, reducing manual intervention, greatly reducing on-site debugging time, and improving the convenience of operation and maintenance.

[0054] In some embodiments, the number of regions of interest extracted from each focused image is multiple; obtaining an evaluation metric to characterize the sharpness of each focused image includes: averaging a first evaluation metric for multiple regions of interest in the same focused image to obtain a second evaluation metric.

[0055] like Figure 5 The diagram shown is a schematic representation of selecting a region of interest from a focused image according to some embodiments of this application. Figure 4The difference lies in the extraction of multiple Regions of Interest (ROIs) from the focused image 400, including ROI 413a and ROI 413b. ROI 413a includes the boundary line 414 between the first color patch 411 and the second color patch 412, and ROI 413b includes the boundary line 414 between the first color patch 411 and the second color patch 412. ROI 413a has a corresponding first evaluation index, and ROI 413b has a corresponding first evaluation index. Both the first evaluation indexes of ROI 413a and ROI 413b are determined based on the number of transition pixels within each and the total number of pixels. The average of the first evaluation indices of ROI 413a and ROI 413b is the second evaluation index, used as an evaluation index to characterize the sharpness of the focused image. A smaller second evaluation index indicates greater sharpness.

[0056] In this embodiment, a second evaluation index is obtained by averaging multiple regions of interest in the same focused image using a first evaluation index. This is less affected by local dirt or unclear images in the focused image, achieving fast, accurate, and quantifiable clarity. Thus, automatic focusing of the camera is achieved by calibrating the regions of interest in the pattern, reducing manual intervention, greatly reducing on-site debugging time, and improving the convenience of operation and maintenance.

[0057] In some embodiments, the region of interest is rectangular, and two opposite edges along the length or width of the region of interest are located in adjacent first and second color blocks on both sides of the dividing line, respectively. The region of interest covers at least 4 rows or 4 columns of pixels of the first and second color blocks along the length or width of the dividing line.

[0058] Continue with Figure 4 Taking an example, the two edges of ROI 413, positioned opposite each other along its length, are located within the first color block 411 and the second color block 412 adjacent to each other on both sides of the boundary line 414. ROI 413 covers at least four columns of pixels in the first color block 411 and at least four columns of pixels in the second color block 412 along its length. Alternatively, the two edges of ROI 413, positioned opposite each other along its width, can be located within the first color block 411 and the second color block 412 adjacent to each other on both sides of the boundary line 414. ROI 413 covers at least four rows of pixels in the first color block 411 and at least four rows of pixels in the second color block 412 along its width. In this case, the orientation of the rectangular ROI 413 is... Figure 4 The orientation of ROI 413 is set vertically.

[0059] Continue with Figure 5Taking an example, two opposite edges along the length of ROI 413a are located within the first color block 411 and the second color block 412 adjacent to each other on both sides of the boundary line 414. ROI 413a covers at least four columns of pixels of the first color block 411 and at least four columns of pixels of the second color block 412 along its length. Similarly, two opposite edges along the length of ROI 413b are located within the first color block 411 and the second color block 412 adjacent to each other on both sides of the boundary line 414. ROI 413b covers at least four columns of pixels of the first color block 411 and at least four columns of pixels of the second color block 412 along its length. Of course, for ROI 413a, the two edges set opposite to each other along the width direction of ROI 413a can be located within the first color block 411 and the second color block 412 adjacent to each other on both sides of the boundary line 414. ROI 413a covers at least four rows of pixels of the first color block 411 and at least four rows of pixels of the second color block 412 along the width direction. In this case, the setting direction of the rectangular ROI 413a is... Figure 4 The orientation of ROI 413a is perpendicular to the center. For ROI 413b, two edges positioned opposite each other along its width direction can also be located within adjacent first color blocks 411 and second color blocks 412 on either side of the boundary line 414. ROI 413b covers at least four rows of pixels in the first color block 411 and at least four rows of pixels in the second color block 412 along its width direction. In this case, the orientation of the rectangular ROI 413b is perpendicular to the center. Figure 4 The orientation of ROI 413b is set vertically.

[0060] In this embodiment, the region of interest is set in a rectangle, and two opposite edges along the length or width of the region of interest are located in the first and second color blocks adjacent to each other on both sides of the dividing line. The region of interest covers at least 4 rows or 4 columns of pixels of the first and second color blocks along the length or width, which is beneficial for determining the evaluation index of the sharpness of the focused image and achieving fast, accurate and quantitative sharpness.

[0061] In some embodiments, the first color block includes a border color block, and the second color block is disposed inside the border color block; extracting the region of interest from the focused image includes: extracting a local image from the focused image based on the outer contour of the border color block; extracting the region of interest within the local image, wherein the number of regions of interest is at least one, and at least a portion of the region of interest includes the boundary line between the border color block and the second color block inside it.

[0062] Continue with Figure 4 or Figure 5 Taking this as an example, the first color block 411 is the border color block 411, and the second color block 412 is located within the border color block 411. Figure 5Taking this as an example, regions of interest (ROIs) 413a and 413b are extracted from the focused image 400. Specifically, a local image 410 is extracted from the focused image 400 based on the outer contour of the border color block 411, where the local image 410 corresponds to the calibration pattern 410. Subsequently, ROIs 413a and 413b are extracted within the local image 410. ROI 413a includes the boundary line 414 between the border color block 411 and the second color block 412, and ROI 413b includes the boundary line 414 between the border color block 411 and the second color block 412.

[0063] In this embodiment, a local image is extracted from the focused image based on the outer contour of the border color block; at least one region of interest is extracted within the local image, and at least part of the region of interest includes the boundary line between the border color block and the second color block inside it, thereby achieving fast, accurate and quantifiable clarity.

[0064] In some embodiments, the first color block further includes an inner color block, which is disposed inside the border color block and is spaced apart from the border color block by the second color block. The number of regions of interest is multiple, and some regions of interest include the boundary line between the inner color block and the second color block.

[0065] like Figure 6 The diagram shown is a schematic diagram illustrating the extraction of regions of interest from a focused image according to some embodiments of this application. Figure 6 The calibration pattern in Figure 5 The difference in the marking patterns lies in the first color block. Figure 6 In the focused image 600, the calibration pattern 610 has a first color block and a second color block 612 arranged adjacently. The first color block includes a first color block 611a and a first color block 611b, that is, the first color block includes a border color block 611a and an inner color block 611b. The inner color block 611b is disposed inside the border color block 611a, and the inner color block 611b is spaced apart from the border color block 611a by the second color block 612. A local image 610 is extracted from the focused image 600 based on the outer contour of the border color block 611a, wherein the local image 610 corresponds to the calibration pattern 610.

[0066] Subsequently, Regions of Interest (ROIs) are extracted within the local image 610. The number of extracted ROIs is 3, including ROI 613a, ROI 613b, and ROI 613c. Among them, ROI 613a includes the boundary line 614 between the border color block 611a and the second color block 612. Two edges set opposite to each other along the length direction of ROI 613a are respectively located within the adjacent border color block 611a and the second color block 612 on both sides of the boundary line 614. For example, ROI 613a covers at least 4 columns of pixels of the border color block 611a and at least 4 columns of pixels of the second color block 612 along the length direction. ROI 613b includes a boundary line 615 between the second color block 612 and the inner color block 611b. Two edges, arranged opposite to each other along the length direction of ROI 613b, are located within the adjacent second color block 612 and inner color block 611b on both sides of the boundary line 615. For example, ROI 613b covers at least four columns of pixels of the second color block 612 and at least four columns of pixels of the inner color block 611b along the length direction. ROI 613c includes a boundary line 615 between the second color block 612 and the inner color block 611b. Two edges, arranged opposite to each other along the length direction of ROI 613c, are located within the adjacent inner color block 611b and second color block 612 on both sides of the boundary line 615. For example, ROI 613c covers at least four columns of pixels of the inner color block 611b and at least four columns of pixels of the second color block 612 along the length direction. The first evaluation index of ROI613a, the first evaluation index of ROI613b, and ROI613c are all determined based on the number of transition pixels within each ROI and the total number of pixels. The average of the first evaluation indices of ROI613a, ROI613b, and ROI613c is the second evaluation index, which serves as an evaluation index for characterizing the sharpness of the focused image 600. The smaller the second evaluation index, the greater the sharpness.

[0067] For the border color block 611a and the second color block 612, the border color block 611a has a first expected brightness, for example, the border color block 611a is a black color block, and the second color block 612 has a second expected brightness, for example, the second color block 612 is a white color block. For the inner color block 611b, it has a third expected brightness, wherein the third expected brightness may be the same as the first expected brightness or less than the first expected brightness. For example, the inner color block 611b may also be a black color block, or a color block with a grayscale smaller than black.

[0068] In this embodiment, the internal color blocks in the calibration pattern are set inside the border color blocks, and the second color blocks are spaced apart from the border color blocks. There are multiple regions of interest, and some regions of interest include the boundary line between the internal color blocks and the second color blocks, which makes ROI detection more selective, has strong compatibility, and achieves fast, accurate, and quantifiable clarity.

[0069] In some embodiments, the border color block is arranged in a ring with an angle; extracting a local image from the focused image based on the outer contour of the border color block includes: determining a reference point in the focused image based on the angle; setting an extraction region in the focused image based on the reference point; and extracting a local image from the extraction region.

[0070] like Figure 7 The diagram shown is a schematic diagram illustrating the extraction of regions of interest from a focused image according to some embodiments of this application. Figure 7 The calibration pattern in Figure 6 The difference in the calibration pattern lies in the fact that the border color block 611a is arranged in a ring with an oblique angle 6111a. The region of interest is extracted from the focused image 600. Specifically, a reference point P is determined in the focused image 600 based on the oblique angle 6111a. An extraction region 620 is set in the focused image 600 based on the reference point P, and a local image 610 is extracted from the extraction region 620, where the local image 610 corresponds to the calibration pattern 610. That is, the reference point P is used to determine the extraction region 620, which is the region where the local image 610 is located. The reference point P can be a point related to the oblique angle 6111a; for example, the reference point P can be the intersection of the extensions of the two right-angled sides connected by the oblique angle 6111a, or it can be one of the intersections of the oblique angle 6111a and the two right-angled sides it connects. Subsequently, ROI extraction is performed within the local image 610. The number of extracted ROIs is 3, including ROI 613a, ROI 613b and ROI 613c. ROI 613a includes the boundary line 614 between the border color block 611a and the second color block 612. ROI 613b includes the boundary line 615 between the second color block 612 and the inner color block 611b. ROI 613c includes the boundary line 615 between the second color block 612 and the inner color block 611b.

[0071] In this embodiment, a reference point is determined in the focused image based on the oblique angle of the border color block set in a ring; an extraction area is set in the focused image based on the reference point, and a local image is extracted from the extraction area, which makes it easier to quickly and accurately locate the image and effectively reduces the impact of manually pasting the calibration pattern.

[0072] In some embodiments, determining a reference point in the focused image based on the oblique angle includes using the intersection of the extensions of the two right-angled sides connected by the oblique angle as the reference point.

[0073] Continue with Figure 7 Taking the example of the intersection of the extensions of the two direct sides connected by the oblique angle 6111a, we take the reference point P as the reference point.

[0074] In this embodiment, the intersection of the extensions of the two right-angled sides connected by the oblique angle is used as the reference point. Based on the reference point, the extraction area is set in the focused image, and the local image is extracted from the extraction area. This makes it easier to locate quickly and accurately, and effectively reduces the impact of manually pasting the calibration pattern.

[0075] In some embodiments, setting the extraction region based on a reference point includes: determining the extraction region based on a plurality of reference points that have a predetermined relative positional relationship with the reference point.

[0076] Continue with Figure 6 Taking this example, based on the reference point P, each vertex of the extraction region 620 can be determined as multiple reference points with a predetermined relative positional relationship to the reference point P. Thus, based on the multiple reference points, i.e., each vertex of the extraction region 620, the extraction region 620 is determined.

[0077] In this embodiment, the extraction area is determined by multiple reference points that have a predetermined relative positional relationship with the benchmark point, which makes it easier to locate quickly and accurately and effectively reduces the impact of manually pasting the calibration pattern incorrectly.

[0078] In some embodiments, before extracting a local image from the focused image based on the outer contour of the border color block, the method further includes: performing rotation correction on the focused image based on the oblique angle.

[0079] Continue with Figure 7 Taking this example, before extracting the local image 610 from the focused image 600 based on the outer contour of the border color block 611a, the focused image 600 is rotated and corrected based on the oblique angle 6111a.

[0080] In this embodiment, by performing rotational correction on the focus image based on the oblique angle before extracting the local image, the focus image is corrected, which makes it easier to locate quickly and accurately, and effectively reduces the impact of manually pasting the misaligned calibration pattern.

[0081] In some embodiments, determining the target shooting position based on the evaluation index of the focus images corresponding to multiple candidate shooting positions includes: determining the focus image with the highest sharpness from multiple focus images, and taking the candidate shooting position corresponding to the focus image with the highest sharpness as the target shooting position; or in response to the sharpness of the currently acquired focus image meeting a preset sharpness requirement, taking the candidate shooting position corresponding to the currently acquired focus image as the target shooting position, and stopping the acquisition of subsequent focus images.

[0082] For example, at each candidate shooting location, a focused image and its sharpness evaluation index are obtained. Multiple candidate shooting locations result in multiple focused images, and thus multiple evaluation indices. Based on these multiple evaluation indices, the smallest evaluation index is determined, representing the highest sharpness. The candidate shooting location corresponding to this smallest evaluation index is then determined as the target shooting location. The smallest evaluation index can be less than a preset value. For example, this preset value can be the proportion of transition pixels in a 4-row or 4-column layout within the corresponding region, such as the proportion within the region of interest.

[0083] For example, the currently acquired focused image is obtained by processing a photo taken at the current candidate shooting position. At the current candidate shooting position, the current focused image and its sharpness evaluation index are obtained. If the sharpness evaluation index corresponding to the current focused image meets the preset sharpness requirements, then the current candidate shooting position is taken as the target shooting position. At this time, the acquisition of subsequent focused images is stopped, that is, control is no longer applied. Figure 2 The transmission module 220 moves the camera 210 to a subsequent candidate shooting position for shooting. The preset sharpness requirement can refer to an evaluation metric that corresponds to a sharpness level lower than a preset value. For example, the preset value could be the percentage of transition pixels in a 4-row or 4-column layout within the corresponding area, such as the percentage within the region of interest.

[0084] In this embodiment, the focus image with the highest sharpness is determined from multiple focus images, and the candidate shooting position corresponding to the focus image with the highest sharpness is taken as the target shooting position; or, in response to the sharpness of the currently acquired focus image meeting the preset sharpness requirement, the candidate shooting position corresponding to the currently acquired focus image is taken as the target shooting position, and the acquisition of subsequent focus images is stopped for camera focusing, which meets the debugging requirements, thereby realizing automatic camera focusing, reducing manual intervention, greatly reducing on-site debugging time, and improving the convenience of operation and maintenance.

[0085] In some embodiments, the camera focusing method is performed in a cyclic manner, wherein in each cycle, the camera moves relative to a calibration battery from a starting position to a plurality of candidate shooting positions by a preset movement step size, the starting position of the next cycle is the target shooting position of the previous cycle, and the movement step size of the next cycle is smaller than the movement step size of the previous cycle.

[0086] In one loop, assuming the starting position is the origin P(0), and the preset movement step size is D (e.g., D can be 0.5mm), the camera moves H times in both positive and negative directions (e.g., H is 10 times) to obtain multiple candidate shooting positions, namely P(0.5), P(1)...P(5) and P(-0.5), P(-1)...P(-5). From these multiple candidate shooting positions P(0.5), P(1)...P(5) and P(-0.5), P(-1)...P(-5), one candidate shooting position is determined and denoted as P(x). The candidate shooting position P(x) has the lowest sharpness evaluation index, that is, the candidate shooting position P(x) has the highest sharpness. At this time, the candidate shooting position P(x) can be used as the target shooting position for camera focusing.

[0087] Next, if the candidate shooting position P(x) was not used as the target shooting position for camera focusing in the previous loop, then in the next loop, the candidate shooting position P(x) (i.e., the target shooting position of the previous loop) is used as the starting position of the next loop. Starting from the candidate shooting position P(x) (i.e., the target shooting position of the previous loop), the preset movement step size is D', where D' is less than D, for example, D' can be 0.1mm. The camera moves h times in each of the positive and negative directions, for example, H is 20 times, to obtain multiple candidate shooting positions, namely P(x), P(x+0.1)...P(x+2) and P(x-2), P(x-1.9)...P(x). Then, the target shooting position is determined from these multiple candidate shooting positions P(x), P(x+0.1)...P(x+2) and P(x-2), P(x-1.9)...P(x). For example, the candidate shooting position corresponding to the minimum sharpness evaluation index is used as the target shooting position for camera focusing.

[0088] In this embodiment, a method for camera focusing is performed in a cyclic manner. In each cycle, the camera moves relative to the calibration battery from the starting position to multiple candidate shooting positions according to a preset movement step size. The starting position of the next cycle is the target shooting position of the previous cycle, and the movement step size of the next cycle is smaller than that of the previous cycle. This achieves accurate determination of the target shooting position for camera focusing, thereby realizing automatic camera focusing, reducing manual intervention, greatly reducing on-site debugging time, and improving the convenience of operation and maintenance.

[0089] In some embodiments, the method further includes: generating an alarm signal in response to an evaluation index of the sharpness of the focused image corresponding to the target shooting position being greater than a preset evaluation index threshold.

[0090] The preset evaluation metric threshold can be the proportion of transition pixels in the corresponding area, for example, the proportion of 4 rows or 4 columns of transition pixels in the region of interest of the focused image. The preset evaluation metric threshold corresponds to the preset sharpness threshold. The smaller the sharpness evaluation metric, the greater the sharpness. In other words, when the sharpness of the focused image corresponding to the target shooting position is less than or equal to the preset sharpness threshold, an alarm signal is generated. The alarm signal is used to prompt manual intervention.

[0091] In this embodiment, an alarm signal is generated when the sharpness evaluation index of the focused image corresponding to the target shooting position is greater than a preset evaluation index threshold, thereby quickly realizing the switching and reducing manual intervention.

[0092] Please see Figure 8 This is a schematic diagram of the structure of a camera focusing system provided in some embodiments of this application. The camera focusing system 800 includes a camera 810, a transmission module 820, a controller 850, and a host computer 860. Both the camera 810 and the transmission module 820 are electrically connected to the controller 850, and the host computer 860 is electrically connected to the controller 850. The camera 810 is mounted on the transmission module 820 and is used to photograph the surface of a calibration battery 830 containing a calibration pattern 840. The transmission module 820 is used to move the camera 810 so that it aligns with the calibration battery 830. The controller 850 is used to control the transmission module 820 to move the camera 810, controlling the camera 810 to photograph the calibration battery 830 and the calibration pattern 840 on it, and to acquire the image captured by the camera 810, such as a battery image of the calibration battery 830. The host computer 860 is used to execute the camera focusing method of any of the above embodiments.

[0093] Camera 810, also known as imaging module, includes camera components, a light source, a light source controller, etc. Drive module 820 may include servo drive components, etc. Controller 850 may be a corresponding integrated chip or device, such as a Programmable Logic Controller (PLC). After the camera 810 completes focusing, camera focusing system 800 can be used for battery detection.

[0094] In this embodiment, by acquiring multiple focused images, an evaluation index is obtained to characterize the sharpness of each focused image. Based on the evaluation index of the focused images corresponding to multiple candidate shooting positions, the target shooting position is determined for camera focusing. Automatic camera focusing is achieved by calibrating the calibration pattern on the calibration battery, reducing manual intervention, greatly reducing on-site debugging time, and improving the convenience of operation and maintenance.

[0095] In some embodiments, combined with Figure 8 and Figure 9 The calibration pattern 840 is set on the calibration sheet. After the calibration sheet is attached to the surface of the calibration battery, as shown... Figure 10 As shown, the camera focusing process includes the following steps:

[0096] Step S101: Controller 850 controls transmission module 820 to move camera 810 relative to calibration battery 830 to multiple candidate shooting positions with a preset first movement step.

[0097] The controller 850 controls the drive module 820 to move the camera 810 relative to the calibration battery 830 to multiple candidate shooting positions by a preset first movement step.

[0098] In one cycle, assuming the starting position is the origin P(0), the distance between it and the surface of the calibrated battery 830 is preset, and the preset first moving step size is D, for example, D can be 0.5mm. Move along the positive and negative directions H times, for example, H is 10 times, to obtain multiple candidate shooting positions, namely P(0.5), P(1)...P(5) and P(-0.5), P(-1)...P(-5).

[0099] Step S102: At each candidate shooting position, the controller 850 controls the camera 810 to shoot the calibration pattern 840 on the calibration battery 830, so as to acquire and transmit the battery image T to the host computer 860.

[0100] At each candidate shooting position, the camera 810 takes a picture of the surface of the calibration battery 830 containing the calibration pattern 840 to obtain a battery image T, which is then transmitted to the controller 850. Subsequently, the controller 850 transmits the battery image T to the host computer 860.

[0101] Step S103: The host computer 860 obtains the focus image 90 based on the battery image T, and extracts the local image 910 from the focus image 90 according to the outer contour of the border color block 911a.

[0102] The host computer 860 acquires the battery image T and extracts the portion corresponding to the calibration pattern 840 from the battery image T, which is the focus image 90. Specifically, the focus image 90 is rotated and corrected according to the oblique angle 9111a, thereby extracting the local image 910 from the focus image 90 based on the outer contour of the border color block 911a.

[0103] The host computer 860 extracts a local image 910 from the focused image 90 based on the outer contour of the border color block 911a. Specifically, the host computer 860 determines a reference point P in the focused image 90 based on the oblique angle 9111a, for example, using the intersection of the extensions of the two right-angled sides connected by the oblique angle 9111a as the reference point P. Subsequently, an extraction region 920 is set in the focused image 90 based on the reference point P. For example, the extraction region 920 is determined based on multiple reference points with a predetermined relative positional relationship to the reference point P, and the local image 910 is extracted from the extraction region 920, where the local image 910 corresponds to the calibration pattern 910. In other words, the reference point P is used to determine the extraction region 920, and the extraction region 920 is the area where the local image 910 is located. The reference point P can be a point related to the oblique angle 9111a. For example, the reference point P can be the intersection of the extensions of the two right-angled sides connected by the oblique angle 9111a, or it can be one of the intersections of the oblique angle 9111a and the two right-angled sides connected by it.

[0104] Step S104: The host computer 860 extracts the region of interest within the local image 910.

[0105] The number of extracted ROIs is 3, including ROI 913a, ROI 913b and ROI 913c. ROI 913a includes a boundary line 914 between border color block 911a and color block 912. Two edges set opposite to each other along the length direction of ROI 913a are located in the adjacent border color block 911a and color block 912 on both sides of the boundary line 914. For example, ROI 913a covers at least 4 columns of pixels of border color block 911a and at least 4 columns of pixels of color block 912 along the length direction. ROI 913b includes a boundary line 915 between color block 912 and inner color block 911b. Two opposite edges along the length of ROI 913b are located within the adjacent second color block 912 and inner color block 911b on both sides of the boundary line 915. ROI 913b covers at least four columns of pixels of the second color block 912 and at least four columns of pixels of the inner color block 911b along its length. ROI 913c includes a boundary line 915 between color block 912 and inner color block 911b. Two opposite edges along the length of ROI 913c are located within the adjacent inner color block 911b and second color block 912 on both sides of the boundary line 915. For example, ROI 913c covers at least four columns of pixels of the inner color block 911b and at least four columns of pixels of the second color block 912 along its length.

[0106] Step S105: The host computer 860 counts the number of transition pixels in the region of interest.

[0107] Transition pixels are pixels whose brightness falls within a preset brightness range, which is between a first expected brightness and a second expected brightness. The expected brightness can be a specific value or a specific range, referring to the brightness a particular color block should exhibit when the focused image is sufficiently sharp. This can be set empirically. For example, if the expected brightness for a black color block is 0-50, and the expected brightness for a white color block is 220-255, then the brightness range of the transition pixels would be set to 50-220.

[0108] Step S106: The host computer 860 obtains an evaluation index to characterize sharpness based on the proportion of transition pixels in the region of interest.

[0109] Assuming the number of transition pixels in ROI 913a is Wa, and the total number of pixels in ROI 913a is Sa, an evaluation metric for characterizing sharpness can be determined based on Wa / Sa. For example, the evaluation metric is Wa / Sa. The smaller Wa / Sa is, the smaller the evaluation metric, the smaller the number of transition pixels, and thus the greater the sharpness of ROI 913a. Assuming the number of transition pixels in ROI 913b is Wb, and the total number of pixels in ROI 913b is Sb, an evaluation metric for characterizing sharpness can be determined based on Wb / Sb. For example, the evaluation metric is Wb / Sb. The smaller Wb / Sb is, the smaller the first evaluation metric, the smaller the number of transition pixels, and thus the greater the sharpness of ROI 913b. Assuming the number of transition pixels in ROI 913c is Wc, and the total number of pixels in ROI 913c is Sc, an evaluation metric for characterizing sharpness can be determined based on Wc / Sc. For example, the evaluation metric is Wc / Sc. The smaller the Wc / Sc ratio, which is the smaller the primary evaluation metric, the smaller the number of transition pixels, and consequently the greater the sharpness of the ROI 913c.

[0110] The average of the evaluation metrics for ROIs 913a, 913b, and 913c can be chosen as the evaluation metric for characterizing the sharpness of the focused image 90. Alternatively, the largest evaluation metric among ROIs 913a, 913b, and 913c can be chosen as the evaluation metric for characterizing the sharpness of the focused image 90.

[0111] Step S107: The host computer 860 determines the candidate shooting position with the highest sharpness represented by the evaluation index.

[0112] After steps S102-S107, the sharpness evaluation index of the focused image 90 corresponding to the multiple candidate shooting positions P(0.5), P(1)...P(5) and P(-0.5), P(-1)...P(-5) is obtained. Then, one candidate shooting position is determined from these multiple candidate shooting positions P(0.5), P(1)...P(5) and P(-0.5), P(-1)...P(-5), denoted as P(x), where the sharpness evaluation index of the candidate shooting position P(x) is the smallest, that is, the sharpness corresponding to the candidate shooting position P(x) is the largest. The candidate shooting position P(x) can be used as the target shooting position. Then, it is determined whether the sharpness evaluation index of the focused image corresponding to the target shooting position is greater than the preset evaluation index threshold. If so, the target shooting position is used for camera focusing, and the controller 850 controls the transmission module 820 to move the camera 810 to the target shooting position for focusing. Otherwise, an alarm signal is generated to prompt manual intervention.

[0113] Step S108: Controller 850 controls transmission module 820 to move camera 810 relative to calibration battery 830 to multiple candidate shooting positions with a preset second movement step.

[0114] In the next iteration, starting from the candidate shooting position P(x), the preset second moving step size is D', where D' is less than D. For example, D' can be 0.1mm. Move h times in each of the positive and negative directions. For example, H is 20 times, to obtain multiple candidate shooting positions, namely P(x), P(x+0.1)...P(x+2) and P(x-2), P(x-1.9)...P(x).

[0115] Next, steps S102-S107 are repeated to obtain the sharpness evaluation index of the focused image 100 corresponding to these multiple candidate shooting positions P(x), P(x+0.1)...P(x+2) and P(x-2), P(x-1.9)...P(x). Then, the target shooting position is determined from these multiple candidate shooting positions P(x), P(x+0.1)...P(x+2) and P(x-2), P(x-1.9)...P(x). For example, the candidate shooting position corresponding to the smallest sharpness evaluation index is taken as the target shooting position.

[0116] Next, it is determined whether the sharpness evaluation index of the focused image corresponding to the target shooting position is greater than the preset evaluation index threshold. If so, the target shooting position is used for camera focusing, and the controller 850 controls the transmission module 820 to move the camera 810 to the target shooting position for focusing. Otherwise, an alarm signal is generated to prompt manual intervention.

[0117] Please see Figure 11 , Figure 11This is a schematic diagram of the structure of a camera focusing system according to some embodiments of this application. The camera focusing system 110 includes: a focus image acquisition module 111, an evaluation index acquisition module 112, and a determination module 113. The focus image acquisition module 112 is used to acquire multiple focus images, wherein the multiple focus images are obtained by moving the camera relative to a calibration battery to multiple candidate shooting positions and taking pictures of the calibration pattern on the calibration battery. The evaluation index acquisition module 112 is used to acquire an evaluation index characterizing the sharpness of each focus image. The determination module 113 is used to determine a target shooting position based on the evaluation index of the focus images corresponding to the multiple candidate shooting positions, wherein the target shooting position is used for camera focusing.

[0118] In this embodiment, by acquiring multiple focused images, an evaluation index is obtained to characterize the sharpness of each focused image. Based on the evaluation index of the focused images corresponding to multiple candidate shooting positions, the target shooting position is determined for camera focusing. Automatic camera focusing is achieved by calibrating the calibration pattern on the calibration battery, reducing manual intervention, greatly reducing on-site debugging time, and improving the convenience of operation and maintenance.

[0119] In some embodiments, the calibration pattern has a first color block and a second color block arranged adjacent to each other; the evaluation index acquisition module 112 is specifically used to: extract the region of interest from the focused image, wherein the region of interest includes the boundary line between the first color block and the second color block; count the number of transition pixels in the region of interest; and acquire a first evaluation index for characterizing sharpness based on the proportion of transition pixels in the region of interest, wherein the smaller the proportion of transition pixels in the region of interest, the greater the sharpness.

[0120] In this embodiment, by extracting the region of interest (ROI) from the focused image, including the boundary line between the first and second color blocks in the calibration pattern, counting the number of transition pixels within the ROI, and obtaining a first evaluation index to characterize sharpness based on the proportion of transition pixels in the ROI, a fast, accurate, and quantifiable sharpness is achieved. Thus, automatic camera focusing is realized through the ROI in the calibration pattern, reducing manual intervention, greatly reducing on-site debugging time, and improving the convenience of operation and maintenance.

[0121] In some embodiments, the number of regions of interest extracted from each focused image is multiple; the evaluation index acquisition module 112 is used to perform mean processing on the first evaluation index of multiple regions of interest in the same focused image to obtain a second evaluation index.

[0122] In this embodiment, a second evaluation index is obtained by averaging multiple regions of interest in the same focused image using a first evaluation index. This is less affected by local dirt or unclear images in the focused image, achieving fast, accurate, and quantifiable clarity. Thus, automatic focusing of the camera is achieved by calibrating the regions of interest in the pattern, reducing manual intervention, greatly reducing on-site debugging time, and improving the convenience of operation and maintenance.

[0123] In some embodiments, the region of interest is rectangular, and two opposite edges along the length or width of the region of interest are located in adjacent first and second color blocks on both sides of the dividing line, respectively. The region of interest covers at least 4 rows or 4 columns of pixels of the first and second color blocks along the length or width of the dividing line.

[0124] In this embodiment, the region of interest is set in a rectangle, and two opposite edges along the length or width of the region of interest are located in the first and second color blocks adjacent to each other on both sides of the dividing line. The region of interest covers at least 4 rows or 4 columns of pixels of the first and second color blocks along the length or width, which is beneficial for determining the evaluation index of the sharpness of the focused image and achieving fast, accurate and quantitative sharpness.

[0125] In some embodiments, the first color block includes a border color block, and the second color block is disposed inside the border color block; the evaluation index acquisition module 112 is used to extract the region of interest from the focused image, specifically to extract a local image from the focused image based on the outer contour of the border color block; extracting the region of interest within the local image, wherein the number of regions of interest is at least one, and at least a portion of the regions of interest includes the boundary line between the border color block and the second color block inside it.

[0126] In this embodiment, a local image is extracted from the focused image based on the outer contour of the border color block; at least one region of interest is extracted within the local image, and at least part of the region of interest includes the boundary line between the border color block and the second color block inside it, thereby achieving fast, accurate and quantifiable clarity.

[0127] In some embodiments, the first color block further includes an inner color block, which is disposed inside the border color block and is spaced apart from the border color block by the second color block. The number of regions of interest is multiple, and some regions of interest include the boundary line between the inner color block and the second color block.

[0128] In this embodiment, the internal color blocks in the calibration pattern are set inside the border color blocks, and the second color blocks are spaced apart from the border color blocks. There are multiple regions of interest, and some regions of interest include the boundary line between the internal color blocks and the second color blocks, which makes ROI detection more selective, has strong compatibility, and achieves fast, accurate, and quantifiable clarity.

[0129] In some embodiments, the border color block is arranged in a ring with an oblique angle; the evaluation index acquisition module 112 is used to extract a local image from the focus image according to the outer contour of the border color block, specifically used to: determine a reference point in the focus image according to the oblique angle; set an extraction area in the focus image based on the reference point, and extract a local image from the extraction area.

[0130] In this embodiment, a reference point is determined in the focused image based on the oblique angle of the border color block set in a ring; an extraction area is set in the focused image based on the reference point, and a local image is extracted from the extraction area, which makes it easier to quickly and accurately locate the image and effectively reduces the impact of manually pasting the calibration pattern.

[0131] In some embodiments, determining a reference point in the focused image based on the oblique angle includes using the intersection of the extensions of the two right-angled sides connected by the oblique angle as the reference point.

[0132] In this embodiment, the intersection of the extensions of the two right-angled sides connected by the oblique angle is used as the reference point. Based on the reference point, the extraction area is set in the focused image, and the local image is extracted from the extraction area. This makes it easier to locate quickly and accurately, and effectively reduces the impact of manually pasting the calibration pattern.

[0133] In some embodiments, setting the extraction region based on a reference point includes: determining the extraction region based on a plurality of reference points that have a predetermined relative positional relationship with the reference point.

[0134] In some embodiments, before extracting a local image from the focused image based on the outer contour of the border color block, the method further includes: performing rotation correction on the focused image based on the oblique angle.

[0135] In this embodiment, by performing rotational correction on the focus image based on the oblique angle before extracting the local image, the focus image is corrected, which makes it easier to locate quickly and accurately, and effectively reduces the impact of manually pasting the misaligned calibration pattern.

[0136] In some embodiments, the determining module 113 is used to determine the focus image with the highest sharpness from multiple focus images, and to take the candidate shooting position corresponding to the focus image with the highest sharpness as the target shooting position; or in response to the sharpness of the currently acquired focus image meeting a preset sharpness requirement, to take the candidate shooting position corresponding to the currently acquired focus image as the target shooting position, and to stop acquiring subsequent focus images.

[0137] In this embodiment, the focus image with the highest sharpness is determined from multiple focus images, and the candidate shooting position corresponding to the focus image with the highest sharpness is taken as the target shooting position; or, in response to the sharpness of the currently acquired focus image meeting the preset sharpness requirement, the candidate shooting position corresponding to the currently acquired focus image is taken as the target shooting position, and the acquisition of subsequent focus images is stopped for camera focusing, which meets the debugging requirements, thereby realizing automatic camera focusing, reducing manual intervention, greatly reducing on-site debugging time, and improving the convenience of operation and maintenance.

[0138] In some embodiments, the camera focusing system 130 is executed in a cyclic manner, wherein in each cycle, the camera moves relative to the calibration battery from a starting position to a plurality of candidate shooting positions by a preset movement step size, the starting position of the next cycle is the target shooting position of the previous cycle, and the movement step size of the next cycle is smaller than the movement step size of the previous cycle.

[0139] In this embodiment, the camera is executed in a cyclic manner. In each cycle, the camera moves from the starting position to multiple candidate shooting positions relative to the calibration battery according to a preset movement step size. The starting position of the next cycle is the target shooting position of the previous cycle, and the movement step size of the next cycle is smaller than that of the previous cycle. This enables precise determination of the target shooting position for camera focusing, thereby achieving automatic camera focusing, reducing manual intervention, greatly reducing on-site debugging time, and improving the convenience of operation and maintenance.

[0140] In some embodiments, the camera focusing system 110 further includes an alarm module (not shown) for generating an alarm signal in response to an evaluation index of the sharpness of the focused image corresponding to the target shooting position being greater than a preset evaluation index threshold.

[0141] In this embodiment, an alarm signal is generated when the sharpness evaluation index of the focused image corresponding to the target shooting position is greater than a preset evaluation index threshold, thereby quickly realizing the switching and reducing manual intervention.

[0142] Please see Figure 12 , Figure 12 This is a schematic diagram of the structure of an electronic device provided in some embodiments of this application. The electronic device 120 can be applied to the host computer 860 of the above embodiments, including a memory 121 and a processor 122. The processor 122 is used to execute program instructions stored in the memory 121 to implement the steps in any of the above-described camera focusing method embodiments. In a specific implementation scenario, the electronic device 120 may include, but is not limited to, a microcomputer or a server. Furthermore, the electronic device 120 may also include a laptop computer, tablet computer, or other carrier device, which is not limited here.

[0143] Specifically, processor 122 controls itself and memory 121 to implement the steps in any of the above-described camera focusing method embodiments. Processor 122 can also be referred to as a CPU (Central Processing Unit). Processor 122 may be an integrated circuit chip with signal processing capabilities. Processor 122 can also be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor. Furthermore, processor 122 can be implemented using integrated circuit chips.

[0144] Please see Figure 13 , Figure 13 This is a schematic diagram of the structure of a computer-readable storage medium provided in some embodiments of this application. The computer-readable storage medium 130 stores program instructions 1301 thereon, which, when executed by a processor, implement the steps in any of the above-described camera focusing method embodiments.

[0145] In the above scheme, multiple focus images are acquired, and an evaluation index is obtained to characterize the sharpness of each focus image. Based on the evaluation index of the focus images corresponding to multiple candidate shooting positions, the target shooting position is determined for camera focusing. Automatic camera focusing is achieved by calibrating the calibration pattern on the calibration battery, reducing manual intervention, greatly reducing on-site debugging time, and improving the convenience of operation and maintenance.

[0146] In some embodiments, the functions or modules of the apparatus provided in this disclosure can be used to perform the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0147] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.

[0148] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus implementations described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, units or components may be combined or integrated into another system, or some features may be ignored or not executed. In another image location, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.

[0149] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

Claims

1. A method for focusing a camera, characterized in that, include: Multiple focus images are acquired, wherein the multiple focus images are obtained by moving the camera relative to the calibration battery to multiple candidate shooting positions and taking pictures of the calibration pattern on the calibration battery; Obtain an evaluation metric to characterize the sharpness of each of the focused images; The target shooting position is determined based on the evaluation index of the focused image corresponding to the plurality of candidate shooting positions, wherein the target shooting position is used for camera focusing.

2. The method according to claim 1, characterized in that, The calibration pattern has a first color block and a second color block arranged adjacent to each other; The evaluation metrics used to characterize the sharpness of each of the focused images include: Extract the region of interest from the focused image, wherein the region of interest includes the boundary line between the first color patch and the second color patch; Count the number of transition pixels within the region of interest; A first evaluation index for characterizing the sharpness is obtained based on the proportion of the transition pixels in the region of interest, wherein the smaller the proportion of the transition pixels in the region of interest, the greater the sharpness.

3. The method according to claim 2, characterized in that, The number of regions of interest extracted from each of the focused images is multiple; The evaluation metrics used to characterize the sharpness of each of the focused images include: A second evaluation index is obtained by averaging the first evaluation index of multiple regions of interest in the same focused image.

4. The method according to claim 2 or 3, characterized in that, The region of interest is rectangular in shape, with two opposite edges along the length or width of the region of interest located within the first and second color blocks adjacent to each other on both sides of the dividing line. The region of interest covers at least four rows or four columns of pixels of the first and second color blocks along the length or width of the region of interest.

5. The control method according to any one of claims 2-4, characterized in that, The first color block includes a border color block, and the second color block is disposed inside the border color block; Extracting the region of interest from the focused image includes: Extract a local image from the focused image based on the outer contour of the border color block; The region of interest is extracted within the local image, wherein the number of regions of interest is at least one, and at least a portion of the region of interest includes the boundary line between the border color block and the second color block inside it.

6. The method according to claim 5, characterized in that, The first color block also includes an inner color block, which is disposed inside the border color block and is separated from the border color block by the second color block. The number of regions of interest is multiple, and some of the regions of interest include the boundary line between the inner color block and the second color block.

7. The method according to claim 5 or 6, characterized in that, The border color blocks are arranged in a ring with an angle; The step of extracting a local image from the focused image based on the outer contour of the border color block includes: A reference point is determined in the focused image based on the oblique angle; Based on the reference point, an extraction region is set in the focused image, and the local image is extracted from the extraction region.

8. The method according to claim 7, characterized in that, Determining a reference point in the focused image based on the oblique angle includes: The intersection of the extensions of the two right-angled sides connected by the oblique angle is taken as the reference point.

9. The method according to claim 7 or 8, characterized in that, The step of setting the extraction region based on the reference point includes: The extraction area is determined based on multiple reference points that have a predetermined relative positional relationship with the benchmark point.

10. The method according to any one of claims 7-9, characterized in that, Before extracting the local image from the focused image based on the outer contour of the border color block, the method further includes: The focused image is rotated and corrected based on the oblique angle.

11. The method according to any one of claims 1-10, characterized in that, Determining the target shooting position based on the evaluation index of the focused image corresponding to the plurality of candidate shooting positions includes: From the plurality of focused images, determine the focused image with the highest sharpness, and use the candidate shooting position corresponding to the focused image with the highest sharpness as the target shooting position; or In response to the fact that the sharpness of the currently acquired focused image meets the preset sharpness requirement, the candidate shooting position corresponding to the currently acquired focused image is taken as the target shooting position, and the acquisition of subsequent focused images is stopped.

12. The method according to any one of claims 1-11, characterized in that, The method of focusing the camera is performed in a cyclic manner, wherein in each cycle, the camera moves relative to the calibration battery from a starting position to the plurality of candidate shooting positions by a preset movement step size, the starting position of the next cycle is the target shooting position of the previous cycle, and the movement step size of the next cycle is smaller than the movement step size of the previous cycle.

13. The method according to any one of claims 1-12, characterized in that, Also includes: An alarm signal is generated in response to the fact that the sharpness evaluation index of the focused image corresponding to the target shooting position is greater than a preset evaluation index value.

14. A camera focusing system, characterized in that, The camera focusing system includes a camera, a transmission module, a controller, and a host computer, wherein: The camera is used to photograph the calibration battery and the calibration pattern on it; The transmission module is used to drive the camera to move; The controller is used to control the transmission module to move the camera, control the camera to take pictures of the calibration battery and the calibration pattern on it, and acquire the images taken by the camera. The host computer is used to perform the camera focusing method as described in any one of claims 1-13.

15. A computer-readable storage medium having program instructions stored thereon, characterized in that, When the program instructions are executed by the processor, they implement the camera focusing method according to any one of claims 1 to 13.