Plant Image Analysis Machine Vision System in Greenhouse

. In this paper, we use greenhouse field plants as studying objects 1 to build a plant image analysis agricultural intelligent machine vision system based on web control. The system can provide data support for intelligent decision when manage a producing process by acquiring agronomic parameters of plant development and plant nutrition in real-time and remote through image analysis algorithm and relevant hardware and software platforms. For the software part of the system, we use an assembled installing environment based on Windows, Apache, PHP, MySql as the web application platform and establish the data structure of B/S network model based on Web. We build an image data base and use the agricultural parameters of plant development and plant nutrition to analyze the image and dynamically publish it on Web. At present, we have measurement algorithm modules include segmentation algorithm, shape recognition algorithm, 3D reconstruction algorithm, ranging algorithm, chlorophyll and nitrogen contents measure algorithm. We use these algorithms to obtain agricultural parameters such as nutrition, developing size, quality, diseases and pests and put thoroughly monitors and alerts into practice. For the hardware part of the system, it is consists of remote Web server, machine vision control equipments in field and sensors. The equipments on the platform can practice close-cycle control and condition management. These functions make it possible for the assemblage of internet controlled hardware system.


Introduction
The study and application of machine vision system in agriculture date from the late 1970s. The study was focusing on using machine vision system to conduct quality detect and classification of agricultural products [1]- [4].
In 1995, Xiaoguang Chen [5] used computer image processing technique to identify characteristics such as contour line and coordinate position of vegetable seeding, analyze and judge their growth, provide the necessary information for transplant and thinning in the whole growth process. In 1996, P.Ling [6] has established an automated plant monitoring system by using machine vision system, the turntable can realized all-around monitoring, the machine vision system can determine the change of nutrition in 24 hours, it can calculate the reflectance projection area of lettuce seedlings, and reflectance projection area can reflect lack of fertilizer. In 2002, Guili Xu [7] measured the plant leaf area by using machine vision system and Reference substance method, designed sample light box, and optimized light box parameter, the method improved the calculation efficiency and accuracy of leaf area, made average error reduced to 2.86%.Qiaoxue Dong [8] designed greenhouse computer distributed automatic control system, it can realize real time read and store environment parameter values and alarm information of the greenhouse, then monitor the operation of the greenhouse. In 2003, Changying Li [9] used computer vision system to monitor the condition of cucumber seedling growth. By using image processing technology to extract reflectance projection area and plant height, and it is concluded that the average height measured by image processing is 0.927 relevant to artificial measurement results, the system can save measure consumption, quick and easy. In 2007, Libin Zhang [10] used machine vision system to detect greenhouse cucumbers with near-infrared spectral imaging. Zhiyu Ma [11] monitored the growth information of plants using technology of machine vision and image processing in 2010, the CCD camera of its monitoring system was installed in the precious rotation PTZ which was surrounded by ten plants to be researched. Near infrared filter was installed on the camera, and near infrared light was installed on the top of the camera. The PTZ rotated automatically in a certain time interval, and the CCD camera would take pictures of the tested plants.
With the development of information technology, network controlled agriculture intelligent control system, which is based on Web and Internet, has becomes the combination of multidisciplinary theory and technologies. It raises the management of agricultural production to a new technology platform.
In this article, we use greenhouse field plants as studying objects to build a plant image analysis agricultural intelligent machine vision system based on web control. The system can provide data support for intelligent decision when manage a producing process by acquiring agronomic parameters of plant development and plant nutrition in real-time and remote through image analysis algorithm and relevant hardware and software platforms [20].
Combining industrial network control technology, Internet technology, Web technology, Database technology, SOC technology, model technique, GIS technology, machine vision system and agronomy technology into a powerful extra management platform, not only can we solve problems in agricultural production, but also establish a precise operation control of the whole real-time online production process of machine vision, establish the acquisition and backtracking of agricultural field realtime data, publish and share resources.
Thus, the agricultural production can meet the standards of industrialize, precise and intelligent. It greatly improves the management efficiency and the quality of agricultural production.
According to the requirements of the greenhouse production and the controlling problems of the machine vision system, we need to firstly consider the climatic conditions of agricultural production, the production layout of equipments and network conditions. On this basis, we can analyze the image characteristics of plants and by combining the plant physiology cycle with the production management process and the occurrence of plant diseases and insect pests, we can fully understand the condition for getting clear images. Then we can analyze control problems and set up reasonable control targets as well as their logical relationship according to the functions of the machine vision system. At last, we can analyze the relationship between control activities and controlled object in detail during the control process, derive the relationship between input and output, the order of the various movements, or rule of time of the movement, develop system control scheme and the control system structure, according to the actual conditions.

2.1The network stability, reliability and security requirement analysis
The control network which responsible for monitoring and controlling the agricultural production site, the information transmission direct to production process, it need to meet the requirement such as real-time, high reliability, harsh environment adaptability. At the same time, for the characteristics of openness, decentralization and low cost, agricultural control network requires to add office automation system, upper middle class network communication such as control management layer and control layer, as well as communication between the field devices. Due to its simple protocol, open, stable and reliable characteristics, industrial Ethernet can be used as the reference of agricultural production network. This network has advantages such as good compatibility, easy connection to Internet, low cost, high development potential, high communication speed.
There are some problems correspond to the agricultural operating environment of industrial control. With the continuous improvement of Ethernet technology, there has development corresponding key technology to adapt the requirements such as stability and reliability or certainty and real-time, as well as the standardization of interconnection and security and so on.
(1) The technique which is used to ensure certainty and instantaneity of communication.
①Fast Ethernet and switched Ethernet technology reduce the network transmission delay and the collision probability by increasing communication rate. ②The Ethernet interchanger with the star topology structure divides network into segments, not only does it has the function of data storage and forwarding, makes the data frame buffering in the port between input and output and has no collision, but also filters the data .Data between the nodes in the segments was limited to the local network, without occupying other network or bandwidth of backbone segments, in order to reduce the load and reduce the data frame collision probability.
③ The full duplex technology makes two twisted pair or fibers between ports can also receive and transmit message frame at the same time, they can avoid conflict, greatly improving the confirmation and real time communication of the industrial Ethernet.
(2) The technique which is used to ensure the stability of the system ①According to the adverse industry site environment such as vibration, dust, high temperature, low temperature, high humidity and so on, we put forward higher request to the tolerance and the installation of the equipment, also develop corresponding products. ② Redundant Ethernet can improve the system recovery, and guarantee the reliability of the industrial control system. ③ The technology which is to ensure the network security. Control network for production process, especially the structure of B/S network, has a high requirement of real-time, reliability, security and data integrity. We can take strict privilege management, key information encryption, and security technology which based on interchangers such as flow control, access control list, and secure connection layer.
As a result, the existing Ethernet control technology based on TCP/IP protocol stack can ensure the security, stable and reliable operation of the greenhouse machine vision system.

① Environmental factors
Generally, the normal working condition of a greenhouse machine vision system is with natural sunlight, high humidity, high temperature and wide differences in temperature. These factors require the equipment has characteristics of moisture resistance, radiation resistance, and an extreme endurance of high temperature. In the process of designing and installing the equipment, there are a lot of factors for us to concern. Such as working conditions, install space, whether the positions of the shooting target are suitable, whether the circuits are safe enough, and whether the controlling methods are proper. ② Shoot object factors The shooting objects of greenhouse machine vision system are fruits, leaves and stems of plants. There are relatively taller fruit trees (e.g. cherry trees and flat peach trees), liana plants which people need to build stands (e.g. tomatoes and cucumbers), ground cover plants (e.g. strawberries), medium height plants (e.g. lily), etc. It is necessary to adjust object numbers and shooting distance according to the different needs of image analysis.
The growth areas of leaves and fruits are different. We need to adjust shooting height, distance and angle according to the size and position of leaves and fruits. Controlling the angle, motion and speed of camera platforms is also needed.
According to the characteristics of agricultural production, we need platforms to make proper progresses for the camera to be adjustable in an effort to thoroughly monitor the trends of plants growing within the whole producing process. To ensure that the cameras scanning the whole producing area without influencing the production, we require the devices abilities to responsibly carry the cameras, at the same time move within the greenhouse. Using this kind of device, we no longer need multiple camera sets in order to capture clear pictures. Thus, we may progressively simplify the system structure, cut the cost, and maintain the cost. ③ Image analysis factors To meet the demand of making clear pictures, we need to estimate the cost performance of cameras and lenses. And control of focal distance, zooming and aperture is required for the chosen camera. ④ Benefit cost factors Cost effective of production management decide the economic system of greenhouse machine vision system. There is a simple equipment design requirements. The system should be convenient for operation and maintenance at same time. The camera shooting requires that the movement of the motor can be remote automatic controlled in orbit. ⑤ Infrastructure needs Infrastructures are needed for running mechanical visual systems. There are 3 factors to be considered. They are Internet connection, the safety of circuit, and the quality of the greenhouse construction.

The analysis of the needs of software modular integration
The concept, which we used for this article is IMS (Integrated Modular System), contains the characteristics of integration and sharing of information resources, distributed functional areas and parallel processing, and function module. IMS requires a compositing use of both software and hardware. In other words, it needs to be independent, transplantable and replaceable between the operating system and first floor software.
Establishing distributed control and management is the synthetically miniaturization of function modular. To ensure the system health monitor, we need the software to be openly built to ensure its reliability and safety.
3 The overall structure of the field machine vision system

Frame structure system
In this paper, according to the requirement of greenhouse production and control problem of machine vision system, as well as design thoughts of software system [27], combine with the algorithms, we have designed the following structure as shown in Figure 1.

Network architecture
Network interconnection equipment is the key to industrial network, according to the physical structure, from low to high is divided into the network access layer, network distribution layer, core layer network remote device interconnection layer. Network access layer devices mainly include Internet access serial interface, embedded Web server module, remote server network interface card and interchangers. Distribution layer devices are mainly consist of routers and responsible for the wireless LAN access lines [28]. Core layer is mainly responsible for highspeed connection and its access equipment is mainly interchanger which is used to connect the data exchange between different greenhouses. Remote interconnection equipment which mainly refers to 3G router, can communicate with a remote server through the establishment of VPN channel.
This system with computer network as the main body has designed industrial control network which based on Internet and IPSec, use sensors to measure monitoring data and do real-time transmission, such as plant image, soil temperature and humidity, CO2 concentration and radiation and so on. Using the wireless network to send the data which is measured by the sensors or the machine vision system to the server, then it is published by the server in real time.
The system also uses B/S mode to exchange data, and uses the embedded web to access device control points to network. The network structure uses flat network, routers directly connect to switches, and switches drive workstation work, and then connect to the next switch. At the same time, combine with the Ethernet technology to achieve remote control devices, and it can publish data in real time on the Web, use B/S mode for remote monitoring. Ordinary users can use this system through a browser, to achieve the purpose of Web remote control.
(1) The network protocol of greenhouse machine vision system Control of greenhouse machine vision system and industrial network control is based on computer network as the main structure of the control system, so its structure contains the network protocol and hierarchical structure. TCP/IP protocol stack is earlier than the OSI reference model, but they are both designed for the collaborative work between heterogeneous computer network. Table 1 is shown as follow. The physical layer Transmission media Machine vision network control system is composed of computer, routers, switches, camera, PTZ, the logic control module and the controller hardware composition, and they link through different levels of agreement rules.
Repeaters of the machine vision system network work in the physical layer of the OSI reference model, is responsible for the physical layer of two nodes on a transmission of information and signal amplification of Ethernet, and the hub can be used as a multiport repeater, is used to gather the cable, it transmit data by sharing.
In this paper, the bridge in the equipment system work on the data layer of the OSI reference model and it can be connected to the same network in order to achieve the interconnection between remote LAN.
Switch operates at the data link layer of the OSI reference model, which is transmitted by way of exchanging data, can connect the workstations, hubs, and servers in Ethernet.
Routers which work at the network layer of the OSI reference model, is responsible for transferring data between two Ethernet network layer according to the data packet, change its physical address when forwarding packets, in order to be interconnected heterogeneous networks with multiple subnets or the Internet.
Gateway belongs in the application layer of the OSI reference model and it is mainly used to connect two different network architectures. In TCP / IP protocol, the gateway is an IP address leads to another network.
The network adapter on the machine vision system remote control program is the interface between the computer and the network physical transmission medium. With the driver you can achieve a variety of functional data link layer on the computer, but also as an integral part of the physical layer.
(2) Internet-based industrial control network structure of the machine vision system Network structure of the machine vision system grew out of industrial control network based on Internet, with the development of Ethernet technology and Internet applications in the control area, making network-based remote monitoring system based on Web technology has become an important part of the industrial Ethernet technology. With the development of applications of embedded Web server in PLC, inverter and other control devices, B / S model has become an important way of industrial data exchange. In this paper, a machine vision system built network also uses the B / S mode of data exchange, with using of embedded Web access network control points of each device.
With the development of microelectronics, integrated circuits and embedded technology [30], 32-bit processing chip allows embedded systems into TCP / IP protocol, which has Internet access performance. Embedded operating system will regard mini Web server as part of the operating system to support its Web features that make embedded devices become simplified Web server.
Devices with embedded Web server can communicate via HTML pages and allow Web server on the Internet to visit the device. Networked Intelligent IP sensors or actuators can put sensing, signal processing, control, Ethernet, TCP / IP protocols, real-time operating system and simplified Web server and other hardware and software together, by B / S structure of the system can remotely maintain it.
In this technical background, machine vision control system adopts this mode of Internet-based network structure ( see Figure 11), the devices which need remotely control [29]are all adopt the equipments with embedded interface or RJ45,or that can be connect to Internet via serial server.
In machine vision systems, interfaces between devices and configuration interface use application layer protocols, as industrial Ethernet allows different devices application layer protocol on the same network running .Configuration software uses Microsoft's ActiveX, a set of standard (device drivers) application software development technologies including COM technology, methods and properties for the communication between different devices on site to provide public interface that provides data exchange standards for different applications , unified incompatible industrial Ethernet protocols. This industrial control network based on Internet has a lot of features. ①Information network and the control network have no difference, and we simplify the control architecture of the network, so that the control network and the information network further "flat" (see Figure 11). ②Field devices with embedded WEB server on the configuration can be directly connected to the corporate information network and become an Internet node, realize plug and play.
③Remote control, maintenance and management are true sense, also local control and remote control together. ④Scheduling for networked control systems, security and stability issues need to be further analyzed.

System facility
Based on WAMP installation environment, including integrated Windows, Apache, MySql, PHP as a Web application platform on which the software and hardware platform Web-based data exchange B / S network structure model. Through the establishment of a database of images, using plant growth and nutrition agronomic trait parameters measurement module for image analysis algorithms and dynamic Web publishing. In this paper, the PHP syntax mixed C, Java, Perl and PHP syntax itself, to meet the needs of all levels of application software designed in this paper.
System's servers include Web server, database server, map server. System software includes the Windows operating system, Apache, MySql, PHP, C++ and so on. Data storage devices include remote databases, site caching devices. Field devices include embedded Web equipment, VPN, 3G router, switches, NPORT, PLC, PTZ cameras, data acquisition instruments, etc.

The database
The system according to system requirement analysis and data type designs database as below: plant fruit and leaf image library, plant disease and insect sample library, biomass calculates sample library, plant nutrition sample library, template library and algorithm model library.
Plants fruit leaf image feature library collects plant fruit and leaf color, texture and geometric features of the data. They are used to get agronomy trait parameters for plant growth [20].
Plant disease and insect sample library contains types and symptoms of common plant diseases and insect pests. Combine with corresponding algorithm [18]- [19], we can diagnose plant diseases and give prevention measures.
Biomass calculate sample library is used to store all kinds of image analysis to calculate the status information for plant growth, leaf area, stem diameter, plant height, fruit size, color, shape, and so on, they are used to determine the growing plants.
Plant nutrition sample library is used to store the chlorophyll and nitrogen contents in the process of plant growth and related characteristic data, it is used to determine the nutritional status of plants, and we can combine with the plant disease part, to determine whether it is suffering from disease such as nutrient deficiency in the plant growth cycle.
Template library contains template and characteristic data of plant leaves and fruits used in the process of algorithm design.
Algorithm model library contains all image processing algorithms: plant growing biomass algorithm module, plant disease and insect pest module, plant nutrition module.

Application support layer design
Application support layer mainly contains algorithm design and component design. Algorithm design further comprises: plant disease and insect pest recognition algorithm, plant nutrition recognition algorithm and biomass image measurement algorithm. Plant disease and insect pest recognition algorithm aims at identifying the disease and making early warning for plants in the whole plant growth process. Plant nutrition recognition algorithm helps get the nutritional status of the process of plant growth, like chlorophyll content, get the nutritional status of different stages, and assisting users to make corresponding measurement. Biomass image measurement aims at getting agronomic traits of plant growth, like leaf area, and judging plant growing conditions of different stages.
Component module further comprises: information extract component, information classification component, data store component, system management component, middleware component, configuration control component. Through information extract component we can obtain the needed information from acquired images, and use classification component to classify the large amount of information, then store in the data store component. Middleware component includes PLC and PC data transfer drive, PTZ control drive, camera control drive, to realize the network control of trolley track, PTZ and camera. Configuration control component can realize online access or modify parameters of camera and PTZ remotely, control the movement of the orbit.

System application platform
There is a decision making platform in system's server, the decision making platform mainly used in fertilizer [13], irrigation [23], diagnosis and treatment of diseases [12] and other agricultural production projects, which provide decision making support for users in different plant growth stages. The decision making platform has its own algorithm module, it contains fertilization decision making algorithm [15], irrigation fuzzy control algorithm and diseases and pests warning algorithms. Decision support platform supports remote data collection and analytical decision-making and services to provide decision support for plant production management of fertilization, irrigation, pest and disease management.

Algorithm software platform
Machine vision algorithm layer contains image feature extraction module and image parsing module. They can obtain plant growing biomass (leaf area, stem diameter, plant height) and fruit quality (fruit size, fruit shape and fruit color), plant diseases and insect pests and plant nutrition.
Image feature extraction module uses a mathematical model to extract the image edge of leaf or fruit, skeleton, the three-dimensional shape information and optical properties [16-17, 21-22, 24]. Image feature extraction used to extract plant leaves or fruit edge and skeleton and other information, image parsing module can obtain plant nutrition, disease and other conditions by extracting plant image information. The algorithm module is shown as Figure 2   is on behalf of a hardware primitive of classification . and are sample points of classification .
represents extension. Line is the extension of point. If there is a distance threshold, the feature lines of line model can construct cylinders. The scope of sample space is the superposition of each cylinder.
③Feature surface is a promotion of feature line. The expression is as follow.
is on behalf of a hardware primitive of classification . are sample points of classification ≠ ≠ . represents extension. The extension of three points is a plane.
④Hypercube model simulates the learning process of the human brain. The basic idea of it is to select some points as memory point of learning. Then we increase sample constantly, and expand the hypercube, and increase the weight of successful learning. The model is shown as follow. ⑤The hyper sphere model is on behalf of a cluster of points. A sample data can be regarded as a high dimensional space point. A classification of points is a point set. It is shown as follow.
is on behalf of super ball center. represents the hyper sphere radius. This can be similar to expression of hypercube, also.
⑥Ellipsoid model is extension of sphere model. Ellipsoid expresses better than sphere model. Ellipsoid can have different length in each feature dimension, and its spindle can be arbitrarily rotated. Ellipsoid can be recognized directly, and can be combined with many kinds of classifications to improve the precision of recognition, also. The concrete representation is as follow. (3-6) is on behalf of a hardware primitive of classification . represents the center of ellipsoid and represent covariance of matrix. The center of ellipsoid and the covariance of ellipsoid are shown as follow.
Ellipsoid model is one of the most complex models. For its complexity, the length and direction of the spindle can be different. For the usage of the extracted information, we extract mean value, variance, energy, twist, kurtosis, entropy of the image color, extract them directly in every quadrant of color space or change to other color space (for example ). We extract feature data of image gray, image shape, image texture from varies color space quadrants, or multiple color space quadrants. ⑶Texture feature extraction Texture is a pattern of the change of gray or color space. Texture closely relate to high frequency components of the image spectrum. The texture analysis methods commonly used are statistical method, structure method, and spectrum method. Gray level co-occurrence matrix is established by pixel relative position in gray area space, and is used to define and calculate the texture descriptor. It is shown as follow.
[ ] Let be a spatial associated pixel pair set of target area , then the elements of the normalized co-occurrence matrix can be defined as follow.
[ ] | (3-10) The numerator of above formula is the number of pixel pairs with a kind of spatial relationship, and the gray value of the pixel pairs are and . The denominator of the formula is the total sum of the pixel pairs. represents number. The area texture descriptors which are defined on the basis of co-occurrence matrix, for example, angular second moment, contrast, relevance, differential moments, inverse difference moment, sum average, sum variance, sum entropy, entropy, differential variance, differential entropy, related information measure, the maximum correlation coefficient, etc.

Feature databases
Feature databases can be divided into the following three categories according to the feature extraction method. ①Shape feature database contain all kinds of leaf shape features, all kinds of fruit shape features, and all kinds of plant type features. ②Color feature database contain fruit color features, leaf chlorophyll level color features, and leaf nitrogen level color features. ③Texture feature database contains all kinds of plant disease textures and all kinds of plant insect attack textures.
We set up the database according to the following requirements. ① Classify the data according to plant species, part and growth stages.
② Collect the feature data in accordance with the requirements of image parsing process. ③Establish algorithms that corresponding to the search and match of database.

Pattern recognition and algorithm model database
⑴ Image pattern recognition method There are three directions of image pattern recognition. One is statistical pattern recognition which is based on the classical decision theory. The second is structure pattern recognition which is based on formal language. The third is fuzzy pattern recognition which is based on fuzzy mathematics theory. In general, the pattern of images consists of characteristics. Pattern category is composed of a set of patterns that have similar characteristics. Pattern recognition process is the process to analyze and describe the pattern categories. Pattern usually quantitatively and structured shown as vectors, strings and tree structure. Pattern vector, string, and tree structure is commonly used in quantitative and structured representation.
For a pattern class set , if its corresponding discriminant function set is , and unknown pattern has in the solution set, then is belong to pattern . If there is , then is the boundary condition of and .When , belongs to . When , belongs to .
The pattern class of nearest neighbor classifier is each pattern itself, but the discriminant function is Euclidean distance. It means that for unknown sample , if there is a pattern closet to , then belongs to . For instance, the neighbor rule classifies to its nearest class.
⑵Image parsing module Image analysis can base on pattern recognition, or according to characteristics of other images. According to the change rule of color, texture and shape, we build characteristic patterns in order to analyze or recognize images. Greenhouse machine vision system, which is used to analyze plant field images, has the following parse modules. ① Image segmentation module Plant image segmentation module mainly analyzes plant leaves, stem and fruits. We extract the feature at the edges of these parts, for the subsequent local feature extraction of 3D reconstruction, texture analysis, etc. ② 3D reconstruction module The 3D reconstruction module recovery the images of leaves, stems and fruits, to get the exact leaf area, stem diameter, fruit size and shape. ③ Distance measure module Distance measure module combines with field equipment and three-dimensional reconstruction module to measure leaf area, stem diameter, plant height, fruit size and shape. ④ Growing biomass measure module Through field image parsing, we can get the plant growing data, which mainly contains the correlation model of growth. And build plant growing model in order to combine with production manage process such as water and fertilizer management, and to further build the virtual model in the whole process of plant growth. ⑤ Plant disease and insect recognition module We can get features like texture, color and shape through image parsing [31], and build the analysis models of diseases. We can effectively monitor the status of plant disease and insects through real-time image data, provide data support for disease and pest control. ⑥ Plant nutrition monitor module Through the analysis of plant leaf images, we can measure the chlorophyll and nitrogen content, and build image analysis measurement model. We can effectively monitor the nutritional status of plants through real-time data, and cooperate with water and fertilizer management.

⑶ Algorithm model library
Algorithm model library contains growing biomass module, plant disease and insect module, nutrition module. Growing biomass module includes segmentation algorithm [14], three-dimensional reconstruction algorithm and ranging algorithm. ①Segmentation algorithm includes fitness function algorithm module [21,25], preprocessing module, partial differential parsing algorithm module, morphological algorithm module, edge extraction module, split operation module, shape discrimination module, character description module and clustering module, we can extract the key parts from plant images such as plant leaves and fruits, to do particular area study. ② Three-dimensional reconstruction [20] algorithm contains Lambert reflector model, normal vector and vector model, and leaf surface model, they are used to transfer the leaf image or other part images from two-dimensional coordinate to threedimensional coordinate, in order to take further measurement. ③ Ranging algorithm includes difference registration algorithm model, motion single visual distance algorithm model, zoom single visual distance algorithm model and real measure algorithm model, they are used to measure leaf area, plant height, stem diameter, fruit color, fruit shape and quality. Plant disease and insect module contains feature description operator, clustering operator or template classifier and template database. Feature description operator is used to describe all kinds of plant diseases and insects, determine the corresponding disease category through the clustering algorithm [26], in preparation for diagnosis and treatment. Nutrition module includes feature description operator, clustering algorithm module, information fusion algorithm module, chlorophyll recognition module and nitrogen identity module. Through feature description operator we can get threedimensional shape, texture and color of plant key parts. Through the combination with clustering fusion algorithm, we can extract the chlorophyll and nitrogen content of plant growth and different stages, judge the plant growth situation.The design and content of algorithm model library as shown in Figure 3.

The software platform of machine vision system
The GOA model defines the structure of software, hardware and interface. The frame of hardware and software contains four logical layers, and nine logical interfaces.
The software platform of greenhouse machine vision system in this paper designs based on universal "General open architecture (GOA) framework" [28], this standard is an important standard of open system structure. It is shown in Figure 4.
GOA model includes application layer, system service layer, resource access service layer and physical resource layer. The application layer contains 4L logical interface among software application components. System service layer provides public service of application software, and it contains the operating system components and 4D as well as 3L interfaces. Resource access service layer provides direct access to the software component of hardware, such as device drivers and storage that have IO definition, 3D interface, 2D interface between software and hardware, peer 2L interface. Physical resource layer provides the direct interface 1D and 1L between different physical components, it contains the physical definition and data link definition of the bus, 1D defines the electrical/mechanical requirements and 1L defines the decoding.
Among 4 layer structures, simplify defines the common interface point, realize the interaction of the logical independent layers and that of equivalence relation layer, through the interaction and isolation of logical/physical interface. This 4 layer 9 interface mode realizes the functions of the machine vision software and hardware, and facilitates the expansion of the ready-to-use components, provides the unified basis platform for the application of system components. The system platform can perform operation and constraint instructions, and realize the interoperability between devices of every level. As shown in Figure 4.
The logical interface which is expressed by the dotted line realizes standard of support information sharing between point to point entities, it includes sharing and standard of object, data, parameters, status and control. The direct interface expressed by solid line realizes the standard of information transform between entities. It includes sharing and standard of object, data, parameters, status and control.

The system software architecture
In this paper, the machine vision system software builds on the open software architecture, it can realize following functions. ①Apply and test software running normally under the operating system. ②Construct and test of drivers and complex routing under multiple network environments. ③ Access and test between file system and network file system server. ④ Manage the resource of the processor and CPU. ⑤ Manage the application node. ⑥ System time configure. ⑦ Announce.
⑧ Data configure and use. ⑨ System monitor and receive agent. The architecture is shown as Figure 5.

Fig 5 Software framework
Under the system software architecture, the operation management corresponding to functions contains the following parts. ① The service of operating system. It includes task management, time management, memory management and external events management. ②Node administrate. Mainly supervise and control the state of application software. It includes node online or offline query and control service, application software initialization and restart, access control and maintain control. ③ Message manage. It provides exchange type for the data of application software and control information. The objects are system information, application information, general information, urgent information and broadcast message. System information is the universal message that defined by software running framework, including node online or offline information, test information, etc. Application information contains the data and control information among all application software and internal communication. General information is that of source and destination address in the message queue. Urgent information doesn"t wait in the message queue. Broadcast message is multiple receiving. The main function of information management is to provide interface, routing, broadcast news and urgent information support of application message sending and receiving. ④ System communicate control. It manages all the network communication interface of the system. Including TCP/IP network manager and wireless broadband management, Rapid IO interface management, RS-422 interface management and 1394 interface management. Wireless broadband management contains initialization of the control network switch, network routing load, network configuration management, the maintenance or monitor of switch and the backup of network controllers. Rapid IO interface management contains communication interface management within system module or between system modules. ⑤ System time serve manage. The system software platform provides unified time service for all users, including the system clock calendar and real-time services. ⑥System reconstruct services. Use the configuration items in database to construct the whole system, including network reconfiguration service, application software refactoring service, migration service of task software or add software to specified module, power control service.
⑦ The management of data access. It provides unified interface for data storage, including removing access, query, encryption and other functions. Manage object includes large capacity storage module, etc. ⑧Integrated monitoring management. Including monitoring agent, news monitoring, node status monitoring. ⑨Health manage. Including the test result and error report service of hardware layer, receiving and reading the health data, fault processing services of equipments of all levels.

Data structure
In this paper, we describe the data structure of greenhouse machine vision system take Java custom universal data structure or Java class set for example as shown in Figure 6.
As shown in figure 6 is a class structure, the four kinds of structure are Field, Field Map, Field Map Set and Field Map Node, the system allows for the business scenario select data structure. ①Field is the smallest data structure. Field contain name and value, the typical XML structure corresponding to Field is as follow.
<Sensor Name>Temperature</Sensor Name> <Value>29</Value> ②Field Map is used to assembly or classify different Field and show a specific business. It mainly contains member variable such as name, Field Map. Name stores the name of current Field Map. The type of Field Map is Map<String, Field>, it can assemble different Field. XML structure corresponding to Field Map is as follow.
<Sensor> <Sensor Name> Temperature </Sensor Name> <Value>29</Value> </Sensor> ③Field Map Set is the set of Field Map, it can assemble complex business data, also can contain Field directly. This Field is the Attribute of Field Map Set. XML structure corresponding structure is as follow.
<Sensor Infos> <Fid>PICNIC01</Fid> <Sensor> <Sensor Name > Temperature </Sensor Name> <Value >29</Value> </Sensor> </Sensor Infos> ④Field Map Node use nested recursive fashion to load all nodes, similar to directly use DOM analysis. ⑤CommonMsg depends on the above four kinds of data structure, it is the external unified interface of application. Its construction mode is as follow.
CommonMsg； String strMsg="…"； CommonMsg cm=New CommonMsg()； cm.set MsgString (strMsg) CommonMsg is used to hand all the switch control to the XML protocol, let the application which is based on protocol specification to analyze the data.

Data analysis
In the field of industrial control, in the interaction process of the data which belong to the communication of upper and lower machine, there exists a variety of network communication protocol such as OPC, UDP.
The transmission data format is simple text data, like TXT, XML, etc. Data specification is used to explain data format and construct data relationship, then acquire the initial data and conduct data provide constraints.
Through the data acquisition interface, we encapsulate the logical operation module of specific data access, transfer and integrate process, analyze the data source into a unified format of metadata "name-value" structure.
The main function of the logical processor is to operate the metadata and return the result according to the configuration transformation rules of data source.
The main function of custom visual control is intelligently manage the call of data providing interface, abstract the data attribute by defining, transfer parameters required for logical processor and return the result to caller.
The generic data acquisition and monitoring software, through dynamic script, DLL call and execute logical control, realizes the real-time acquisition, display and storage. Take OPC for example, the data analysis process is shown as figure 7. ①Establish the corresponding fields and field types of metadata in the database table. ②Customize a template to achieve a batch conduct of data files, and establish the template library. ③Parse the Data-XML of XML schema, and store the data in database.

System data flow chart
The data in this system is from camera real-time data, environmental sensor realtime data and knowledge library experimental data, these data is submitted to the terminal processing algorithm on the server through all kinds of middleware, process and store, and through the dynamic Web page call and process data and display result. The algorithm database can extract and analyze image characteristics, and submit the result to decision support module. The data which has been parsed by decision support algorithm can be used in production decision and management.
Data is maintained and copied by administrator, after filtering and screening it can be released on the Web platform. The data flow diagram of the system shown as Figure 8.

The hardware platform of machine vision system
The hardware platform of greenhouse networked machine vision system consists of remote Web server, Web database server, field machine vision control system and sensors. Devices in the platform can do closed-loop control and state management based on Web, and realizes the integration of network controlled hardware system. The hardware system structure is shown as Figure 9. Hardware system contains motion control part, machine vision part, environment data acquisition part, configuration software, middleware and industrial controlled network.

Motion control part
Motion control part contains: PLC, trolley and rail, frequency converter. PLC uses a series of programmable memory, for its internal storage procedures, perform user-oriented instructions such as logical calculate, sequential control, timing, counting and arithmetic operations, and through digital or analog input/output control various types of machinery or production process. It can modify online or query the parameters of camera, PTZ, lens and rail, control the motion state of devices, realize the intelligent control of the valve opening and closing as well as move and pause of the trolley.
The track adopts hanging steel slide rail system, by using a series of pulleys to control the shrinkage of cables on the rail, and use a pulley with large affordability to hang PTZ and camera, to help shooting. The boom is flexible, and it is easy to adjust according to plant type and growth cycle. Rail system has its own proprietary movement rules: the camera on the track will stop when it has moved a ridge, PTZ stop capture images every 45 degree angle in the direction of 360 degree, when a ridge finish, move forward to the next ridge. The rules of camera move shown as Figure 10. Motor moves along the track from point X pass point Y to point Z, it will stop for a period of time when after a ridge"s shooting, at this time, PTZ completes shooting at points ABCDEFGH, when finish shooting at point H, the motor starts, moving forward next ridge, then complete other points" shooting. When PLC gets the trip switch input, motor reversal. The movement rule is shown as Figure 10.

Sensors and data acquisition equipment
①Vision sensors and related equipment Vision sensors and related equipment contains camera, intelligent PTZ, lens.
The system uses a GigE industrial network digital video camera, adopts the frame exposure CCD progressive scan sensor, has high image quality and high cost effective, color reproduction is good, it is suitable for the needs of plant image analysis. GigE gigabit network digital camera can trigger an acquisition or continuous acquisition by external signals. It can control brightness, gain, frame rate, exposure time and asynchronous reset by programming. It is also suitable for greenhouse orchard remote monitoring requirements.
The PTZ can change speed intelligently and rotate 360 degree endless, they have a wide perspective, and they can get the greenhouse plant images in a wide range. The lens is industrial lens which is megapixels, the aperture, focus and zoom can be controlled by PTZ. ②Environmental data acquisition part Environment data contains soil humidity, specific conductance, temperature, PH value, the air temperature and humidity, CO 2 concentration and irradiance. They are acquired by corresponding sensors.

Configuration software and middleware
The system configuration software is King View. Monitoring functions of configuration software can control the state of devices and running status of controller as well as travel switch via Internet, the data statistic function of configuration software can obtain data by directly reading the register of related equipment, it supports SQL Server, Access, able to get the data processing, the required data is automatically stored in the database, facilitate later query analysis.
The function of record state is characteristic of the configuration software, it provides a convenient tool for reporting statistics, according to the summary finally generate different statements, it can also visually dynamic display the status of various devices. The system configuration software and PLC connected into a remote monitoring system via the network, it can remotely modify and maintain equipment parameters and achieve the purpose of remote control. The device interface component of the system mainly the device driver provided by equipment manufacturers, and is installed on the PC side by configuration control software. The middleware consists of PLC and PC data transmission driver, PTZ control driver, camera control driver.
The PC act as upper computer in this system, the middleware can conduct configure, monitor, modify parameters online, real-time alarm and record data to the PLC system, PC can also provide a development environment and download the code to PLC via Ethernet or serial port, this can shorten the development cycle and simplify the programming process. The visual control configuration software on PC can control simulation modeling and generate code for motor, the code can be downloaded to PLC via Internet and consist a control loop, as well as remote monitoring and management.
PTZ control driver and camera control driver can connect the PTZ and camera with PC, modify the parameters of the camera and PTZ on the PC, and change their motion state according to need. The configuration controlling is shown as Figure 11.

Industrial controlled network
The control nodes of Web server has been embedded in the system, interactive information services can be provided through a network server, provides a remote monitoring user interface that comply the Http protocol and conduct information exchange. The remote high-definition cameras with large amount of information use remote monitoring system of independent Web server. Remote monitoring security measures by using the system security management function is provided by King View.
The remote loop control system is implemented by variable frequency inverter, motor, PLC, travel switch and PC. PC can conduct functions as configure, monitor, modify parameters and record data, PC also can provide a development environment and download the code to PLC via Ethernet or serial port, this can simplify the programming process.
PLC communicates with PC via TCP/IP protocol, signals of the remote controller interact with the controller feedback signals via Ethernet, form remotely close-loop control, and design special motor movement rules, to ensure that all plants in greenhouse images can be collected. By programming in remote and upload to the PLC to control the camera rail. When they are online, we can go directly to PLC, by modifying the output port to control the movement of the camera track. Through the simple system that composed by configuration and PLC, to realize real-time control of Machine vision system. King View has monitor function, it can control the status of devices and the running state of controller as well as travel switch via Internet, it can obtain data from registers of related devices directly, the record function can provide report and summary into different statements.
The system can realize image acquisition, image processing and greenhouse production intelligent management. The image processing module through the segmentation algorithm to get accurate leaf edge, the addition of leaf shape recognition algorithm, makes the segment result more accurate. Through the threedimensional reconstruction algorithm can obtain accurate leaf area. Through image analysis, building the relationship between image and parameters that needed to calculate the parameters, use the software to replace hardware or manual measurement.
(1). Image acquisition module: including camera equipment, track motion device, network closed loop control system. They are used to acquire field leaf images under the condition of natural light. (2). Image processing module: including image feature extraction module and image analysis module. By using the image segmentation algorithm which based on adaptive threshold, image recognition algorithm that based on leaf shape discrimination, image three-dimensional algorithm that based on single leaf image and plant leaf nutrition analysis algorithm by means of image parsing to establish the calculate model from leaf image enhancement, image segmentation, edge extraction, leaf shape feature extraction, shape discrimination, leaf position information acquisition to leaf threedimensional surface reconstruction, ranging, leaf area calculate model, chlorophyll and nitrogen measurement model, in order to achieve the machine visual measurement of leaf area, and get the plant growing biomass, nutrition, disease and insect pests condition.
(3). Greenhouse orchard production and management intelligent decision support module includes the digital management intelligent decision system that based on machine vision, plant leaves and fruit parameters obtained by image processing module can realize remote management specific to the digital block and plants, provide managers of decision information and support tools in the whole agricultural production process (including fertilization [15], irrigation, pest and disease diagnosis and treatment and early warning). The system functions are shown in Figure 12.

Summary
The greenhouse machine vision system use the greenhouse field plant as research object, it is a kind of network controlled agricultural intelligent visual control system that based on Web and Internet. The system selects devices and networking according to demand analysis such as the geographical location of greenhouse, network conditions, equipment conditions and greenhouse environmental conditions, and integrates the agricultural production machine vision equipment which based on TCP/IP network control. The system combines the Ethernet control technology, can make the machine vision system realize real-time remotely acquire parameters of plant growth or nutrition and online monitor the growth condition of the plant, through image parsing algorithm and corresponding software and hardware platform. It provides data support for the control of the whole production process and intelligent decision.
The system software sets up the WAMP integrated installation environment as the web application platform, the platform realizes the data structure of B/S network model based on Web. Through the image, parameters and model database, establish agronomy trait parameters measurement algorithm module, to measure the agronomic parameters. Publish the results as dynamic Web page, the published result contain image data, image parsing result, decision support data, etc.
The hardware of the greenhouse machine vision system consists of remote Web server, Web database server, the machine vision control equipment in field and sensors. Equipments of the platform can realize close-cycle control that based on Web as well as condition management, making the integration of network controlled hardware system come true.
This system organic combines computer technology, automatic control technology, image parsing technology, machine vision technology with the agronomic trait parameters acquire demand in the agricultural production process. The process object is the important agronomic variables that difficult to measure or need large amount of data. Through the logical process such as data collection and analysis of the plant key part, the selection and extraction of characteristic variables, image parsing, construction of mathematical model relationship between image model and parameters which need to be measured, we can calculate or statistic the needed parameters. It provides important fundamental methods and basis for application work such as plant growth condition survey, prevention and control of plant disease and insects, plant nutrition monitoring, water and fertilizer management or decision making. And it provides technical guarantee for improving the work efficiency of agricultural production and developing intelligent agriculture.