A kind of intelligence water gauge recognition methods
Technical field
The present invention relates to water level monitoring technical fields, specifically, being related to a kind of intelligent water gauge recognition methods.
Background technique
Water level monitoring is of great significance for the important monitoring index of the water bodys such as river, river, reservoir.In the prior art,
Conventional water level monitoring method has sensor monitoring and water-level measuring post personal monitoring.Wherein, water-saving to reach in terms of water gauge identification
Purpose, using the method for video image monitoring to river, irrigate the water level in canal and monitor in real time.It is read although with artificial
The method of video can recorde the data such as the water level of water gauge, but due to monitoring point enormous amount, recording personnel's attention cannot grow
Time concentrates, and in face of so many monitoring image, often due to the carelessness of record personnel, input when may be generated
Situations such as fault.There are also the methods of many automatic identification water gauges, such as:
The Chinese patent literature that publication No. is CN101886942A discloses a kind of water gauge identification method and water level detecting side
Method, this method shoot water gauge using video image, then achieve the purpose that detection, but the party by the identification to image
Method is needed using specific scale, and application range is very limited.
In addition, publication No. be CN102975826A Chinese patent literature disclose it is a kind of based on the portable of machine vision
Shipping depth gauge detects automatically and recognition methods, and this method uses machine vision and image processing techniques, to ship under offshore environment
Water gauge video data is handled, and detects and identify shipping depth gauge scale, and count to the testing result of video successive frame
Analysis, finally obtains drauht value.Publication No. is that the Chinese patent literature of CN105046212A discloses a kind of waterline scale
Automatic identifying method, this method obtain the packet in water surface line of demarcation or more by the water surface line of demarcation in criterion of identification sample image
The water gauge digital picture of aqueous footage word obtains water gauge scale into identification.And publication No. is the China of CN108318101A
Patent document discloses a kind of water gauge water level video intelligent monitoring method based on deep learning algorithm and system, this method include
Video acquisition, video frame processing, water level line identification and water level measuring and calculating and etc..It is supervised using deep learning neural fusion water level
The intelligence and automation of survey.
Although above method is able to achieve the automation of water level monitoring without specific scale, water level is being carried out
It only considered the opaque situation of water turbidity during monitoring, when water quality is limpid, the color and water level line of water are not easy to know
Bigger error is had when other, therefore use scope is caused to be restricted.
Summary of the invention
It is an object of the present invention to provide a kind of intelligent water gauge recognition methods, this method during carrying out water level monitoring,
The opaque situation of water turbidity can be not only identified, water quality is limpid, color of water and water level line do not allow situation easy to identify
Under also can be carried out efficient identification.
To achieve the goals above, intelligent water gauge recognition methods provided by the invention the following steps are included:
1) water gauge image is acquired, and all water gauge images are divided into training set and verifying collection;Filter out the water in training set
Ruler image extracts, and obtains the target area of water gauge;
2) width of water gauge is set as a, using a length of 2a, width intercepts the target area for the rectangle of 2a with a fixed step size,
The part under guaranteeing to intercept is needed to be no more than the left and right edges of water gauge during interception;
3) using the image more than water surface of interception as positive sample, water surface image below is corresponded to as negative sample, deposit
Water gauge scale value data set in;
4) the corresponding data set training neural network model of all water gauge scale values is utilized;
5) target area for intercepting water gauge image to be identified uses trained neural network mould after step 2) processing
Type judges water level, and image is stored in the data set of corresponding water gauge scale value.
In above-mentioned technical proposal, using video image automatic identification, self registering method, artificial work can be not only reduced
It measures, and accurately and timely can be automatically stored and be shown.Since the amount of images of water gauge is relatively fewer, using random
The method for sampling small rectangle can be repeated as many times and utilize same image, and guarantee the diversity of sample, so that the model of training
Robustness is stronger.
Specifically, step 1) further include: random augmentation is carried out to the water gauge image of acquisition, and will be schemed using bilinear interpolation
Piece is adjusted to fixed size, and image is normalized.
Carrying out random augmentation to picture includes at random plus dry, random brightness adjustment, random cropping, random mirror image reversal etc.;
Image normalization can speed the speed of neural metwork training.
Specifically, the color characteristic in step 1) by water gauge determines the target area of water gauge;If there are multiple regions, lead to
The size in region is crossed, length-width ratio is screened;If still there is multiple regions, calculate in each region the mean value and variance of pixel with
Water gauge region in training set compares, and selects immediate region.
When actually identifying water gauge water level, water gauge image needs to be tested are placed on verifying and concentrate.Confirm water gauge region
Method be mainly reading by the color characteristic of water gauge, on water gauge and scale is blue or red, this color will be met
The region of feature scans for.
Specifically, step 3) further include: the positive sample and the negative sample are divided into instruction respectively with the ratio of 1:1
Practice collection and test set, and the corresponding water gauge scale value of truncated picture is converted into binary file storage, convenient for training
When data reading.
Specifically, include: using the method for data set training neural network model in step 4)
4-1) weight of convolutional layer and full articulamentum is initialized using xavier initialization, while setting super ginseng
Number;The purpose of initialization is to allow neural network to acquire useful information in study, and hyper parameter includes learning rate, batch_
Size, epoch etc.;
4-2) picture in data set is put into convolutional neural networks and is trained, which successively includes
Output layer, the first convolutional layer, the first pond layer, the second convolutional layer, the second pond layer, the first full articulamentum, the second full articulamentum
With Loss layers, output result be 2 neurons;
Loss 4-3) is calculated using softmax function, then gradient is calculated by gradient descent method, uses back-propagation algorithm
Disease gradient updates the parameter of neural network;
4-4) train neural network until the loss of test set no longer declines.
Specifically, step 4-2) in input layer input be size be 20x20x3 RGB three-dimensional matrice;First convolutional layer
Convolution kernel size be 5x5, step-length 1, dimension 3x96;The size of the convolution kernel of second convolutional layer is 3x3, step-length 1, dimension
Degree is 96x256;The size of the Chi Huahe of first pond layer is 2x2, and step-length 2, the feature sizes of Chi Huahou are 10x10x96;
The size of the Chi Huahe of second pond layer is 2x2, and step-length 2, the feature sizes of Chi Huahou are 5x5x256;First full articulamentum
Input neuron be 6400, output neuron be 512, drop out be 0.5;The input neuron of second articulamentum is
512, output neuron is 2.Specifically, step 4-4) in training neural network when, first use high
Learning rate when training tends towards stability to loss, is declined 10 times, continues to train, and repeat aforesaid operations twice by habit rate.
Specifically, the method for water level is judged in step 5) using neural network model are as follows:
It sets the width of the target area of water gauge image to be identified 5-1) as b, target area is divided into m a length of b, width is
The fritter of b is sent among neural network after each fritter is adjusted to fixed size, judges the region by the output of full articulamentum
Whether under water;
It 5-2) finds from waterborne and is converted into two underwater critical zones, then the two regions are divided into n a length of c, it is wide
For the fritter of b, wherein n*c=2b;
It is put into after fritter 5-3) is adjusted to the input size of neural network in order from top to bottom, passes through full articulamentum
Whether under water output judge the region, when it is underwater for exporting result, the Y coordinate of fritter at this time is recorded, according to coordinate
Calculate the height of water level.
Step 5-1) it is used as coarse adjustment, can quickly position the Position Approximate of water level line, claim 5-2)~5-3) it is thin
It adjusts, keeps the position of water level line more accurate.
Specifically, c takes b/8.Improve the accuracy of identification.
Compared with prior art, the invention has the benefit that
The accuracy of intelligent water gauge recognition methods in example of the present invention is higher, strong antijamming capability, to environment and camera picture
The requirement of element is lower.It can not be illuminated by the light intensity substantially using the water level identification of water gauge in outdoor environment, leaf blocks,
The influence of the natural causes such as rainy.Even if camera distance equally can be identified precisely farther out, color limpid for water quality, water
Situation easy to identify is not allowed with water level line, can be carried out efficient identification yet.
Detailed description of the invention
Fig. 1 is the flow chart of the intelligent water gauge recognition methods of the embodiment of the present invention;
Fig. 2 is water gauge picture to be identified in the embodiment of the present invention;
Fig. 3 is the water gauge picture extracted in the embodiment of the present invention;
Fig. 4 is the picture of water gauge to be identified in the embodiment of the present invention;
Fig. 5 is the picture extracted in the embodiment of the present invention as data set positive sample;
Fig. 6 is the picture extracted in the embodiment of the present invention as data set negative sample;
Fig. 7 is convolutional neural networks of embodiment of the present invention structure chart;
Fig. 8 is water gauge picture to be identified when the water surface is more muddy of the embodiment of the present invention;
Fig. 9 is water gauge picture to be identified when the water surface is more limpid of the embodiment of the present invention;
Figure 10 is the picture of water gauge to be identified when the water surface of the embodiment of the present invention is very limpid.
Specific embodiment
To make the object, technical solutions and advantages of the present invention clearer, with reference to embodiments and its attached drawing is to this hair
It is bright to be described further.
Embodiment
Referring to fig. 2, after the specific image of certain water level to be identified is extracted as shown in Figure 3.It is needed when processing by picture point
, with underwater two parts, to calculate water level at that time on the water surface further according to the position of water level line, reaching real-time automatic monitoring water
The purpose of position.
Referring to Fig. 1, the intelligent water gauge recognition methods of the present embodiment the following steps are included:
Picture in the database of water gauge is divided into training set to S1 and verifying collects, and filters out from training set relatively clear
Picture, as shown in figure 4, the width of water gauge be a.With a length of 2a, width is that the rectangle of 2a size is intercepted at random from figure in the water surface
The water gauge of top guarantees that the part under interception is no more than the left and right edges of water gauge, and not comprising underwater portion, as shown in Figure 5.It will
Positive sample of the picture intercepted as data set.
S2 selects picture at random from training set, and equally with a length of 2a, width is that the rectangle of 2a intercepts water gauge underwater at random
Picture, as shown in Figure 6.Using picture as the negative sample of data set.
Positive negative sample is divided into training set and test set respectively with the ratio of 1:1 by S3, and image and label are converted to two
Binary file storage, convenient for the reading of data when training.
S4 reads image data from data set, carries out random augmentation to picture, including at random plus dry, random brightness
Adjustment, random cropping, random mirror image reversal etc..Picture is adjusted to fixed size using bilinear interpolation.Image is returned
One changes, and image normalization can speed the speed of neural metwork training.
S5 using xavier initialization the weight of convolutional layer and full articulamentum is initialized, the purpose of initialization be for
The neural network is allowed to acquire useful information in study.Hyper parameter is set simultaneously, including learning rate, batch_
Size, epoch etc..
The picture handled well is put into convolutional neural networks and is trained by S6.The construction of the convolutional neural networks such as Fig. 7
Shown, for the data set of water level identification, the convolutional neural networks model that this example uses has eight layers (comprising input and output layer) altogether.
Wherein first layer is input layer, and input is RGB three-dimensional matrice that size is 20x20x3.Before training, first by input picture into
Row random cropping, at random plus dry, random mirror face turning, input of the renormalization to [0,1] as network.The second layer is convolution
The convolution kernel size of layer, the convolutional layer is 5x5, and the weight of step-length 1, dimension 3x96, convolution kernel is initialized using xavier,
Bias term is 0.The feature sizes obtained after convolution are 20x20x96.Third layer is pond layer, and using maximum pond, Chi Huahe's is big
Small is 2x2, step-length 2.Feature sizes behind pond are 10x10x96.4th layer is convolutional layer, and the size of convolution kernel is 3x3,
Step-length is 1, and the weight of dimension 96x256, convolution kernel are initialized using xavier, bias term 0.Feature sizes after convolution
For 10x10x256.Layer 5 is pond layer, and using maximum pond, the size of Chi Huahe is 2x2, step-length 2.Feature behind pond
Size is 5x5x256.Layer 6 is full articulamentum, and input neuron is 6400, and output neuron is 512, drop out
It is 0.5.Layer 7 is full articulamentum, and input neuron is 512, and output neuron is 2.8th layer is Loss layers, is used
SOFTMAX calculates loss, and stochastic gradient descent carries out backpropagation.
S7 training neural network no longer declines until the loss of test set.
S8 is concentrated from verifying and is chosen picture as shown in Figure 8, and the region where water gauge is determined by the color characteristic of water gauge.
S9 sets the width in region as b, and by region segmentation at m a length of b, width is the fritter of b.Fritter is adjusted to fixed big
It is sent among neural network after small, whether judge that the region belongs to by the output of full articulamentum is under water.
S10 finds from waterborne and is converted into two underwater critical zones, then the two regions are divided into n a length of c, and width is
The fritter of b, wherein n*c=2b.It is put into after fritter is adjusted to the input size of neural network in order from top to bottom, by complete
Whether it is under water that the output of articulamentum judges that the region belongs to.When it is underwater for exporting result, by the Y coordinate of fritter at this time
Record, the height of water level is calculated according to coordinate.
This example uses data augmentation method, joined more random factors, so that model anti-interference ability is reinforced, and not
It is easy over-fitting.Neural network structure in this example can according to need adjustment, increase the number of plies of network and the dimension of convolution kernel
The effect of classification can be enhanced.In this example, when training neural network, a higher learning rate, training are used first
When tending towards stability to loss, learning rate is declined 10 times, continues to train, repeats aforesaid operations twice, it is available more satisfactory
Result.
If identifying the water level value of picture shown in Fig. 9, Fig. 9 is chosen, repeats step S8 to step S10, Figure 10 also one
Sample.When recognition result shows the water gauge figure such as Fig. 8, the water surface is more muddy, and discrimination is higher up and down for the water surface, and error can be in 1cm
Within;As Fig. 9 water gauge figure when, the water surface is more limpid, and error is generally in 1~3cm;As Figure 10 water gauge figure when, the water surface is very
When limpid, it is easy to produce biggish error, generally in 3~5cm.It should be noted that this result is that due to currently scheming
Caused by sheet data amount is also considerably less, when image data reaches certain quantity, then its precision can greatly improve.Compared to
The method of others image recognition water gauge at present, precision of the invention is high, and strong antijamming capability wants environment and camera pixel
Ask low.
When actually identifying water gauge water level, the image needs of water gauge to be tested are placed on verifying and concentrate.Water is confirmed in step S8
The method of ruler region is mainly the color characteristic by water gauge, and the reading and scale on water gauge are blue or red, will
The region for meeting this color characteristic in step S8 scans for.If there is multiple regions, by the size in region, length-width ratio is carried out
Screening.If still there are multiple regions, calculates the mean value with variance of pixel in each region and oppose with the water gauge region in training set
Than selecting immediate region.This example obtains the coordinate of water level line using two steps of step S9 and step S10, wherein walking
Rapid S9 can quickly position the Position Approximate of water level line as coarse adjustment, and step S10 is fine tuning, and speed is slower, but is positioned more
Precisely.Wherein the accuracy of step S10 is influenced by the size of c, and c takes effect when b/8 preferable in test.