Automatic testing method for terminal camera
Through the combination of deep learning technology and OpenCV library, a convolutional neural network model is constructed, which solves the inconsistency and accuracy of traditional image quality evaluation methods, realizes automated and unified image quality evaluation, and improves evaluation efficiency and accuracy.
Patent Information
- Application Number
- CN202411589880.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-08
- Publication Date
- 2024-12-27
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional image quality evaluation methods rely on manual subjective judgment or reference images and are susceptible to personal preferences and external environments, resulting in inconsistency and reduced accuracy.
Deep learning technology is adopted to build a convolutional neural network model by collecting and preprocessing sample images, using data augmentation and transfer learning technology, combining OpenCV library for image processing and scoring histogram annotation, and realize automated image quality evaluation.
It improves the efficiency and accuracy of image quality evaluation, reduces manual participation, ensures the unity of testing standards, and can effectively evaluate image quality in different environments.
Smart Images

Figure CN119211519A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of camera testing, and in particular to an automatic testing method for a terminal camera. Background Art
[0002] With the widespread use of smart devices, automated image quality assessment has become particularly important in the testing process of terminal cameras and other devices. Traditional image quality assessment methods usually rely on manual subjective judgment or reference image comparison. However, subjective assessment is easily affected by personal preferences, which increases labor costs and inconsistency; while reference image assessment is limited by changes in external environments such as lighting and angles, which reduces the accuracy of the assessment. Summary of the invention
[0003] The main purpose of the present invention is to provide an automated testing method for terminal cameras, aiming to ensure the unification of testing standards and improve the efficiency and accuracy of image quality assessment.
[0004] To achieve the above object, the present invention proposes an automatic testing method for a terminal camera, comprising: Collect sample images and perform preprocessing and annotation; Use the preprocessed and annotated sample images for training and build a model; Acquire target images; Inputting the acquired target image into the model, reasoning and calculating the image quality score; The score is compared with the preset threshold. If the score is higher than the threshold, the test passes, otherwise it fails.
[0005] In a possible implementation, in the step of collecting sample images and performing preprocessing and annotation, the collected sample images are processed using the OpenCV library, including but not limited to image segmentation, cropping, and scaling.
[0006] In a possible implementation, the sample images are labeled in a scoring histogram manner, with scores ranging from 1 to 10, and a weight is assigned to each score, with the weight ranging from 0 to 100.
[0007] In a possible implementation, the step of training using the preprocessed and annotated sample images and constructing a model includes: Use DataLoader to load the image and the corresponding annotations, and recalculate the weights of the annotation scores, normalizing them into a probability distribution so that each score has a corresponding probability; Based on the deep learning framework, the model is constructed using network layers including but not limited to convolutional layers and fully connected layers, and the image rating is predicted through the forward propagation method; The Adam optimizer and mean square error (MSE) are used as the loss function. In each training cycle, the predicted value is calculated through forward propagation, the difference between the predicted value and the true value is calculated using the MSE loss function, and the model parameters are updated through back propagation. Evaluate the accuracy of the model using a small amount of sample image data to ensure that the model can effectively predict image quality scores.
[0008] In a possible implementation, when using the preprocessed and annotated sample images for training, the sample images are expanded using data enhancement technology, where the data enhancement includes but is not limited to rotation, flipping, cropping, noise addition, brightness adjustment, and color jittering.
[0009] In a possible implementation, the model is constructed using transfer learning technology, using a pre-trained sample quality assessment model, and fine-tuning the model to adapt to the image quality assessment requirements of a specific terminal device.
[0010] In a possible implementation, in the step of inputting the acquired target image into the model, inferring and calculating the image quality score, the model performs quality scoring through a multi-scale image input strategy during the inference process.
[0011] In a possible implementation manner, the evaluation indexes of the image quality score include but are not limited to clarity, contrast, color accuracy, noise level and edge sharpness.
[0012] The technical solution of the present invention realizes automatic evaluation of camera image quality by adopting deep learning and preset scoring thresholds, reduces manual participation and improves test efficiency; uses OpenCV for image processing and adopts a scoring histogram annotation method to increase data diversity and annotation standardization; uses convolutional neural networks and optimizers to design an efficient image scoring prediction model. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] 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 the structures shown in these drawings without paying creative work.
[0014] Figure 1 This is a flow chart of an embodiment of a terminal camera automatic testing method of the present invention.
[0015] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0016] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0017] The present invention proposes a terminal camera automatic testing method, combined with reference Figure 1 As shown, the following steps are included: S1. Collect sample images and perform preprocessing and annotation.
[0018] In this step, a large number of sample images are collected using the terminal camera under different lighting, backgrounds and angles. The collected images should include a variety of scenes, such as indoor, outdoor, low light, strong light, etc., to ensure that the model adapts to a variety of environments. The collected samples should also include images with noise, blur and different color distortions to ensure the model's recognition ability for low-quality images. Exemplarily, 2,000 images are collected, including 1,000 images taken under normal light, 500 images taken under low light conditions, and 500 noisy and blurred images, and the image resolution is unified to 1080p. Then, the sample images are preprocessed using the OpenCV library, including segmentation, cropping, scaling, etc. Exemplarily, OpenCV is used to segment the image and cut out the main objects in the image; then the image is scaled to adjust the size of each image to 640x640 to meet the input requirements of the deep learning model. In addition, each image is annotated according to a standard of 1 to 10 points, and the annotation method adopts the histogram distribution method. By analyzing factors such as image clarity and color accuracy, different scores are given and weights are assigned to each score, ranging from 0 to 100. The higher the weight, the greater the possibility of a high score, such as: gather , which represents the weight of each image score between 1 and 10.
[0019] Table 1 Image ID 1 2 3 4 5 6 7 8 9 10 1001 0 3 10 32 54 62 38 26 3 1 , In Table 1, the image with image ID 1001 is annotated and scored from 1 to 10, and the weight of each score is: 1 point 0, 2 points 3, 3 points 10, 4 points 32, 5 points 54, 6 points 62, 7 points 38, 8 points 26, 9 points 3, 10 points 1. In this example, the sample image with image ID 1001 has the highest weight of 6 points, which is 62. This means that the quality of the image is most likely close to 6 points, while the weight of 1 or 10 points is close to 0, indicating that the image is unlikely to be of extremely poor or extremely high quality.
[0020] S2. Use the preprocessed and labeled sample images for training and build a model.
[0021] In this step, the image data and annotations are loaded and batched using the DataLoader. The weights of the annotation scores are recalculated. , which represents the probability that each image score is between 1 and 10.
[0022] in, , is the actual probability value of each score, is the weight of any of the scores.
[0023] Table 2 Image ID 1 2 3 4 5 6 7 8 9 10 1001 0 0.013 0.044 0.140 0.236 0.271 0.166 0.114 0.013 0.004 , In Table 2, the image with image ID 1001 is annotated and scored from 1 to 10, and the weights of each score are: 1 point 0, 2 points 0.013, 3 points 0.044, 4 points 0.14, 5 points 0.236, 6 points 0.271, 7 points 0.166, 8 points 0.114, 9 points 0.013, 10 points 0.004. In this example, the sample image with image ID 1001 has the highest weight of 0.271 when it is scored 6 points. This means that the quality of the image is most likely close to 6 points, while the weights of scores of 1 or 10 points are close to 0. Create a custom model based on Module, define the network layer (convolutional layer, fully connected layer, etc.) and the forward propagation method (the core of prediction). This method uses ReLU, Dropout, Linear, Softmax, etc. to build the network structure.
[0024] First, define the optimizer (Adam) and the loss function. In each epoch, the forward propagation method is used to calculate the predicted value, and then the loss function is used to calculate the difference between the model output and the real image. Then, backpropagation is performed to calculate the gradient and the optimizer is used to update the model parameters. , represents the model output result. The mean square error MSE is used to calculate the loss function.
[0025] in, , is the actual probability value, is the model prediction value.
[0026] After training, evaluate the accuracy of the model using a small set of image data and annotations, and then save the entire model.
[0027] S3. Acquire target image.
[0028] In this step, the terminal device to be detected is used to collect a predetermined environmental image and preprocess it, including segmentation, cropping, scaling and other steps to ensure that the image meets the input requirements of the model.
[0029] S4. Input the acquired target image into the model, infer and calculate the image quality score.
[0030] In this step, the model receives the target image as input and obtains a score through forward propagation. The score is based on multiple quality evaluation indicators, including clarity, contrast, color accuracy, noise level, and edge sharpness.
[0031] Specifically, the terminal application loads the model, inputs the image to be detected, waits for the model to infer the output results, and finally calculates the final score of the image based on the inference results. The score range is (0,10), where 0 represents the worst image quality and 10 represents the best image quality. Score set Represents the model output results.
[0032] in, , S5. Compare the score with a preset threshold. If the score is higher than the threshold, the test passes. Otherwise, the test fails.
[0033] In this step, the final score is compared with the preset threshold to determine whether the terminal camera passes the test.
[0034] In a possible implementation, in the step of collecting sample images and performing preprocessing and annotation, the collected sample images are processed using the OpenCV library, including but not limited to image segmentation, cropping, and scaling.
[0035] Image segmentation is to distinguish the background and foreground of the image, focusing on the area of the target object; cropping is to crop out the redundant background for images that are not shot in a standard way; scaling is to scale the image to a standard input size (for example, 640x640) to meet the requirements of the model input layer.
[0036] In a possible implementation, the sample images are labeled in a scoring histogram manner, with scores ranging from 1 to 10, and a weight is assigned to each score, with the weight ranging from 0 to 100.
[0037] The scoring histogram is used to evaluate the quality of each sample image, limiting its quality score to a range of 1 to 10 points. This scoring standard can be comprehensively evaluated based on multiple image quality indicators such as image clarity, color reproduction, contrast, and noise level. Different quality levels correspond to different scores, 1 point indicates very poor image quality, and 10 points indicates very high image quality. The definition and assignment rule of weights is that after scoring each image, a weight is assigned to each scoring score. The range of weights is 0 to 100, and the value of the weight indicates that the higher the probability that the image may belong to a certain score. The higher the weight score, the more likely the image quality is to be rated as this score. For example, when the image quality is good, the weights of scores 8, 9, and 10 may be higher, while the weights of scores 1 and 2 are close to 0.
[0038] In order to use these weights more effectively in model training, the weights are normalized to a probability distribution so that the sum of the probabilities corresponding to each score is 1. This can help the model more accurately assess the quality of the image during the prediction process.
[0039] In a possible implementation, the step of training using the preprocessed and annotated sample images and constructing a model includes the following steps: S201. Use DataLoader to load the image and the corresponding annotations, and recalculate the weights of the annotation scores, normalizing them into a probability distribution so that each score has a corresponding probability.
[0040] In deep learning models, DataLoader is a tool for loading and batching data. It can automatically load images and their corresponding annotations from a dataset in batches. Usually, the dataset is too large to be loaded into memory at once, so DataLoader loads in batches to improve efficiency. Since the annotated image score is a discrete value (such as 1 to 10), converting the score histogram to a probability distribution during training can help the model learn better. Normalizing the weights to the interval [0, 1] makes the weight of each score a probability value, representing the probability that the image's score falls within a certain score interval.
[0041] S202. Based on a deep learning framework, a model is constructed using network layers including but not limited to convolutional layers and fully connected layers, and the image score is predicted by a forward propagation method.
[0042] The purpose of this step is to build a deep neural network, which includes convolutional layers (for extracting image features), fully connected layers (for classification or regression tasks), and ReLU layers for activation. The convolutional layer can extract local features from the input image, and the fully connected layer is used to combine the extracted features to generate the final prediction. In the forward propagation, the input image is processed by each layer of the model, and the predicted score probability distribution is finally output.
[0043] S203, using the Adam optimizer and mean square error MSE as the loss function. In each training cycle, the predicted value is calculated by forward propagation, the difference between the predicted value and the true value is calculated by using the MSE loss function, and the model parameters are updated by back propagation.
[0044] Adam is an optimization algorithm with adaptive learning rate. Compared with traditional stochastic gradient descent (SGD), it performs better in training deep learning models, especially when dealing with large data sets or complex networks. It can adaptively adjust the learning rate according to the gradient of each parameter.
[0045] S204. Use a small amount of sample image data to evaluate the accuracy of the model to ensure that the model can effectively predict the image quality score.
[0046] After each training cycle or after training, the performance of the model is evaluated using the validation dataset. The accuracy of the model is evaluated by calculating the difference between the predicted values and the true labels.
[0047] In a possible implementation, when using the preprocessed and annotated sample images for training, the sample images are expanded using data enhancement technology, where the data enhancement includes but is not limited to rotation, flipping, cropping, noise addition, brightness adjustment, and color jittering.
[0048] In this embodiment, the rotation is to randomly rotate the image so that the model can learn the image features at different angles and improve its adaptability to different shooting angles. The rotation angle can be a randomly selected value, usually within a certain range, such as [-30°, +30°].
[0049] Flipping includes horizontal flipping and vertical flipping. Flipped images can help the model learn symmetric characteristics in different directions and improve robustness to directional changes. Horizontal flipping (left-right flipping) is a common enhancement method, while vertical flipping (up-down flipping) is usually determined by specific application scenarios. Cropping randomly crops part of the image, keeping important areas unchanged, so that the model can focus on learning local features. After cropping, the image is scaled to a fixed size. Noise addition randomly adds noise (such as Gaussian noise or salt and pepper noise) to the image to simulate image noise in a real shooting environment, helping the model to be robust to noise interference. Brightness adjustment randomly adjusts the brightness of the image to simulate the shooting effects under different lighting conditions. By increasing or decreasing the brightness, the model can adapt to image quality assessment in strong or weak light environments. Color jittering randomly changes the color of the image, including brightness, contrast, saturation, etc. Color jittering helps the model have stronger adaptability to images in different color spaces.
[0050] In a possible implementation, the model is constructed using transfer learning technology, using a pre-trained sample quality assessment model, and fine-tuning the model to adapt to the image quality assessment requirements of a specific terminal device.
[0051] Transfer learning is a technique for transferring knowledge learned from one task (usually a model trained on a large-scale dataset) to another related task. In this method, a model pre-trained on a large-scale image quality assessment dataset can be used and fine-tuned to adapt it to the specific needs of the terminal device. This not only reduces the reliance on large-scale sample data, but also significantly shortens the training time.
[0052] In a possible implementation, in the step of inputting the acquired target image into the model, inferring and calculating the image quality score, the model performs quality scoring through a multi-scale image input strategy during the inference process.
[0053] Multi-scale input is a strategy that processes the same image at different resolutions and then feeds it into the model. Image quality assessment does not rely solely on features at a specific scale, but rather on extracting effective information at multiple scales. Low-resolution images can help the model understand the overall structure and layout, while high-resolution images can help capture details such as edge sharpness and noise levels. Assume that in the automated testing of smartphone terminal cameras, different users may take photos in different scenarios, such as long or close distances, indoors or outdoors, during the day or at night. In order to ensure that the model can stably assess image quality under these different conditions, the multi-scale input strategy can be applied to evaluate the same image at multiple resolutions, thereby capturing global layout and local details and improving the accuracy and stability of the assessment. For example, there may be blurred edges in the images taken by users, which are difficult to detect in low-resolution images, but the defect can be clearly identified in high-resolution images. Through the multi-scale input strategy, the model can comprehensively consider these factors at different levels and give a more accurate quality score.
[0054] In a possible implementation manner, the evaluation indexes of the image quality score include but are not limited to clarity, contrast, color accuracy, noise level and edge sharpness.
[0055] The above are only preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present application should be included in the protection scope of the present application.
Claims
1. A terminal camera automatic testing method, characterized in that: include: Collect sample images and perform preprocessing and annotation; Use the preprocessed and annotated sample images for training and build a model; Acquire target images; Inputting the acquired target image into the model, reasoning and calculating the image quality score; Compare the score with the preset threshold. If the score is higher than the threshold, the test passes, otherwise it fails. The step of training with the preprocessed and annotated sample images and constructing a model includes: Use DataLoader to load the image and the corresponding annotations, and recalculate the weights of the annotation scores, normalizing them into a probability distribution so that each score has a corresponding probability; Based on the deep learning framework, the model is constructed using network layers including but not limited to convolutional layers and fully connected layers, and the image rating is predicted through the forward propagation method; The Adam optimizer and mean square error (MSE) are used as the loss function. In each training cycle, the predicted value is calculated by forward propagation, the difference between the predicted value and the true value is calculated by using the MSE loss function, and the model parameters are updated by back propagation. Evaluate the accuracy of the model using a small amount of sample image data to ensure that the model can effectively predict image quality scores.
2. The terminal camera automatic testing method according to claim 1, characterized in that: In the step of collecting sample images and performing preprocessing and annotation, the collected sample images are processed using the OpenCV library, including but not limited to image segmentation, cropping, and scaling.
3. The terminal camera automatic testing method according to claim 2, characterized in that: The sample images are labeled using a scoring histogram, with scores ranging from 1 to 10, and a weight is assigned to each score, with the weight ranging from 0 to 100.
4. The terminal camera automatic testing method according to claim 1, characterized in that: When using the preprocessed and annotated sample images for training, the sample images are expanded using data enhancement technology, and the data enhancement includes but is not limited to rotation, flipping, cropping, noise addition, brightness adjustment, and color jittering.
5. The terminal camera automatic testing method according to claim 1, characterized in that: The model is constructed by adopting transfer learning technology, using a pre-trained sample quality assessment model, and fine-tuning the model to adapt to the image quality assessment requirements of a specific terminal device.
6. The terminal camera automatic testing method according to claim 1, characterized in that: In the step of inputting the acquired target image into the model, reasoning and calculating the image quality score, the model performs quality scoring through a multi-scale image input strategy during the reasoning process.
7. The terminal camera automatic testing method according to claim 6, characterized in that: The evaluation indicators of the image quality score include but are not limited to clarity, contrast, color accuracy, noise level and edge sharpness.
Citation Information
Patent Citations
Image quality evaluation method and device, electronic equipment and storage medium
CN111161238A
No-reference image quality detection method and system, terminal and medium
CN113066065A
Blind image quality evaluation method based on multi-scale features and long-distance dependence
CN116596915A
Coal mine underground image quality evaluation method
CN117197092A
Scanning tunneling microscope image quality evaluation method based on deep learning
CN117876350A
Cited By
Equipment testing method and device and equipment
CN122550605A
Device testing method, apparatus, and device
CN122550605B