Insect recognition and number statistics system based on Python machine learning

Table of contents

Abstract I
ABSTRACT II
Contents III
Chapter 1 Introduction 1
1.1 Background and Significance of the Research 1
1.2 Research Status at Home and Abroad 1
1.2.1 Research Status in China 2
1.2.2 Research Status in Foreign Countries 2
1.3 Research Content and Purpose 3
1.3.1 Research Content 3
1.3.2 Research Purpose 3
1.4 Chapter Arrangement 4
Chapter 2 System Overall Design 5
2.1 System Design Objective 5
2.2 System Overall Architecture 5
2.3 Image Acquisition Node 6
2.3.1 Device Overall Design 6
2.3.2 Operation Process 9
2.4 Insects Identification server and insect information database design 10
2.4.1 Server design 10
2.4.2 Server insect classifier implementation 11 2.4.3
Insect classification and recognition software on PC 12
Chapter 3 Insect image preprocessing and counting research 15
3.1 Insect image Acquisition 15
3.2 Preprocessing of insect images 16
3.2.1 Image grayscale, Gaussian filtering and scale transformation 16
3.2.2 Binarization 17
3.2.3 Application of Otsu method OTSU in insect image binarization 18
3.3 Insect images Counting 20
3.3.1 Detecting contours 20
3.3.2 Counting insects 20
Chapter 4 Research on feature extraction and recognition of insect images 23
4.1 Selection of features 23
4.2 Feature description and extraction methods 23
4.3 Selection and training of classifiers 32
4.4 Analysis of machine learning results 33
4.4.1 Performance evaluation indicators 33
4.4.2 Three classifications 34
Chapter 5 Summary and Outlook 37
5.1 Summary 37
5.1.1 Work Done 37
5.1.2 Innovations and Inadequacies 37
5.2 Outlook 38
Acknowledgments... Error! Undefined bookmark.
References 40
Appendix 1: Some insect image samples 42
Appendix 2: OTSU’s PYTHON implementation 44
1.3 Research content and purpose
1.3.1 Research content
In order to solve the problem of pest identification in agricultural production areas, a pest detection system based on machine vision is proposed. Species and quantity detection scheme, and completed the following work:
(1) Design and implement a set of pest capture and image acquisition device that can be applied in the field. The device is placed in the agricultural planting area to trap and kill pests and collect images 24 hours a day. At the same time, the device can upload the images of pests to the insect identification server of the agricultural monitoring center through the wireless network, and identify the types of pests, and detect the pests in the production area. The number of categories of information collected.
(2) Developed a set of machine vision-based insect counting methods suitable for images of most insect equipment such as fly sticky boards. This method first performs binarization preprocessing on pictures containing many insects, then searches for contours and counts the contours, and the number obtained is approximately equal to the number of insects in the picture.
(3) Developed a set of machine vision-based insect recognition methods and processes suitable for this set of image acquisition devices. Based on the basis of previous work, this method selects five features of insect morphological features, including insect rectangularity, insect elongation, insect circularity, insect globularity, and insect leaf-likeness, to perform feature extraction of insect images. extract. Afterwards, the logistic regression model, linear SVM model and K-neighbor classifier were used for training respectively, and the training results were tested and compared to screen the classifier algorithm.
(4) A set of remote pest automatic identification system is designed. Combining the above three functions, the system can achieve: pest capture and insect image collection at the image collection node, and insect image recognition and classification at the insect identification server.
1.3.2 Research purpose
The purpose of the research is to establish a remote automatic identification system for pests and diseases, which will help alleviate the shortage of human resources for agricultural plant protection personnel and pest identification experts, and help agricultural personnel with limited knowledge of pests and diseases to conduct timely detection of pests and diseases, and Through the monitoring of the number of pest species and information collection, the insect data is regularly sorted and analyzed to establish a regular model of pest outbreaks, and then predict and judge the outbreak time of pests and diseases, and timely notify agricultural plant protection personnel and farmers for reasonable and scientific prevention. Improve crop yield and quality.

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'MainWindow.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1239, 727)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.videoFrame = QtWidgets.QLabel(self.centralwidget)
        self.videoFrame.setGeometry(QtCore.QRect(0, 0, 600, 400))
        self.videoFrame.setFrameShape(QtWidgets.QFrame.WinPanel)
        self.videoFrame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.videoFrame.setMidLineWidth(2)
        self.videoFrame.setObjectName("videoFrame")
        self.videoFrame_2 = QtWidgets.QLabel(self.centralwidget)
        self.videoFrame_2.setGeometry(QtCore.QRect(630, 0, 600, 400))
        self.videoFrame_2.setFrameShape(QtWidgets.QFrame.WinPanel)
        self.videoFrame_2.setFrameShadow(QtWidgets.QFrame.Raised)
        self.videoFrame_2.setMidLineWidth(2)
        self.videoFrame_2.setObjectName("videoFrame_2")
        self.btnCapture = QtWidgets.QPushButton(self.centralwidget)
        self.btnCapture.setGeometry(QtCore.QRect(200, 520, 171, 101))
        self.btnCapture.setObjectName("btnCapture")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(860, 530, 161, 61))
        font = QtGui.QFont()
        font.setPointSize(20)
        self.label.setFont(font)
        self.label.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.label.setObjectName("label")
        self.label_status = QtWidgets.QLabel(self.centralwidget)
        self.label_status.setGeometry(QtCore.QRect(1120, 650, 111, 31))
        self.label_status.setText("")
        self.label_status.setObjectName("label_status")
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setGeometry(QtCore.QRect(1050, 660, 54, 12))
        self.label_2.setObjectName("label_2")
        self.label_3 = QtWidgets.QLabel(self.centralwidget)
        self.label_3.setGeometry(QtCore.QRect(473, 442, 81, 20))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.label_success = QtWidgets.QLabel(self.centralwidget)
        self.label_success.setGeometry(QtCore.QRect(580, 440, 91, 31))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label_success.setFont(font)
        self.label_success.setText("")
        self.label_success.setObjectName("label_success")
        self.label_4 = QtWidgets.QLabel(self.centralwidget)
        self.label_4.setGeometry(QtCore.QRect(473, 490, 81, 20))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.label_rect = QtWidgets.QLabel(self.centralwidget)
        self.label_rect.setGeometry(QtCore.QRect(570, 480, 91, 31))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label_rect.setFont(font)
        self.label_rect.setText("")
        self.label_rect.setObjectName("label_rect")
        self.label_5 = QtWidgets.QLabel(self.centralwidget)
        self.label_5.setGeometry(QtCore.QRect(470, 530, 61, 16))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label_5.setFont(font)
        self.label_5.setObjectName("label_5")
        self.label_extend = QtWidgets.QLabel(self.centralwidget)
        self.label_extend.setGeometry(QtCore.QRect(580, 520, 91, 31))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label_extend.setFont(font)
        self.label_extend.setText("")
        self.label_extend.setObjectName("label_extend")
        self.label_6 = QtWidgets.QLabel(self.centralwidget)
        self.label_6.setGeometry(QtCore.QRect(470, 560, 61, 21))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label_6.setFont(font)
        self.label_6.setObjectName("label_6")
        self.label_circle = QtWidgets.QLabel(self.centralwidget)
        self.label_circle.setGeometry(QtCore.QRect(580, 560, 91, 31))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label_circle.setFont(font)
        self.label_circle.setText("")
        self.label_circle.setObjectName("label_circle")
        self.label_7 = QtWidgets.QLabel(self.centralwidget)
        self.label_7.setGeometry(QtCore.QRect(470, 600, 71, 21))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label_7.setFont(font)
        self.label_7.setObjectName("label_7")
        self.label_spherical = QtWidgets.QLabel(self.centralwidget)
        self.label_spherical.setGeometry(QtCore.QRect(580, 595, 81, 31))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label_spherical.setFont(font)
        self.label_spherical.setText("")
        self.label_spherical.setObjectName("label_spherical")
        self.label_8 = QtWidgets.QLabel(self.centralwidget)
        self.label_8.setGeometry(QtCore.QRect(470, 640, 71, 21))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label_8.setFont(font)
        self.label_8.setObjectName("label_8")
        self.label_leaf = QtWidgets.QLabel(self.centralwidget)
        self.label_leaf.setGeometry(QtCore.QRect(570, 640, 91, 31))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label_leaf.setFont(font)
        self.label_leaf.setText("")
        self.label_leaf.setObjectName("label_leaf")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1239, 23))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.videoFrame.setText(_translate("MainWindow", "Video Frame"))
        self.videoFrame_2.setText(_translate("MainWindow", "Video Frame"))
        self.btnCapture.setText(_translate("MainWindow", "拍照"))
        self.label.setText(_translate("MainWindow", "Species"))
        self.label_2.setText(_translate("MainWindow", "状态"))
        self.label_3.setText(_translate("MainWindow", "检测状态"))
        self.label_4.setText(_translate("MainWindow", "矩形度"))
        self.label_5.setText(_translate("MainWindow", "延长度"))
        self.label_6.setText(_translate("MainWindow", "似圆度"))
        self.label_7.setText(_translate("MainWindow", "球状性"))
        self.label_8.setText(_translate("MainWindow", "叶状性"))


insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/sheziqiong/article/details/130740439