System and method for automatically testing focusing quality based on opencv and Laplacian algorithms

Through an automatic testing system based on opencv and Laplacian algorithms, the problems of inefficient detection of IPC focus quality and inaccurate judgment in the prior art are solved, and automated detection and high-accurate focus quality evaluation are achieved.

CN120075426APending Publication Date: 2025-05-30SICHUAN TIANYI COMHEART TELECOM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510197564.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-21
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

The method of detecting IPC focus quality in the prior art is inefficient, prone to human judgment errors, and it is impossible to adjust the detection stringency to control the focus pass rate.

Method used

An automatic testing system based on opencv and Laplacian algorithms is adopted to obtain comparison pictures through IPCs with known focus capabilities, automatically search and decode the IPC video stream, calculate whether the gradient value of the IPC picture to be detected is within the preset range, and determine whether its focus capabilities are qualified.

Benefits of technology

It realizes automatic detection of IPC focus quality, improves detection efficiency and accuracy, can detect IPC focus capabilities with one click, eliminates human factors, and ensures the focus qualification rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120075426A_ABST
    Figure CN120075426A_ABST
Patent Text Reader

Abstract

The invention relates to a system and a method for automatically testing focusing quality based on opencv and Laplacian algorithms. The method comprises the following steps: obtaining a comparison picture through an ipc with qualified known focusing capability; the automatic test focusing system is started, the ipc under the same local area network is automatically searched, the ipc sends a video stream to the system for decoding, and after the video stream is decoded, a picture which is being shot by the ipc is displayed to obtain a to-be-detected picture; storing the to-be-detected picture to a specified directory, and obtaining a comparison picture; electrifying the to-be-detected ipc, starting a system, finding the to-be-detected ipc, and placing the to-be-detected ipc at the same position of the ipc with qualified focusing capability; and selecting a comparison picture, carrying out operation on the comparison picture and the picture of the to-be-detected ipc through a Laplacian algorithm, and calculating whether the gradient value of the picture of the to-be-detected ipc is within a preset range so as to judge that the focusing capability of the to-be-detected camera is unqualified. The technical problems that in the prior art, focusing is complex, and the focusing qualification rate of the ipc cannot be controlled by adjusting the detection strict degree in an existing mode are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical fields of integrated circuits and electronic communications, and particularly relates to a system and method for automatically testing focus quality based on the opencv and Laplacian algorithms. Background Art

[0002] With the enhancement of people's awareness of security, the recognition of security products has been continuously improved. Coupled with the reduction in the cost of intelligent network cameras (IPCs) and the promotion of intelligence, the demand for IPCs is increasing continuously. At present, IPCs are widely used in various fields such as home security, public security, transportation, medical care, and finance. People have put forward higher requirements for the imaging and image quality of IPCs. For IPCs of the same product with the same focal length, due to slight differences in product hardware, the focusing conditions may be different, ultimately resulting in deviations in the image imaging quality. And whether the focusing quality of the IPC is qualified is one of the important reasons for the clarity of the image. Therefore, in the production inspection of IPCs in the factory, it is particularly important to detect the focusing quality of IPCs with the same focal length, and to prevent IPCs with problems in focusing ability caused by hardware or other reasons from flowing into the market. At present, the main method for detecting the focusing quality of IPCs is still the traditional method of human eye observation and judgment. This method is not only inefficient but also prone to inaccurate judgment. The method of obtaining images through equipment for detection is more troublesome and inconvenient, and it is necessary to carry the equipment all the time to conduct the detection. And the current method cannot adjust the detection strictness to control the focusing qualification rate of IPCs.

[0003] Therefore, there is an urgent need to provide a system and method for automatically testing focus quality to solve the technical problems in the prior art that the method of obtaining images for detection is more troublesome and inconvenient, it is necessary to carry the equipment all the time to conduct the detection, and the current method cannot adjust the detection strictness to control the focusing qualification rate of IPCs. Summary of the Invention

[0004] The purpose of the present invention is to provide a system and method for automatically testing focus quality based on the opencv and Laplacian algorithms to solve the technical problems in the prior art that the method of obtaining images for detection is more troublesome and inconvenient, it is necessary to carry the equipment all the time to conduct the detection, and the current method cannot adjust the detection strictness to control the focusing qualification rate of IPCs.

[0005] To solve the above technical problems, the technical solutions adopted by the present invention are as follows:

[0006] In the first aspect, a method for automatically testing focus quality based on the opencv and Laplacian algorithms is provided, including the following steps:

[0007] S1: Obtain a comparison picture through an IPC with qualified known focusing ability. Power on the IPC with qualified focusing ability and make it enter the production test mode;

[0008] S2: Start the automatic test focusing system, automatically search for the IPCs under the same local area network. The IPCs send video streams to the system for decoding. After decoding the video streams, display the pictures being taken by the IPCs to obtain the pictures to be detected;

[0009] S3: Save the pictures to be detected to a specified directory, and obtain the comparison pictures, where the comparison pictures have the same picture and resolution as the pictures to be detected;

[0010] S4: Power on the IPC to be detected and turn on the system. Locate the IPC to be detected and place it at the same position as the IPC with qualified focusing ability, so that the comparison pictures and the pictures of the IPC to be detected have the same picture and resolution;

[0011] S5: Select the comparison pictures, enter the specified directory where the pictures are saved, confirm and then enter the detection. Perform operations on the comparison pictures and the pictures of the IPC to be detected through the Laplacian algorithm, and calculate whether the gradient value of the pictures of the IPC to be detected is within the preset range. If so, it is determined that the focusing ability of the camera to be detected is qualified; if not, it is determined that the focusing ability of the camera to be detected is unqualified.

[0012] Preferably, the specific process of performing operations on the comparison pictures and the pictures of the IPC to be detected through the Laplacian algorithm in step S5 is as follows:

[0013] S51: Perform filtering processing on the pictures of the IPC to be detected;

[0014] S52: Define the Laplacian operator as a 3x3 matrix, and each element in the matrix represents the pixel value in the pictures of the IPC to be detected;

[0015] S53: Perform convolution operations on each pixel point in the pictures of the IPC to be detected in turn through the Laplacian operator to obtain the convolution result of each pixel point;

[0016] S54: Obtain the gradient value of the pictures of the IPC to be detected based on the convolution results of each pixel point.

[0017] Preferably, the specific process of performing filtering processing on the pictures of the IPC to be detected in step S51 is as follows:

[0018] S511: Set the size and standard deviation of the Gaussian kernel;

[0019] S512: Perform convolution operations on the set Gaussian kernel and the pictures of the IPC to be detected to obtain a new image;

[0020] S513: Perform a convolution operation after filling the pixel points at the edge of the image of the IPC to be detected.

[0021] S514: Set a filtering threshold and then save after filtering.

[0022] Preferably, the specific process of performing a convolution operation on each pixel point in the image of the IPC to be detected by the Laplacian operator in step S53 is as follows:

[0023] S531: Select the pixel point to be convolved, and obtain the pixel values of the four pixel points above, below, left, and right of the pixel point to be convolved according to the Laplacian operator.

[0024] S532: Perform a convolution calculation based on the pixel values of the four pixel points above, below, left, and right. The specific calculation formula is as follows:

[0025] P5lap = (P2 + P4 + P6 + P8) - 4·P5;

[0026] Wherein, P5 is the pixel value of the pixel point to be convolved, P2 is the pixel value of the pixel point above the pixel point to be convolved, P4 is the pixel value of the pixel point to the left of the pixel point to be convolved, P6 is the pixel value of the pixel point to the right of the pixel point to be convolved, and P8 is the pixel value of the pixel point below the pixel point to be convolved.

[0027] In a second aspect, a system for automatically testing the focus quality based on OpenCV and the Laplacian algorithm is provided, which is used to implement the method for automatically testing the focus quality based on OpenCV and the Laplacian algorithm described in any one of the above. The system includes an image acquisition module, a decoding module, a storage module, an IPC, an IPC position placement module, and a focus detection module. The image acquisition module is connected to the decoding module, the decoding module is connected to the storage module, the decoding module is connected to the IPC, the IPC is connected to the IPC position placement module, and the IPC position placement module is connected to the focus detection module;

[0028] The image acquisition module is used to obtain a comparison image through an IPC with known qualified focusing ability.

[0029] The decoding module is used to perform decoding processing on the video stream sent by the IPC after automatically searching for the IPC under the same local area network when starting the automatic focus testing system.

[0030] The IPC serves as a server.

[0031] The IPC position placement module places the IPC to be detected at the same position as the IPC with qualified focusing ability, so that the pictures of the comparison picture and the IPC to be detected have the same picture and resolution.

[0032] The focusing detection module is used to select a comparison picture, enter the specified directory where the picture is saved for confirmation and then enter the detection. The comparison picture and the picture of the IPC to be detected are calculated by the Laplacian algorithm, and it is calculated whether the gradient value of the picture of the IPC to be detected is within the preset range. If so, it is determined that the focusing ability of the camera to be detected is qualified; if not, it is determined that the focusing ability of the camera to be detected is unqualified.

[0033] The beneficial effects of the present invention include:

[0034] The automatic test focusing quality system and method based on opencv and Laplacian algorithm provided by the present invention obtain a comparison picture through an IPC with known qualified focusing ability; start the automatic test focusing system, automatically search for IPCs under the same local area network, and the IPC sends a video stream to the system for decoding. After decoding the video stream, the picture being captured by the IPC is displayed to obtain the picture to be detected; the picture to be detected is saved to the specified directory, and the comparison picture is obtained; the IPC to be detected is powered on and the system is turned on, the IPC to be detected is found, and the IPC to be detected is placed at the same position as the IPC with qualified focusing ability; the comparison picture is selected, the comparison picture and the picture of the IPC to be detected are calculated by the Laplacian algorithm, and it is calculated whether the gradient value of the picture of the IPC to be detected is within the preset range, and then it is determined that the focusing ability of the camera to be detected is unqualified. This solves the technical problems in the prior art that the focusing is complex and the current method cannot adjust the detection strictness to control the focusing qualification rate of the IPC.

[0035] Through the automatic test focusing quality system based on opencv and Laplacian algorithm, production testers can use this system for one-key detection, so as to obtain information on whether the current IPC focusing ability is qualified, eliminate problems with IPC focusing caused by human factors such as focusing adjustment, and screen out IPC products with unqualified focusing quality due to hardware damage or production mistakes, and prevent them from flowing into the market. It effectively avoids the errors and low efficiency caused by the judgment of the traditional method of observing IPC images with human eyes, improves the production efficiency and detection accuracy, and also solves the trouble of having to use corresponding equipment during detection.

[0036] On the premise that the picture frames are the same and the resolutions are equal, compared with pictures with poor focusing ability, pictures with better focusing ability have clearer levels and are more finely divided, that is, the color differences and gradients are greater. Based on this, the Laplacian operator can be used to calculate the gradients of the image in the horizontal and vertical directions respectively. The higher the comprehensive gradient value of the images in the same scene, the clearer the image and the better the IPC focusing ability. Therefore, the overall gradient value of the picture can be conveniently obtained by calculating the convolution values of all pixel points, and finally the focusing situation is reflected by comparing the picture gradient values, improving the focusing detection efficiency and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 It is a schematic flowchart of a method for automatically testing focusing quality based on opencv and Laplacian algorithm of the present invention.

[0038] Figure 2 It is a schematic diagram of a 3x3 matrix of the Laplacian operator of the present invention.

[0039] Figure 3 It is a schematic structural diagram of a system for automatically testing focusing quality based on opencv and Laplacian algorithm of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0040] The following is a further detailed description of the present invention with reference to the Figures 1 to 3 accompanying drawings:

[0041] Embodiment 1

[0042] Referring to the Figure 1 accompanying drawings, a method for automatically testing focusing quality based on opencv and Laplacian algorithm includes the following steps:

[0043] S1: Obtain comparison pictures through an IPC with qualified focusing ability. Power on the IPC with qualified focusing ability and make it enter the production test mode;

[0044] S2: Start the automatic focusing test system, automatically search for the IPC under the same local area network. The IPC sends a video stream to the system for decoding. After decoding the video stream, display the picture being taken by the IPC to obtain the picture to be detected;

[0045] S3: Save the picture to be detected in a specified directory, and obtain the comparison picture, where the comparison picture has the same picture and resolution as the picture to be detected;

[0046] S4: Power on the IPC to be detected and turn on the system, find the IPC to be detected, place the IPC to be detected at the same position as the IPC with qualified focusing ability, so that the pictures of the comparison picture and the IPC to be detected have the same picture and resolution;

[0047] S5: Select a comparison picture, enter the specified directory where the picture is saved, confirm and then enter the detection. Perform an operation on the comparison picture and the picture of the IPC to be detected through the Laplacian algorithm, and calculate whether the gradient value of the picture of the IPC to be detected is within a preset range. If so, it is determined that the focusing ability of the camera to be detected is qualified; if not, it is determined that the focusing ability of the camera to be detected is unqualified.

[0048] In this embodiment, a comparison picture is obtained through an IPC with a known qualified focusing ability; the automatic test focusing system is started, and the IPCs under the same local area network are automatically searched. The IPCs send video streams to the system for decoding. After decoding the video streams, the pictures being taken by the IPCs are displayed to obtain the pictures to be detected; the pictures to be detected are saved to the specified directory to obtain the comparison picture; the IPC to be detected is powered on and the system is turned on, the IPC to be detected is found, and the IPC to be detected is placed at the same position as the IPC with a qualified focusing ability; select the comparison picture, perform an operation on the comparison picture and the picture of the IPC to be detected through the Laplacian algorithm, and calculate whether the gradient value of the picture of the IPC to be detected is within a preset range to further determine that the focusing ability of the camera to be detected is unqualified. This solves the technical problems in the prior art that the focusing is complex and the current method cannot adjust the detection strictness to control the focusing qualification rate of the IPC.

[0049] Embodiment 2

[0050] Based on Embodiment 1, the specific process of performing an operation on the comparison picture and the picture of the IPC to be detected through the Laplacian algorithm in step S5 is as follows:

[0051] S51: Perform filtering processing on the picture of the IPC to be detected;

[0052] S52: Define the Laplacian operator as a 3x3 matrix, and each element in the matrix represents the pixel value in the picture of the IPC to be detected;

[0053] S53: Perform a convolution operation on each pixel point in the picture of the IPC to be detected in turn through the Laplacian operator to obtain the convolution result of each pixel point;

[0054] S54: Obtain the gradient value of the picture of the IPC to be detected based on the convolution result of each pixel point.

[0055] In this embodiment, the specific process of performing filtering processing on the picture of the IPC to be detected in step S51 is as follows:

[0056] S511: Set the size and standard deviation of the Gaussian kernel;

[0057] S512: After performing a convolution operation on the set Gaussian kernel and the image of the IPC to be detected, obtain a new image;

[0058] S513: After performing padding processing on the pixel points at the edge of the image of the IPC to be detected, perform a convolution operation;

[0059] S514: After setting a filtering threshold, perform filtering and then save.

[0060] Embodiment 3

[0061] Based on Embodiment 1 or Embodiment 2, the specific process of successively performing a convolution operation on each pixel point in the image of the IPC to be detected through the Laplacian operator in step S53 is as follows:

[0062] S531: Select the pixel point to be subjected to the convolution operation, and obtain the pixel values of the four pixel points above, below, left, and right of the pixel point to be subjected to the convolution operation according to the Laplacian operator;

[0063] S532: Perform convolution calculation based on the pixel values of the four pixel points above, below, left, and right. The specific calculation formula is as follows:

[0064] P5lap = (P2 + P4 + P6 + P8) - 4·P5;

[0065] Among them, P5 is the pixel value of the pixel point to be subjected to the convolution operation, P2 is the pixel value of the pixel point above the pixel point to be subjected to the convolution operation, P4 is the pixel value of the pixel point to the left of the pixel point to be subjected to the convolution operation, P6 is the pixel value of the pixel point to the right of the pixel point to be subjected to the convolution operation, and P8 is the pixel value of the pixel point below the pixel point to be subjected to the convolution operation.

[0066] A system for automatically testing the focus quality based on the opencv and Laplacian algorithms, used to implement the method for automatically testing the focus quality based on the opencv and Laplacian algorithms described in any one of the above, includes an image acquisition module, a decoding module, a storage module, an IPC, an IPC position placement module, and a focus detection module. The image acquisition module is connected to the decoding module, the decoding module is connected to the storage module, the decoding module is connected to the IPC, the IPC is connected to the IPC position placement module, and the IPC position placement module is connected to the focus detection module; the image acquisition module is used to obtain a comparison image through an IPC with known qualified focus ability; the decoding module is used to, after starting the automatic focus testing system and automatically searching for an IPC under the same local area network, perform decoding processing on the video stream sent by the IPC.

[0067] The IPC serves as a server; the IPC position placement module places the IPC to be detected at the same position as the IPC with qualified focusing ability, so that the pictures of the comparison picture and the IPC to be detected have the same picture and resolution; the focusing detection module is used to select the comparison picture, enter the specified directory where the picture is saved for confirmation and then enter the detection, perform operations on the comparison picture and the picture of the IPC to be detected through the Laplacian algorithm, and calculate whether the gradient value of the picture of the IPC to be detected is within the preset range. If so, it is determined that the focusing ability of the camera to be detected is qualified; if not, it is determined that the focusing ability of the camera to be detected is unqualified.

[0068] In summary, the system and method for automatically testing focusing quality based on OpenCV and the Laplacian algorithm provided by the present invention obtain a comparison picture through an IPC with qualified focusing ability; start the automatic focusing test system, automatically search for IPCs under the same local area network, the IPC sends a video stream to the system for decoding, and after decoding the video stream, the picture being captured by the IPC is displayed to obtain the picture to be detected; save the picture to be detected in the specified directory, and obtain the comparison picture; power on the IPC to be detected and turn on the system, find the IPC to be detected, and place the IPC to be detected at the same position as the IPC with qualified focusing ability; select the comparison picture, perform operations on the comparison picture and the picture of the IPC to be detected through the Laplacian algorithm, and calculate whether the gradient value of the picture of the IPC to be detected is within the preset range, and then determine that the focusing ability of the camera to be detected is unqualified. This solves the technical problems in the prior art that focusing is complex and the current method cannot adjust the detection strictness to control the focusing qualification rate of the IPC.

[0069] Production testers of this system for automatically testing focusing quality can use this system for one-key detection, so as to obtain information on whether the current IPC focusing ability is qualified, eliminate problems with IPC focusing caused by human factors such as focusing adjustment, screen out IPC products with unqualified focusing quality due to hardware damage or production flaws, and prevent them from flowing into the market. It avoids the errors and low efficiency caused by the judgment of the traditional method of observing IPC images with the human eye, improves production efficiency and detection accuracy, and also solves the trouble of having to use corresponding equipment during detection. On the premise that the picture frames are the same and the resolutions are equal, pictures with better focusing ability have clearer levels and more detailed divisions compared to pictures with poor focusing ability, that is, the color difference and gradient are greater. Therefore, the Laplacian operator can be used to calculate the gradients in the horizontal and vertical directions of the image respectively. The higher the comprehensive gradient value of the images in the same scene, the clearer the image and the better the IPC focusing ability. Therefore, the overall gradient value of the picture can be conveniently obtained by calculating the convolution values of all pixel points, and finally the focusing situation is reflected by comparing the picture gradient values, improving the focusing detection efficiency and accuracy.

Claims

1. A method for automatically testing focus quality based on opencv and Laplacian algorithm, characterized in that: The following steps are involved: S1: Get a comparison picture through an IPC with known qualified focusing capability, power on the IPC with qualified focusing capability and put it into production test mode; S2: Start the automatic test focus system, automatically search for the ipc under the same LAN, the ipc sends the video stream to the system for decoding, and after decoding the video stream, the picture being shot by the ipc is displayed to obtain the picture to be tested; S3: Save the image to be detected to a specified directory, and obtain a comparison image, which has the same picture and resolution as the image to be detected; S4: Power on the IPC to be detected and turn on the system, find the IPC to be detected, and put the IPC to be detected on the same position of the IPC with qualified focusing ability, so that the picture and resolution of the comparison picture and the picture of the IPC to be detected are the same; S5: Select a comparison image, enter the specified directory where the image is saved to confirm and then enter the test, calculate the comparison image and the image of the ipc to be tested through the Laplacian algorithm, and calculate whether the gradient value of the image of the ipc to be tested is within the preset range. If so, it is determined that the focusing ability of the camera to be tested is qualified. If not, it is determined that the focusing ability of the camera to be tested is unqualified.

2. The method for automatically testing focus quality based on opencv and Laplacian algorithm according to claim 1, characterized in that, The specific process of performing Laplacian algorithm calculation on the comparison image and the image of the ipc to be detected in step S5 is as follows: S51: Filter the image to be detected ipc; S52: define the Laplacian operator as a 3x3 matrix, where each element in the matrix represents a pixel value in the image of the ipc to be detected; S53: performing convolution operation on each pixel point in the image to be detected ipc in sequence through the Laplacian operator to obtain the convolution result of each pixel point; S54: Obtain the gradient value of the image of the ipc to be detected based on the convolution result of each pixel.

3. The method for automatically testing focus quality based on opencv and Laplacian algorithm according to claim 2, characterized in that, The specific process of filtering the image to be detected ipc in step S51 is as follows: S511: Set the size and standard deviation of the Gaussian kernel; S512: performing a convolution operation on the set Gaussian kernel and the image of the ipc to be detected to obtain a new image; S513: performing a convolution operation after filling pixel points at the edge of the image to be detected ipc; S514: After setting the filtering threshold, perform filtering and save.

4. The method for automatically testing focus quality based on opencv and Laplacian algorithm according to claim 2, characterized in that, The specific process of performing convolution operation on each pixel in the image to be detected ipc in step S53 in sequence by the Laplacian operator is as follows: S531: Select a pixel point to be convolved, and obtain pixel values ​​of four pixel points above, below, left and right of the pixel point to be convolved according to the Laplacian operator; S532: Perform convolution calculation based on the pixel values ​​of the four upper, lower, left and right pixels. The specific calculation formula is as follows: P5lap=(P2+P4+P6+P8)-4·P5; Among them, P5 is the pixel value of the pixel to be convolved, P2 is the pixel value of the pixel above the pixel to be convolved, P4 is the pixel value of the pixel to the left of the pixel to be convolved, P6 is the pixel value of the pixel to the right of the pixel to be convolved, and P8 is the pixel value of the pixel below the pixel to be convolved.

5. based on the system of automatic test focus quality of opencv, Laplacian algorithm, for realizing the method for automatic test focus quality based on opencv, Laplacian algorithm described in any one of claim 1-4, it is characterized in that, comprise picture acquisition module, decoding module, storage module, ipc, ipc position placement module, focus detection module, described picture acquisition module is connected with decoding module, described decoding module is connected with storage module, described decoding module is connected with ipc, described ipc is connected with ipc position placement module, described ipc position placement module is connected with focus detection module; The image acquisition module is used to obtain a comparison image through an IPC with a known qualified focusing capability; The decoding module is used to decode the video stream sent by the IPC after starting the automatic test focus system and automatically searching for the IPC under the same local area network; The ipc acts as a server; The IPC position placement module places the IPC to be detected on the same position as the IPC with qualified focusing ability, so that the picture and resolution of the comparison picture and the picture of the IPC to be detected are the same; The focus detection module is used to select a comparison image, enter the specified directory where the image is saved for confirmation, and then enter the detection, calculate the comparison image and the image of the ipc to be detected through the Laplacian algorithm, and calculate whether the gradient value of the image of the ipc to be detected is within a preset range. If so, it is determined that the focus ability of the camera to be detected is qualified, if not, it is determined that the focus ability of the camera to be detected is unqualified.