Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the Plant recognition system based on Python

Shulou Source: shulou.com Published: 2022-06-02 06:46:14 10月04日 Update

This article mainly introduces how to achieve a small plant recognition system based on Python, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.

Body 1) Environmental installation

The environment used in this article: Python3.7 Pycharm Community Edition module: PyQt5.

2) main program import sysfrom PyQt5.QtWidgets import (QWidget,QApplication,QGridLayout,QLabel, QLineEdit,QTextEdit,QPushButton,QFrame) QFileDialog) from PyQt5.QtGui import QPixmap# import baiduAPI call module import requestclass AIGUI (QWidget): def _ _ init__ (self): super (). _ init__ () self.initUI () def initUI (self): # related initialization code for table classes # setSpacing is to set the outer frame of each control grid=QGridLayout () grid.setSpacing (10) # each control # 1 control explain=QLabel ('Please select the picture you want to identify') # 2 order number text box self.imgUrl=QLineEdit () # 3 Button self.select=QPushButton ("Select Picture") # add an event handler function self.select.clicked.connect (self.openfile) # 4 to the button Picture frame self.imgLab=QLabel ("11.png") self.imgLab.setFrameShape (QFrame.Box) # imgLab.setFrameShadow (QFrame.Raised) self.imgLab.setLineWidth (1) # imgLab.setPixmap (QPixmap (")) # No. 5 Multi-line self.info=QTextEdit () # rational layout of controls grid.addWidget (explain,1,0) grid.addWidget (self.imgUrl,1,1) grid.addWidget (self.select,1,2) grid.addWidget (self.imgLab,2,0,5,3) grid.addWidget (self.info,1,3 6 grid 1) # the last setting of the window self.setLayout (grid) self.setGeometry (300300350300) self.setWindowTitle ("plant recognition mini system") self.show () def openfile (self): # Open the picture pop-up window Select picture self.select_path=QFileDialog.getOpenFileName (self, "Select picture to be recognized", "/", "Imgae Files (* .jpg * .png)") # if no picture is selected Empty if not self.select_path [0] .strip (): pass else: # execute the following content after selecting the picture # set the path of the picture self.imgUrl.setText (self.select_path [0]) # display the picture in the picture label box # 1) according to the path pixmap Parse pixmap=QPixmap (self.select_path [0]) # 2) Zoom Image scalePixmap=pixmap.scaledToWidth (300) # scaledPixmap=pixmap.scaled (QSize (311301)) # 3) display self.imgLab.setPixmap (scalePixmap) result=self.identify () self.info.setText (result) # with Baidu AI Platform completes plant recognition work def identify (self): result=Request.BaiduAPI (self.select_path [0]) return result def main (): app=QApplication (sys.argv) ai=AIGUI () sys.exit (app.exec_ ()) if _ name__=='__main__': main () 3) effect display

First group of roses:

Second group of lilies:

Thank you for reading this article carefully. I hope the article "how to implement a small plant recognition system based on Python" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Picture selection plant control article system button module environment path main program event code value interest content function order number at the same time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Information Shulou Tech Info Xiaomi vpn