Projector focusing method, device, equipment and storage medium

Through lightweight image clarity detection network and multi-scale feature extraction, combined with multi-core loss and information entropy theory, combined with adaptive PID controller and golden segmentation search algorithm, the robustness of traditional projector focus method in complex environments is solved. and efficiency issues, high-precision and rapid focal length adjustment and picture clarity evaluation are achieved.

CN118972533BActive Publication Date: 2025-01-10SHENZHEN ZHENHUO TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411448910.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-01-10
Estimated Expiration
2044-10-17

AI Technical Summary

Technical Problem

The focus method of traditional projectors is time-consuming and labor-intensive, and it is difficult to ensure accuracy and consistency. Especially in complex environments, the robustness is insufficient, the calculation complexity is high, and the traditional focus evaluation index is simple, which cannot fully reflect the clarity of the picture.

Method used

The lightweight one-stage image clarity detection network and edge detection algorithm are adopted, combined with multi-scale parallel convolution and attention mechanism to extract image features, domain adaptation is carried out through multi-core maximum mean difference and multi-core center loss, and spatial frequency-clearity 2 is calculated. Dimensional spectral and information entropy theory obtain the optimal focal length value, and combine the adaptive PID controller and the golden segmentation search algorithm for closed-loop iterative optimization.

Benefits of technology

It realizes fast and accurate picture clarity evaluation, enhances the robustness and generalization ability of feature representation, provides high-precision focal length adjustment, and significantly improves the operating efficiency and applicability of the algorithm.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118972533B_ABST
    Figure CN118972533B_ABST
Patent Text Reader

Abstract

The present application relates to the field of image processing technology, and discloses a focusing method, device, equipment and storage medium for a projector, the method comprising: performing image acquisition and preprocessing on a projection screen to obtain a preprocessed image; applying a lightweight one-stage image clarity detection network and an edge detection algorithm to obtain a binary clarity map; extracting image features to obtain a multi-scale fusion feature vector; performing domain adaptation to obtain a projection scene feature representation; calculating a spatial frequency-clarity two-dimensional spectrum based on the projection scene feature representation, and calculating an optimal focal length value using information entropy theory; creating an adaptive PID controller and a golden section search algorithm based on the optimal focal length value, performing closed-loop iterative optimization on the focal length of the projector, and obtaining an accurate focal length value, thereby being able to quickly and accurately evaluate the picture clarity, adapt to different projection environments, and achieve precise closed-loop control, thereby greatly improving the projection quality and ease of use.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a focusing method, device, equipment and storage medium for a projector. Background Art

[0002] With the continuous development of projection technology, projectors are increasingly used in education, business, entertainment and other fields. However, traditional projector focusing methods often rely on manual operation, which is not only time-consuming and labor-intensive, but also difficult to ensure accuracy and consistency. Especially in some special scenarios, such as large conference rooms or outdoor projection, changes in environmental factors will have a significant impact on the clarity of the projected image, increasing the difficulty of focusing.

[0003] In recent years, with the advancement of computer vision and artificial intelligence technology, automatic focusing technology has become a research hotspot. However, there are still some problems with existing automatic focusing methods: most methods are not robust enough in complex environments and are difficult to adapt to different projection scenes; secondly, the computational complexity of existing algorithms is high, making it difficult to achieve real-time focusing; thirdly, traditional focusing evaluation indicators are often too simple and cannot fully reflect the clarity of the picture. Summary of the invention

[0004] The present application provides a focusing method, device, equipment and storage medium for a projector, which can quickly and accurately evaluate the clarity of the picture, adapt to different projection environments, and achieve precise closed-loop control, thereby greatly improving the projection quality and ease of use.

[0005] A first aspect of the present application provides a focusing method for a projector, the focusing method for a projector comprising:

[0006] Performing image acquisition and preprocessing on the projection screen to obtain a preprocessed image;

[0007] Applying a lightweight one-stage image clarity detection network and an edge detection algorithm to the preprocessed image to obtain a binary clarity map;

[0008] Based on the binary clarity map, image features are extracted through multi-scale parallel convolution and attention mechanism to obtain a multi-scale fusion feature vector;

[0009] According to the multi-scale fusion feature vector, domain adaptation is performed using multi-core maximum mean difference and multi-core center loss to obtain a projected scene feature representation;

[0010] Based on the projection scene feature representation, a spatial frequency-definition two-dimensional spectrum is calculated by spatial frequency analysis, and an optimal focal length value is calculated using information entropy theory;

[0011] According to the optimal focal length value, an adaptive PID controller and a golden section search algorithm are created to perform closed-loop iterative optimization on the focal length of the projector to obtain an accurate focal length value.

[0012] A second aspect of the present application provides a focusing device for a projector, the focusing device for a projector comprising:

[0013] An acquisition module is used to collect and preprocess the projection image to obtain a preprocessed image;

[0014] A detection module, used for applying a lightweight one-stage image clarity detection network and an edge detection algorithm to the preprocessed image to obtain a binary clarity map;

[0015] An extraction module, configured to extract image features based on the binary clarity map and through multi-scale parallel convolution and attention mechanism to obtain a multi-scale fusion feature vector;

[0016] A processing module, configured to perform domain adaptation according to the multi-scale fusion feature vector by using multi-core maximum mean difference and multi-core center loss to obtain a projection scene feature representation;

[0017] A calculation module, used to calculate the spatial frequency-definition two-dimensional spectrum through spatial frequency analysis based on the projection scene feature representation, and calculate the optimal focal length value using information entropy theory;

[0018] The optimization module is used to create an adaptive PID controller and a golden section search algorithm according to the optimal focal length value, perform closed-loop iterative optimization on the focal length of the projector, and obtain an accurate focal length value.

[0019] The third aspect of the present application provides an electronic device, comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor calls the instructions in the memory so that the electronic device executes the above-mentioned projector focusing method.

[0020] A fourth aspect of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the above-mentioned projector focusing method.

[0021] Compared with the prior art, the present application has the following beneficial effects: by adopting a lightweight one-stage image clarity detection network and edge detection algorithm, a binary clarity map can be obtained quickly and accurately, thereby improving the efficiency and accuracy of clarity evaluation. The use of multi-scale parallel convolution and attention mechanism to extract image features can comprehensively capture image information of different scales, thereby enhancing the richness and robustness of feature representation. The introduction of multi-core maximum mean difference and multi-core center loss for domain adaptation effectively improves the generalization ability of the algorithm in different projection scenarios. The optimal focal length value is calculated by spatial frequency analysis and information entropy theory, providing a more comprehensive and accurate evaluation index for focal length adjustment. The closed-loop iterative optimization of focal length is combined with an adaptive PID controller and a golden section search algorithm to achieve high-precision focal length adjustment while improving the convergence speed. While ensuring the focusing accuracy, the present invention significantly improves the operating efficiency of the algorithm, making it more suitable for practical application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0023] The structures, proportions, sizes, etc. illustrated in the drawings of this specification are only used to match the contents disclosed in the specification so as to facilitate understanding and reading by persons familiar with this technology. They are not used to limit the conditions under which the present invention can be implemented, and therefore have no substantive technical significance. Any structural modification, change in proportion or adjustment of size, without affecting the effects and purposes that can be achieved by the present invention, should still fall within the scope of the technical contents disclosed by the present invention.

[0024] Figure 1 is a flow chart of a focusing method for a projector provided by an embodiment of the present invention;

[0025] Figure 2 It is a schematic block diagram of the structure of a focusing device for a projector provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0026] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0027] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.

[0028] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0029] It should be further understood that the term "and / or" used in the specification and appended claims of this application refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations. Figure 1 , an embodiment of the focusing method of the projector in the embodiment of the present application includes:

[0030] Step 100: performing image acquisition and preprocessing on the projection screen to obtain a preprocessed image;

[0031] It is understandable that the execution subject of the present application may be a focus adjustment device of a projector, or a terminal or a server, which is not limited here. The present application embodiment is described by taking a server as the execution subject as an example.

[0032] Specifically, a high-resolution image is captured on the projection screen to obtain an original image. A Gaussian filter is performed on the original image to remove noise in the image and obtain a denoised image. Gaussian filtering reduces high-frequency noise components in the image by smoothing the image. Adaptive histogram equalization is performed on the denoised image to obtain a contrast-enhanced image. Adaptive histogram equalization enhances the overall contrast of the image and can enhance the visibility of image details in local areas. The contrast-enhanced image is grid-divided and locally histogram equalized to obtain a locally enhanced image. By dividing the image into a plurality of small grids and performing histogram equalization respectively, the contrast of the image in each local area is optimized, the overall image quality is improved, and the image can show good visual effects in different areas. Bilinear interpolation is performed on the locally enhanced image to resample the image at the pixel level to obtain a merged processing result. Bilinear interpolation calculates new pixel values ​​by using the values ​​of adjacent pixels in the image to ensure that good image quality and smoothness are maintained when the image is enlarged or reduced. The pixel values ​​of the merged processing result are normalized so that the pixel values ​​of the image are distributed within a uniform range, thereby improving the overall consistency of the image and obtaining a preprocessed image.

[0033] Step 200, applying a lightweight one-stage image clarity detection network and an edge detection algorithm to the preprocessed image to obtain a binary clarity map;

[0034] Specifically, the preprocessed image is input into the MobileNetV3 backbone network for processing to obtain the initial feature map. The MobileNetV3 backbone network adopts a lightweight design and contains 16 inverted residual blocks. Each residual block uses a depth-separable convolution and attention mechanism. This design ensures the network computational efficiency while retaining the richness of image features. As the image is processed by the inverted residual block, the initial feature map is gradually extracted. The initial feature map is input into the feature pyramid network for processing to obtain a multi-scale feature map. The feature pyramid network achieves effective fusion of multi-scale features through a top-down feature fusion path and lateral connections. This structure enables the network to focus on both details and overall information in the image. The multi-scale feature map is input into the global context module for processing to obtain an enhanced feature map. The global context module can capture the global dependencies in the image and improve the expressiveness of the feature map by using spatial and channel attention mechanisms. The enhanced feature map is input into the 1x1 convolution for processing to obtain a compressed feature map. The role of the 1x1 convolution is to reduce the feature dimension and fuse information from multi-scale features. The compressed feature map is upsampled to restore it to the same size as the input image, and the restored feature map is operated with the Sigmoid activation function to obtain a preliminary clarity map. The Sigmoid activation function maps the value of the feature map to the interval between 0 and 1, generating a preliminary judgment result reflecting the clarity of the image. At the same time, the preprocessed image is analyzed by the Sobel operator to obtain horizontal and vertical gradient maps. The Sobel operator reveals the edge change information in the image by calculating the gradient of the image in the x and y directions respectively. The gradient amplitude is calculated for the horizontal and vertical gradient maps to obtain an edge strength map, where the gradient amplitude reflects the edge strength information by calculating the square root of the sum of the squares of the gradients. The preliminary clarity map and the edge strength map are weighted fused to obtain a fused clarity map. In the weighted fusion process, the preliminary clarity map and the edge strength map are assigned weights of 0.7 and 0.3 respectively, so that the final fused map retains the dominant role of the clarity information and comprehensively considers the edge strength information, resulting in a more balanced and accurate clarity evaluation. Adaptive threshold processing is performed on the fused clarity map to obtain a binary clarity map. Adaptive threshold processing dynamically adjusts the threshold according to the local characteristics of the image, so that the clear and blurred parts can be accurately identified in different areas, forming a binary clarity map.

[0035] Step 300: extracting image features based on the binary clarity map through multi-scale parallel convolution and attention mechanism to obtain a multi-scale fusion feature vector;

[0036] It should be noted that the binary clarity map is subjected to three-way parallel convolution processing. The convolution kernels of 3x3, 5x5 and 7x7 are used respectively to obtain the small-scale feature map, the medium-scale feature map and the large-scale feature map. The three different sizes of convolution kernels can capture the features of different levels in the image. Among them, the 3x3 convolution kernel focuses on the extraction of local details, while the 7x7 convolution kernel is more suitable for capturing global features in a larger range, and the 5x5 convolution kernel provides a balance between the two. Through three-way parallel convolution processing, the multi-scale features in the binary clarity map can be fully mined. The small-scale feature map is subjected to channel attention processing to obtain the small-scale channel enhanced feature map. The channel attention mechanism compresses the spatial information of each channel into a single global description through the global average pooling operation, and calculates the channel weights through two fully connected layers, highlighting the channels with higher feature strength in the image and weakening those channels that contribute less to the current task. At the same time, the medium-scale feature map is subjected to spatial attention processing to obtain the medium-scale spatial enhanced feature map. The spatial attention mechanism generates a two-dimensional spatial weight map through convolution operation, and then performs weighted processing on the original feature map to enhance the features of specific spatial positions in the image. Through processing, the representative spatial structure in the medium-scale feature map can be effectively strengthened, making the medium-scale spatial enhanced feature map more prominent and clear. The large-scale feature map is processed by self-attention to obtain a large-scale self-attention enhanced feature map. The self-attention mechanism measures the correlation between different features by calculating the scaled dot product attention. This mechanism can capture the feature dependency relationship in the global range, making the large-scale self-attention enhanced feature map more holistic and coordinated, and can more accurately reflect the global features of the image. The small-scale channel enhanced feature map, the medium-scale spatial enhanced feature map and the large-scale self-attention enhanced feature map are processed by feature splicing to obtain a multi-scale fusion feature map. The multi-scale fusion feature map is processed by 1x1 convolution to obtain a reduced dimension feature map. 1x1 convolution can reduce the feature dimension and effectively integrate information across channels, ensuring that the features of each channel can be organically combined, simplifying subsequent processing operations and reducing the amount of calculation. The reduced dimension feature map is globally averaged pooled to obtain a global feature vector. Global average pooling performs an average operation on the feature map of each channel to compress the information dimension, so that the generated global feature vector can represent the comprehensive features of the entire image. The global feature vector is processed by a fully connected layer and normalized to obtain a normalized feature vector, and feature selection is performed on the normalized feature vector to obtain a multi-scale fusion feature vector.

[0037] Step 400: Based on the multi-scale fusion feature vector, multi-core maximum mean difference and multi-core center loss are used to perform domain adaptation to obtain a projection scene feature representation;

[0038] Specifically, the multi-scale fusion feature vector is processed by Gaussian kernel function to obtain kernelized features. The Gaussian kernel function realizes diversified mapping of features by using multi-kernel functions with different bandwidth parameters. In this process, 5 different bandwidth parameters are used to ensure that the differences between features are fully captured at different scales. The use of multi-kernel functions enhances the nonlinear expression ability of features, so that features between different domains can be better matched in a higher-dimensional space. The kernel matrix of the source domain and target domain samples is calculated based on the kernelized features to obtain a multi-kernel matrix. Through the construction of the kernel matrix, the similarities and differences between the source domain and target domain samples are effectively captured. The multi-kernel matrix is ​​subjected to eigenvalue decomposition to obtain an eigenvector matrix. The multi-kernel maximum mean difference loss is calculated based on the eigenvector matrix to obtain the inter-domain distance metric. The multi-kernel maximum mean difference loss measures the similarity between the source domain and the target domain by measuring the difference in feature distribution between the two domains. The smaller the loss value, the more similar the feature distribution of the two domains. At the same time, the category center of the multi-scale fusion feature vector is calculated to obtain the feature center of each category. The multi-kernel center loss is calculated based on the category center to obtain the intra-class distance metric. The multi-core center loss measures the consistency within a class by measuring the distance between the samples in each class and their feature centers. The inter-domain distance metric and the intra-class distance metric are weighted and summed to obtain the overall loss function. The overall loss function comprehensively considers the distribution differences between domains and the consistency within the class, and balances the two in a weighted manner to optimize the performance of the feature extraction network. The feature extraction network is back-propagated based on the overall loss function to obtain updated network parameters. During the back-propagation process, the network parameters are gradually adjusted to minimize the overall loss function, thereby optimizing the ability of the feature extraction network. As the network parameters are updated, the learning rate is adjusted to obtain the optimized network parameters. The purpose of the learning rate adjustment is to refine the update step of the parameters in the later stage of training to ensure that the network converges to the optimal solution. The feature extraction network is adjusted using the optimized network parameters, and the multi-scale fusion feature vector is forward-propagated through the adjusted feature extraction network to finally obtain the projection scene feature representation, ensuring that the network can achieve effective feature migration between different domains, so that the projector can stably achieve accurate focusing in different environments.

[0039] Step 500: Based on the projection scene feature representation, a spatial frequency-definition two-dimensional spectrum is calculated by spatial frequency analysis, and an optimal focal length value is calculated using information entropy theory;

[0040] Specifically, a two-dimensional discrete Fourier transform is performed on the projection scene feature representation to obtain a frequency domain representation. The two-dimensional discrete Fourier transform reveals the frequency components in the image by converting the image from the spatial domain to the frequency domain, and obtains the spatial frequency characteristics of the image. The amplitude spectrum is calculated for the frequency domain representation to obtain the spatial frequency amplitude spectrum, which reflects the intensity distribution of each frequency component of the image. The spatial frequency amplitude spectrum is subjected to polar coordinate transformation to obtain the radial-angular frequency distribution. The polar coordinate transformation converts the frequency distribution in the rectangular coordinate system into the polar coordinate system, so that the frequency distribution more intuitively presents the change law in the radial and angular directions. Based on the radial-angular frequency distribution, the spatial frequency-clarity two-dimensional spectrum at different focal lengths is calculated to obtain an evaluation matrix. In the evaluation matrix, each row corresponds to a focal length value, and each column corresponds to a specific spatial frequency interval. In this way, the change of image clarity at different focal lengths is comprehensively evaluated. The evaluation matrix is ​​normalized to obtain a probability distribution matrix. The normalization process converts the values ​​in the matrix into a probability distribution by mapping them to a certain range, so that the clarity characteristics at different focal lengths can be compared on a unified scale. Based on the probability distribution matrix, the spatial frequency spectrum entropy corresponding to each focal length is calculated to obtain an entropy value sequence. The entropy value sequence reflects the complexity and uncertainty of image clarity at different focal lengths. The lower the entropy value, the closer the image is to the optimal clarity. The entropy value sequence is interpolated to obtain a continuous entropy value function. Interpolation processing increases data points to make the entropy value sequence a continuous function, describing the trend of entropy value changes with focal length. Based on the continuous entropy value function, a minimum value search is performed to obtain an initial optimal focal length estimate. The minimum value search preliminarily determines the optimal focal length by finding the lowest point of the entropy value function. A local fine search is performed on the initial optimal focal length estimate to obtain the final optimal focal length value. By performing a more detailed search near the initially estimated optimal focal length, the focal length value is optimized to ensure the accuracy and stability of the projector focus.

[0041] Step 600: Create an adaptive PID controller and a golden section search algorithm according to the optimal focal length value, perform closed-loop iterative optimization on the focal length of the projector, and obtain an accurate focal length value.

[0042] Specifically, the PID controller parameters are initialized based on the optimal focal length value to obtain an initial PID parameter set. The initial parameters of the PID controller determine the response speed and accuracy of the focal length adjustment. Fuzzy logic rules are applied to the initial PID parameter set to generate an adaptive PID controller. The fuzzy logic rules can dynamically adjust the PID parameters according to real-time feedback, so that the controller can automatically adapt to the needs of focal length changes in different projection scenes, and improve the stability and accuracy of the focusing process. The focal length adjustment amount is calculated based on the adaptive PID controller to obtain an initial focal length adjustment instruction. The focal length adjustment amount determines the adjustment amplitude and direction of the projector lens, and the initial adjustment instruction can quickly approach the ideal focal length value. The golden section search algorithm is applied to the initial focal length adjustment instruction to obtain an optimized focal length adjustment range. The golden section search algorithm selects two golden section points within a predefined range for evaluation, so that the search process of focal length adjustment is more efficient and the optimal focal length range can be found in fewer iterations. Based on the optimized focal length adjustment range, multiple candidate focal length values ​​are generated to obtain a candidate focal length set. The candidate focal length set includes several discrete points around the current focal length value, and these candidate points represent the possible optimal focal length value range. The image clarity is evaluated for each focal length value in the candidate focal length set to obtain a clarity score sequence. The clarity score reflects the image quality corresponding to each focal length value. By comparing these scores, the optimal candidate focal length value is selected. The optimal focal length of this iteration is compared with the result of the previous iteration to obtain the convergence judgment result. The basis for convergence judgment is the focal length change and the clarity improvement. If the focal length change is small enough and the clarity improvement is not significant, it is considered that the convergence condition has been met, indicating that the focal length is close to the optimal value. Otherwise, based on the convergence judgment result, the PID controller parameters and search range are updated to provide new initial conditions for the next round of iteration. The entire closed-loop iterative process continues until the preset convergence condition is met or the maximum number of iterations is reached, and finally the accurate focal length value is obtained.

[0043] In the embodiment of the present application, a lightweight one-stage image clarity detection network and edge detection algorithm are used to quickly and accurately obtain a binary clarity map, thereby improving the efficiency and accuracy of clarity assessment. The use of multi-scale parallel convolution and attention mechanism to extract image features can fully capture image information of different scales, enhancing the richness and robustness of feature representation. The introduction of multi-core maximum mean difference and multi-core center loss for domain adaptation effectively improves the generalization ability of the algorithm in different projection scenarios. The optimal focal length value is calculated by spatial frequency analysis and information entropy theory, providing a more comprehensive and accurate evaluation index for focal length adjustment. The closed-loop iterative optimization of focal length is combined with an adaptive PID controller and a golden section search algorithm to achieve high-precision focal length adjustment while improving the convergence speed. While ensuring the focusing accuracy, the present invention significantly improves the operating efficiency of the algorithm, making it more suitable for practical application scenarios.

[0044] In a specific embodiment, the process of executing step 100 may specifically include the following steps:

[0045] Capture high-resolution images of the projection screen to obtain the original image;

[0046] Perform Gaussian filtering on the original image to obtain a denoised image;

[0047] Adaptive histogram equalization is performed on the denoised image to obtain a contrast enhanced image;

[0048] Perform grid division and local histogram equalization on the contrast enhanced image to obtain a local enhanced image;

[0049] Perform bilinear interpolation on the local enhanced image to obtain a merged processing result;

[0050] The pixel values ​​of the merged processing results are normalized to obtain the preprocessed image.

[0051] Specifically, high-resolution image acquisition is performed on the projection screen to obtain the original image. Assume that the size of the original image is Pixels, each pixel has a value of ,in and Represent the horizontal and vertical coordinates of the image respectively. Gaussian filtering is performed on the original image to obtain a denoised image. Gaussian filtering is a process of convolving an image with a Gaussian function. Its main function is to remove high-frequency noise in the image and retain the main features of the image. The convolution kernel of Gaussian filtering is usually defined as:

[0052] ;

[0053] in, is the standard deviation of the Gaussian function, controlling the smoothness of the filter. A higher value will result in a stronger smoothing effect, but may also blur the edges of the image. With Gaussian kernel Perform convolution to obtain the denoised image

[0054] ;

[0055] The symbol * represents the convolution operation. The denoised image reduces the interference of noise, making subsequent image processing more stable. The denoised image is subjected to adaptive histogram equalization to obtain a contrast-enhanced image. Adaptive histogram equalization improves the visual effect of the image by enhancing the local contrast of the image. Unlike traditional histogram equalization, adaptive histogram equalization applies equalization operations to different areas of the image, thereby improving the contrast of the local area while maintaining the global brightness. For example, for a shadow area in an image, adaptive histogram equalization makes the details hidden in the shadow more obvious. This step can be expressed by the following formula:

[0056] ;

[0057] in, is the image after contrast enhancement. Adaptive histogram equalization calculates the local histogram in the neighborhood of each pixel and redistributes the pixel values ​​to make the brightness distribution more uniform. The image after contrast enhancement is gridded and subjected to local histogram equalization to obtain a local enhanced image. The purpose of gridding is to divide the image into several small blocks, and each small block is subjected to independent histogram equalization to refine the contrast enhancement effect. Assume that the image is divided into grids, then the image obtained after equalization in each grid is ,in and Represent the row and column indexes of the grid respectively. Perform bilinear interpolation on the local enhanced image to obtain the merged processing result. Bilinear interpolation calculates new pixel values ​​by using the values ​​of adjacent pixels in the image to achieve the purpose of enlarging or reducing the image while ensuring the smoothness of the image. The bilinear interpolation formula is as follows:

[0058] ;

[0059] in, and is the interpolated pixel coordinate, and Respectively and The interpolation coefficient in the direction, and is the integer coordinate of the original pixel. The image processed by bilinear interpolation is not only adjusted in size, but also retains the continuity and details of the image. The pixel value of the merged result is normalized, and the grayscale value of the image is remapped to a fixed range, usually [0, 1] or [0, 255], so that the brightness and contrast of the image are more consistent, and the final preprocessed image is obtained.

[0060] In a specific embodiment, the process of executing step 200 may specifically include the following steps:

[0061] The preprocessed image is input into the MobileNetV3 backbone network for processing to obtain the initial feature map; the MobileNetV3 backbone network contains 16 inverted residual blocks, each of which uses depth-separable convolution and attention mechanism;

[0062] The initial feature map is input into the feature pyramid network for processing to obtain a multi-scale feature map; the feature pyramid network includes a top-down feature fusion path and lateral connections;

[0063] The multi-scale feature map is input into the global context module for processing to obtain an enhanced feature map; the global context module uses spatial and channel attention mechanisms to capture global dependencies;

[0064] The enhanced feature map is input into the 1x1 convolution process to obtain the compressed feature map; the 1x1 convolution is used to reduce the feature dimension and fuse multi-scale information;

[0065] The compressed feature map is upsampled to obtain a feature map with the same size as the input image, and the Sigmoid activation function is performed on the feature map with the same size as the input image to obtain a preliminary clarity map;

[0066] The preprocessed image is analyzed by Sobel operator to obtain horizontal and vertical gradient maps; the Sobel operator calculates the gradients in the x-direction and y-direction respectively;

[0067] The gradient amplitude is calculated for the horizontal and vertical gradient images to obtain the edge strength image; the gradient amplitude is calculated by the square root of the sum of squares;

[0068] The preliminary clarity map and the edge strength map are subjected to weighted fusion processing to obtain a fused clarity map; the weighted fusion uses weights of 0.7 and 0.3 corresponding to the clarity map and the edge strength map respectively;

[0069] The fused clarity map is processed by adaptive threshold to obtain a binary clarity map.

[0070] Specifically, the preprocessed image is input into the MobileNetV3 backbone network for processing to obtain the initial feature map. MobileNetV3 is a lightweight convolutional neural network that uses depthwise separable convolution to reduce the amount of computation while maintaining high accuracy. The MobileNetV3 backbone network contains 16 inverted residual blocks, each of which uses depthwise separable convolution and attention mechanism. The structure of the inverted residual block is dimensioned by 1x1 convolution, followed by depthwise separable convolution, and then dimensioned by 1x1 convolution, which reduces the amount of computation while maintaining the ability to express features. The attention mechanism adjusts the weights of each channel to make the network pay more attention to important features and improve the network's expressiveness. The initial feature map is input into the feature pyramid network for processing to obtain a multi-scale feature map. The feature pyramid network is an architecture for multi-scale feature extraction that processes feature maps through a top-down feature fusion path and lateral connections. The top-down feature fusion path generates a series of multi-scale features by gradually upsampling high-level features and fusing them with low-level features. This architecture enables the network to process image information of different scales at the same time, capturing global and local features, and is suitable for tasks that require high precision. The multi-scale feature map is input into the global context module for processing to obtain an enhanced feature map. The global context module captures global dependencies in the image by using spatial and channel attention mechanisms. The spatial attention mechanism focuses on different positions in the image, and enhances or suppresses the features of specific areas by calculating the weights of different positions; while the channel attention mechanism calculates the importance of each channel and readjusts the weights of each channel to improve the expressiveness of the features. The global context module enables the network to better understand the relationship between the overall structure and local details of the image, and obtain a more accurate enhanced feature map. The enhanced feature map is input into the 1x1 convolution layer for processing to obtain a compressed feature map. 1x1 convolution is used to reduce feature dimensions and fuse multi-scale information at the same time. In this process, 1x1 convolution compresses the multi-channel feature map to a lower dimension through linear combination, reducing computational overhead and retaining important information. Assume that the number of channels of the input feature map is , the number of feature map channels obtained after 1x1 convolution is , each new feature map pixel value It can be expressed as:

[0071] ;

[0072] in, is the weight of the 1x1 convolution kernel, Indicates that in the channel The compressed feature map is upsampled to obtain a feature map of the same size as the input image. The upsampling process restores the feature map to the same size as the original input image through methods such as bilinear interpolation or deconvolution. Perform Sigmoid activation function operation to obtain a preliminary clarity map The Sigmoid function compresses the pixel values ​​of the feature map to the range of 0 to 1, providing a normalized clarity index, which is expressed as:

[0073] ;

[0074] The Sigmoid function enables the preliminary clarity map to reflect the clarity probability of each pixel. The closer the value is to 1, the higher the clarity. At the same time, the Sobel operator is used to analyze the preprocessed image to obtain the horizontal and vertical gradient maps. and The Sobel operator is a classic edge detection operator that calculates the gradient of the image in the x and y directions respectively. The expressions are as follows:

[0075] ;

[0076] Among them, * represents the convolution operation. The edge strength map is obtained by calculating the gradient amplitude of the horizontal and vertical gradient maps. , the formula is:

[0077] ;

[0078] Edge Strength Map Indicates the edge strength of each pixel in the image. The larger the value, the more obvious the edge of the pixel. With edge strength map Perform weighted fusion processing to obtain a fused clarity map Weighted fusion adds the clarity map and edge strength map according to a certain weight to comprehensively consider the clarity and edge information of the image. Assuming that the weights of the clarity map and edge strength map are 0.7 and 0.3 respectively, the expression of the fused clarity map is:

[0079] ;

[0080] Fusion Clarity Map Perform adaptive threshold processing to obtain a binary clarity map Adaptive threshold processing dynamically adjusts the threshold according to the local characteristics of the image, so that the clear and blurred parts can be accurately identified in different areas. The final binary clarity map Classify each pixel as sharp or blurry.

[0081] In a specific embodiment, the process of executing step 300 may specifically include the following steps:

[0082] The binary clarity map is processed by three-way parallel convolution to obtain a small-scale feature map, a medium-scale feature map, and a large-scale feature map. The three-way parallel convolution uses convolution kernels of 3x3, 5x5, and 7x7 respectively.

[0083] Perform channel attention processing on the small-scale feature map to obtain a small-scale channel enhanced feature map; channel attention uses global average pooling and two fully connected layers to calculate channel weights;

[0084] Perform spatial attention processing on the mid-scale feature map to obtain a mid-scale spatial enhanced feature map; spatial attention uses convolution operation to generate a two-dimensional spatial weight map;

[0085] Perform self-attention processing on the large-scale feature map to obtain a large-scale self-attention enhanced feature map; self-attention uses the scaled dot product attention mechanism to calculate the correlation between features;

[0086] Perform feature splicing processing on the small-scale channel enhanced feature map, the medium-scale spatial enhanced feature map and the large-scale self-attention enhanced feature map to obtain a multi-scale fusion feature map;

[0087] Perform 1x1 convolution on the multi-scale fusion feature map to obtain a reduced-dimensional feature map; 1x1 convolution is used to reduce feature dimensions and integrate cross-channel information;

[0088] Perform global average pooling on the reduced dimension feature map to obtain a global feature vector; global average pooling performs an average operation on the feature map of each channel;

[0089] The global feature vector is subjected to full connection layer processing and normalization processing to obtain a normalized feature vector, and feature selection is performed on the normalized feature vector to obtain a multi-scale fusion feature vector.

[0090] Specifically, the binary clarity map is subjected to three-way parallel convolution processing to obtain a small-scale feature map, a medium-scale feature map, and a large-scale feature map. The three-way parallel convolution processing captures different scale features in the image by using convolution kernels of different sizes. The binary clarity map is convolved using 3x3, 5x5, and 7x7 convolution kernels, respectively. The smaller 3x3 convolution kernel can capture detailed information in the image, such as edges and textures, while the larger 7x7 convolution kernel can extract more global image features, such as large areas of blur or clear areas. Assume that the binary clarity map is , then the small-scale feature map, medium-scale feature map and large-scale feature map can be expressed as , and , the convolution process can be expressed as:

[0091] ;

[0092] in, , and They represent 3x3, 5x5, and 7x7 convolution kernels respectively, and the symbol * represents the convolution operation. Perform channel attention processing to obtain a small-scale channel enhanced feature map. The channel attention mechanism weights the features of each channel to highlight the most important features for the current task. In this process, global average pooling is performed on the small-scale feature map, the global average of each channel is calculated, and a compact feature vector is generated to represent the global information of each channel. The feature vector is processed through two fully connected layers to obtain the channel weight. The channel weight reflects the importance of each channel and is used to weight the channels of the original feature map to generate an enhanced feature map. At the same time, the medium-scale feature map Perform spatial attention processing to obtain a mid-scale spatial enhanced feature map. The spatial attention mechanism generates a two-dimensional spatial weight map by analyzing the feature importance of each position. The mid-scale feature map is convolved to generate a two-dimensional spatial weight map, and then the weight map is multiplied point by point with the original feature map to enhance the important spatial positions in the feature map. At the same time, the large-scale feature map Perform self-attention processing to obtain a large-scale self-attention enhanced feature map. The self-attention mechanism captures global information by calculating the correlation between features, especially the dependencies between distant pixels. In this process, the scaled dot product attention mechanism is used to measure the similarity between different features, and the weights in the feature map are adjusted according to these similarities. The formula is as follows:

[0093] ;

[0094] in, , and denote query, key, and value matrices respectively, is the dimension of the key matrix. The large-scale feature map generated by the self-attention mechanism can capture the global features of the image. The small-scale channel enhanced feature map, the medium-scale spatial enhanced feature map and the large-scale self-attention enhanced feature map are processed by feature splicing to obtain a multi-scale fused feature map. Input 1x1 convolution layer to get the dimension reduction feature map . 1x1 convolution reduces the dimension by linearly combining the features of different channels while retaining the key features. The formula is expressed as:

[0095] ;

[0096] in, is the weight of the 1x1 convolution. Perform global average pooling on the reduced dimension feature map to obtain a global feature vector. Global average pooling compresses the two-dimensional feature map into a one-dimensional vector by averaging the feature map of each channel to generate a global feature vector. Perform a fully connected layer and normalization on the global feature vector to obtain a normalized feature vector. The normalization process compresses the value of the feature vector to a certain range, usually between 0 and 1, so that it can be used in subsequent processing and analysis. The most representative features are selected through feature selection, and finally a multi-scale fusion feature vector is obtained.

[0097] In a specific embodiment, the process of executing step 400 may specifically include the following steps:

[0098] The multi-scale fusion feature vector is processed by Gaussian kernel function to obtain kernelized features; the Gaussian kernel function uses 5 different bandwidth parameters to construct a multi-kernel function;

[0099] The kernel matrix of the source domain and target domain samples is calculated based on the kernelized features to obtain a multi-kernel matrix, and the multi-kernel matrix is ​​subjected to eigenvalue decomposition to obtain an eigenvector matrix.

[0100] The multi-core maximum mean difference loss is calculated based on the feature vector matrix to obtain the inter-domain distance metric, and the category center is calculated for the multi-scale fusion feature vector to obtain the feature center of each category;

[0101] The multi-core center loss is calculated based on the category center to obtain the intra-class distance metric, and the inter-domain distance metric and the intra-class distance metric are weighted summed to obtain the overall loss function;

[0102] Based on the overall loss function, the feature extraction network is back-propagated to obtain updated network parameters, and the learning rate of the updated network parameters is adjusted to obtain optimized network parameters;

[0103] The feature extraction network is adjusted using the optimized network parameters, and the multi-scale fusion feature vector is forward propagated through the adjusted feature extraction network to obtain the projected scene feature representation.

[0104] Specifically, the multi-scale fusion feature vector is processed by Gaussian kernel function to obtain kernelized features. Gaussian kernel function is a commonly used kernel method. By mapping the input features to a higher-dimensional space, nonlinear problems in the space become linearized, making them easier to handle. The expression of Gaussian kernel function is:

[0105] ;

[0106] in, There are two samples and The kernel function value between is the Euclidean distance, is the bandwidth parameter, which controls the smoothness of the kernel function. Five different bandwidth parameters are used. Construct a multi-kernel function to generate kernelized features of multiple scales. The kernelized features corresponding to each bandwidth parameter will capture the feature distribution at different scales and form a multi-kernel matrix. Calculate the kernel matrix of the source domain and target domain samples based on the kernelized features to obtain a multi-kernel matrix. The source domain and target domain represent different feature spaces, such as training sets and test sets or data sets in different environments. The elements of the multi-kernel matrix are Represents source domain samples and target domain samples The similarity between the two domains with different distributions is measured by mapping them into a unified high-dimensional feature space through the kernel matrix. The multi-kernel matrix is ​​decomposed into an eigenvalue matrix to obtain an eigenvector matrix. The multi-kernel matrix is ​​decomposed into a set of eigenvectors, which constitute a new feature space and can more effectively represent the distribution characteristics of the samples. The multi-kernel maximum mean difference (MMD) loss is calculated based on the eigenvector matrix to obtain the inter-domain distance metric. Multi-kernel MMD is an unsupervised method to measure the difference between two distributions. It calculates the kernel mean difference between the source domain and the self-labeled domain samples. The smaller the MMD loss value, the closer the distribution of the two domains. The formula for MMD loss is:

[0107] ;

[0108] in, and denote the distribution of the source domain and the target domain respectively, is a high-dimensional feature map, and is the number of samples. By minimizing the MMD loss, the feature distribution of the source domain and the target domain is made more consistent, and the generalization ability of the model between different domains is improved. At the same time, the category center is calculated for the multi-scale fusion feature vector to obtain the feature center of each category. The category center refers to the feature mean of samples of the same category, which represents the position of the category in the feature space. By calculating the feature center of each category, the consistency of samples within the category is analyzed. Assume that The sample of the category is , whose characteristic center is:

[0109] ;

[0110] in, Indicates The number of samples of the class, It is a sample The multi-core center loss is calculated based on the category center to obtain the intra-category distance metric. The multi-core center loss is used to measure the distance between samples in the same category and their category center. The smaller the intra-category distance metric, the closer the characteristics of the same category samples are, and the better the classification effect of the model. By calculating the intra-category distance metric and the inter-domain distance metric, and taking a weighted sum of the two, the overall loss function is obtained. The overall loss function can be expressed as:

[0111] ;

[0112] in, and is the weight coefficient, which controls the relative importance of the inter-domain distance and the intra-class distance in the overall loss. Based on the overall loss function, the feature extraction network is back-propagated to update the network parameters. During the back-propagation process, the gradient of the loss function relative to the network parameters is calculated, and the weights of the network are adjusted so that the loss function gradually converges to the minimum value. After obtaining the updated network parameters, the learning rate is adjusted to obtain the optimized network parameters. The learning rate adjustment can be achieved through an adaptive optimization algorithm (such as Adam or SGD) to ensure that the network parameters can stably converge to the optimal solution. Using the optimized network parameters, the feature extraction network is adjusted, and the multi-scale fusion feature vector is forward-propagated through the adjusted feature extraction network to finally obtain the projected scene feature representation. This process ensures that the feature extraction network can extract consistent and discriminative features between different domains, thereby improving the robustness of the model in different environments.

[0113] In a specific embodiment, the process of executing step 500 may specifically include the following steps:

[0114] Performing a two-dimensional discrete Fourier transform on the projection scene feature representation to obtain a frequency domain representation, and performing amplitude spectrum calculation on the frequency domain representation to obtain a spatial frequency amplitude spectrum;

[0115] The spatial frequency amplitude spectrum is transformed into polar coordinates to obtain the radial-angular frequency distribution; the polar coordinate transformation is to convert the frequency distribution in the rectangular coordinate system into the polar coordinate system;

[0116] Based on the radial-angular frequency distribution, the spatial frequency-sharpness two-dimensional spectrum at different focal lengths is calculated to obtain an evaluation matrix; each row of the evaluation matrix corresponds to a focal length value, and each column corresponds to a spatial frequency interval;

[0117] The evaluation matrix is ​​normalized to obtain a probability distribution matrix, and the spatial frequency spectrum entropy corresponding to each focal length is calculated based on the probability distribution matrix to obtain an entropy value sequence;

[0118] Interpolate the entropy value sequence to obtain a continuous entropy value function, and perform a minimum value search based on the continuous entropy value function to obtain an initial optimal focal length estimate;

[0119] A local fine search is performed on the initial best focal length estimate to obtain the optimal focal length value.

[0120] Specifically, a two-dimensional discrete Fourier transform is performed on the projection scene feature representation to obtain a frequency domain representation. The Fourier transform converts the image from the spatial domain to the frequency domain and analyzes the frequency components in the image. Image , its two-dimensional discrete Fourier transform formula is:

[0121] ;

[0122] in, is the image representation in the frequency domain, and are the frequency coordinates, is an imaginary unit. Through Fourier transform, the frequency distribution of the image is obtained, where the high-frequency components correspond to the edges and details in the image, and the low-frequency components correspond to the overall structure and background of the image. Perform amplitude spectrum calculation to obtain the spatial frequency amplitude spectrum The amplitude spectrum reflects the intensity distribution of the image at different frequencies and can be calculated by the following formula:

[0123] ;

[0124] in, and Represent the real part and imaginary part of the frequency domain representation respectively. By calculating the amplitude spectrum, we can understand the frequency characteristics of the image more intuitively. Polar coordinate transformation is performed to obtain radial-angular frequency distribution. Polar coordinate transformation converts the frequency distribution originally expressed in the rectangular coordinate system into the polar coordinate system, where the radial direction represents the magnitude of the frequency and the angle represents the direction of the frequency. The formula for polar coordinate transformation is:

[0125] ;

[0126] in, is the radial frequency, indicating the magnitude of the frequency; is an angle, indicating the direction of the frequency. Through polar coordinate transformation, the radial-angular frequency distribution obtained can more conveniently analyze the anisotropic characteristics and overall frequency characteristics of the image. Based on the radial-angular frequency distribution, the spatial frequency-clarity two-dimensional spectrum at different focal lengths is calculated to obtain an evaluation matrix. Each row of the evaluation matrix corresponds to a focal length value, and each column corresponds to a spatial frequency interval. In order to calculate the spatial frequency-clarity two-dimensional spectrum, the image features at different focal lengths are mapped to the frequency space, and the relationship between their frequency distribution and clarity is analyzed. By evaluating the changes in the frequency distribution of the image at different focal lengths, the frequency characteristics corresponding to the optimal focal length are identified. The evaluation matrix is ​​normalized to obtain a probability distribution matrix. The values ​​in the matrix are standardized so that their sum is 1, generating a probability distribution matrix. ,in represents the frequency interval, Represents the focal length value. The normalized probability distribution matrix is ​​used to analyze the frequency characteristics at each focal length. Based on the probability distribution matrix , calculate the spatial frequency spectrum entropy corresponding to each focal length , thus obtaining the entropy value sequence. The entropy value sequence reflects the complexity and uncertainty of the image frequency characteristics at different focal lengths, and is usually calculated using the information entropy formula:

[0127] ;

[0128] in, is the focal length The corresponding entropy value is is at focal length Lower frequency range The lower the entropy value, the clearer the image. By minimizing the entropy value, the optimal focal length can be found. Interpolate the entropy value sequence to obtain a continuous entropy value function. Convert the discrete entropy value sequence into a continuous function , describes the trend of entropy value changing with focal length. The interpolation method can be spline interpolation or other smooth interpolation methods. The continuous entropy function obtained is Used for further minimum search. Based on continuous entropy function Perform a minimum search to obtain an initial optimal focal length estimate. The minimum search preliminarily determines the optimal focal length value by finding the lowest point of the entropy function. Usually, the search method can use the bisection method or the golden section method to ensure the efficiency and accuracy of the search process. Perform a local fine search on the initial optimal focal length estimate to obtain the final optimal focal length value. The local fine search is a more detailed search near the initially estimated optimal focal length to further optimize the focal length value to ensure that the clarity of the projected image is optimal. The fine search can be combined with gradient descent or other optimization methods to ensure the accuracy of the final focal length value.

[0129] In a specific embodiment, the process of executing step 600 may specifically include the following steps:

[0130] Initializing PID controller parameters based on the optimal focal length value to obtain an initial PID parameter set, and applying fuzzy logic rules to the initial PID parameter set to obtain an adaptive PID controller;

[0131] The focus adjustment amount is calculated based on the adaptive PID controller to obtain an initial focus adjustment instruction, and the golden section search algorithm is applied to the initial focus adjustment instruction to obtain an optimized focus adjustment range; the golden section search algorithm selects two golden section points within a predefined range for evaluation;

[0132] Generate multiple candidate focal length values ​​based on the optimized focal length adjustment range to obtain a candidate focal length set; the candidate focal length set includes a number of discrete points around the current focal length value;

[0133] Perform image clarity evaluation on each focal length value in the candidate focal length set to obtain a clarity score sequence, and select the optimal candidate focal length value based on the clarity score sequence to obtain the optimal focal length of this iteration;

[0134] Compare the optimal focal length of this iteration with the result of the previous iteration to obtain the convergence judgment result; the convergence judgment is based on the focal length change and the clarity improvement;

[0135] Based on the convergence judgment result, the PID controller parameters and search range are updated to obtain the initial conditions for the next round of iterations until the preset convergence conditions are met or the maximum number of iterations is reached to obtain the accurate focal length value.

[0136] Specifically, the PID controller parameters are initialized based on the optimal focal length value to obtain the initial PID parameter set. The PID controller controls the system output through three parts: proportional, integral, and derivative. Each part has a corresponding control parameter, which is usually expressed as , and . These parameters determine the response characteristics of the system, such as stability, response speed, and oscillation amplitude. In the initialization phase, the optimal focal length value is used as a reference to set the initial PID parameter set so that the controller can effectively adjust the focal length under the initial conditions. Fuzzy logic rules are applied to the initial PID parameter set to obtain an adaptive PID controller. Fuzzy logic can dynamically adjust PID parameters according to input conditions through fuzzy sets and rule reasoning to adapt to different focal length adjustment requirements. Fuzzy logic rules will adjust the current focal length error and error change rate according to the current focal length error. , and For example, when the focus error is large and changes rapidly, fuzzy logic may increase to respond quickly; when the error is small but there is still fluctuation, it may increase To eliminate the residual error. Based on the adaptive PID controller, the focal length adjustment amount is calculated to obtain the initial focal length adjustment instruction. The calculation formula of the focal length adjustment amount is:

[0137] ;

[0138] in, is the focal length adjustment at the current moment, is the current focal error, and the integral term and differential term reflect the influence of the cumulative error and the error change rate on the adjustment amount respectively. After obtaining the initial focal adjustment instruction, the golden section search algorithm is applied to it to optimize the focal adjustment range. The golden section search algorithm is an effective global optimization algorithm. It uses the golden section ratio (about 0.618) to select two golden section points within the predefined focal adjustment range for evaluation to quickly narrow the search range. Select two focal points within the current adjustment range and , whose locations are:

[0139] ;

[0140] in, and are the upper and lower limits of the current focal length adjustment range. is the golden ratio. By comparing the clarity scores of these two points, a better focal adjustment range is determined. Based on the optimized focal adjustment range, multiple candidate focal values ​​are generated to obtain a candidate focal set. The candidate focal set contains a number of discrete points around the current focal value, which are evenly distributed in the optimized adjustment range and cover the possible best focal values. The image clarity is evaluated for each focal value in the candidate focal set to obtain a clarity score sequence. The clarity score is based on an image processing algorithm, such as measuring clarity by calculating the edge strength, contrast or frequency distribution of the image. The score sequence reflects the difference in image clarity at different focal values. Based on the clarity score sequence, the optimal candidate focal value is selected to obtain the optimal focal length of this iteration. The optimal focal length refers to the focal length value that gives the highest image clarity score in the candidate focal set. The optimal focal length of this iteration is compared with the result of the previous iteration to obtain a convergence judgment result. Convergence judgment is based on two key indicators: the focal length change and the clarity improvement. If the focal length change is small and the clarity improvement is not significant, it means that the system is close to the optimal focal length and meets the convergence condition; otherwise, the system needs to continue to iterate and adjust the focal length. Based on the convergence judgment result, the PID controller parameters and search range are updated to obtain the initial conditions for the next iteration. After each iteration, the parameters of the PID controller are adjusted according to the fuzzy logic rules, and the new search range is reduced or expanded based on the current optimal focal length. This process continues until the preset convergence condition is met or the maximum number of iterations is reached, and finally an accurate focal length value is obtained.

[0141] The above describes the focusing method of the projector in the embodiment of the present application. The following describes the focusing device 10 of the projector in the embodiment of the present application. Figure 2 In the embodiment of the present application, an embodiment of the focusing device 10 of the projector includes:

[0142] The acquisition module 11 is used to collect and preprocess the projection image to obtain a preprocessed image;

[0143] A detection module 12, for applying a lightweight one-stage image clarity detection network and an edge detection algorithm to the preprocessed image to obtain a binary clarity map;

[0144] An extraction module 13 is used to extract image features based on the binary clarity map and through multi-scale parallel convolution and attention mechanism to obtain a multi-scale fusion feature vector;

[0145] A processing module 14 is used to perform domain adaptation according to the multi-scale fusion feature vector by using multi-core maximum mean difference and multi-core center loss to obtain a projection scene feature representation;

[0146] A calculation module 15 is used to calculate the spatial frequency-definition two-dimensional spectrum through spatial frequency analysis based on the projection scene feature representation, and calculate the optimal focal length value using information entropy theory;

[0147] The optimization module 16 is used to create an adaptive PID controller and a golden section search algorithm according to the optimal focal length value, perform closed-loop iterative optimization on the focal length of the projector, and obtain an accurate focal length value.

[0148] Through the collaborative cooperation of the above-mentioned components, a lightweight one-stage image clarity detection network and edge detection algorithm are used to quickly and accurately obtain a binary clarity map, thereby improving the efficiency and accuracy of clarity assessment. The use of multi-scale parallel convolution and attention mechanism to extract image features can fully capture image information of different scales, enhancing the richness and robustness of feature representation. The introduction of multi-core maximum mean difference and multi-core center loss for domain adaptation effectively improves the generalization ability of the algorithm in different projection scenarios. The optimal focal length value is calculated by spatial frequency analysis and information entropy theory, providing a more comprehensive and accurate evaluation index for focal length adjustment. The closed-loop iterative optimization of focal length is combined with an adaptive PID controller and a golden section search algorithm to achieve high-precision focal length adjustment while improving the convergence speed. While ensuring the focusing accuracy, the present invention significantly improves the operating efficiency of the algorithm, making it more suitable for practical application scenarios.

[0149] The present application also provides an electronic device, which includes a memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor executes the steps of the projector focusing method in the above-mentioned embodiments.

[0150] The present application also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium, wherein instructions are stored in the computer, and when the instructions are executed on a computer, the computer executes the steps of the projector focusing method.

[0151] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0152] If the integrated unit is implemented in the form of 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 the present application is essentially 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. The computer software product is stored in a storage medium, including several instructions to enable an electronic device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.

[0153] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A focusing method for a projector, characterized in that: The method comprises: Performing image acquisition and preprocessing on the projection screen to obtain a preprocessed image; Applying a lightweight one-stage image clarity detection network and an edge detection algorithm to the preprocessed image to obtain a binary clarity map; Based on the binary clarity map, image features are extracted through multi-scale parallel convolution and attention mechanism to obtain a multi-scale fusion feature vector; According to the multi-scale fusion feature vector, domain adaptation is performed using multi-core maximum mean difference and multi-core center loss to obtain a projected scene feature representation; Based on the projection scene feature representation, a spatial frequency-clarity two-dimensional spectrum is calculated through spatial frequency analysis, and the optimal focal length value is calculated using information entropy theory; specifically comprising: performing a two-dimensional discrete Fourier transform on the projection scene feature representation to obtain a frequency domain representation, and performing amplitude spectrum calculation on the frequency domain representation to obtain a spatial frequency amplitude spectrum; performing a polar coordinate transformation on the spatial frequency amplitude spectrum to obtain a radial-angular frequency distribution; the polar coordinate transformation is to convert the frequency distribution in a rectangular coordinate system into a polar coordinate system; based on the radial-angular frequency distribution, a spatial frequency-clarity two-dimensional spectrum at different focal lengths is calculated to obtain an evaluation matrix; each row of the evaluation matrix corresponds to a focal length value, and each column corresponds to a spatial frequency interval; normalizing the evaluation matrix to obtain a probability distribution matrix, and calculating the spatial frequency spectrum entropy corresponding to each focal length based on the probability distribution matrix to obtain an entropy value sequence; interpolating the entropy value sequence to obtain a continuous entropy value function, and performing a minimum value search based on the continuous entropy value function to obtain an initial optimal focal length estimate; performing a local fine search on the initial optimal focal length estimate to obtain an optimal focal length value; According to the optimal focal length value, an adaptive PID controller and a golden section search algorithm are created to perform closed-loop iterative optimization on the focal length of the projector to obtain an accurate focal length value.

2. The focusing method of a projector according to claim 1, characterized in that: The step of collecting and preprocessing the projection image to obtain the preprocessed image includes: Capture high-resolution images of the projection screen to obtain the original image; Performing Gaussian filtering on the original image to obtain a denoised image; Performing adaptive histogram equalization on the denoised image to obtain a contrast enhanced image; Performing grid division and local histogram equalization on the contrast enhanced image to obtain a local enhanced image; Performing bilinear interpolation on the local enhanced image to obtain a merged processing result; The pixel values ​​of the merging result are normalized to obtain a preprocessed image.

3. The focusing method of a projector according to claim 1, characterized in that: The step of applying a lightweight one-stage image clarity detection network and an edge detection algorithm to the preprocessed image to obtain a binary clarity map includes: Input the preprocessed image into the MobileNetV3 backbone network for processing to obtain an initial feature map; the MobileNetV3 backbone network includes 16 inverted residual blocks, each of which uses a depth-separable convolution and attention mechanism; Inputting the initial feature map into a feature pyramid network for processing to obtain a multi-scale feature map; the feature pyramid network includes a top-down feature fusion path and a lateral connection; Inputting the multi-scale feature map into a global context module for processing to obtain an enhanced feature map; the global context module uses a spatial and channel attention mechanism to capture global dependencies; The enhanced feature map is input into a 1x1 convolution process to obtain a compressed feature map; the 1x1 convolution is used to reduce the feature dimension and fuse multi-scale information; Performing upsampling processing on the compressed feature map to obtain a feature map with the same size as the input image, and performing a Sigmoid activation function operation on the feature map with the same size as the input image to obtain a preliminary clarity map; Performing Sobel operator analysis on the preprocessed image to obtain horizontal and vertical gradient maps; the Sobel operator calculates the gradients in the x direction and the y direction respectively; Calculating the gradient amplitude of the horizontal and vertical gradient images to obtain an edge strength image; the gradient amplitude is calculated by the square root of the sum of squares; Performing weighted fusion processing on the preliminary clarity map and the edge strength map to obtain a fused clarity map; the weighted fusion uses weights of 0.7 and 0.3 corresponding to the clarity map and the edge strength map respectively; Adaptive threshold processing is performed on the fused clarity map to obtain a binary clarity map.

4. The method for adjusting the focus of a projector according to claim 1, characterized in that: The method of extracting image features based on the binary clarity map through multi-scale parallel convolution and attention mechanism to obtain a multi-scale fusion feature vector includes: Performing three-way parallel convolution processing on the binary clarity map to obtain a small-scale feature map, a medium-scale feature map and a large-scale feature map respectively; the three-way parallel convolution uses convolution kernels of 3x3, 5x5 and 7x7 respectively; Performing channel attention processing on the small-scale feature map to obtain a small-scale channel enhanced feature map; the channel attention uses global average pooling and two fully connected layers to calculate channel weights; Performing spatial attention processing on the mesoscale feature map to obtain a mesoscale spatial enhanced feature map; the spatial attention uses a convolution operation to generate a two-dimensional spatial weight map; Performing self-attention processing on the large-scale feature map to obtain a large-scale self-attention enhanced feature map; the self-attention uses a scaled dot product attention mechanism to calculate the correlation between features; Performing feature splicing processing on the small-scale channel enhancement feature map, the medium-scale space enhancement feature map, and the large-scale self-attention enhancement feature map to obtain a multi-scale fusion feature map; Performing 1x1 convolution processing on the multi-scale fusion feature map to obtain a reduced-dimensional feature map; the 1x1 convolution is used to reduce the feature dimension and integrate cross-channel information; Performing global average pooling on the dimension-reduced feature map to obtain a global feature vector; the global average pooling performs an average operation on the feature map of each channel; The global feature vector is subjected to full connection layer processing and normalization processing to obtain a normalized feature vector, and feature selection is performed on the normalized feature vector to obtain a multi-scale fusion feature vector.

5. The method for adjusting the focus of a projector according to claim 1, characterized in that: The method of performing domain adaptation based on the multi-scale fusion feature vector by using multi-core maximum mean difference and multi-core center loss to obtain a projection scene feature representation includes: Performing Gaussian kernel function processing on the multi-scale fusion feature vector to obtain kernelized features; the Gaussian kernel function uses 5 different bandwidth parameters to construct a multi-kernel function; Calculating kernel matrices of source domain and target domain samples based on the kernelized features to obtain a multi-kernel matrix, and performing eigenvalue decomposition on the multi-kernel matrix to obtain an eigenvector matrix; Calculating the multi-core maximum mean difference loss based on the feature vector matrix to obtain the inter-domain distance metric, and calculating the category center of the multi-scale fusion feature vector to obtain the feature center of each category; Calculating a multi-core center loss based on the category center to obtain an intra-class distance metric, and performing a weighted summation of the inter-domain distance metric and the intra-class distance metric to obtain an overall loss function; Based on the overall loss function, back-propagating the feature extraction network to obtain updated network parameters, and adjusting the learning rate of the updated network parameters to obtain optimized network parameters; The feature extraction network is adjusted using the optimized network parameters, and the multi-scale fusion feature vector is forward propagated through the adjusted feature extraction network to obtain a projection scene feature representation.

6. The method for adjusting the focus of a projector according to claim 1, characterized in that: The method of creating an adaptive PID controller and a golden section search algorithm according to the optimal focal length value, performing closed-loop iterative optimization on the focal length of the projector, and obtaining an accurate focal length value includes: Initializing PID controller parameters based on the optimal focal length value to obtain an initial PID parameter set, and applying fuzzy logic rules to the initial PID parameter set to obtain an adaptive PID controller; Calculating a focal length adjustment amount based on the adaptive PID controller to obtain an initial focal length adjustment instruction, and applying a golden section search algorithm to the initial focal length adjustment instruction to obtain an optimized focal length adjustment range; the golden section search algorithm selects two golden section points within a predefined range for evaluation; Generate multiple candidate focal length values ​​based on the optimized focal length adjustment range to obtain a candidate focal length set; the candidate focal length set includes a number of discrete points around the current focal length value; Performing image clarity evaluation on each focal length value in the candidate focal length set to obtain a clarity score sequence, and selecting an optimal candidate focal length value based on the clarity score sequence to obtain an optimal focal length for this iteration; Comparing the optimal focal length of the current iteration with the result of the previous iteration to obtain a convergence judgment result; the convergence judgment is based on the focal length change and the clarity improvement; Based on the convergence judgment result, the PID controller parameters and the search range are updated to obtain the initial conditions for the next round of iterations, until the preset convergence conditions are met or the maximum number of iterations is reached, and the accurate focal length value is obtained.

7. A focusing device for a projector, characterized in that: The device is used to perform the focusing method of a projector according to any one of claims 1 to 6, the device comprising: An acquisition module is used to collect and preprocess the projection image to obtain a preprocessed image; A detection module, used for applying a lightweight one-stage image clarity detection network and an edge detection algorithm to the preprocessed image to obtain a binary clarity map; An extraction module is used to extract image features based on the binary clarity map and through multi-scale parallel convolution and attention mechanism to obtain a multi-scale fusion feature vector; A processing module, configured to perform domain adaptation according to the multi-scale fusion feature vector by using multi-core maximum mean difference and multi-core center loss to obtain a projection scene feature representation; A calculation module, used to calculate the spatial frequency-definition two-dimensional spectrum through spatial frequency analysis based on the projection scene feature representation, and calculate the optimal focal length value using information entropy theory; The optimization module is used to create an adaptive PID controller and a golden section search algorithm according to the optimal focal length value, perform closed-loop iterative optimization on the focal length of the projector, and obtain an accurate focal length value.

8. An electronic device, characterized in that: The electronic device comprises: a memory and at least one processor, wherein instructions are stored in the memory; The at least one processor calls the instructions in the memory to enable the electronic device to execute the focusing method of the projector according to any one of claims 1-6.

9. A computer-readable storage medium having instructions stored thereon, characterized in that: When the instructions are executed by the processor, the focusing method of the projector according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Image definition quantification method in visual detection focusing process

    CN115049587A

  • Image definition evaluation method and device, equipment and storage medium

    CN117218037A