Focal plane alignment method and alignment system
By combining object distance information and regionalized edge contrast detection, the focal plane position is adjusted, solving the problem of accurate focusing in automated and complex environments using traditional focal plane alignment methods, and achieving fast and accurate focal plane alignment.
Patent Information
- Application Number
- CN202411211686.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-11-08
AI Technical Summary
Traditional focal plane alignment methods rely on the photographer's experience and are difficult to adjust the focal plane position quickly and accurately in automated and efficient shooting scenarios, especially in complex lighting conditions and shooting environments with fast-moving targets.
By combining object distance information to calculate the reference focal plane, and through regional edge detection and contrast detection, the actual focal plane position is gradually adjusted, and key areas are processed first to ensure image sharpness.
It significantly shortens focusing time, improves focal plane alignment accuracy, adapts to shooting environments with complex lighting and fast-moving targets, and ensures fast and accurate focusing results.
Smart Images

Figure CN118921554A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a focal plane alignment method and an alignment system. Background Art
[0002] In digital imaging and photography technology, focal plane alignment is a key step in ensuring that the target is clearly presented in the image. Traditional focusing methods often rely on the photographer's experience and manual adjustment, which is particularly inconvenient in many automated and efficient shooting scenarios, especially in applications that require rapid capture of moments or high-precision measurement and imaging.
[0003] With the advancement of science and technology, especially the rapid development of computer vision, image processing technology and autofocus systems, automatic and accurate focal plane alignment methods have become a research hotspot. Traditional autofocus methods often directly analyze the entire image, ignoring the possible focusing difficulty and priority differences in different areas of the image. At the same time, for targets at different distances, it is often necessary to dynamically adjust the position of the focal plane to ensure image clarity.
[0004] Therefore, it is necessary to develop a more intelligent and efficient focal plane alignment method, which can combine the target object distance information to preliminarily determine the reference focal plane position, and further accurately adjust the actual focal plane position by combining regionalized edge detection and contrast detection to ensure the clarity and imaging quality of the photographed target. Summary of the invention
[0005] In order to solve the above technical problems, the present invention provides a focal plane alignment method and an alignment system, which can achieve the beneficial effect of more flexible and precise focal plane alignment adjustment.
[0006] The present invention provides a focal plane alignment method, which comprises the following steps:
[0007] S1: Acquire an object distance of a target to be photographed, and acquire a reference focal plane of the target to be photographed according to the object distance;
[0008] S2: Calculate the displacement difference between the reference focal plane and the actual focal plane, and adjust the position of the actual focal plane according to the displacement difference, so that the actual focal plane is preliminarily aligned with the reference focal plane, wherein the actual focal plane is the image plane where the photosensitive element is located at the current moment;
[0009] S3: After the preliminary alignment, a reference image at the current moment is obtained, and edge detection is performed on the segmented regions of the reference image to obtain edge detection values of each region;
[0010] S4: performing contrast detection on the area with the highest edge detection value to obtain a contrast detection value;
[0011] S5: gradually moving the actual focal plane according to a preset step length, and reacquiring the reference image until the contrast detection value of the reacquired reference image meets a threshold condition.
[0012] Preferably, step S3 includes the following specific steps:
[0013] S301: After preliminary alignment, a reference image at the current moment is obtained, and the reference image at the current moment is adaptively segmented based on the image content to obtain multiple regions;
[0014] S302: Execute an edge detection algorithm on each segmented region to obtain a preliminary edge detection value of each region;
[0015] S303: normalizing the preliminary edge detection values to obtain edge detection values of each region.
[0016] Preferably, step S4 comprises the following steps:
[0017] S401: Selecting a region with the highest edge detection value as a detection selected region, and calculating pixel differences within the detection selected region, wherein the pixel differences include internal pixel differences and boundary pixel differences;
[0018] S402: summing the internal pixel difference and the boundary pixel difference to obtain a preliminary contrast detection value;
[0019] S403: normalizing the preliminary contrast detection value to obtain a contrast detection value.
[0020] Preferably, in step S401, the calculation formula of the internal pixel difference is:
[0021] D internal (x,y)=|I(x+1,y)-(x,y)|+|I(x,y+1)-(x,y)|
[0022] Among them, D internal (x, y) is the internal pixel difference, I(x, y) is the pixel value of the internal pixel at the position (x, y);
[0023] The calculation formula for boundary pixel difference is:
[0024]
[0025] Among them, D boundary 9x,y) is the boundary pixel difference, B(x,y) is the pixel value of the boundary pixel at the (x,y) position.
[0026] Preferably, in step S402, the calculation formula of the preliminary contrast detection value is:
[0027]
[0028] Among them, C is the preliminary contrast detection value, D internal (x, y) is the internal pixel difference, D boundary (x,y) is the boundary pixel difference.
[0029] Preferably, in step S403, the formula for normalizing the preliminary contrast detection value is:
[0030]
[0031] Among them, C n is the contrast detection value, C is the preliminary contrast detection value, |internal| is the number of internal pixels, and |boundary| is the number of boundary pixels.
[0032] Preferably, step S5 includes the following specific steps:
[0033] S501: randomly moving the actual focal plane in a direction from the current position according to a preset step length to obtain a new reference image at the current moment, performing region-corresponding segmentation on the new reference image with reference to the region of the reference image to obtain a new region, and selecting a region corresponding to the position of the selected region from the new region for contrast detection to obtain a new contrast detection value;
[0034] S502: Determine whether the difference between the new contrast detection value and the contrast detection value of the reference image is positive or negative. If the difference is positive, the current moving direction is the correct direction. Otherwise, the opposite direction of the current moving direction is the correct moving direction.
[0035] S503: gradually move the actual focal plane according to the preset step size and the correct moving direction, and obtain a new reference image until the contrast detection value of the new reference image is greater than or equal to the preset threshold, stop moving the actual focal plane, and complete the final focal plane alignment.
[0036] The present invention also provides a focal plane alignment system, which is applied to a focal plane alignment method. The focal plane alignment system comprises:
[0037] A reference focal plane calculation module is used to obtain an object distance of a target to be photographed, and obtain a reference focal plane of the target to be photographed according to the object distance;
[0038] A focal plane preliminary alignment module calculates the displacement difference between the reference focal plane and the actual focal plane, and adjusts the position of the actual focal plane according to the displacement difference so that the actual focal plane is preliminarily aligned with the reference focal plane, wherein the actual focal plane is the image plane where the photosensitive element is located at the current moment;
[0039] The edge detection module obtains the reference image at the current moment after preliminary alignment, and performs edge detection on the regions segmented from the reference image to obtain edge detection values for each region;
[0040] The contrast detection module performs contrast detection on the area with the highest edge detection value to obtain the contrast detection value;
[0041] The focal plane final alignment module gradually moves the actual focal plane according to a preset step length, and reacquires the reference image until the contrast detection value of the reacquired reference image meets a threshold condition.
[0042] Compared with the related art, the focal plane alignment method and alignment system provided by the present invention have the following beneficial effects:
[0043] Compared with traditional technologies, the present invention first calculates the reference focal plane position based on the object distance information of the target to be photographed. The present invention can greatly reduce the scope of subsequent focus search, thereby significantly reducing the focusing time. At the same time, combined with regionalized edge detection and contrast detection, it can more accurately judge the clarity of different areas in the image, and give priority to areas or key areas where focal plane alignment is more difficult, further improving the accuracy of focal plane alignment. In shooting environments with complex lighting conditions, low-contrast scenes or fast-moving targets, traditional autofocus methods often perform poorly, and the present invention can better cope with these challenges through refined regional analysis and contrast detection, ensuring fast and accurate focusing in a variety of environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 is a flow chart of a focal plane alignment method of the present invention;
[0045] Figure 2 The module structure diagram of a focal plane alignment system of the present invention. DETAILED DESCRIPTION
[0046] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only the parts related to the present invention, rather than all structures, are shown in the accompanying drawings. In addition, the embodiments of the present invention and the features in the embodiments may be combined with each other without conflict.
[0047] It should also be noted that, for ease of description, only the part relevant to the present invention but not all the content is shown in the accompanying drawings. It should be mentioned before discussing the exemplary embodiments in more detail that some exemplary embodiments are described as the processing or method described as a flow chart. Although the flow chart describes each operation (or step) as being processed sequentially, many operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of each operation can be rearranged. When its operation is completed, the processing can be terminated, but it can also have additional steps not included in the accompanying drawings. The processing can correspond to a method, a function, a procedure, a subroutine, a subprogram, etc.
[0048] Embodiment 1
[0049] The present invention provides a focal plane alignment method. In a specific implementation process, Figure 1 As shown, it shows a flow chart of a focal plane alignment method provided by the present invention, and the focal plane alignment method includes:
[0050] Step S1, obtaining an object distance of a target to be photographed, and obtaining a reference focal plane of the target to be photographed according to the object distance.
[0051] In the specific implementation process, the object distance of the target to be photographed is obtained through a rangefinder. The distance measurement methods of the rangefinder include but are not limited to laser, ultrasonic, and infrared. According to the lens imaging formula, the reference focal plane of the target to be photographed is calculated. The lens imaging formula is: 1 / =1 / u+1 / v, where f is the effective focal length of the lens combination, u is the object distance, and v is the image distance. The image distance is calculated according to this formula, and the imaging plane at the image distance is the reference focal plane of the target to be photographed.
[0052] Step S2, calculating the displacement difference between the reference focal plane and the actual focal plane, and adjusting the position of the actual focal plane according to the displacement difference, so that the actual focal plane is preliminarily aligned with the reference focal plane, wherein the actual focal plane is the image plane where the photosensitive element is located at the current moment.
[0053] In the specific implementation process, the displacement difference between the reference focal plane and the actual focal plane is calculated. The actual focal plane is the image plane where the photosensitive element is located at the current moment. The photosensitive element is moved according to the displacement difference so that the image plane of the photosensitive element is aligned and overlapped with the reference focal plane, thereby achieving rapid preliminary alignment of the focal plane.
[0054] Step S3, after the preliminary alignment, obtain the reference image at the current moment, and perform edge detection on the regions after the reference image is segmented to obtain edge detection values of each region.
[0055] Specifically, step S3 includes the following specific steps:
[0056] Step S301 , after preliminary alignment, obtain a reference image at the current moment, and adaptively segment the reference image at the current moment based on the image content to obtain multiple regions.
[0057] Step S302, executing an edge detection algorithm on each segmented region to obtain a preliminary edge detection value for each region.
[0058] Step S303: normalize the preliminary edge detection values to obtain edge detection values of each region.
[0059] In the specific implementation process, after the preliminary alignment, a reference image at the current moment is obtained. This reference image is the preliminary imaging of the target to be photographed on the image plane of the photosensitive element after the preliminary focal plane alignment. Since the preliminary alignment is based on the measurement and calculation of the focal plane position of the object distance, it is a rough calculation, so there are errors, including but not limited to measurement errors and calculation accuracy errors. Therefore, after the preliminary focal plane alignment, a more refined focal plane alignment operation is required. First, the reference image is adaptively segmented based on the image content to obtain multiple regions. The adaptive segmentation method based on the image content includes but is not limited to texture-based and color-based segmentation methods. Secondly, edge detection is performed on each segmented region. The algorithms used for edge detection include but are not limited to Canny edge detection algorithm, Sobel algorithm, and Prewitt algorithm to obtain a preliminary edge detection value for each region. Since the sizes of the segmented regions are different, the preliminary edge detection value will be affected by the size of the region. In order to remove the influence of the region size on the preliminary edge detection value, the preliminary edge detection values of each region are normalized to obtain the edge detection value of each segmented region after normalization.
[0060] Step S4, performing contrast detection on the area with the highest edge detection value to obtain a contrast detection value.
[0061] Specifically, step S4 includes the following specific steps:
[0062] Step S401 : Selecting an area with the highest edge detection value as a detection selected area, and calculating pixel differences within the detection selected area, wherein the pixel differences include internal pixel differences and boundary pixel differences.
[0063] Step S402: sum the internal pixel difference and the boundary pixel difference to obtain a preliminary contrast detection value.
[0064] Step S403: normalize the preliminary contrast detection value to obtain a contrast detection value.
[0065] In the specific implementation process, the area with the highest edge detection value is selected for contrast detection. The area with the highest edge value is richer in image texture and details and is more representative. Therefore, it is more reasonable to select this area for contrast detection and use it as an indicator for subsequent judgment. Contrast detection first requires pixel difference calculation for the area with the highest edge detection value. Since the segmented area is not a regular graphic, it is necessary to calculate the internal pixel difference and boundary pixel difference in the area separately, and then merge the internal pixel difference and boundary pixel difference. For example, the calculation formula of the internal pixel difference is:
[0066] D internal (x,y)=|I(x+1,y)-(x,y)|+|I(x,y+1)-(x,y)|
[0067] Among them, D internal (x, y) is the internal pixel difference, I(x, y) is the pixel value of the internal pixel at the (x, y) position, and the internal pixel difference calculation includes calculating the difference between each pixel and its adjacent pixel on the right, that is, the horizontal difference, and calculating the difference between each pixel and its adjacent pixel below, that is, the vertical difference, and then merging the horizontal difference and the vertical difference. The merging method includes but is not limited to the Euclidean norm method and the sum of absolute values. The example formula here is to calculate the sum of absolute values, and a comprehensive contrast index is obtained after merging.
[0068] Exemplarily, the calculation formula of the boundary pixel difference is:
[0069]
[0070] Among them, D boundary (x,y) is the boundary pixel difference, B(x,y) is the pixel value of the boundary pixel at the (x,y) position. For boundary pixels, the difference between them and the adjacent internal pixels is calculated. Due to the irregular shape of the boundary, each boundary pixel needs to be processed separately. For each boundary pixel B(x,y), check whether there are adjacent internal pixels in the four directions of up, down, left and right. If there are adjacent internal pixels, calculate the difference value. Exemplarily, for the formula |B*x+1,y)-*x,y)|if(x+1,y)internal shown in the first line of the boundary pixel difference calculation formula, if*x+1,y)internal means to determine whether the boundary pixel B(x+1,y) is the adjacent internal pixel on the right side of B(x,y). If so, calculate the difference between them. If not, do not calculate. And so on, check whether there are adjacent internal pixels in other directions and calculate the pixel difference.
[0071] The obtained internal pixel difference and boundary pixel difference are summed to obtain a preliminary contrast detection value. Exemplarily, the calculation formula of the preliminary contrast detection value is:
[0072]
[0073] Among them, C is the preliminary contrast detection value, D internal (x, y) is the internal pixel difference, D boundary (x, y) is the boundary pixel difference, and the obtained preliminary contrast detection value is normalized to obtain the final contrast detection value. Exemplarily, the formula for normalizing the preliminary contrast detection value is:
[0074]
[0075] Among them, C n is the contrast detection value, C is the preliminary contrast detection value, |internal| is the number of internal pixels, |boundary| is the number of boundary pixels. Similarly, the normalization process eliminates the influence of image size.
[0076] Step S5, gradually moving the actual focal plane according to a preset step length, and reacquiring a reference image until the contrast detection value of the reacquired reference image meets a threshold condition.
[0077] Specifically, step S5 includes the following specific steps:
[0078] Step S501, according to a preset step size, randomly move the actual focal plane from the current position in one direction to obtain a new reference image at the current moment, perform region correspondence segmentation on the new reference image with reference to the region of the reference image to obtain a new region, and select an area corresponding to the position of the selected detection area from the new region for contrast detection to obtain a new contrast detection value.
[0079] Step S502, determining whether the difference between the new contrast detection value and the contrast detection value of the reference image is positive or negative. If the difference is positive, the current moving direction is the correct direction. Otherwise, the opposite direction of the current moving direction is the correct moving direction.
[0080] Step S503, gradually move the actual focal plane according to the preset step size and the correct moving direction, and obtain a new reference image until the contrast detection value of the new reference image is greater than or equal to the preset threshold, stop moving the actual focal plane, and complete the final focal plane alignment.
[0081] In the specific implementation process, the focal plane has completed the preliminary alignment, and then a more precise alignment is required. First, it is necessary to determine the moving direction of the actual focal plane. First, it is randomly moved in a direction according to a preset step length. The actual focal plane, that is, the photosensitive element obtains a new reference image, and the new reference image is segmented in the same way as the reference image obtained during the preliminary alignment. The area corresponding to the position of the selected area is selected for contrast detection to obtain a new contrast detection value. If the new contrast detection value is greater than the contrast detection value during the preliminary alignment, it means that the moving direction of the actual focal plane is correct. Otherwise, the opposite direction of this direction is the correct moving direction of the actual focal plane. After determining the moving direction, the actual focal plane is continuously moved according to the correct moving direction and the preset step length. After each movement, a new reference image is obtained, and a new contrast detection value of the new reference image is obtained. It is judged whether the new contrast detection value is greater than the preset threshold T. If the new contrast detection value is greater than the preset threshold T, it means that the position of the actual focal plane has reached the position that makes the image clearest. Therefore, the movement of the actual focal plane is stopped, and the final alignment of the focal plane is completed. The threshold T and the preset step length can be obtained through experimental data.
[0082] The working principle of a focal plane alignment method provided by the present invention is as follows:
[0083] According to the object distance, the approximate position of the focal plane of the target to be photographed is calculated as the reference focal plane. Based on the displacement difference between the reference focal plane and the actual focal plane, the position of the actual focal plane is adjusted according to the displacement difference so that the actual focal plane and the reference focal plane are quickly aligned. At this time, the position of the actual focal plane is close to the focal plane position for the best image imaging, and the preliminary alignment of the focal plane is completed. The image information on the actual focal plane at this time is obtained as the reference image, and the region is segmented according to the characteristics of the reference image. Edge detection is performed on each region, and the region with the highest edge detection value is selected as the detection selected region. Contrast detection is performed on the detection selected region to obtain the contrast detection value. The contrast detection value is used as the contrast value when the focal plane is adjusted and moved. First, the moving direction of the actual focal plane for precise adjustment is determined, and a new reference image is obtained by randomly moving the actual focal plane once according to a preset step size. Image, refer to the area of the reference image to perform regional correspondence segmentation on the new reference image to obtain a new area, and select the same area for contrast detection to obtain a new contrast detection value. If the new contrast detection value is greater than the contrast detection value during the initial alignment, it means that the actual focal plane movement direction is correct. Otherwise, the opposite direction of this direction is the correct actual focal plane movement direction. After determining the movement direction, the actual focal plane is continuously moved according to the correct movement direction and the preset step size. After each movement, a new reference image is obtained, and a new contrast detection value of the new reference image is obtained. It is judged whether the new contrast detection value is greater than the preset threshold value T. If the new contrast detection value is greater than the preset threshold value T, it means that the position of the actual focal plane has reached the position that makes the image clearest, the movement of the actual focal plane is stopped, and the alignment of the focal plane is completed.
[0084] Embodiment 2
[0085] The present invention provides a focal plane alignment system. In a specific implementation process, Figure 2 As shown, it shows a module structure diagram of a focal plane alignment system provided by the present invention, and the focal plane alignment system includes:
[0086] The reference focal plane calculation module 100 obtains the object distance of the target to be photographed, and obtains the reference focal plane of the target to be photographed according to the object distance.
[0087] The focal plane preliminary alignment module 200 calculates the displacement difference between the reference focal plane and the actual focal plane, and adjusts the position of the actual focal plane according to the displacement difference so that the actual focal plane is preliminarily aligned with the reference focal plane, wherein the actual focal plane is the image plane where the photosensitive element is located at the current moment.
[0088] The edge detection module 300 obtains the reference image at the current moment after preliminary alignment, and performs edge detection on the regions after segmentation of the reference image to obtain edge detection values of each region.
[0089] The contrast detection module 400 performs contrast detection on the area with the highest edge detection value to obtain a contrast detection value.
[0090] The focal plane final alignment module 500 gradually moves the actual focal plane according to a preset step length, and reacquires the reference image until the contrast detection value of the reacquired reference image meets the threshold condition.
[0091] The working principle of a focal plane alignment system provided by the present invention is as follows:
[0092] The reference focal plane calculation module 100 calculates the focal plane of the target to be photographed according to the object distance. This focal plane is the reference focal plane. The reference focal plane is the approximate position of the focal plane where the image of the target to be photographed is clearest. The focal plane preliminary alignment module 200 calculates the displacement difference between the reference focal plane and the actual focal plane, and adjusts the position of the actual focal plane based on the displacement difference so that the actual focal plane is aligned with the reference focal plane. This is the preliminary alignment of the focal plane, wherein the actual focal plane is the image plane where the photosensitive element is located at the current moment. After the focal plane is initially aligned, a more refined alignment is required to obtain clearer image information. Therefore, next, the edge detection module 300 obtains the reference image at the current moment after the preliminary alignment, performs regional segmentation on the reference image based on image characteristics, and performs edge detection on each region to obtain the edge detection value of each region. The contrast detection module 400 selects the region with the highest edge detection value for contrast detection, obtains the contrast detection value of the region, and the contrast detection value is used as the subsequent fine focus plane alignment contrast value; finally, the focal plane final alignment module 500 randomly moves the actual focal plane once according to the preset step length, obtains a new reference image, and performs region correspondence segmentation on the new reference image with reference to the region of the reference image to obtain a new region, and selects the same region for contrast detection to obtain a new contrast detection value. If the new contrast detection value is greater than the contrast detection value during the initial alignment, it means that the actual focal plane moving direction is correct. Otherwise, the opposite direction of this direction is the correct actual focal plane moving direction. After determining the moving direction, the actual focal plane is continuously moved according to the correct moving direction and the preset step length. After each movement, a new reference image is obtained, and a new contrast detection value of the new reference image is obtained. It is judged whether the new contrast detection value is greater than the preset threshold value T. If the new contrast detection value is greater than the preset threshold value T, it means that the position of the actual focal plane has reached the position that makes the image clearest, and the movement of the actual focal plane is stopped to complete the alignment of the focal plane.
[0093] The present application is described with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0094] A person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable rewritable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0095] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
Claims
1. A focal plane alignment method, characterized in that: The focal plane alignment method comprises the following steps: S1: Acquire an object distance of a target to be photographed, and acquire a reference focal plane of the target to be photographed according to the object distance; S2: Calculate the displacement difference between the reference focal plane and the actual focal plane, and adjust the position of the actual focal plane according to the displacement difference, so that the actual focal plane is preliminarily aligned with the reference focal plane, wherein the actual focal plane is the image plane where the photosensitive element is located at the current moment; S3: After the preliminary alignment, a reference image at the current moment is obtained, and edge detection is performed on the segmented regions of the reference image to obtain edge detection values of each region; S4: performing contrast detection on the area with the highest edge detection value to obtain a contrast detection value; S5: gradually moving the actual focal plane according to a preset step length, and reacquiring the reference image until the contrast detection value of the reacquired reference image meets a threshold condition.
2. A focal plane alignment method according to claim 1, characterized in that: Step S3 includes the following specific steps: S301: After preliminary alignment, a reference image at the current moment is obtained, and the reference image at the current moment is adaptively segmented based on the image content to obtain multiple regions; S302: Execute an edge detection algorithm on each segmented region to obtain a preliminary edge detection value of each region; S303: normalizing the preliminary edge detection values to obtain edge detection values of each region.
3. A focal plane alignment method according to claim 2, characterized in that: Step S4 includes the following steps: S401: Selecting a region with the highest edge detection value as a detection selected region, and calculating pixel differences within the detection selected region, wherein the pixel differences include internal pixel differences and boundary pixel differences; S402: summing the internal pixel difference and the boundary pixel difference to obtain a preliminary contrast detection value; S403: normalizing the preliminary contrast detection value to obtain a contrast detection value.
4. A focal plane alignment method according to claim 3, characterized in that: In step S401, the calculation formula of the internal pixel difference is: D internal (x,y)=|I(x+1,y)-(x,y)|+|I(x,y+1)-(x,y)| Among them, D internal (x, y) is the internal pixel difference, I(x, y) is the pixel value of the internal pixel at the position 9x, y); The calculation formula for boundary pixel difference is: Among them, D boundary (x, y) is the boundary pixel difference, and B(x, y) is the pixel value of the boundary pixel at the (x, y) position.
5. A focal plane alignment method according to claim 4, characterized in that: In step S402, the calculation formula of the preliminary contrast detection value is: Among them, C is the preliminary contrast detection value, D internal (x, y) is the internal pixel difference, D boundary (x,y) is the boundary pixel difference.
6. A focal plane alignment method according to claim 5, characterized in that: In step S403, the formula for normalizing the preliminary contrast detection value is: Among them, C n is the contrast detection value, C is the preliminary contrast detection value, |internal| is the number of internal pixels, and |boundary| is the number of boundary pixels.
7. A focal plane alignment method according to claim 6, characterized in that: Step S5 includes the following specific steps: S501: randomly moving the actual focal plane in a direction from the current position according to a preset step length to obtain a new reference image at the current moment, performing region-corresponding segmentation on the new reference image with reference to the region of the reference image to obtain a new region, and selecting a region corresponding to the position of the selected region from the new region for contrast detection to obtain a new contrast detection value; S502: Determine whether the difference between the new contrast detection value and the contrast detection value of the reference image is positive or negative. If the difference is positive, the current moving direction is the correct direction. Otherwise, the opposite direction of the current moving direction is the correct moving direction. S503: gradually move the actual focal plane according to the preset step size and the correct moving direction, and obtain a new reference image until the contrast detection value of the new reference image is greater than or equal to the preset threshold, stop moving the actual focal plane, and complete the final focal plane alignment.
8. A focal plane alignment system, characterized in that: Applied to a focal plane alignment method according to any one of claims 1 to 7, the focal plane alignment system comprising: A reference focal plane calculation module is used to obtain an object distance of a target to be photographed, and obtain a reference focal plane of the target to be photographed according to the object distance; A focal plane preliminary alignment module calculates the displacement difference between the reference focal plane and the actual focal plane, and adjusts the position of the actual focal plane according to the displacement difference so that the actual focal plane is preliminarily aligned with the reference focal plane, wherein the actual focal plane is the image plane where the photosensitive element is located at the current moment; The edge detection module obtains the reference image at the current moment after preliminary alignment, and performs edge detection on the regions segmented from the reference image to obtain edge detection values for each region; The contrast detection module performs contrast detection on the area with the highest edge detection value to obtain the contrast detection value; The focal plane final alignment module gradually moves the actual focal plane according to a preset step length, and reacquires the reference image until the contrast detection value of the reacquired reference image meets a threshold condition.
