Disclosure of Invention
Aiming at the technical problems, the application provides an automatic control water changing method for aquaculture based on image processing, which comprises the following steps:
acquiring a water body image to be analyzed and a checkerboard image of an aquaculture space, wherein the checkerboard image is a checkerboard image photographed by placing a black-white checkerboard in the water body of the aquaculture space;
obtaining a tone value of each pixel point in the HIS color space in the water body image to be analyzed and the frequency of each tone value, calculating the water body chromaticity of the water body to be analyzed, and obtaining a water body chromaticity difference factor by utilizing the obtained water body chromaticity of the water body to be analyzed;
performing edge detection on the checkerboard image to obtain a checkerboard edge image, acquiring gray values of each edge line pixel point and neighborhood pixel points thereof on the checkerboard edge image in the checkerboard image, and calculating gray variation degree of each edge line pixel point;
calculating the water transparency of the water to be analyzed according to the gray level change degree of each edge line pixel point in the checkerboard edge image, and obtaining a water transparency judgment coefficient by utilizing the water transparency of the water to be analyzed under different conditions;
acquiring continuous multi-frame aquaculture space surface images, marking surrounding frames of the culture in each frame of aquaculture space surface images by using a target detection network, and obtaining culture floating surface characteristic parameters according to the number of the surrounding frames in each frame of aquaculture space surface images;
acquiring a water quality factor of an aquaculture space by combining the acquired water chromaticity difference factor, the water transparency judgment coefficient and the characteristic parameters of the floating surface of the culture with the pH value offset of the water to be analyzed;
and automatically controlling water change for aquaculture according to the water quality factor of the aquaculture space and the aquaculture space capacity.
The method for automatically controlling water changing of the aquaculture according to the water quality factor of the aquaculture space and the aquaculture space capacity comprises the following steps:
setting a water quality threshold, and when the water quality factor is smaller than the water quality threshold, not changing water in the aquaculture space;
when the water quality factor is greater than or equal to the water quality threshold, calculating the water change amount according to the capacity of the aquaculture space and the water quality factor, and changing the water of the aquaculture space according to the obtained water change amount to ensure that the water quality of the aquaculture space meets the requirements for survival of the culture;
the formula for calculating the water conversion amount according to the aquaculture space capacity and the water quality factor of the aquaculture space is as follows:
V′=δ×V
wherein: v' is the water change amount required by the aquaculture space, delta is the water quality factor of the aquaculture space, V is the aquaculture space capacity of the aquaculture space, and the product of the water quality factor of the water body cultivation space and the aquaculture space capacity is taken as the water change amount of the water body cultivation space because the water quality factor of the water body cultivation space is larger, the water quality of the water body cultivation space is worse, and the water change amount is more.
The formula of the water quality factor of the aquaculture space is as follows:
δ=ΔPH×(ρ×(d+ε -w ))
wherein: delta represents the water quality factor of the aquaculture space, d represents the water chromaticity difference factor, epsilon represents the water transparency judgment coefficient, w is a model parameter, wherein delta PH is the offset of the water PH value of the aquaculture space relative to the PH value of a standard aquaculture water, delta PH=PH' -PH, and the water pH value of the aquaculture space is taken into consideration to be a key factor of a breeder in the aquaculture water changing process, so that the water quality condition is accurately regulated and controlled through the water pH value of the aquaculture space.
The process for obtaining the water chromaticity difference factor comprises the following steps:
performing HIS color space conversion on the water body image to be analyzed, extracting tone values in the HIS color space in the water body image to be analyzed, counting the frequency of each tone, and obtaining the average value of K tone values with the highest frequency as the water body chromaticity of the water body to be analyzed;
obtaining a water body chromaticity difference factor according to the standard water body chromaticity range of the aquaculture space and the water body chromaticity of the water body to be analyzed, wherein the expression of the water body chromaticity difference factor is as follows:
wherein: d represents the chromaticity difference factor of the water body,for the water chromaticity of the water to be analyzed, +.>Representing a standard water chromaticity range for an aquaculture space.
The method for calculating the gray level change degree of each edge line pixel point comprises the following steps:
and acquiring gray values of each pixel point on the edge line and the pixels in the four neighborhoods of the pixel points in the edge line in the checkerboard edge image, and taking the average value of absolute values of differences between each pixel point on the edge line and the pixels in the four neighborhoods as the gray change degree of the pixel points on the edge line.
The method for acquiring the water transparency judgment coefficient comprises the following steps:
and obtaining a water transparency judgment coefficient by utilizing the water transparency of the water to be analyzed, wherein the water transparency judgment coefficient is expressed as follows:
where epsilon represents the water transparency determination coefficient,a standard water transparency range representing the aquaculture space, < > is provided>Indicating the water transparency of the water to be analyzed.
The method for calculating the water transparency of the water to be analyzed comprises the following steps:
the gray level change degree of each edge line pixel point in the checkerboard image is obtained, the average value of the gray level change degrees of the obtained edge line pixel points is used as a gray level change index, the water transparency of the water to be analyzed is calculated according to the gray level change index, and the calculation formula is as follows:
wherein:representing the transparency of the water body to be analyzed, wherein e is a natural logarithmic base number and +.>Represents the gray scale change index.
The method for obtaining the characteristic parameters of the floating surface of the culture according to the number of bounding boxes in the surface image of each frame of aquaculture space comprises the following steps:
acquiring shot continuous multi-frame aquaculture space surface images, regarding tag data obtained by each frame of aquaculture space surface image through a target detection network, and taking the average value of the number of bounding boxes of the tag data in all aquaculture space surface images as the number of aquaculture floating surfaces on the aquaculture space surface;
obtaining the characteristic parameters of the floating surfaces of the aquaculture space according to the quantity of the floating surfaces of the aquaculture space, wherein the expression of the characteristic parameters of the floating surfaces of the aquaculture space is as follows:
wherein: ρ represents the characteristic parameters of the floating surface of the culture,representing the number of aquaculture surfaces on the surface of an aquaculture space.
Compared with the prior art, the embodiment of the application has the beneficial effects that:
1. according to the application, the tone value of the water body image in the HIS color space is obtained by analyzing the water body image in the aquaculture space, the water body chromaticity of the water body to be analyzed is calculated according to each tone value and the frequency thereof, the water body chromaticity difference factor is calculated by utilizing the obtained water body chromaticity of the water body to be analyzed, the water body transparency of the water body to be analyzed is calculated by utilizing the gray level change degree of each edge line pixel point in the checkerboard edge image, the water body transparency judgment coefficient is obtained by utilizing the water body transparency of the water body to be analyzed, and the water quality condition of the aquaculture space is more accurate by utilizing the water body chromaticity of the water body to be analyzed and the water body transparency judgment coefficient.
2. According to the application, the water change amount required by the aquaculture space is determined by the finally obtained water quality factor and the aquaculture space capacity, and the aquaculture space is changed according to the water change amount required by the aquaculture space, so that the water quality of the aquaculture space can be ensured to be in a proper range in time to maintain the growth environment requirement of the aquaculture, and the aquaculture resources can be saved due to the proper water change amount.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
In the following description, for purposes of explanation and not limitation, specific details are set forth such as the particular system architecture, 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.
The terms "first," "second," and the like, are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first", "a second" may include one or more such features, either explicitly or implicitly; in the description of the present embodiment, unless otherwise specified, the meaning of "plurality" is two or more.
Example 1
The embodiment of the application provides an automatic control water changing method for aquaculture based on image processing, which is shown in fig. 1, and specifically comprises the following steps:
s101, acquiring a water body image to be analyzed
Firstly, an image acquisition device above a cultivation space is used for acquiring a cultivation space image as reference data for water body detection in a later cultivation space.
1. In order to realize comprehensive acquisition of the aquaculture space images, the embodiment is provided with image acquisition equipment, the image acquisition equipment comprises a camera, a light source and other devices, the camera is arranged above the aquaculture space, the image acquisition is carried out on the aquaculture space through a view angle of the camera in overlooking, and the image acquisition equipment can be set by practitioners such as a camera frame rate, a sampling time interval and the like according to actual conditions.
2. Firstly, the acquired aquaculture space image is segmented through a semantic segmentation network, and a water body area in the aquaculture space image is identified, wherein label data of the semantic segmentation network are as follows: the pixel values of the pixel points of the water body region are set to be 1, the pixel values of the pixel points of other background regions are set to be 0, and the loss function of network training is a cross entropy loss function, so that the extraction of the water body region in the image can be realized;
3. for the water body region, the embodiment performs multiplication operation on the semantic segmentation effect graph serving as a mask and the aquaculture space image to obtain an RGB image of the water body region, then the embodiment performs clustering analysis on the water body region based on a DBSCAN clustering algorithm, the specific clustering process is the prior known technology, and after clustering, for each cluster, the application takes the region corresponding to the cluster with the largest number of pixel points as the water body image to be analyzed, so that the large-range water body condition in the aquaculture space can be represented;
so far, the embodiment obtains the water body image to be analyzed of the aquaculture space.
S102, obtaining a water body chromaticity difference factor of the water body to be analyzed
In the embodiment, the influence of the color caused by plankton and dissolved organic matters in the water body on the water color is considered, and if the number of plankton in the water body is large, the color of the water body is greener and darker; if the organic matters in the water body are too much, the color of the water body is darkened, and different changes are found in the color of the water body, so that the embodiment can acquire the water body chromaticity difference factor as a water body chromaticity test index of the water body to be analyzed, and analyze the water body chromaticity of the culture space.
(1) Acquiring distribution of each tone level
The HIS color space conversion is carried out on the water body image to be analyzed to obtain the HIS color space of the water body image to be analyzed, the HIS model has the great advantages that the influence of the change of illumination intensity on color discrimination can be reduced, the color characteristics can be reduced from three dimensions to one dimension, the color information is not lost, the color space distribution can be integrally represented, and the color tone of the water body image to be analyzed is changed in consideration of the change of the water body in the culture space, so that the color tone level histogram is obtained by counting the color tone level of the water body image to be analyzed, and the frequency of each color tone level is obtained as the distribution condition of each color tone level.
The distribution of the tone levels, i.e., the frequency of each tone level, is calculated as follows:
wherein: p (h) k ) For the kth tone level h k Frequency of (h), N (h) k ) Represents the kth tone level h k K is the sequence number of the tone levels of the water body image to be analyzed, and M represents the number of the tone levels of the water body image to be analyzed.
(2) Obtaining a water body chromaticity difference factor of the water body to be analyzed
In order to accurately evaluate the chromaticity of the water body in the culture space, the embodiment performs filtering analysis on the tone level histogram, selects K tone levels with highest frequency from the tone level histogram to analyze the overall chromaticity of the water body so as to avoid influence of irrelevant color information, and then calculates the chromaticity of the water body according to the K tone levels with highest frequency to detect the color distribution condition of the water body, wherein the chromaticity of the water body is specifically:
wherein: τ represents the water chromaticity of the water to be analyzed, K represents the number of selected tone levels, a represents the sequence number of the tone levels selected by the water image to be analyzed, h a Representing water to be analyzedThe a-th tone level of the volume image selection.
The embodiment detects the water chromaticity distribution condition of the aquaculture space based on the water chromaticity to obtain the water chromaticity difference factor of the water to be analyzed, and the specific expression is as follows:
wherein: d represents the chromaticity difference factor of the water body,for the water chromaticity of the water to be analyzed, +.>Representing a standard water chromaticity range for an aquaculture space.
S103, acquiring checkerboard images of aquaculture space
According to the characteristics of the aquaculture space, the transparency of the water body in the aquaculture space is analyzed by considering that the transparency of the water body in the space is also an important index of the water quality condition of aquaculture. The transparency of the culture water body is too large or too small, and the culture water body has great influence on the growth of the cultured animals. The transparency is too large, so that the cultured organisms are easy to be in an unstable state, the stress reaction of the organisms is caused, plants such as the water floss and the like are easy to propagate, the pH value in the water is always maintained at a higher level through photosynthesis of the plants, and the toxicity of carbonate alkalinity is increased; the transparency is too small, which indicates that organic pollutants in the culture pond are increased, or the pond is eutrophicated, phytoplankton is overgrown, the water quality is easy to deteriorate, and the survival of the aquatic products is not facilitated, so that the occurrence of diseases of the culture is induced.
Therefore, the transparency of the water body in the aquaculture space is analyzed based on the aquaculture space image data, wherein the aquaculture space image data is a checkerboard image in the aquaculture space, a black-white checkerboard is placed at a position of 30cm to 80cm, and the black-white checkerboard is subjected to image acquisition through a camera to obtain checkerboard image data. It should be noted here that 30cm to 80cm is the best visibility of the water body in the culture space, and in this embodiment, the checkerboard is placed at the depth of 50cm for collecting the checkerboard image.
S104, calculating a water transparency judgment coefficient of the water to be analyzed
(1) Obtaining gray level change degree of pixel points of edge lines of checkerboard image
According to the fuzzy condition of the obtained checkerboard image, the embodiment performs edge detection on the checkerboard image by using a canny operator to obtain a checkerboard edge image and edge lines thereof so as to obtain edge information of the checkerboard in the checkerboard image.
For the obtained edge lines, extracting gray values of each edge line pixel point and four neighborhood pixels on the checkerboard image, and calculating gray variation degree of each edge line pixel point according to the obtained gray values of each edge line pixel point and four neighborhood pixels on the checkerboard image, wherein the calculation formula is as follows:
wherein: t (T) i The gray level change degree of the pixel point of the ith edge line is represented, i represents the serial number of the pixel point of the edge line, g i Representing the gray value g of the pixel point of the ith edge line l 、g r 、g U 、g D Respectively representing gray values of pixel points of the ith edge line pixel point in four adjacent domains in the checkerboard image, wherein g l G is the pixel point at the left side of the pixel point of the ith edge line r G is the pixel point on the right side of the pixel point of the ith edge line U Is the pixel point g above the pixel point of the ith edge line D Is the pixel point below the pixel point of the ith edge line.
(2) Calculating the transparency of the water body to be analyzed
The gray level change conditions of all edge line pixel points are obtained and used for detecting the checkerboard fuzzy condition; considering that the higher the transparency of the water body is, the more obvious the gray level change of the pixel points at the edge line of the checkerboard is; the lower the transparency is, the more serious the blurring phenomenon appears on the edge line of the checkerboard, so the embodiment analyzes the blurring degree of the edge line of the checkerboard based on the gray level change degree of the pixel points of the edge line on the edge line of the checkerboard image, and further determines the transparency of the water body to be analyzed, and the calculation formula of the transparency of the water body to be analyzed is as follows:
wherein:the transparency of the water body to be analyzed is represented, the transparency of the water body to be analyzed is considered to be higher as the function value is larger, e is a natural logarithmic base number, and the function value is +.>Represents the gray scale change index.
(3) Calculating the water transparency judgment coefficient
And obtaining a water transparency judgment coefficient by utilizing the water transparency of the water to be analyzed, wherein the water transparency judgment coefficient is expressed as follows:
wherein,represents the water transparency of the water to be analyzed, epsilon represents the water transparency judgment coefficient,representing standard water transparency range of aquaculture space, namely respectively placing chess and card grids at 80cm and 30cm to obtain corresponding water transparency as standard water transparency range, and taking min () as minimum value to operateNormalized, where the value of the guarantee function isAt (0, 1), the water transparency determination coefficient epsilon of the water to be analyzed is obtained (the value range is (0, 1)]) The closer the water body of the culture space is to the standard transparency index, the larger the transparency judgment coefficient is.
S105, calculating water quality factors of aquaculture space
In aquaculture, "floating head" is a common phenomenon, and a large amount of feed residues and excrement are piled up at the bottom of a cultivation box to cause excessive water and fertilizer in the cultivation box, so that the water temperature rises greatly in a high-temperature period, and a large amount of oxygen is decomposed by fermentation of fertilizer and organic piled up matters, so that the oxygen-deficient floating head is very easy to appear due to insufficient dissolved oxygen in water.
In the middle and later stages of cultivation, a large amount of toxic and harmful substances such as hydrogen sulfide, methane, ammonia nitrogen and the like accumulate in a pond to poison a water body, if abnormal conditions such as weather mutation and the like are met, layering phenomenon can occur in pond water, the dissolved oxygen of the whole pond becomes low, the toxic and harmful substances are obviously increased, fishy smell can be smelled when the pond stands down, and the water quality is deteriorated quickly.
The aquatic product floats to the water surface with higher oxygen content for oxygen inhalation because the dissolved oxygen content in water is lower and the water quality is deteriorated, so the embodiment analyzes the oxygen content of the water body in the culture space according to the condition of the floating surface of the culture, analyzes the water quality by taking the characteristic parameters of the floating surface of the culture as the judgment standard of the oxygen content, and judges whether new water needs to be added.
(1) Obtaining the characteristic parameters of the floating surface of the culture
In order to accurately detect the water quality of the culture space and extract a water quality factor accurately, the embodiment further detects the floating surface condition of the culture in the culture space, the embodiment acquires images of the surface of the culture space through a camera to acquire continuous multiframe culture space surface images for analyzing the floating surface condition of the culture, and the embodiment performs target identification on the culture in the culture space through a target detection network, wherein the tag data in the target detection network are the culture and the surrounding frame surrounded by the surrounding frame when the water surface is exposed and the water surface is jumped out, and data marking (x, y, w, h) is performed, and the specific target detection network and the specific process are the prior known technology.
Acquiring the number A of bounding boxes in the image data of each culture space surface image, and averaging the number average value of bounding boxes in the multi-frame culture space surface imageAs the number of the floating surfaces of the aquaculture space, calculating the characteristic parameters of the floating surfaces of the aquaculture, wherein the specific expression is as follows:
wherein: ρ represents the characteristic parameters of the floating surface of the culture,the number of floating surfaces of the culture representing the surface of the aquaculture space, namely the average value of the number of bounding boxes of the tag data in all the surface images of the aquaculture space.
(2) Calculating water quality factor of aquaculture space
And extracting the water quality factor of the aquaculture space based on the extracted water condition characteristic parameters, and correcting the water quality factor according to the culture floating surface characteristic parameters of the aquaculture space so as to accurately acquire the water condition of the aquaculture space.
The formula for calculating the water quality factor of the aquaculture space by combining the obtained water chromaticity difference factor, the water transparency judgment coefficient and the characteristic parameters of the floating surface of the aquaculture is as follows:
δ=ΔPH×(ρ×(d+ε -w ))
wherein: delta represents the water quality factor of the aquaculture space, d represents the water chromaticity difference factor, epsilon represents the water transparency judgment coefficient, w is a model parameter, wherein delta PH is the offset of the water PH value of the aquaculture space relative to the PH value of a standard aquaculture water, delta PH=PH' -PH, and the water pH value of the aquaculture space is taken into consideration to be a key factor of a breeder in the aquaculture water changing process, so that the water quality condition is accurately regulated and controlled through the water pH value of the aquaculture space.
So far, the water quality factor of the aquaculture space is obtained, and the larger the water quality factor is, the worse the water quality of the aquaculture space is, the lower the water requirement of the aquaculture space can be met, and the water changing operation is needed. And (3) carrying out normalization treatment on the water quality factor model, wherein the value of the guarantee function is (0, 1), so that the calculated amount is reduced.
S106, automatically changing water in aquaculture space
The water quality factor is extracted, and the water changing condition of the aquaculture space is automatically controlled based on the water quality factor.
Setting a water quality threshold, in this embodiment
When the water quality factor is less than the water quality threshold, i.eWhen the aquaculture space is not required to be changed;
when the water quality factor is greater than or equal to the water quality threshold, namelyCalculating water exchange amount according to the capacity of the aquaculture space and the water quality factor of the aquaculture space, and changing water of the aquaculture space according to the obtained water exchange amount to ensure that the water quality of the aquaculture space meets the living requirement of the culture;
the formula for calculating the water conversion amount according to the aquaculture space capacity and the water quality factor of the aquaculture space is as follows:
V′=δ×V
wherein: v' is the water change amount required by the aquaculture space, delta is the water quality factor of the aquaculture space, V is the aquaculture space capacity of the aquaculture space, and the product of the water quality factor of the water body cultivation space and the aquaculture space capacity is taken as the water change amount of the aquaculture space because the water quality factor of the water body cultivation space is larger, the water quality of the water body cultivation space is worse, and the water change amount is more.
The water quality factor of the aquaculture space and the water change amount required by the aquaculture space are sent to a controller from a data processing unit, the controller receives the water quality factor sent by the data processing unit and the water change amount required by the aquaculture space, controls a water pump outside the aquaculture space to extract and discharge the water change amount required by the aquaculture space in the aquaculture space, and simultaneously utilizes the other water pump to extract the new water in a water change well to fill the water extracted by the aquaculture space, wherein the water amount of the new water in the water change well is the water change amount required by the aquaculture space.
So far, the water quality factor extracted by the embodiment can be based on, and the self-adaptive implementation can automatically change water in the water body of the aquaculture space.
The foregoing description of the preferred embodiments of the application is not intended to be limiting, but rather is intended to cover all modifications, equivalents, alternatives, and improvements that fall within the spirit and scope of the application.