Disclosure of Invention
The invention mainly aims to provide a method and a device for detecting the light guide chromatic aberration of a car lamp, so as to solve the defects of the prior art.
In order to achieve the purpose, the technical scheme provided by the invention is as follows: a method for detecting the chromatic aberration of a car light guide comprises the following steps: firstly, acquiring the type information of the car light guide with detection, and selecting a corresponding parameter file in a preset classification model database according to the acquired information; acquiring a light guide image of a vehicle lamp to be detected; extracting HSV color histogram feature vectors of the car light guide; and then, the extracted feature vectors are sent into a classifier model corresponding to the selected car light guide type, a classification result of the light guide to be detected is obtained through calculation, and whether the color of the light guide is qualified or not is judged.
Further, the selecting a corresponding parameter file in a preset classification model database according to the acquired information includes:
if the classification model parameter file corresponding to the light guide type to be detected exists in the system, selecting the type;
if the preset classification model database does not have the corresponding parameter file, a new car light guide type needs to be added to manufacture a corresponding classification model.
Further, the step of adding a new car light guide type comprises: making an image library of the new type of light guide; acquiring images of the light guide sample piece through a color camera, wherein the images in an image library comprise M types of light guides with standard colors and car light guide images with various chromatic aberrations, and respectively labeling and storing category labels; extracting color characteristic vectors of M types of car light guide images in an image library; and for a training set consisting of M-class feature vectors and class labels, learning M two-class support vector machine classifiers by a one-to-many method, and storing corresponding classifier parameter model files for subsequent light guide classification detection.
Further, the acquiring of the light guide image of the vehicle lamp to be detected comprises: and lighting the car lamp to enable the light guide to emit light, acquiring an image of the light emitted by the light guide by using the color camera, and transmitting the image to the computer.
Further, the extracting the color feature vector of the car light guide comprises: converting the image from an RGB color space to an HSV color space; the H, S, V3 color channels are quantized at unequal intervals to form color feature vectors.
Further, the formula for converting the image from the RGB color space to the HSV color space is as follows:
in the formula, R, G, and B represent that the initial color information of the car light guide image is RGB values, and the converted HSV color space divides the color information of the car light guide into three elements: hue H, saturation S and brightness V, wherein H belongs to [0,360], S belongs to [0,1], V belongs to [0,1 ].
Further, the method for extracting the HSV color histogram feature vector of the car light guide comprises the following steps:
carrying out non-uniform quantization on three HSV components, wherein the H space is divided into 8 grades, S is divided into 3 grades, and V is divided into 3 grades:
and constructing a one-dimensional feature vector. According to the quantization method, the color components are synthesized into a one-dimensional feature vector G:
G=HQSQV+SQV+V
wherein QSAnd QVThe number of quantization levels, i.e. Q, for the components S and V, respectivelyS=3,QVIf 3, the formula translates to:
G=9H+3S+V
a 72-handle one-dimensional histogram of G, i.e. the color feature vector of the car light guide image, is thus obtained.
A car light guide chromatic aberration detection device for realizing a car light guide chromatic aberration detection method, the car light guide chromatic aberration detection device comprising: the device comprises a memory, a processor and a car light guide color difference detection program which is stored on the memory and can run on the processor.
A computer-readable storage medium for a vehicle light guide color difference detection method, the computer-readable storage medium having stored thereon a light guide color difference detection program, which when executed by a processor, implements the light guide color difference detection method steps.
The invention has the beneficial effects that:
according to the method, the car light guide image is obtained, a training image library and a learning classification model of the car light guide are manufactured, the car light guide color feature vector to be detected is extracted, the feature vector is sent into a classifier model corresponding to the selected car light guide type for classification detection, the classification result of the light guide to be detected is obtained, if the classification result is the standard color, the classification result is qualified, and if the classification result is other color cast, the classification result is unqualified. Therefore, the chromatic aberration detection of the car light guide is realized, and compared with the existing manual detection method, the method can improve the detection speed and the accuracy and reduce the production cost.
Detailed Description
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The terminal of the embodiment of the invention can be a PC. As shown in fig. 1, the terminal may include: a processor 1001, such as a CPU, a camera interface 1004, a user interface 1003, a memory 1005, a communication bus 1002. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The camera interface 1004 may optionally include standard serial, parallel, USB, IEEE1394, etc. The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.
Optionally, the terminal may further include a sensor, a voltage current detection circuit, a communication module, and the like.
Those skilled in the art will appreciate that the terminal structure shown in fig. 1 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is a kind of computer storage medium, may include therein an operation server, an image capturing module, a user interface module, and a car light guide color difference detection program.
In the terminal shown in fig. 1, the camera interface 1004 is mainly used for connecting a color camera and collecting images for subsequent color difference detection; the user interface 1003 is mainly used for connecting a client (user side) and performing data communication with the client; and the processor 1001 may be configured to call a car light guide color difference detection program stored in the memory 1005.
In this embodiment, the vehicular lamp light guide color difference detection device includes: a memory 1005, a processor 1001 and a car light guide chromatic aberration detection program stored on the memory 1005 and executable on the processor 1001, wherein when the processor 1001 calls the car light guide chromatic aberration detection program stored in the memory 1005, the following operations are performed:
acquiring the type information of the car light guide with detection, and selecting a corresponding parameter file in a preset classification model database according to the acquired information;
acquiring a light guide image of a vehicle lamp to be detected;
extracting HSV color histogram feature vectors of the car light guide;
and sending the extracted feature vectors into a classifier model corresponding to the selected car light guide type, calculating to obtain a classification result of the light guide to be detected, and judging whether the color of the light guide is qualified.
Further, the processor 1001 may call a car light guide color difference detection program stored in the memory 1005, and further perform the following operations:
if the classification model parameter file corresponding to the light guide type to be detected exists in the system, selecting the type;
if the preset classification model database does not have the corresponding parameter file, a new car light guide type needs to be added to manufacture a corresponding classification model.
Further, the processor 1001 may call a car light guide color difference detection program stored in the memory 1005, and further perform the following operations:
and lighting the car lamp to enable the light guide to emit light, acquiring an image of the light emitted by the light guide by using the color camera, and transmitting the image to the computer.
Further, the processor 1001 may call a car light guide color difference detection program stored in the memory 1005, and further perform the following operations:
converting the image from an RGB color space to an HSV color space;
the 3 color channels of H, S, V are quantized at unequal intervals to form color feature vectors.
Further, the processor 1001 may call a car light guide color difference detection program stored in the memory 1005, and further perform the following operations:
making an image library of a new type of light guide, wherein the images in the image library comprise light guides with standard colors and car light guide images with various chromatic aberrations, and the image library is respectively marked with category labels and stored, and the step of acquiring the images is as in claim 3;
extracting color feature vectors of the M types of car light guide images in the image library, wherein the steps are as in claim 4;
for a training set consisting of M-class feature vectors and class labels, a one-to-many method is adopted to learn M two-class Support Vector Machine (SVM) classifiers, and corresponding classifier parameter model files are stored for subsequent light guide classification detection.
The invention further provides a car light guide chromatic aberration detection method, and referring to fig. 2, fig. 2 is a flow diagram of the car light guide chromatic aberration detection method of the invention.
In the embodiment, the color difference of the car light guide is detected by using a machine vision method, and the detection method comprises the following steps:
step S10, obtaining the car light guide type information with detection, and selecting the corresponding parameter file in the preset classification model database according to the obtained information;
in this embodiment, if the classification model parameter file corresponding to the light guide type to be detected already exists in the system, the type is selected; if the preset classification model database does not have the corresponding parameter file, a new car light guide type needs to be added, and a corresponding classification learning model is manufactured.
When a new car lamp light guide type is added, firstly, obtaining an image of a car lamp light guide sample piece through a color camera, and making an image library of the new type light guide, wherein the image in the image library comprises M types of light guides with standard colors and car lamp light guide images with various chromatic aberrations, and respectively labeling and storing a category label; further, converting the M-type car lamp light guide images in the image library from an RGB color space to an HSV color space, and then extracting HSV color feature vectors; further, a training set formed by the M-class feature vectors and class labels is used for learning M two-class Support Vector Machine (SVM) classifiers by a one-to-many method, and corresponding classifier parameter model files are stored for subsequent light guide classification detection.
Step S20, acquiring a light guide image of the vehicle lamp to be detected;
in this embodiment, the light of the vehicle is controlled by a program to illuminate, the light guide is caused to emit light, an image of the light emitted by the light guide is acquired by the color camera, and the image is transmitted to the computer.
Step S30, extracting HSV color histogram feature vectors of the car light guide;
in this embodiment, first, the image is converted from RGB color space to HSV color space by the following formula:
in the formula, R, G, and B represent that the initial color information of the car light guide image is RGB values, and the converted HSV color space divides the color information of the car light guide into three elements: hue H (Hue), saturation S (Satution), and lightness V (value), where H ∈ [0,360], S ∈ [0,1], and V ∈ [0,1 ].
The three color channels of H, S, V are then quantized at unequal intervals to form a 72-bin color feature vector. The method for extracting the HSV color histogram feature vector of the car light guide comprises the following steps:
the three components of HSV are non-uniformly quantized according to the following method, wherein H space is divided into 8 grades, S is divided into 3 grades, and V is divided into 3 grades:
and constructing a one-dimensional feature vector. According to the quantization method, the color components are synthesized into a one-dimensional feature vector:
G=HQSQV+SQv+V
wherein QSAnd QVThe number of quantization levels, i.e. Q, for the components S and V, respectivelyS=3,QVIf 3, the formula translates to:
G=9H+3S+V
a 72-handle one-dimensional histogram of G, i.e. the color feature vector of the car light guide image, is thus obtained.
And step S40, sending the extracted HSV color feature vectors into a classifier model corresponding to the selected car light guide type, calculating to obtain a classification result of the light guide to be detected, and judging whether the light guide color is qualified.
In the embodiment, if the classification result is the standard color, the color is qualified, and if the classification result is other color cast, the color is unqualified, and meanwhile, the color difference condition of the light guide can be obtained according to the unqualified light guide color label, and the light guide is improved.
The method for detecting the car lamp light guide chromatic aberration comprises the steps of obtaining a car lamp light guide image, manufacturing a training image library and a learning classification model of the car lamp light guide, extracting a feature vector of the color of the car lamp light guide to be detected, sending the feature vector into a classifier model corresponding to the selected car lamp light guide type for classification detection, obtaining a classification result of the light guide to be detected, and determining that the light guide to be detected is qualified if the classification result is a standard color and determining that the light guide to be detected is unqualified if the classification result is other color cast. Therefore, the chromatic aberration detection of the car light guide is realized, and compared with the existing detection method, the method can improve the detection speed and the accuracy and reduce the production cost.
The present invention further provides a computer-readable storage medium, in this embodiment, a light guide color difference detection program is stored on the computer-readable storage medium, and the steps of the color difference detection method for a light guide of a vehicle lamp can be implemented.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.