A camera sharpness detection method
By acquiring calibration board images in real time using an infrared camera and utilizing template image matching and light source adjustment, the dispersion of pixel grayscale values is calculated, solving the accuracy and speed problems of infrared camera sharpness detection and achieving efficient sharpness detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN MAXVISION TECH
- Filing Date
- 2023-02-06
- Publication Date
- 2026-07-07
AI Technical Summary
Existing methods for detecting the clarity of infrared cameras are inaccurate and slow, mainly because they rely on human visual judgment and are greatly affected by infrared light intensity, making them difficult to apply to conventional detection methods.
The calibration board image is acquired in real time by an infrared camera. The area to be detected is found by template image matching. The infrared light source is adjusted to traverse the threshold range. The dispersion of the gray value of the pixels in the area to be detected is calculated, and the clarity is output.
This technology improves the accuracy and speed of infrared camera clarity detection, enabling the acquisition of multiple consecutive clear images in real time, and reducing errors from manual judgment and environmental interference.
Smart Images

Figure CN116091613B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of image processing technology, and more specifically, relates to a sharpness detection method based on real-time image capture by an infrared camera. Background Technology
[0002] In recent years, cameras have been widely used in various industries such as intelligent transportation, intelligent attendance, and security monitoring. Therefore, the quality of images captured by cameras has become one of the key factors in the performance of many applications, making camera clarity detection a very important step.
[0003] In existing technologies, cameras are often used to photograph sharpness test charts with scales, and the readings are used to determine whether the sharpness meets the requirements. However, infrared cameras, as a special type of camera, rely on infrared light, which is invisible. On the one hand, their image quality is greatly affected by the intensity of infrared light, and they generally need to be used in conjunction with an infrared light source. On the other hand, it is difficult to detect the light intensity with the naked eye or sensors. Therefore, the sharpness detection methods in existing technologies are not applicable. In the current process of sharpness detection and debugging of infrared cameras, it is done by manually observing with the naked eye and subjectively judging whether the image captured by the infrared camera is sharp. However, everyone has different standards for evaluating sharpness, and given that the image quality of infrared cameras is greatly affected by the intensity of infrared light, people can only evaluate under a normal infrared light intensity. This manual judgment has the problems of inaccurate infrared camera sharpness detection and slow speed. Summary of the Invention
[0004] The purpose of this application is to provide a camera sharpness detection method to solve the technical problems of inaccuracy and slow speed in the existing infrared camera sharpness detection process.
[0005] To achieve the above objectives, the technical solution adopted in this application is: to provide a camera sharpness detection method, comprising:
[0006] The infrared camera acquires the image of the calibration board to be tested in real time;
[0007] The region to be detected in the image to be detected is identified by matching the template image.
[0008] Detect the image brightness of the area to be detected;
[0009] The infrared light source is adjusted according to the image brightness so that the image brightness of the area to be detected traverses the threshold range T1.
[0010] Calculate the dispersion of grayscale values of all pixels in the region to be detected;
[0011] Output the clarity of the infrared camera.
[0012] Preferably, the template image is a local area image of the central region of the calibration board.
[0013] Preferably, the template image comprises several bundles of wires, with one end of each bundle converging at the center and the other end radiating outwards.
[0014] Preferably, the method for matching the region to be detected in the image to be detected using a template image includes the following steps:
[0015] Calculate the result matrix of each matching image and template image on the image to be detected in turn;
[0016] Find the minimum value in the result matrix, output the coordinates as the top left corner coordinates of the template image, and use the width and height of the matching image as the width and height of the template image.
[0017] The location of the region to be detected is obtained from the image to be detected.
[0018] Preferably, before detecting the image brightness of the area to be detected, the method further includes the following step:
[0019] Replace the gray value of each pixel in the region to be detected with the average gray value of all pixels in its surrounding neighborhood.
[0020] Preferably, the method for detecting the image brightness of the area to be detected includes the following steps:
[0021] The formula for calculating the average grayscale value μ of each pixel in the region to be detected is:
[0022]
[0023] Where H and W are the height and width of the region to be detected, respectively, (i,j) represents the coordinates of a pixel in the region to be detected, and a ij It is the value of pixel (i,j).
[0024] Preferably, the method for calculating the dispersion of grayscale values of all pixels in the region to be detected includes the following steps:
[0025] The variance σ of the gray values of all pixels in the region to be detected is calculated using the following formula:
[0026]
[0027] Preferably, the method for improving the clarity of the output infrared camera includes the following steps:
[0028] Within the threshold range T1, the sharpness of the infrared camera is output based on the peak value of the dispersion of grayscale values of all pixels in the area to be detected.
[0029] Preferably, the method for improving the clarity of the output infrared camera includes the following steps:
[0030] Within the threshold range T1, the clarity of the infrared camera is output based on the mean of the dispersion of gray values of all pixels in the area to be detected.
[0031] Preferably, the method for improving the clarity of the output infrared camera includes the following steps:
[0032] Within the threshold range T1, based on the mean of the dispersion of gray values of all pixels in the detection area, the score corresponding to the sharpness gradient where the mean of the dispersion is located is output.
[0033] The camera sharpness detection method provided in this application, compared with the prior art, can acquire the image to be detected on the calibration board in real time through an infrared camera, and accurately find the area to be detected from the image through template image matching; the infrared light source is dynamically adjusted according to the image brightness of the area to be detected, so that the image brightness of the area to be detected traverses the threshold range T1, thus ensuring that the infrared camera acquires clear images of the area to be detected for multiple consecutive frames; the sharpness is represented by the dispersion of the gray values of all pixels in the area to be detected, and the sharpness of the infrared camera is output, thereby improving the accuracy and speed of infrared camera sharpness detection. Attached Figure Description
[0034] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0035] Figure 1 A schematic flowchart illustrating the camera sharpness detection method provided in this application embodiment;
[0036] Figure 2 A schematic diagram of the calibration plate provided in the embodiments of this application;
[0037] Figure 3 A schematic diagram of the image to be detected provided in an embodiment of this application;
[0038] Figure 4 This is a schematic diagram of a template image provided for an embodiment of this application. Detailed Implementation
[0039] To make the technical problems, technical solutions, and beneficial effects to be solved by this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and are not intended to limit the scope of this application.
[0040] It should be noted that when a component is referred to as being "fixed to" or "set on" another component, it can be directly on or indirectly on that other component. When a component is referred to as being "connected to" another component, it can be directly connected to or indirectly connected to that other component.
[0041] It should be understood that the terms "length", "width", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this application.
[0042] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified.
[0043] Please refer to the following: Figures 1 to 4 The camera sharpness detection method provided in this application embodiment will now be described. The camera sharpness detection method includes:
[0044] Step S1: The infrared camera acquires the image of the calibration board to be tested in real time;
[0045] Step S2: Match the region to be detected in the image to be detected using the template image;
[0046] Step S3: Detect the image brightness of the area to be detected;
[0047] Step S4: Adjust the infrared light source according to the image brightness so that the image brightness of the area to be detected traverses the threshold range T1.
[0048] Step S5: Calculate the dispersion of gray values of all pixels in the area to be detected;
[0049] Step S6: Output the clarity of the infrared camera.
[0050] Understandably, in step S1, the infrared light source illuminates the entire calibration plate. Preferably, the infrared camera is placed 60 to 80 cm away from the calibration plate, and more preferably, it is placed 70 cm away. To ensure the accuracy of the clarity detection, the infrared light source illuminating the calibration plate should be uniform. Preferably, the detection environment is a closed environment free from interference light.
[0051] The image to be tested is obtained by photographing the calibration plate, wherein the size of the calibration plate is preferably 300×300mm, the maximum field of view that the infrared camera can acquire should be smaller than the area of the calibration plate, and the brightness of the infrared light source is adjusted by the controller.
[0052] In step S2, the region to be detected in the image to be detected is matched with the template image. The template image can be a local region image in the calibration plate. The region to be detected is the region that matches the template image in the region to be detected in the image to be detected. In this way, the region to be detected can be accurately found in the image to be detected.
[0053] Compared to traditional methods that use positioning blocks on a calibration plate to locate the area to be detected, the template matching method in this application can also detect whether the position or angle of the infrared camera has shifted. This is because when the position or angle of the infrared camera shifts, the image to be detected will be distorted, reducing the matching accuracy when using a template image. In other words, if no area to be detected matching the template image is detected, it indicates that the position or angle of the infrared camera has shifted, and the position or angle of the infrared camera needs to be adjusted so that it is positioned at the designated location. If an area to be detected matching the template image is detected, it indicates that the infrared camera is positioned accurately.
[0054] In steps S3-4, since infrared light is invisible light, it is difficult to detect its intensity with the naked eye or a sensor. Therefore, the infrared light source can be adjusted by detecting the image brightness of the area to be detected, so that the image brightness of the area to be detected traverses the threshold range T1. This ensures that clear images of the area to be detected are obtained in multiple consecutive frames.
[0055] In step S5, since the area to be detected is obtained by matching the template image in the same calibration plate, if the clarity of the area to be detected is relatively low, the dispersion of the gray values of all pixels in the area to be detected will necessarily be smaller; conversely, if the clarity of the area to be detected is relatively high, the dispersion of the gray values of all pixels in the area to be detected will necessarily be larger.
[0056] In step S6, within the threshold range T1, the clarity of the infrared camera is output based on the dispersion of the gray values of all pixels in the area to be detected.
[0057] Thus, the camera sharpness detection method provided in this application has a fast calculation speed and low requirements for hardware computing power, so it can achieve real-time detection of the sharpness of infrared cameras.
[0058] The camera sharpness detection method provided in this application, compared with the prior art, can acquire the image to be detected on the calibration board in real time through an infrared camera, and accurately find the area to be detected from the image through template image matching; the infrared light source is dynamically adjusted according to the image brightness of the area to be detected, so that the image brightness of the area to be detected traverses the threshold range T1, thus ensuring that the infrared camera acquires clear images of the area to be detected for multiple consecutive frames; the sharpness is represented by the dispersion of the gray values of all pixels in the area to be detected, and the sharpness of the infrared camera is output, thereby improving the accuracy and speed of infrared camera sharpness detection.
[0059] In another embodiment of this application, please refer to [the relevant document / reference]. Figure 4 In step S1, the template image is a local area image of the central region of the calibration board.
[0060] It is understandable that when the template image is a local area image of the central region of the calibration board, that is, the center position on the calibration board is obtained by matching the template image, which is beneficial for the positioning of the infrared camera and obtaining a clear image of the area to be detected.
[0061] Furthermore, please refer to the following: Figure 4 The template image comprises several wire bundles, with one end of each bundle converging at the center and the other end radiating outwards.
[0062] It is understandable that since one end of several bundles converges at the center and the other end diverges outwards, pixel-level template image matching can be achieved. That is, as long as the template image deviates from the area to be detected by one pixel, the matching degree will change dramatically.
[0063] On the other hand, due to the peripheral divergence characteristic, the spacing between adjacent line bundles is relatively large, and infrared cameras can generally capture a clear outline. Conversely, due to the central convergence characteristic, the spacing between line bundles closer to the center is smaller; that is, a clearer infrared camera captures an outline closer to the center. Therefore, by calculating the dispersion of the grayscale values of all pixels in the detection area to output the sharpness of the infrared camera, the sharpness difference between infrared cameras with different parameters can be amplified. This, in comparison, can reduce the impact of interference factors on the sharpness detection results.
[0064] Further, in step S2, the method for matching the region to be detected in the image to be detected using a template image includes the following steps:
[0065] Calculate the result matrix R(x,y) of each matching image I and template image G on the image to be detected, then:
[0066] Where G is the template image and I is the matching image. At the (x,y) position of the matching image, the region of the template image G is defined by moving x' to the right and y' downwards.
[0067] Find the minimum value in matrix R(x,y), output the coordinates as the top left corner of template image G, and use the width and height of matching image I as the width and height of template image G;
[0068] The location of the region to be detected is obtained from the image to be detected.
[0069] It is understandable that for an image to be detected captured by an infrared camera, the most important location is the central area of the image. If the central area of the image is clear, then the entire image is clear. Therefore, the central area of the image to be detected can be located by template matching.
[0070] Template matching first requires a template image G. Preferably, on the image to be detected, the matching degree between the template image G and the matching image I is calculated from left to right and top to bottom. The higher the matching degree, the greater the probability that the two are the same. This implementation uses the squared difference matching method method=TM SQDIFF. This type of method uses the sum of squares of the differences between each pixel of the image and the template for matching. Theoretically, a calculated value of 0 indicates the best matching degree, and a larger calculated value indicates a worse matching degree. However, in practice, the calculated value can be set to the range (0, 0.01) to indicate a successful match. After obtaining the result R(x,y), the minimum value is found in the matrix, and its position is given. This minimum value is used as the top left corner of the template image G, and the width and height of the template image T are used as the width and height of the template image G, thus obtaining the position of the template in the original image.
[0071] In another embodiment of this application, before detecting the image brightness of the region to be detected in step S3, the following step is further included:
[0072] Replace the gray value of each pixel in the region to be detected with the average gray value of all pixels in its surrounding neighborhood.
[0073] The calculation formula is as follows:
[0074]
[0075] Where g(x,y) is the gray value of the pixel after filtering, i.e., the output gray value, f(x,y) is the gray value of the pixel before filtering, and m is the total number of pixels contained in the filtering window.
[0076] Further, in step S3, the method for detecting the image brightness of the region to be detected includes the following steps:
[0077] The formula for calculating the average grayscale value μ of each pixel in the region to be detected is:
[0078]
[0079] Where H and W are the height and width of the region to be detected, respectively, (i,j) represents the coordinates of a pixel in the region to be detected, and a ij It is the value of pixel (i,j).
[0080] It is understandable that the larger the average gray value μ of each pixel in the area to be detected, the greater the image brightness, and vice versa.
[0081] Further, in step S5, the method for calculating the dispersion of grayscale values of all pixels in the region to be detected includes the following steps:
[0082] The variance σ of the gray values of all pixels in the region to be detected is calculated using the following formula:
[0083]
[0084] In another embodiment of this application, step S6, the method for outputting the clarity of the infrared camera, includes the following steps:
[0085] Within the threshold range T1, the sharpness of the infrared camera is output based on the peak value of the dispersion of grayscale values of all pixels in the area to be detected.
[0086] Understandably, the definition of infrared camera sharpness varies depending on the application scenario. For example, in enclosed indoor environments, infrared light intensity is less affected by environmental interference, and infrared light is primarily supplemented by infrared light sources. Therefore, the required infrared light intensity can be controlled at a stable level. In this application scenario, the sharpness detection result of the infrared camera can be obtained by taking the peak value of the dispersion of grayscale values of all pixels in the detection area. This allows for the detection of the infrared camera with the highest sharpness, maximizing its effectiveness in that scenario.
[0087] In another embodiment of this application, step S6, the method for outputting the clarity of the infrared camera, includes the following steps:
[0088] Within the threshold range T1, the clarity of the infrared camera is output based on the mean of the dispersion of gray values of all pixels in the area to be detected.
[0089] Understandably, in complex outdoor scenarios, for example, infrared light intensity is significantly affected by environmental interference. Besides supplementing infrared light with infrared light sources, sunlight also contains infrared light, making it difficult to control infrared light intensity at a stable level. In this application scenario, the infrared camera can use the average of the dispersion of grayscale values of all pixels in the detection area as the output sharpness detection result. This allows for the detection of sharpness within a threshold range T1, balancing stability and effectiveness, thus improving the applicability of the infrared camera in this scenario.
[0090] In another embodiment of this application, step S6, the method for outputting the clarity of the infrared camera, includes the following steps:
[0091] Within the threshold range T1, based on the mean of the dispersion of gray values of all pixels in the detection area, the score corresponding to the sharpness gradient where the mean of the dispersion is located is output.
[0092] It is understood that this embodiment is based on the template image comprising several wire bundles. Since one end of each wire bundle is clustered at the center and the other end radiates outwards, and the spacing between wire bundles closer to the center is smaller, when the camera's resolution reaches a high value, the growth curve of the dispersion parameter is smaller when calculating the dispersion of grayscale values of all pixels in the detection area. Therefore, in order to accurately reflect the difference in resolution between different infrared cameras by calculating the dispersion of grayscale values of all pixels in the detection area, the corresponding score is output based on the resolution gradient where the mean of the dispersion is located, which can directly reflect the difference in resolution between different infrared cameras.
[0093] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for detecting camera sharpness, characterized in that, include: The infrared camera acquires the image of the calibration board to be tested in real time; The region to be detected in the image to be detected is determined by matching the template image; the template image is a local region image of the central region of the calibration board; the template image includes several line bundles, with one end of the line bundles converging at the center and the other end diverging outwards. Replace the gray value of each pixel in the region to be detected with the average gray value of all pixels in its surrounding neighborhood to detect the image brightness of the region to be detected; The infrared light source is adjusted according to the image brightness so that the image brightness of the area to be detected traverses the threshold range T1. Calculate the dispersion of grayscale values of all pixels in the region to be detected; Outputting the clarity of the infrared camera, including the following steps: Within the threshold range T1, the sharpness of the infrared camera is output based on the peak value of the dispersion of grayscale values of all pixels in the area to be detected.
2. The camera sharpness detection method as described in claim 1, characterized in that, The method for matching the region to be detected in an image to be detected using a template image includes the following steps: Calculate the result matrix of each matching image and template image on the image to be detected in turn; Find the minimum value in the result matrix, output the coordinates as the top left corner coordinates of the template image, and use the width and height of the matching image as the width and height of the template image. The location of the region to be detected is obtained from the image to be detected.
3. The camera sharpness detection method as described in claim 1, characterized in that, The method for detecting the image brightness of the region to be detected includes the following steps: The formula for calculating the average grayscale value μ of each pixel in the region to be detected is: , Where H and W are the height and width of the region to be detected, respectively, (i,j) represents the coordinates of a pixel in the region to be detected, and a ij It is the value of pixel (i,j).
4. The camera sharpness detection method as described in claim 3, characterized in that, The method for calculating the dispersion of gray values of all pixels in the region to be detected includes the following steps: The variance σ of the gray values of all pixels in the region to be detected is calculated using the following formula: 。