Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to" determining "or" in response to detecting ". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
Furthermore, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used for distinguishing between descriptions and not necessarily for describing or implying relative importance.
Reference throughout this specification to "one embodiment" or "some embodiments," or the like, means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," or the like, in various places throughout this specification are not necessarily all referring to the same embodiment, but rather "one or more but not all embodiments" unless specifically stated otherwise. The terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless expressly specified otherwise. "plurality" means "two or more".
Example one
The embodiment of the application provides a water quality detection method, which can be executed by a processor of a terminal device when a corresponding computer program is operated, and is used for controlling a light source to emit a light beam to a water sample to be detected containing pollutants to be detected, collecting a spectrogram of the light beam penetrating through the water sample to be detected through a portable device, calculating a target color value of a pixel position corresponding to a target wavelength in the spectrogram, obtaining the detection concentration of the pollutants to be detected according to a preset functional relation based on the target color value, converting a chemical signal of the pollutants to be detected into a spectral signal, and then converting the spectral signal into a color signal, so that the detection accuracy is improved, and the rapid detection of the water quality on site can be realized through the light source and the portable device.
As shown in fig. 1, the water quality detection method provided by this embodiment includes the following steps S11 to S14:
s11, controlling the light source to emit light beams to the water sample to be detected containing the pollutants to be detected.
In application, the light source is controlled to emit a light beam to a water sample to be tested containing a contaminant to be tested, the light source 201 in the water quality detection system shown in fig. 2 may be controlled to emit a light beam to a water sample to be tested containing a contaminant to be tested, the light source 201 may be a fixed light source such as a quartz halogen tungsten lamp, and the light beam emitted by the light source 201 passes through a slit 202 with a width of 1mm and then is emitted to a cuvette 203 containing the water sample to be tested. Optionally, the pollutant to be detected may be ammonia nitrogen.
And S12, collecting a spectrogram of the light beam penetrating through the water sample to be detected through the portable equipment.
In application, the spectrogram obtained by collecting the light beam through the portable device after penetrating through the water sample to be tested can be obtained by collecting the spectrogram obtained by collecting the light beam through the portable device 204 in the water quality detection system shown in fig. 2 after penetrating through the water sample to be tested, the portable device 204 can be a device with a photographing function, such as a smart phone, and the light beam penetrates through the cuvette 203 containing the water sample to be tested and is projected onto the grating 205 to be decomposed into spectral bands, the spectral bands are collected by the camera of the portable device 204 to be photographed into a photo, the photo collected by the portable device 204 is captured by capturing software to obtain an effective area of the photo, and the effective area is a visible light spectral band in the photo, so that the spectrogram is obtained.
And S13, calculating a target color value of a pixel position corresponding to the target wavelength in the spectrogram.
In an application, the target color value may be an RGB value related to the contaminant to be detected, and specifically, may be a complementary color of a water sample to be detected containing the contaminant to be detected. Optionally, the pollutant to be detected is ammonia nitrogen, the color of the water sample to be detected containing ammonia nitrogen is yellow, the complementary color of the yellow is blue, and the target color value of the ammonia nitrogen is the B value. Along with the higher ammonia nitrogen concentration, the deeper the color of the water sample to be detected, the more the light beam is absorbed, and the color of the blue wave band in the spectrogram is gradually weakened. The above-mentioned target wavelength is a wavelength at which the absorbance is maximum, which is known in advance. After the spectrogram is collected, the target color value of the pixel position corresponding to the target wavelength can be calculated through matlab.
And S14, obtaining the detection concentration of the pollutant to be detected according to a preset function relation based on the target color value.
In an application, the preset functional relationship may be a pre-established functional relationship between a target color value of a pixel position corresponding to the target wavelength and the concentration of the contaminant to be detected, and specifically, may be a negative correlation relationship. Optionally, the pollutant to be detected is ammonia nitrogen, and the value B of the pixel position corresponding to the target wavelength is substituted into the preset functional relation, so that the detection concentration of the ammonia nitrogen can be obtained.
The water quality detection method provided by the embodiment of the application comprises the steps of emitting a light beam to a water sample to be detected containing pollutants to be detected by controlling a light source, collecting a spectrogram after the light beam penetrates through the water sample to be detected by a portable device, calculating a target color value of a pixel position corresponding to a target wavelength in the spectrogram, obtaining the detection concentration of the pollutants to be detected according to a preset functional relation based on the target color value, carrying out RGB color quantization on the absorption degree of the incident light by the water sample to be detected, converting a chemical signal of the pollutants to be detected into a spectral signal, converting the chemical signal into the color signal, realizing quantitative analysis of substances, improving the accuracy of detection, and realizing the field rapid detection of water quality by the light source and the portable device.
Example two
The second embodiment of the present application provides a water quality detection method implemented based on the first embodiment, which can be executed by a processor of a terminal device when running a corresponding computer program.
In one embodiment, before step S23, the method includes: preparing test water samples containing pollutants to be tested with different concentrations; controlling the light source to respectively emit light beams to the test water samples with different concentrations; respectively collecting spectrograms of light beams penetrating through test water samples with different concentrations by portable equipment; and according to the spectrograms of the test water samples with different concentrations, taking the wavelength corresponding to the pixel position with the maximum target color value change as the target wavelength.
Optionally, according to spectrograms of test water samples of different concentrations, taking a wavelength corresponding to a pixel position where a target color value changes most as a target wavelength, including: respectively calculating target color values of pixel positions corresponding to different wavelengths in spectrograms of test water samples with different concentrations; and taking the wavelength corresponding to the pixel position with the maximum target color value change as the target wavelength.
In application, 0.00 mL, 2.50 mL, 5.00 mL, 7.50 mL, 10.0 mL and 12.5mL of ammonia nitrogen standard solution (10 ug/mL) can be respectively measured and put into 6 50mL cuvettes, deionized water is respectively added to dilute the solution to a scale, 1mL of potassium sodium tartrate solution is respectively added into each cuvette, the cuvette is evenly shaken, 1.5mL of Nashin reagent is added, the cuvette is evenly shaken, and finally the cuvette is placed for 10min to obtain 6 test water samples. The water quality detection system shown in fig. 2 is used for analyzing the test water sample and calculating the B values of the pixel positions corresponding to different wavelengths. As shown in fig. 3, a spectrogram of the test water sample is converted into a graph of a wavelength and a B value, a wavelength corresponding to a pixel position where the B value changes most is screened out, and the maximum absorption wavelength of the test water sample is obtained as 432nm, which is then used as a target wavelength.
In one embodiment, step S24 is preceded by: according to spectrograms of test water samples with different concentrations, acquiring a corresponding relation between a target color value of a pixel position corresponding to a target wavelength and the concentration of a pollutant to be tested; and performing linear fitting according to the corresponding relation to obtain a preset functional relation.
In application, as shown in fig. 4, after the target wavelength is obtained, points can be plotted in a coordinate system by taking different ammonia nitrogen concentrations as abscissa and taking the B value of the pixel position corresponding to the target wavelength under different ammonia nitrogen concentrations as ordinate, and linear fitting is performed on the points, so as to obtain the preset functional relationship.
In one embodiment, the water quality detection method further comprises: controlling a discontinuous light source to emit light beams to a test water sample containing pollutants to be tested; acquiring a non-continuous spectrogram of a light beam penetrating through a test water sample by using portable equipment; and obtaining the corresponding relation between the wavelength and the pixel position in the spectrogram according to the corresponding relation between the wavelength and the pixel position of the characteristic spectral line in the non-continuous spectrogram.
In application, in order to obtain wavelength information of a spectrogram, pixel positions of the spectrogram need to be converted into wavelengths, that is, a corresponding relationship between the pixel positions and the wavelengths needs to be found. The mercury lamp is a discontinuous light source, and has three characteristic spectral lines in a visible light range, wherein the three characteristic spectral lines are 435.83nm, 546.07nm and 578.02nm respectively. Replacing a quartz tungsten halogen lamp in the water quality detection system with a mercury lamp, shooting a discontinuous spectrogram of the mercury lamp, wherein a blue spectral line is 435.83nm and a green spectral line is 546.07nm, and obtaining a corresponding relation between a wavelength and a pixel position through the correspondence of the wavelengths of two characteristic spectral lines to the pixel position, so as to correct the pixel to the wavelength.
The water quality detection system provided by the embodiment of the application utilizes the principle of a spectrophotometry, combines the portable equipment with the spectrophotometry, namely combines the portable equipment with the light source, the grating and the slit to build a simple spectrophotometer, and provides possibility for rapid detection of water quality on site. The water quality detection method provided by the embodiment of the application is suitable for detecting pollutants which can be measured by a spectrophotometry, has the advantages of high efficiency, convenience, low cost and the like, can realize the field rapid detection of water quality, has higher detection accuracy than a common field rapid detection method, has accuracy not lower than that of a traditional spectrophotometry, and provides a positive effect for the rapid detection in the fields of environmental monitoring and environmental law enforcement.
EXAMPLE III
As shown in fig. 5, the present embodiment further provides a water quality detecting apparatus 500, including:
the light beam emission module 501 is used for controlling a light source to emit light beams to a water sample to be detected containing pollutants to be detected;
the spectrum acquisition module 502 is used for acquiring a spectrogram of a light beam penetrating through a water sample to be detected through intelligent equipment;
the color value calculation module 503 is configured to calculate a target color value of a pixel position corresponding to a target wavelength in the spectrogram;
and the concentration detection module 504 is configured to obtain the detection concentration of the to-be-detected pollutant according to a preset functional relationship based on the target color value.
Optionally, the water quality detecting device 500 further includes:
the test water sample configuration module is used for configuring test water samples containing pollutants to be tested with different concentrations;
the test light beam emitting module is used for controlling the light source to respectively emit light beams to the test water samples with different concentrations;
the test spectrum acquisition module is used for respectively acquiring spectrograms of light beams penetrating through test water samples with different concentrations through the portable equipment;
and the target wavelength acquisition module is used for taking the wavelength corresponding to the pixel position with the maximum target color value change as the target wavelength according to the spectrograms of the test water samples with different concentrations.
Optionally, the target wavelength obtaining module includes:
the target color value calculating unit is used for respectively calculating target color values of pixel positions corresponding to different wavelengths in spectrograms of the test water samples with different concentrations;
and the target wavelength acquisition unit is used for taking the wavelength corresponding to the pixel position with the maximum target color value change as the target wavelength.
Optionally, the water quality detecting device 500 further includes:
the corresponding relation acquisition module is used for acquiring the corresponding relation between the target color value of the pixel position corresponding to the target wavelength and the concentration of the pollutant to be detected according to the spectrograms of the test water samples with different concentrations;
and the functional relation obtaining module is used for performing linear fitting according to the corresponding relation to obtain a preset functional relation.
Optionally, the water quality detecting device 500 further includes:
the discontinuous light source sending module is used for controlling the discontinuous light source to emit light beams to a test water sample containing pollutants to be tested;
the discontinuous spectrum acquisition module is used for acquiring a discontinuous spectrum after the light beam penetrates through the test water sample through the portable equipment;
and the wavelength pixel corresponding relation acquisition module is used for acquiring the corresponding relation between the wavelength and the pixel position in the spectrogram according to the corresponding relation between the wavelength and the pixel position of the characteristic spectral line in the non-continuous spectrogram.
Optionally, the pollutant to be detected comprises ammonia nitrogen, and the target color value comprises a B value.
It should be noted that, for the information interaction, execution process, and other contents between the above-mentioned devices/units, the specific functions and technical effects thereof are based on the same concept as those of the embodiment of the method of the present application, and specific reference may be made to the part of the embodiment of the method, which is not described herein again.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
An embodiment of the present application further provides a terminal device 600, as shown in fig. 6, which includes a memory 601, a processor 602, and a computer program 603 stored in the memory 601 and executable on the processor 602, and when the processor 602 executes the computer program 603, the steps of the water quality detection method provided in the first aspect are implemented.
In an application, the terminal device may include, but is not limited to, a processor and a memory, fig. 6 is only an example of the terminal device and does not constitute a limitation of the terminal device, and may include more or less components than those shown, or combine some components, or different components, such as an input output device, a network access device, and the like. The input and output devices may include a camera, an audio capture/playback device, a display screen, and the like. The network access device may include a network module for wireless networking with external devices.
In an Application, the Processor may be a Central Processing Unit (CPU), and the Processor may also be other general purpose processors, digital Signal Processors (DSPs), application Specific Integrated Circuits (ASICs), field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, and the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
In application, the storage may be an internal storage unit of the terminal device in some embodiments, for example, a hard disk or a memory of the terminal device. The memory may also be an external storage device of the terminal device in other embodiments, for example, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), etc. provided on the terminal device. The memory may also include both internal and external storage units of the terminal device. The memory is used for storing an operating system, an application program, a Boot Loader (Boot Loader), data, and other programs, such as program codes of computer programs. The memory may also be used to temporarily store data that has been output or is to be output.
The embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments may be implemented.
All or part of the flow of the method of the embodiments described above can be implemented by a computer program that can be stored in a computer-readable storage medium and that, when executed by a processor, can implement the steps of the method embodiments described above. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer readable medium may include at least: any entity or device capable of carrying computer program code to a terminal device, recording medium, computer Memory, read-Only Memory (ROM), random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, and software distribution medium. Such as a usb-disk, a removable hard disk, a magnetic or optical disk, etc.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative devices and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described embodiments of the apparatus are merely illustrative, and in addition, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of the apparatus, and may be in an electrical, mechanical or other form.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.