Method and device for measuring sugar content of fruits, computer equipment and storage medium
A measurement method, technology of fruit sugar, applied in the direction of measuring device, computer parts, image detector method and image signal processing, etc., can solve the problems of fruit damage and low efficiency of sugar content
Pending Publication Date: 2020-08-18
AGRI INFORMATION INST OF CAS
3 Cites 2 Cited by
AI-Extracted Technical Summary
Problems solved by technology
Therefore, the efficiency of measuring the sugar content of the fruit by ...
Abstract
The invention discloses a method and device for measuring the sugar content of fruits, computer equipment and a storage medium, relates to the technical field of sugar content measurement, and aims toimprove the efficiency of measuring the sugar content of the fruits and avoid damage to the fruits to be measured in sugar content measurement. According to the main technical scheme, the method comprises the steps: obtaining fruit picture data of a to-be-detected fruit; inputting the fruit picture data into a fruit sugar estimation model to obtain sugar data corresponding to the fruit picture data, wherein the sugar estimation model is obtained by training according to fruit sample picture data and corresponding sugar content; and determining the sugar content of the fruit to be detected according to the sugar data corresponding to the fruit picture data.
Application Domain
Investigation of vegetal materialMethod using image detector and image signal processing +1
Technology Topic
HorticultureAgricultural engineering +3
Image
Examples
- Experimental program(1)
Example Embodiment
[0026] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the present invention.
[0027] The method for measuring the sugar content of fruits provided in this application can be applied to figure 1 In the application environment in which the camera equipment communicates with the computer equipment through the network. The computer device obtains the fruit picture data of the fruit to be tested taken by the camera device, and then inputs the fruit picture data into the fruit sugar estimation model to obtain the sugar data corresponding to the fruit picture data; the sugar estimation model is based on the fruit The sample image data and the corresponding sugar content are trained; finally, the sugar content of the fruit to be tested is determined according to the sugar data corresponding to the fruit image data. Among them, the computer equipment can be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, and the like.
[0028] Such as figure 2 As shown, the embodiment of the present invention provides a method for measuring fruit sugar content, and the method is applied in figure 1 Take the computer equipment in as an example for description, including the following steps:
[0029] S10: Obtain fruit image data of the fruit to be tested.
[0030] In the embodiment of the present invention, the fruit image data of the fruit to be tested may be specifically obtained by a camera device, for example, an RGB image shooting device is used to obtain the fruit image data.
[0031] S20: Input the fruit picture data into a fruit sugar estimation model to obtain sugar data corresponding to the fruit picture data.
[0032] Wherein, the sugar estimation model is obtained by training based on the fruit sample image data and the corresponding sugar content; specifically, the embodiment of the present invention can train the fruit sample image data and the corresponding sugar content through a convolutional neural network architecture. Obtain the fruit sugar estimation model. It should be noted that considering the possibility of deploying the method proposed by the present invention to the mobile terminal, the architecture design of the convolutional neural network needs to pay attention to keeping the model lightweight, that is, the embodiment of the present invention adopts a lightweight network structure design. In this structure, the amount of parameters is greatly reduced by some methods, so the final fruit sugar estimation model will be small.
[0033] S30: Determine the sugar content of the fruit to be tested according to the sugar data corresponding to the fruit image data.
[0034] It should be noted that when measuring the sugar content of the fruit to be tested, the fruit image data of the fruit to be tested can be obtained from multiple angles, and then the sugar data corresponding to each fruit image data is determined according to the sugar estimation model, and then based on the determination The sugar data to determine the sugar content of the fruit to be tested.
[0035] Specific, such as image 3 As shown, the determining the sugar content of the fruit to be tested according to the sugar data corresponding to the fruit picture data includes:
[0036] S301: Average the sugar data corresponding to all fruit picture data of the fruit to be tested.
[0037] For example, three fruit image data at different angles and positions of the fruit to be tested are obtained, and then the three fruit image data are input into the fruit sugar estimation model to obtain the sugar data corresponding to each fruit image data. The corresponding sugar data is averaged, and the average is determined as the sugar content of the fruit to be tested.
[0038] S302: Determine the average value as the sugar content of the fruit to be tested.
[0039] The embodiment of the present invention provides a method for determining the sugar content of a fruit to be tested. After obtaining the sugar data corresponding to each fruit image data of the fruit to be tested, the sugar data corresponding to all the fruit image data of the fruit to be tested is averaged. , And then determine the average value as the sugar content of the fruit to be tested. Since the average value in the embodiment of the present invention is determined based on the fruit image data at multiple locations in the fruit to be tested, the embodiment of the present invention can improve the accuracy of measuring the sugar content of the fruit to be tested.
[0040] The method for measuring the sugar content of fruits provided by the present invention first obtains the fruit picture data of the fruit to be tested; then inputs the fruit picture data into the fruit sugar estimation model to obtain the sugar data corresponding to the fruit picture data; The sugar estimation model is obtained by training according to the fruit sample picture data and the corresponding sugar content; finally, the sugar content of the fruit to be tested is determined according to the sugar data corresponding to the fruit picture data. Compared with the current method of extracting juice from the fruit to be tested, and then measuring the sugar content of the juice with a brix meter to determine the sugar content of the fruit to be tested, the present invention determines the sugar content of the fruit based on the fruit image data of the fruit to be tested, that is, the fruit sugar content is estimated The model determines the sugar content of the fruit to be tested. Since the fruit sugar estimation model in the present invention is trained based on the fruit sample image data and the corresponding sugar content, the model can accurately and effectively measure the sugar content of the fruit to be tested Therefore, the invention improves the efficiency of measuring the sugar content of the fruit, and avoids the damage of the fruit to be tested caused by the sugar measurement.
[0041] In an embodiment provided by the present invention, the fruit sugar estimation model is obtained by training in the following manner: obtaining fruit sample image data and corresponding sugar content; convolving convolution based on the fruit sample image data and corresponding sugar content The neural network is trained to obtain the fruit sugar estimation model. Among them, 80% of the fruit sample image data and the corresponding sugar content are used as the training data set, and 20% of the fruit sample image data and the corresponding sugar content are used as the test data set.
[0042] Such as Figure 4 As shown, in an embodiment provided by the present invention, the obtaining image data of a fruit sample and corresponding sugar content includes:
[0043] S101: Determine sample points on the surface of the sample fruit and the sugar content corresponding to the sample points; perform image collection on each sample point from multiple angles to obtain a sample image.
[0044] In the embodiment of the present invention, multiple sample points may be randomly selected on the surface of the sample fruit, so that the selected sample points relate to different regions of the sample fruit as much as possible. Then take the sample point as the center of the image field of view, such as Figure 5 As shown, an RGB image capturing device is used to collect images from multiple angles for each sample point. In the embodiment of the present invention, the size of the collected sample image may be 640*480.
[0045] Such as Image 6 As shown, after determining the sample point on the surface of the sample fruit, at each sample point on the surface of the sample fruit, take the sample point as the center, cut out the apple pulp with a diameter of 5mm and a depth of 5mm and take the juice, and then use the sugar meter to measure these samples The real sugar content of the point is used as the label of the sample point, that is, the sugar content value of a sample point corresponds to multiple sample images of this sample point. By collecting a large number of sample points of a large number of sample images, construct a sample image and sugar content data set, and then use the sample points on the surface of 80% of the sample fruits and the corresponding sugar content of the sample points as the training data set, and the sample on the surface of 20% of the sample fruits The points and the sugar content corresponding to the sample points are used as the test data set.
[0046] S102, intercepting multiple fruit sample image data of different sizes from the sample image with the sample point as the center.
[0047] It should be noted that since the sample point to be estimated is in the center of the sample image, more weight should be given to the feature information of the area around the sample point in the prediction process, and the apple skin and environmental feature information in a larger field of view should also be combined. Therefore, the embodiment of the present invention adopts multi-scale input to fuse information, that is, intercept multiple fruit sample image data of different sizes from the sample image, and then fuse the intercepted fruit sample image data of different sizes, so that the fused image data is more capable Indicates the characteristics of the sample fruit.
[0048] Specifically, in an embodiment provided by the present invention, the fruit sample image data of the first preset size, the second preset size, and the third preset size are intercepted from the sample image with the sample point as the center, and The fruit sample image data of the first preset size includes the surrounding environment features of the fruit, the fruit sample image data of the second preset size includes the surrounding features of the entire fruit, and the fruit sample image data of the third preset size includes the fruit Features around the sample point.
[0049] For example, take the sample point as the center to intercept the fruit sample image data of the first preset size, the second preset size, and the third preset size from the sample image, and the fruit sample image data of the first preset size is 480* The pixel size is 480, the fruit sample image data of the second preset size is 240*240 pixel size, and the fruit sample image data of the third preset size is 120*120 pixel size. It should be noted that the first preset size, the second preset size, and the third preset size in the embodiment of the present invention can be set according to actual needs, and the embodiment of the present invention does not specifically limit this.
[0050] Correspondingly, after a plurality of fruit sample picture data of different sizes are intercepted from the sample image with the sample point as the center, the convolutional neural network is trained according to the fruit sample picture data and the corresponding sugar content to obtain The fruit sugar estimation model includes: training a convolutional neural network according to the intercepted multiple fruit sample image data of different sizes and the corresponding sugar content to obtain the fruit sugar estimation model. Specifically, the embodiment of the present invention may perform feature fusion on multiple fruit sample image data of different sizes, and then train the convolutional neural network according to the fused fruit sample image data and the corresponding sugar content to obtain a fruit sugar estimation model.
[0051] Such as Figure 7 with Picture 8 As shown, in an embodiment provided by the present invention, the training of the convolutional neural network based on the intercepted multiple fruit sample image data of different sizes and the corresponding sugar content to obtain the fruit sugar estimation model includes :
[0052] S201: The fruit sample image data of the first preset size undergoes a convolution layer to obtain conversion data of a second preset size.
[0053] For example, the fruit sample image data 480*480 of the first preset size is passed through the convolution layer to obtain the converted data 240*240 of the second preset size. Among them, when the size of the convolution kernel is set to 3x3 and the step size is set to 2, the length and width of the input fruit sample image data will be reduced by half.
[0054] S202, splicing the conversion data of the second preset size and the fruit sample image data of the second preset size in the channel direction to obtain a first feature fusion map.
[0055] That is, the conversion data 240*240 of the second preset size and the fruit sample image data of the second preset size 240*240 are spliced in the channel direction to obtain the first feature fusion map.
[0056] S203: Pass the convolutional layer on the first feature fusion image to obtain conversion data of a third preset size.
[0057] Specifically, the first feature fusion map 240*240 is passed through the convolutional layer to obtain the converted data 120*120 of the third preset size.
[0058] S204, splicing the conversion data of the third preset size and the fruit sample image data of the third preset size in the channel direction to obtain a second feature fusion map.
[0059] The conversion data of the third preset size of 120*120 and the fruit sample image data of the third preset size of 120*120 are spliced in the channel direction to obtain the second feature fusion map.
[0060] S205: Train the convolutional neural network according to the second feature fusion map and the corresponding sugar content to obtain the fruit sugar estimation model.
[0061] In the embodiment of the present invention, after the second feature fusion map is obtained, the second feature fusion map is input to the modified ShuffleNetV2 module, and its last layer is replaced with a fully connected layer of single-value output, and finally the fruit to be tested is obtained Predicted sugar content. Using the training data set, the neural network is trained using backpropagation and gradient descent strategies to finally get the apple sugar content estimation model.
[0062] It should be understood that the size of the sequence number of each step in the foregoing embodiment does not mean the order of execution, and the execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0063] In one embodiment, a device for measuring fruit sugar content is provided, and the device for measuring fruit sugar content corresponds to the method for measuring fruit sugar content in the above-mentioned embodiment. Such as Picture 9 As shown, the measuring device for fruit sugar content includes: an acquisition module 10, a calculation module 20, and a determination module 30.
[0064] The detailed description of each functional module is as follows:
[0065] The obtaining module 10 is used to obtain fruit picture data of the fruit to be tested;
[0066] The calculation module 20 is configured to input the fruit picture data into a fruit sugar estimation model to obtain sugar data corresponding to the fruit picture data; the sugar estimation model is obtained by training according to the fruit sample picture data and the corresponding sugar content of;
[0067] The determining module 30 is configured to determine the sugar content of the fruit to be tested according to the sugar data corresponding to the fruit picture data.
[0068] Further, the device further includes:
[0069] The obtaining module 10 is also used for obtaining fruit sample image data and corresponding sugar content;
[0070] The training module 40 is configured to train the convolutional neural network according to the fruit sample image data and the corresponding sugar content to obtain the fruit sugar estimation model.
[0071] Further, the acquisition module 10 includes:
[0072] The determining unit 11 is used to determine the sample points on the surface of the sample fruit and the sugar content corresponding to the sample points; image acquisition is performed on each sample point from multiple angles to obtain a sample image;
[0073] The intercepting unit 12 is configured to intercept multiple fruit sample image data of different sizes from the sample image with the sample point as the center;
[0074] The training module 40 is specifically configured to train the convolutional neural network according to the intercepted multiple fruit sample image data of different sizes and the corresponding sugar content to obtain the fruit sugar estimation model.
[0075] The intercepting unit 12 is specifically configured to intercept fruit sample image data of a first preset size, a second preset size, and a third preset size from the sample image with the sample point as the center, and the first The fruit sample image data of the preset size contains the surrounding environment characteristics of the fruit, the fruit sample image data of the second preset size contains the surrounding features of the whole fruit, and the fruit sample image data of the third preset size contains the surrounding features of the fruit sample point. .
[0076] Further, the training module 40 includes:
[0077] The convolution unit 41 is configured to pass the convolution layer on the fruit sample image data of the first preset size to obtain conversion data of the second preset size;
[0078] The splicing unit 42 is configured to splice the conversion data of the second preset size and the fruit sample image data of the second preset size in the channel direction to obtain a first feature fusion map;
[0079] The convolution unit 41 is further configured to pass the convolution layer on the first feature fusion image to obtain conversion data of a third preset size;
[0080] The splicing unit 42 is further configured to splice the conversion data of the third preset size and the fruit sample image data of the third preset size in the channel direction to obtain a second feature fusion map;
[0081] The training unit 43 is configured to train the convolutional neural network according to the second feature fusion map and the corresponding sugar content to obtain the fruit sugar estimation model.
[0082] Further, the determining module 30 includes:
[0083] The average calculation unit 31 is configured to average the sugar data corresponding to all the fruit picture data of the fruit to be tested;
[0084] The determining unit 32 is configured to determine the average value as the sugar content of the fruit to be tested.
[0085] For the specific definition of the measuring device for fruit sugar content, please refer to the above definition of the method for measuring fruit sugar content, which will not be repeated here. Each module in the above-mentioned measuring device for fruit sugar content can be implemented in whole or in part by software, hardware, and combinations thereof. The foregoing modules may be embedded in the form of hardware or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the foregoing modules.
[0086] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as Picture 10 Shown. The computer equipment includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide calculation and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. The computer program is executed by the processor to realize a method for measuring the sugar content of the fruit.
[0087] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and the processor implements the following steps when the processor executes the computer program:
[0088] Obtain the fruit image data of the fruit to be tested;
[0089] Inputting the fruit picture data into a fruit sugar estimation model to obtain sugar data corresponding to the fruit picture data; the sugar estimation model is obtained by training according to the fruit sample picture data and the corresponding sugar content;
[0090] The sugar content of the fruit to be tested is determined according to the sugar data corresponding to the fruit picture data.
[0091] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0092] Obtain the fruit image data of the fruit to be tested;
[0093] Inputting the fruit picture data into a fruit sugar estimation model to obtain sugar data corresponding to the fruit picture data; the sugar estimation model is obtained by training according to the fruit sample picture data and the corresponding sugar content;
[0094] The sugar content of the fruit to be tested is determined according to the sugar data corresponding to the fruit picture data.
[0095] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage. In the medium, when the computer program is executed, it may include the procedures of the above-mentioned method embodiments. Wherein, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and/or volatile memory. Non-volatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not a limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Channel (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0096] Those skilled in the art can clearly understand that for the convenience and conciseness of the description, only the division of the above-mentioned functional units and modules is used as an example. In practical applications, the above-mentioned functions can be allocated to different functional units and modules as required. Module completion means dividing the internal structure of the device into different functional units or modules to complete all or part of the functions described above.
[0097] The above embodiments are only used to illustrate the technical solutions of the present invention, but not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: The recorded technical solutions are modified, or some of the technical features are equivalently replaced; these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the present invention Within the scope of protection.
PUM


Description & Claims & Application Information
We can also present the details of the Description, Claims and Application information to help users get a comprehensive understanding of the technical details of the patent, such as background art, summary of invention, brief description of drawings, description of embodiments, and other original content. On the other hand, users can also determine the specific scope of protection of the technology through the list of claims; as well as understand the changes in the life cycle of the technology with the presentation of the patent timeline. Login to view more.