Update
This commit is contained in:
		
							parent
							
								
									427fdf4739
								
							
						
					
					
						commit
						54a071efcc
					
				
							
								
								
									
										600
									
								
								Code/Client/Client_Ui.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										600
									
								
								Code/Client/Client_Ui.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,600 @@ | ||||
| # -*- coding: utf-8 -*- | ||||
| 
 | ||||
| # Form implementation generated from reading ui file 'F:/GUO/test/qss/Client_Ui.ui' | ||||
| # | ||||
| # Created by: PyQt4 UI code generator 4.11.4 | ||||
| # | ||||
| # WARNING! All changes made in this file will be lost! | ||||
| 
 | ||||
| from PyQt4 import QtCore, QtGui | ||||
| 
 | ||||
| try: | ||||
|     _fromUtf8 = QtCore.QString.fromUtf8 | ||||
| except AttributeError: | ||||
|     def _fromUtf8(s): | ||||
|         return s | ||||
| 
 | ||||
| try: | ||||
|     _encoding = QtGui.QApplication.UnicodeUTF8 | ||||
|     def _translate(context, text, disambig): | ||||
|         return QtGui.QApplication.translate(context, text, disambig, _encoding) | ||||
| except AttributeError: | ||||
|     def _translate(context, text, disambig): | ||||
|         return QtGui.QApplication.translate(context, text, disambig) | ||||
| 
 | ||||
| class Ui_Client(object): | ||||
|     def setupUi(self, Client): | ||||
|         Client.setObjectName(_fromUtf8("Client")) | ||||
|         Client.resize(760, 610) | ||||
|         palette = QtGui.QPalette() | ||||
|         brush = QtGui.QBrush(QtGui.QColor(72, 72, 72)) | ||||
|         brush.setStyle(QtCore.Qt.SolidPattern) | ||||
|         palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush) | ||||
|         brush = QtGui.QBrush(QtGui.QColor(72, 72, 72)) | ||||
|         brush.setStyle(QtCore.Qt.SolidPattern) | ||||
|         palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush) | ||||
|         brush = QtGui.QBrush(QtGui.QColor(72, 72, 72)) | ||||
|         brush.setStyle(QtCore.Qt.SolidPattern) | ||||
|         palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush) | ||||
|         brush = QtGui.QBrush(QtGui.QColor(72, 72, 72)) | ||||
|         brush.setStyle(QtCore.Qt.SolidPattern) | ||||
|         palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush) | ||||
|         brush = QtGui.QBrush(QtGui.QColor(72, 72, 72)) | ||||
|         brush.setStyle(QtCore.Qt.SolidPattern) | ||||
|         palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush) | ||||
|         brush = QtGui.QBrush(QtGui.QColor(72, 72, 72)) | ||||
|         brush.setStyle(QtCore.Qt.SolidPattern) | ||||
|         palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush) | ||||
|         brush = QtGui.QBrush(QtGui.QColor(72, 72, 72)) | ||||
|         brush.setStyle(QtCore.Qt.SolidPattern) | ||||
|         palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush) | ||||
|         brush = QtGui.QBrush(QtGui.QColor(72, 72, 72)) | ||||
|         brush.setStyle(QtCore.Qt.SolidPattern) | ||||
|         palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush) | ||||
|         brush = QtGui.QBrush(QtGui.QColor(72, 72, 72)) | ||||
|         brush.setStyle(QtCore.Qt.SolidPattern) | ||||
|         palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush) | ||||
|         Client.setPalette(palette) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(14) | ||||
|         Client.setFont(font) | ||||
|         Client.setStyleSheet(_fromUtf8("QWidget{\n" | ||||
| "background:#484848;\n" | ||||
| "}\n" | ||||
| "QAbstractButton{\n" | ||||
| "border-style:none;\n" | ||||
| "border-radius:0px;\n" | ||||
| "padding:5px;\n" | ||||
| "color:#DCDCDC;\n" | ||||
| "background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #484848,stop:1 #383838);\n" | ||||
| "}\n" | ||||
| "QAbstractButton:hover{\n" | ||||
| "color:#FFFFFF;\n" | ||||
| "background-color:#00BB9E;\n" | ||||
| "}\n" | ||||
| "QAbstractButton:pressed{\n" | ||||
| "color:#DCDCDC;\n" | ||||
| "border-style:solid;\n" | ||||
| "border-width:0px 0px 0px 2px;\n" | ||||
| "padding:4px 4px 4px 2px;\n" | ||||
| "border-color:#00BB9E;\n" | ||||
| "background-color:#444444;\n" | ||||
| "}\n" | ||||
| "QLabel{\n" | ||||
| "color:#DCDCDC;\n" | ||||
| "border:1px solid #242424;\n" | ||||
| "background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #484848,stop:1 #383838);\n" | ||||
| "}\n" | ||||
| "QLabel:focus{\n" | ||||
| "border:1px solid #00BB9E;\n" | ||||
| "background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #646464,stop:1 #525252);\n" | ||||
| "}\n" | ||||
| "QLineEdit{\n" | ||||
| "border:1px solid #242424;\n" | ||||
| "border-radius:3px;\n" | ||||
| "padding:2px;\n" | ||||
| "background:none;\n" | ||||
| "selection-background-color:#484848;\n" | ||||
| "selection-color:#DCDCDC;\n" | ||||
| "}\n" | ||||
| "QLineEdit:focus,QLineEdit:hover{\n" | ||||
| "border:1px solid #242424;\n" | ||||
| "}\n" | ||||
| "QLineEdit{\n" | ||||
| "border:1px solid #242424;\n" | ||||
| "border-radius:3px;\n" | ||||
| "padding:2px;\n" | ||||
| "background:none;\n" | ||||
| "selection-background-color:#484848;\n" | ||||
| "selection-color:#DCDCDC;\n" | ||||
| "}\n" | ||||
| "\n" | ||||
| "QLineEdit:focus,QLineEdit:hover{\n" | ||||
| "border:1px solid #242424;\n" | ||||
| "}\n" | ||||
| "QLineEdit{\n" | ||||
| "lineedit-password-character:9679;\n" | ||||
| "}\n" | ||||
| "QSlider::groove:horizontal,QSlider::add-page:horizontal{\n" | ||||
| "height:3px;\n" | ||||
| "border-radius:3px;\n" | ||||
| "background:#18181a;\n" | ||||
| "}\n" | ||||
| "\n" | ||||
| "\n" | ||||
| "QSlider::sub-page:horizontal{\n" | ||||
| "height:8px;\n" | ||||
| "border-radius:3px;\n" | ||||
| "background:#008aff;\n" | ||||
| "}\n" | ||||
| "\n" | ||||
| "\n" | ||||
| "QSlider::handle:horizontal{\n" | ||||
| "width:12px;\n" | ||||
| "margin-top:-5px;\n" | ||||
| "margin-bottom:-4px;\n" | ||||
| "border-radius:6px;\n" | ||||
| "background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #565656,stop:0.8 #565656);\n" | ||||
| "}\n" | ||||
| "\n" | ||||
| "\n" | ||||
| "QSlider::groove:vertical,QSlider::sub-page:vertical{\n" | ||||
| "width:3px;\n" | ||||
| "border-radius:3px;\n" | ||||
| "background:#18181a;\n" | ||||
| "}\n" | ||||
| "\n" | ||||
| "\n" | ||||
| "QSlider::add-page:vertical{\n" | ||||
| "width:8px;\n" | ||||
| "border-radius:3px;\n" | ||||
| "background:#008aff;\n" | ||||
| "}\n" | ||||
| "\n" | ||||
| "\n" | ||||
| "QSlider::handle:vertical{\n" | ||||
| "height:12px;\n" | ||||
| "margin-left:-5px;\n" | ||||
| "margin-right:-4px;\n" | ||||
| "border-radius:6px;\n" | ||||
| "background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #565656,stop:0.8 #565656);\n" | ||||
| "}\n" | ||||
| "")) | ||||
|         self.Btn_ForWard = QtGui.QPushButton(Client) | ||||
|         self.Btn_ForWard.setGeometry(QtCore.QRect(120, 450, 90, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Btn_ForWard.setFont(font) | ||||
|         self.Btn_ForWard.setStyleSheet(_fromUtf8("")) | ||||
|         self.Btn_ForWard.setObjectName(_fromUtf8("Btn_ForWard")) | ||||
|         self.name = QtGui.QLabel(Client) | ||||
|         self.name.setGeometry(QtCore.QRect(0, 1, 660, 40)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(28) | ||||
|         font.setBold(True) | ||||
|         font.setWeight(75) | ||||
|         self.name.setFont(font) | ||||
|         self.name.setStyleSheet(_fromUtf8("")) | ||||
|         self.name.setObjectName(_fromUtf8("name")) | ||||
|          | ||||
|         self.Btn_Turn_Left = QtGui.QPushButton(Client) | ||||
|         self.Btn_Turn_Left.setGeometry(QtCore.QRect(10, 500, 90, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Btn_Turn_Left.setFont(font) | ||||
|         self.Btn_Turn_Left.setStyleSheet(_fromUtf8("")) | ||||
|         self.Btn_Turn_Left.setObjectName(_fromUtf8("Btn_Turn_Left")) | ||||
|          | ||||
|         self.Btn_BackWard = QtGui.QPushButton(Client) | ||||
|         self.Btn_BackWard.setGeometry(QtCore.QRect(120, 550, 90, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Btn_BackWard.setFont(font) | ||||
|         self.Btn_BackWard.setStyleSheet(_fromUtf8("")) | ||||
|         self.Btn_BackWard.setObjectName(_fromUtf8("Btn_BackWard")) | ||||
| 
 | ||||
|         self.Btn_Tracking_Faces = QtGui.QPushButton(Client) | ||||
|         self.Btn_Tracking_Faces.setGeometry(QtCore.QRect(240, 450, 90, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Btn_Tracking_Faces.setFont(font) | ||||
|         self.Btn_Tracking_Faces.setStyleSheet(_fromUtf8("")) | ||||
|         self.Btn_Tracking_Faces.setObjectName(_fromUtf8("Btn_Tracking_Faces")) | ||||
|          | ||||
|         self.Btn_Turn_Right = QtGui.QPushButton(Client) | ||||
|         self.Btn_Turn_Right.setGeometry(QtCore.QRect(240, 500, 90, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Btn_Turn_Right.setFont(font) | ||||
|         self.Btn_Turn_Right.setStyleSheet(_fromUtf8("")) | ||||
|         self.Btn_Turn_Right.setObjectName(_fromUtf8("Btn_Turn_Right")) | ||||
|         self.Btn_Video = QtGui.QPushButton(Client) | ||||
|         self.Btn_Video.setGeometry(QtCore.QRect(240, 380, 90, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Btn_Video.setFont(font) | ||||
|         self.Btn_Video.setStyleSheet(_fromUtf8("")) | ||||
|         self.Btn_Video.setObjectName(_fromUtf8("Btn_Video")) | ||||
|         self.label_Video = QtGui.QLabel(Client) | ||||
|         self.label_Video.setGeometry(QtCore.QRect(1, 42, 400, 300)) | ||||
|         self.label_Video.setText(_fromUtf8("")) | ||||
|         self.label_Video.setObjectName(_fromUtf8("label_Video")) | ||||
|         self.Btn_Down = QtGui.QPushButton(Client) | ||||
|         self.Btn_Down.setGeometry(QtCore.QRect(510, 480, 75, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Btn_Down.setFont(font) | ||||
|         self.Btn_Down.setStyleSheet(_fromUtf8("")) | ||||
|         self.Btn_Down.setObjectName(_fromUtf8("Btn_Down")) | ||||
|         self.Btn_Left = QtGui.QPushButton(Client) | ||||
|         self.Btn_Left.setGeometry(QtCore.QRect(440, 450, 75, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Btn_Left.setFont(font) | ||||
|         self.Btn_Left.setStyleSheet(_fromUtf8("")) | ||||
|         self.Btn_Left.setObjectName(_fromUtf8("Btn_Left")) | ||||
|         self.Btn_Home = QtGui.QPushButton(Client) | ||||
|         self.Btn_Home.setGeometry(QtCore.QRect(510, 450, 75, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Btn_Home.setFont(font) | ||||
|         self.Btn_Home.setStyleSheet(_fromUtf8("")) | ||||
|         self.Btn_Home.setObjectName(_fromUtf8("Btn_Home")) | ||||
|         self.Btn_Up = QtGui.QPushButton(Client) | ||||
|         self.Btn_Up.setGeometry(QtCore.QRect(510, 420, 75, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Btn_Up.setFont(font) | ||||
|         self.Btn_Up.setStyleSheet(_fromUtf8("")) | ||||
|         self.Btn_Up.setObjectName(_fromUtf8("Btn_Up")) | ||||
|         self.Btn_Right = QtGui.QPushButton(Client) | ||||
|         self.Btn_Right.setGeometry(QtCore.QRect(580, 450, 75, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Btn_Right.setFont(font) | ||||
|         self.Btn_Right.setStyleSheet(_fromUtf8("")) | ||||
|         self.Btn_Right.setObjectName(_fromUtf8("Btn_Right")) | ||||
|         self.Window_Close = QtGui.QPushButton(Client) | ||||
|         self.Window_Close.setGeometry(QtCore.QRect(710, 1, 50, 40)) | ||||
|         self.Window_Close.setObjectName(_fromUtf8("Window_Close")) | ||||
|         self.IP = QtGui.QLineEdit(Client) | ||||
|         self.IP.setGeometry(QtCore.QRect(10, 380, 101, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.IP.setFont(font) | ||||
|         self.IP.setStyleSheet(_fromUtf8("")) | ||||
|         self.IP.setObjectName(_fromUtf8("IP")) | ||||
|         self.Btn_Connect = QtGui.QPushButton(Client) | ||||
|         self.Btn_Connect.setGeometry(QtCore.QRect(120, 380, 90, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Btn_Connect.setFont(font) | ||||
|         self.Btn_Connect.setObjectName(_fromUtf8("Btn_Connect")) | ||||
|         self.checkBox_Led1 = QtGui.QCheckBox(Client) | ||||
|         self.checkBox_Led1.setGeometry(QtCore.QRect(420, 120, 91, 31)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.checkBox_Led1.setFont(font) | ||||
|         self.checkBox_Led1.setObjectName(_fromUtf8("checkBox_Led1")) | ||||
|         self.label_Servo2 = QtGui.QLabel(Client) | ||||
|         self.label_Servo2.setGeometry(QtCore.QRect(710, 460, 41, 31)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(14) | ||||
|         self.label_Servo2.setFont(font) | ||||
|         self.label_Servo2.setObjectName(_fromUtf8("label_Servo2")) | ||||
|         self.checkBox_Led2 = QtGui.QCheckBox(Client) | ||||
|         self.checkBox_Led2.setGeometry(QtCore.QRect(420, 170, 91, 31)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.checkBox_Led2.setFont(font) | ||||
|         self.checkBox_Led2.setObjectName(_fromUtf8("checkBox_Led2")) | ||||
|         self.checkBox_Led3 = QtGui.QCheckBox(Client) | ||||
|         self.checkBox_Led3.setGeometry(QtCore.QRect(420, 220, 91, 31)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.checkBox_Led3.setFont(font) | ||||
|         self.checkBox_Led3.setObjectName(_fromUtf8("checkBox_Led3")) | ||||
|         self.checkBox_Led4 = QtGui.QCheckBox(Client) | ||||
|         self.checkBox_Led4.setGeometry(QtCore.QRect(420, 270, 91, 31)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.checkBox_Led4.setFont(font) | ||||
|         self.checkBox_Led4.setObjectName(_fromUtf8("checkBox_Led4")) | ||||
|         self.checkBox_Led5 = QtGui.QCheckBox(Client) | ||||
|         self.checkBox_Led5.setGeometry(QtCore.QRect(530, 120, 91, 31)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.checkBox_Led5.setFont(font) | ||||
|         self.checkBox_Led5.setObjectName(_fromUtf8("checkBox_Led5")) | ||||
|         self.checkBox_Led6 = QtGui.QCheckBox(Client) | ||||
|         self.checkBox_Led6.setGeometry(QtCore.QRect(530, 170, 91, 31)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.checkBox_Led6.setFont(font) | ||||
|         self.checkBox_Led6.setObjectName(_fromUtf8("checkBox_Led6")) | ||||
|         self.checkBox_Led7 = QtGui.QCheckBox(Client) | ||||
|         self.checkBox_Led7.setGeometry(QtCore.QRect(530, 220, 91, 31)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.checkBox_Led7.setFont(font) | ||||
|         self.checkBox_Led7.setObjectName(_fromUtf8("checkBox_Led7")) | ||||
|         self.checkBox_Led8 = QtGui.QCheckBox(Client) | ||||
|         self.checkBox_Led8.setGeometry(QtCore.QRect(530, 270, 91, 31)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.checkBox_Led8.setFont(font) | ||||
|         self.checkBox_Led8.setObjectName(_fromUtf8("checkBox_Led8")) | ||||
|         self.HSlider_Servo1 = QtGui.QSlider(Client) | ||||
|         self.HSlider_Servo1.setGeometry(QtCore.QRect(470, 530, 160, 22)) | ||||
|         self.HSlider_Servo1.setStyleSheet(_fromUtf8("")) | ||||
|         self.HSlider_Servo1.setOrientation(QtCore.Qt.Horizontal) | ||||
|         self.HSlider_Servo1.setObjectName(_fromUtf8("HSlider_Servo1")) | ||||
|         self.VSlider_Servo2 = QtGui.QSlider(Client) | ||||
|         self.VSlider_Servo2.setGeometry(QtCore.QRect(680, 400, 22, 160)) | ||||
|         self.VSlider_Servo2.setStyleSheet(_fromUtf8("")) | ||||
|         self.VSlider_Servo2.setOrientation(QtCore.Qt.Vertical) | ||||
|         self.VSlider_Servo2.setObjectName(_fromUtf8("VSlider_Servo2")) | ||||
|         self.label_Servo1 = QtGui.QLabel(Client) | ||||
|         self.label_Servo1.setGeometry(QtCore.QRect(530, 560, 41, 31)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(14) | ||||
|         self.label_Servo1.setFont(font) | ||||
|         self.label_Servo1.setObjectName(_fromUtf8("label_Servo1")) | ||||
|         self.checkBox_Led_Mode2 = QtGui.QCheckBox(Client) | ||||
|         self.checkBox_Led_Mode2.setGeometry(QtCore.QRect(640, 170, 91, 31)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.checkBox_Led_Mode2.setFont(font) | ||||
|         self.checkBox_Led_Mode2.setObjectName(_fromUtf8("checkBox_Led_Mode2")) | ||||
|         self.checkBox_Led_Mode3 = QtGui.QCheckBox(Client) | ||||
|         self.checkBox_Led_Mode3.setGeometry(QtCore.QRect(640, 220, 91, 31)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.checkBox_Led_Mode3.setFont(font) | ||||
|         self.checkBox_Led_Mode3.setObjectName(_fromUtf8("checkBox_Led_Mode3")) | ||||
|         self.checkBox_Led_Mode4 = QtGui.QCheckBox(Client) | ||||
|         self.checkBox_Led_Mode4.setGeometry(QtCore.QRect(640, 270, 91, 31)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.checkBox_Led_Mode4.setFont(font) | ||||
|         self.checkBox_Led_Mode4.setObjectName(_fromUtf8("checkBox_Led_Mode4")) | ||||
|         self.checkBox_Led_Mode1 = QtGui.QCheckBox(Client) | ||||
|         self.checkBox_Led_Mode1.setGeometry(QtCore.QRect(640, 120, 91, 31)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.checkBox_Led_Mode1.setFont(font) | ||||
|         self.checkBox_Led_Mode1.setObjectName(_fromUtf8("checkBox_Led_Mode1")) | ||||
|         self.Color_R = QtGui.QLineEdit(Client) | ||||
|         self.Color_R.setGeometry(QtCore.QRect(560, 90, 30, 20)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Color_R.setFont(font) | ||||
|         self.Color_R.setObjectName(_fromUtf8("Color_R")) | ||||
|         self.Color_G = QtGui.QLineEdit(Client) | ||||
|         self.Color_G.setGeometry(QtCore.QRect(630, 90, 30, 20)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Color_G.setFont(font) | ||||
|         self.Color_G.setObjectName(_fromUtf8("Color_G")) | ||||
|         self.Color_B = QtGui.QLineEdit(Client) | ||||
|         self.Color_B.setGeometry(QtCore.QRect(700, 90, 30, 20)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Color_B.setFont(font) | ||||
|         self.Color_B.setObjectName(_fromUtf8("Color_B")) | ||||
|         self.HSlider_FineServo2 = QtGui.QSlider(Client) | ||||
|         self.HSlider_FineServo2.setGeometry(QtCore.QRect(480, 370, 160, 22)) | ||||
|         self.HSlider_FineServo2.setOrientation(QtCore.Qt.Horizontal) | ||||
|         self.HSlider_FineServo2.setObjectName(_fromUtf8("HSlider_FineServo2")) | ||||
|         self.HSlider_FineServo1 = QtGui.QSlider(Client) | ||||
|         self.HSlider_FineServo1.setGeometry(QtCore.QRect(480, 320, 160, 22)) | ||||
|         self.HSlider_FineServo1.setOrientation(QtCore.Qt.Horizontal) | ||||
|         self.HSlider_FineServo1.setObjectName(_fromUtf8("HSlider_FineServo1")) | ||||
|         self.label_FineServo1 = QtGui.QLabel(Client) | ||||
|         self.label_FineServo1.setGeometry(QtCore.QRect(650, 320, 41, 31)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(14) | ||||
|         self.label_FineServo1.setFont(font) | ||||
|         self.label_FineServo1.setObjectName(_fromUtf8("label_FineServo1")) | ||||
|         self.label_FineServo2 = QtGui.QLabel(Client) | ||||
|         self.label_FineServo2.setGeometry(QtCore.QRect(650, 360, 41, 31)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(14) | ||||
|         self.label_FineServo2.setFont(font) | ||||
|         self.label_FineServo2.setObjectName(_fromUtf8("label_FineServo2")) | ||||
|         self.Window_Min = QtGui.QPushButton(Client) | ||||
|         self.Window_Min.setGeometry(QtCore.QRect(660, 1, 50, 40)) | ||||
|         self.Window_Min.setObjectName(_fromUtf8("Window_Min")) | ||||
|         self.R = QtGui.QLabel(Client) | ||||
|         self.R.setGeometry(QtCore.QRect(530, 90, 16, 20)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.R.setFont(font) | ||||
|         self.R.setObjectName(_fromUtf8("R")) | ||||
|         self.G = QtGui.QLabel(Client) | ||||
|         self.G.setGeometry(QtCore.QRect(600, 90, 16, 20)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.G.setFont(font) | ||||
|         self.G.setObjectName(_fromUtf8("G")) | ||||
|         self.B = QtGui.QLabel(Client) | ||||
|         self.B.setGeometry(QtCore.QRect(670, 90, 16, 20)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.B.setFont(font) | ||||
|         self.B.setObjectName(_fromUtf8("B")) | ||||
|         self.Led_Module = QtGui.QLabel(Client) | ||||
|         self.Led_Module.setGeometry(QtCore.QRect(410, 90, 111, 25)) | ||||
|         self.Led_Module.setObjectName(_fromUtf8("Led_Module")) | ||||
|         self.Servo1 = QtGui.QLabel(Client) | ||||
|         self.Servo1.setGeometry(QtCore.QRect(420, 320, 54, 20)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Servo1.setFont(font) | ||||
|         self.Servo1.setObjectName(_fromUtf8("Servo1")) | ||||
|         self.Servo2 = QtGui.QLabel(Client) | ||||
|         self.Servo2.setGeometry(QtCore.QRect(420, 370, 54, 20)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Servo2.setFont(font) | ||||
|         self.Servo2.setObjectName(_fromUtf8("Servo2")) | ||||
|         self.progress_Power = QtGui.QProgressBar(Client) | ||||
|         self.progress_Power.setGeometry(QtCore.QRect(20, 550, 70, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.progress_Power.setFont(font) | ||||
|         self.progress_Power.setStyleSheet(_fromUtf8("QProgressBar {\n" | ||||
| "border: 2px solid grey;\n" | ||||
| "border-radius: 5px;\n" | ||||
| "background-color: #FFFFFF;\n" | ||||
| "}\n" | ||||
| "\n" | ||||
| "QProgressBar::chunk {\n" | ||||
| "background-color:#696969;\n" | ||||
| "width: 20px;\n" | ||||
| "}\n" | ||||
| "\n" | ||||
| "QProgressBar {\n" | ||||
| "text-align: center; \n" | ||||
| "color: rgb(152,251,152);\n" | ||||
| "}\n" | ||||
| "")) | ||||
|         self.progress_Power.setProperty("value", 0) | ||||
|         self.progress_Power.setObjectName(_fromUtf8("progress_Power")) | ||||
|         self.Btn_Buzzer = QtGui.QPushButton(Client) | ||||
|         self.Btn_Buzzer.setGeometry(QtCore.QRect(120, 500, 90, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Btn_Buzzer.setFont(font) | ||||
|         self.Btn_Buzzer.setObjectName(_fromUtf8("Btn_Buzzer")) | ||||
|         self.Ultrasonic = QtGui.QPushButton(Client) | ||||
|         self.Ultrasonic.setGeometry(QtCore.QRect(401, 41, 180, 30)) | ||||
|         self.Ultrasonic.setObjectName(_fromUtf8("Ultrasonic")) | ||||
|         self.Light = QtGui.QPushButton(Client) | ||||
|         self.Light.setGeometry(QtCore.QRect(581, 41, 179, 30)) | ||||
|         self.Light.setObjectName(_fromUtf8("Light")) | ||||
|         self.Btn_Mode1 = QtGui.QRadioButton(Client) | ||||
|         self.Btn_Mode1.setGeometry(QtCore.QRect(340, 400, 90, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Btn_Mode1.setFont(font) | ||||
|         self.Btn_Mode1.setObjectName(_fromUtf8("Btn_Mode1")) | ||||
|         self.Btn_Mode2 = QtGui.QRadioButton(Client) | ||||
|         self.Btn_Mode2.setGeometry(QtCore.QRect(340, 450, 90, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Btn_Mode2.setFont(font) | ||||
|         self.Btn_Mode2.setObjectName(_fromUtf8("Btn_Mode2")) | ||||
|         self.Btn_Mode3 = QtGui.QRadioButton(Client) | ||||
|         self.Btn_Mode3.setGeometry(QtCore.QRect(340, 500, 90, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Btn_Mode3.setFont(font) | ||||
|         self.Btn_Mode3.setObjectName(_fromUtf8("Btn_Mode3")) | ||||
|         self.Btn_Mode4 = QtGui.QRadioButton(Client) | ||||
|         self.Btn_Mode4.setGeometry(QtCore.QRect(340, 550, 90, 30)) | ||||
|         font = QtGui.QFont() | ||||
|         font.setFamily(_fromUtf8("3ds")) | ||||
|         font.setPointSize(10) | ||||
|         self.Btn_Mode4.setFont(font) | ||||
|         self.Btn_Mode4.setObjectName(_fromUtf8("Btn_Mode4")) | ||||
| 
 | ||||
|         self.retranslateUi(Client) | ||||
|         QtCore.QMetaObject.connectSlotsByName(Client) | ||||
| 
 | ||||
|     def retranslateUi(self, Client): | ||||
|         Client.setWindowTitle(_translate("Client", "freenove", None)) | ||||
|         self.Btn_ForWard.setText(_translate("Client", "ForWard", None)) | ||||
|         self.name.setText(_translate("Client", "Freenove", None)) | ||||
|         self.Btn_Turn_Left.setText(_translate("Client", "Turn Left", None)) | ||||
|         self.Btn_BackWard.setText(_translate("Client", "BackWard", None)) | ||||
|         self.Btn_Turn_Right.setText(_translate("Client", "Turn Right", None)) | ||||
|         self.Btn_Video.setText(_translate("Client", "Open Video", None)) | ||||
|         self.Btn_Tracking_Faces.setText(_translate("Client", "Tracing-On", None)) | ||||
| 
 | ||||
|         self.Btn_Down.setText(_translate("Client", "Down", None)) | ||||
|         self.Btn_Left.setText(_translate("Client", "Left", None)) | ||||
|         self.Btn_Home.setText(_translate("Client", "Home", None)) | ||||
|         self.Btn_Up.setText(_translate("Client", "Up", None)) | ||||
|         self.Btn_Right.setText(_translate("Client", "Right", None)) | ||||
|         self.Window_Close.setText(_translate("Client", "×", None)) | ||||
|         self.IP.setText(_translate("Client", "IP Address", None)) | ||||
|         self.Btn_Connect.setText(_translate("Client", "Connect", None)) | ||||
|         self.checkBox_Led1.setText(_translate("Client", "Led1", None)) | ||||
|         self.label_Servo2.setText(_translate("Client", "0", None)) | ||||
|         self.checkBox_Led2.setText(_translate("Client", "Led2", None)) | ||||
|         self.checkBox_Led3.setText(_translate("Client", "Led3", None)) | ||||
|         self.checkBox_Led4.setText(_translate("Client", "Led4", None)) | ||||
|         self.checkBox_Led5.setText(_translate("Client", "Led5", None)) | ||||
|         self.checkBox_Led6.setText(_translate("Client", "Led6", None)) | ||||
|         self.checkBox_Led7.setText(_translate("Client", "Led7", None)) | ||||
|         self.checkBox_Led8.setText(_translate("Client", "Led8", None)) | ||||
|         self.label_Servo1.setText(_translate("Client", "90", None)) | ||||
|         self.checkBox_Led_Mode2.setText(_translate("Client", "Led_Mode2", None)) | ||||
|         self.checkBox_Led_Mode3.setText(_translate("Client", "Led_Mode3", None)) | ||||
|         self.checkBox_Led_Mode4.setText(_translate("Client", "Led_Mode4", None)) | ||||
|         self.checkBox_Led_Mode1.setText(_translate("Client", "Led_Mode1", None)) | ||||
|         self.Color_R.setText(_translate("Client", "255", None)) | ||||
|         self.Color_G.setText(_translate("Client", "0", None)) | ||||
|         self.Color_B.setText(_translate("Client", "0", None)) | ||||
|         self.label_FineServo1.setText(_translate("Client", "0", None)) | ||||
|         self.label_FineServo2.setText(_translate("Client", "0", None)) | ||||
|         self.Window_Min.setText(_translate("Client", "-", None)) | ||||
|         self.R.setText(_translate("Client", "R", None)) | ||||
|         self.G.setText(_translate("Client", "G", None)) | ||||
|         self.B.setText(_translate("Client", "B", None)) | ||||
|         self.Led_Module.setText(_translate("Client", "Led Module", None)) | ||||
|         self.Servo1.setText(_translate("Client", "Servo 1", None)) | ||||
|         self.Servo2.setText(_translate("Client", "Servo 2", None)) | ||||
|         self.Btn_Buzzer.setText(_translate("Client", "Buzzer", None)) | ||||
|         self.Ultrasonic.setText(_translate("Client", "Ultrasonic", None)) | ||||
|         self.Light.setText(_translate("Client", "Light", None)) | ||||
|         self.Btn_Mode1.setText(_translate("Client", "M-Free", None)) | ||||
|         self.Btn_Mode2.setText(_translate("Client", "M-Light", None)) | ||||
|         self.Btn_Mode3.setText(_translate("Client", "M-Sonic", None)) | ||||
|         self.Btn_Mode4.setText(_translate("Client", "M-Line", None)) | ||||
| 
 | ||||
							
								
								
									
										676
									
								
								Code/Client/Main.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										676
									
								
								Code/Client/Main.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,676 @@ | ||||
| #!/usr/bin/python  | ||||
| # -*- coding: utf-8 -*- | ||||
| import numpy as np | ||||
| import cv2 | ||||
| import socket | ||||
| import os | ||||
| import io | ||||
| import time | ||||
| import imghdr | ||||
| import sys | ||||
| from threading import Timer | ||||
| from threading import Thread | ||||
| from PIL import Image | ||||
| from Command import COMMAND as cmd | ||||
| from Thread import * | ||||
| from Client_Ui import Ui_Client | ||||
| from Video import * | ||||
| from PyQt4.QtCore import * | ||||
| from PyQt4 import  QtGui, QtCore | ||||
| from PyQt4.QtGui import * | ||||
| from PyQt4.QtCore import pyqtSignature | ||||
| from PyQt4.QtGui import (QApplication, QMainWindow, QGraphicsScene) | ||||
| 
 | ||||
| 
 | ||||
|          | ||||
| class mywindow(QMainWindow,Ui_Client): | ||||
|     def __init__(self): | ||||
|         global timer | ||||
|         super(mywindow,self).__init__() | ||||
|         self.setupUi(self) | ||||
|         self.h=self.IP.text() | ||||
|         self.TCP=VideoStreaming() | ||||
|         self.servo1=90 | ||||
|         self.servo2=20 | ||||
|         self.label_FineServo2.setText("0") | ||||
|         self.label_FineServo1.setText("0") | ||||
|         self.m_DragPosition=self.pos() | ||||
|         self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) | ||||
|         self.setMouseTracking(True) | ||||
|         self.Key_W=False | ||||
|         self.Key_A=False | ||||
|         self.Key_S=False | ||||
|         self.Key_D=False | ||||
|         self.Key_Space=False | ||||
|          | ||||
|         self.setFocusPolicy(Qt.StrongFocus) | ||||
| 
 | ||||
|         self.progress_Power.setMinimum(0) | ||||
|         self.progress_Power.setMaximum(100) | ||||
|          | ||||
|         self.name.setAlignment(QtCore.Qt.AlignCenter) | ||||
|         self.label_Servo1.setText('90') | ||||
|         self.label_Servo2.setText('20') | ||||
|         self.label_Video.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignVCenter) | ||||
|         self.label_Servo1.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignVCenter) | ||||
|         self.label_Servo2.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignVCenter) | ||||
|          | ||||
|         self.label_FineServo1.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignVCenter) | ||||
|         self.label_FineServo2.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignVCenter) | ||||
|          | ||||
|          | ||||
| 
 | ||||
|         self.HSlider_Servo1.setMinimum(0) | ||||
|         self.HSlider_Servo1.setMaximum(180) | ||||
|         self.HSlider_Servo1.setSingleStep(1) | ||||
|         self.HSlider_Servo1.setValue(self.servo1) | ||||
|         self.HSlider_Servo1.valueChanged.connect(self.Change_Left_Right) | ||||
| 
 | ||||
|         self.HSlider_FineServo1.setMinimum(-10) | ||||
|         self.HSlider_FineServo1.setMaximum(10) | ||||
|         self.HSlider_FineServo1.setSingleStep(1) | ||||
|         self.HSlider_FineServo1.setValue(0) | ||||
|         self.HSlider_FineServo1.valueChanged.connect(self.Fine_Tune_Left_Right) | ||||
| 
 | ||||
|         self.HSlider_FineServo2.setMinimum(-10) | ||||
|         self.HSlider_FineServo2.setMaximum(10) | ||||
|         self.HSlider_FineServo2.setSingleStep(1) | ||||
|         self.HSlider_FineServo2.setValue(0) | ||||
|         self.HSlider_FineServo2.valueChanged.connect(self.Fine_Tune_Up_Down) | ||||
|          | ||||
|         self.VSlider_Servo2.setMinimum(0) | ||||
|         self.VSlider_Servo2.setMaximum(150) | ||||
|         self.VSlider_Servo2.setSingleStep(1) | ||||
|         self.VSlider_Servo2.setValue(self.servo2) | ||||
|         self.VSlider_Servo2.valueChanged.connect(self.Change_Up_Down) | ||||
|          | ||||
|         self.checkBox_Led1.setChecked(False) | ||||
|         self.checkBox_Led1.stateChanged.connect(lambda:self.LedChange(self.checkBox_Led1)) | ||||
|         self.checkBox_Led2.setChecked(False) | ||||
|         self.checkBox_Led2.stateChanged.connect(lambda:self.LedChange(self.checkBox_Led2)) | ||||
|         self.checkBox_Led3.setChecked(False) | ||||
|         self.checkBox_Led3.stateChanged.connect(lambda:self.LedChange(self.checkBox_Led3)) | ||||
|         self.checkBox_Led4.setChecked(False) | ||||
|         self.checkBox_Led4.stateChanged.connect(lambda:self.LedChange(self.checkBox_Led4)) | ||||
|         self.checkBox_Led5.setChecked(False) | ||||
|         self.checkBox_Led5.stateChanged.connect(lambda:self.LedChange(self.checkBox_Led5)) | ||||
|         self.checkBox_Led6.setChecked(False) | ||||
|         self.checkBox_Led6.stateChanged.connect(lambda:self.LedChange(self.checkBox_Led6)) | ||||
|         self.checkBox_Led7.setChecked(False) | ||||
|         self.checkBox_Led7.stateChanged.connect(lambda:self.LedChange(self.checkBox_Led7)) | ||||
|         self.checkBox_Led8.setChecked(False) | ||||
|         self.checkBox_Led8.stateChanged.connect(lambda:self.LedChange(self.checkBox_Led8)) | ||||
|          | ||||
|         self.checkBox_Led_Mode1.setChecked(False) | ||||
|         self.checkBox_Led_Mode1.stateChanged.connect(lambda:self.LedChange(self.checkBox_Led_Mode1)) | ||||
|         self.checkBox_Led_Mode2.setChecked(False) | ||||
|         self.checkBox_Led_Mode2.stateChanged.connect(lambda:self.LedChange(self.checkBox_Led_Mode2)) | ||||
|         self.checkBox_Led_Mode3.setChecked(False) | ||||
|         self.checkBox_Led_Mode3.stateChanged.connect(lambda:self.LedChange(self.checkBox_Led_Mode3)) | ||||
|         self.checkBox_Led_Mode4.setChecked(False) | ||||
|         self.checkBox_Led_Mode4.stateChanged.connect(lambda:self.LedChange(self.checkBox_Led_Mode4))  | ||||
| 
 | ||||
|         self.Btn_Mode1.setChecked(True) | ||||
|         self.Btn_Mode1.toggled.connect(lambda:self.on_btn_Mode(self.Btn_Mode1)) | ||||
|         self.Btn_Mode2.setChecked(False) | ||||
|         self.Btn_Mode2.toggled.connect(lambda:self.on_btn_Mode(self.Btn_Mode2)) | ||||
|         self.Btn_Mode3.setChecked(False) | ||||
|         self.Btn_Mode3.toggled.connect(lambda:self.on_btn_Mode(self.Btn_Mode3)) | ||||
|         self.Btn_Mode4.setChecked(False) | ||||
|         self.Btn_Mode4.toggled.connect(lambda:self.on_btn_Mode(self.Btn_Mode4)) | ||||
|          | ||||
|         self.Ultrasonic.clicked.connect(self.on_btn_Ultrasonic) | ||||
|         self.Light.clicked.connect(self.on_btn_Light) | ||||
|          | ||||
|         self.Btn_ForWard.pressed.connect(self.on_btn_ForWard) | ||||
|         self.Btn_ForWard.released.connect(self.on_btn_Stop) | ||||
| 
 | ||||
|         self.Btn_Turn_Left.pressed.connect(self.on_btn_Turn_Left) | ||||
|         self.Btn_Turn_Left.released.connect(self.on_btn_Stop) | ||||
| 
 | ||||
|         self.Btn_BackWard.pressed.connect(self.on_btn_BackWard) | ||||
|         self.Btn_BackWard.released.connect(self.on_btn_Stop) | ||||
| 
 | ||||
|         self.Btn_Turn_Right.pressed.connect(self.on_btn_Turn_Right) | ||||
|         self.Btn_Turn_Right.released.connect(self.on_btn_Stop) | ||||
| 
 | ||||
|         self.Btn_Video.clicked.connect(self.on_btn_video) | ||||
| 
 | ||||
|         self.Btn_Up.clicked.connect(self.on_btn_Up) | ||||
|         self.Btn_Left.clicked.connect(self.on_btn_Left) | ||||
|         self.Btn_Down.clicked.connect(self.on_btn_Down) | ||||
|         self.Btn_Home.clicked.connect(self.on_btn_Home) | ||||
|         self.Btn_Right.clicked.connect(self.on_btn_Right) | ||||
|         self.Btn_Tracking_Faces.clicked.connect(self.Tracking_Face) | ||||
|          | ||||
| 
 | ||||
|         self.Btn_Buzzer.pressed.connect(self.on_btn_Buzzer) | ||||
|         self.Btn_Buzzer.released.connect(self.on_btn_Buzzer) | ||||
|          | ||||
|         self.Btn_Connect.clicked.connect(self.on_btn_Connect) | ||||
|          | ||||
|          | ||||
|         self.Window_Min.clicked.connect(self.windowMinimumed) | ||||
|         self.Window_Close.clicked.connect(self.close) | ||||
|         timer = QTimer(self) | ||||
|         self.connect(timer, SIGNAL("timeout()"), self.time) | ||||
|     def mousePressEvent(self, event): | ||||
|         if event.button()==Qt.LeftButton: | ||||
|             self.m_drag=True | ||||
|             self.m_DragPosition=event.globalPos()-self.pos() | ||||
|             event.accept() | ||||
|   | ||||
|     def mouseMoveEvent(self, QMouseEvent): | ||||
|         if QMouseEvent.buttons() and Qt.LeftButton: | ||||
|             self.move(QMouseEvent.globalPos()-self.m_DragPosition) | ||||
|             QMouseEvent.accept() | ||||
|   | ||||
|     def mouseReleaseEvent(self, QMouseEvent): | ||||
|         self.m_drag=False | ||||
|     def close(self): | ||||
|         timer.stop() | ||||
|         try: | ||||
|             self.TCP.sendData(cmd.CMD_POWER_OFF) | ||||
|             self.TCP.sendData(cmd.CMD_CLOSE) | ||||
|             stop_thread(self.streaming) | ||||
|             stop_thread(self.recv) | ||||
|             self.TCP.StopTcpcClient() | ||||
|         except: | ||||
|             pass | ||||
|         try: | ||||
|             os.remove("video.jpg") | ||||
|         except: | ||||
|             pass | ||||
|         QCoreApplication.instance().quit() | ||||
|         os._exit(0) | ||||
|          | ||||
|     def recvmassage(self): | ||||
|         self.receflag=1 | ||||
|         try: | ||||
|             self.TCP.socket1_connect(self.h) | ||||
|             self.TCP.sendData(cmd.CMD_POWER_ON) | ||||
|             while True: | ||||
|                 Alldata=self.TCP.recvData() | ||||
|                 if Alldata==None: | ||||
|                     pass | ||||
|                 elif Alldata=='': | ||||
|                     break | ||||
|                 elif len(Alldata)>21: | ||||
|                     continue | ||||
|                 else : | ||||
|                     Massage=Alldata.split("#") | ||||
|                 if cmd.CMD_SONIC in Massage: | ||||
|                     self.Ultrasonic.setText('Obstruction:%s cm'%Massage[1]) | ||||
|                 elif cmd.CMD_SERVO in Massage: | ||||
|                     print Massage | ||||
|                 elif cmd.CMD_LIGHT in Massage: | ||||
|                     self.Light.setText("Left:"+Massage[1]+'V'+' '+"Right"+Massage[2]+'V') | ||||
|                 elif cmd. CMD_POWER in Massage: | ||||
|                     percent_power=int((float(Massage[1])*3-7)/1.40*100) | ||||
|                     self.progress_Power.setValue(percent_power) | ||||
|                 else: | ||||
|                     pass | ||||
|                  | ||||
|         except : | ||||
|             pass | ||||
|          | ||||
|     def keyPressEvent(self, event): | ||||
|         if(event.key() == Qt.Key_Up): | ||||
|             self.on_btn_Up() | ||||
|         elif(event.key() == Qt.Key_Left): | ||||
|             self.on_btn_Left() | ||||
|         elif(event.key() == Qt.Key_Down): | ||||
|             self.on_btn_Down() | ||||
|         elif(event.key() == Qt.Key_Right): | ||||
|             self.on_btn_Right() | ||||
|         elif(event.key() == Qt.Key_Home): | ||||
|             self.on_btn_Home() | ||||
| 
 | ||||
| 
 | ||||
|         if(event.key() == Qt.Key_Q): | ||||
|             if self.Btn_Mode1.isChecked() == True: | ||||
|                 self.Btn_Mode2.setChecked(True) | ||||
|             elif self.Btn_Mode2.isChecked() == True: | ||||
|                 self.Btn_Mode3.setChecked(True) | ||||
|             elif self.Btn_Mode3.isChecked() == True: | ||||
|                 self.Btn_Mode4.setChecked(True) | ||||
|             elif self.Btn_Mode4.isChecked() == True: | ||||
|                 self.Btn_Mode1.setChecked(True) | ||||
| 
 | ||||
|         if(event.key() == Qt.Key_L): | ||||
|             count=0 | ||||
|             if  self.checkBox_Led_Mode1.isChecked() == True: | ||||
|                 self.checkBox_Led_Mode2.setChecked(True) | ||||
|             elif  self.checkBox_Led_Mode2.isChecked() == True: | ||||
|                 self.checkBox_Led_Mode3.setChecked(True) | ||||
|             elif  self.checkBox_Led_Mode3.isChecked() == True: | ||||
|                 self.checkBox_Led_Mode4.setChecked(True) | ||||
|             elif  self.checkBox_Led_Mode4.isChecked() == True: | ||||
|                 self.checkBox_Led_Mode1.setChecked(True) | ||||
| 
 | ||||
|             for i in range(1,5): | ||||
|                 checkBox_Led_Mode=getattr(self,"checkBox_Led_Mode%d"%i) | ||||
|                 if  checkBox_Led_Mode.isChecked() == False: | ||||
|                     count+=1 | ||||
|                 else: | ||||
|                     break | ||||
|             if count ==4: | ||||
|                 self.checkBox_Led_Mode1.setChecked(True) | ||||
|                  | ||||
|         if(event.key() == Qt.Key_C): | ||||
|             self.on_btn_Connect() | ||||
|         if(event.key() == Qt.Key_V): | ||||
|             self.on_btn_video() | ||||
| 
 | ||||
|              | ||||
|         if(event.key() == Qt.Key_1): | ||||
|             if self.checkBox_Led1.isChecked() == True: | ||||
|                 self.checkBox_Led1.setChecked(False) | ||||
|             else: | ||||
|                 self.checkBox_Led1.setChecked(True) | ||||
|         elif(event.key() == Qt.Key_2): | ||||
|             if self.checkBox_Led2.isChecked() == True: | ||||
|                 self.checkBox_Led2.setChecked(False) | ||||
|             else: | ||||
|                 self.checkBox_Led2.setChecked(True) | ||||
|         elif(event.key() == Qt.Key_3): | ||||
|             if self.checkBox_Led3.isChecked() == True: | ||||
|                 self.checkBox_Led3.setChecked(False) | ||||
|             else: | ||||
|                 self.checkBox_Led3.setChecked(True) | ||||
|         elif(event.key() == Qt.Key_4): | ||||
|             if self.checkBox_Led4.isChecked() == True: | ||||
|                 self.checkBox_Led4.setChecked(False) | ||||
|             else: | ||||
|                 self.checkBox_Led4.setChecked(True) | ||||
|         elif(event.key() == Qt.Key_5): | ||||
|             if self.checkBox_Led5.isChecked() == True: | ||||
|                 self.checkBox_Led5.setChecked(False) | ||||
|             else: | ||||
|                 self.checkBox_Led5.setChecked(True) | ||||
|         elif(event.key() == Qt.Key_6): | ||||
|             if self.checkBox_Led6.isChecked() == True: | ||||
|                 self.checkBox_Led6.setChecked(False) | ||||
|             else: | ||||
|                 self.checkBox_Led6.setChecked(True) | ||||
|         elif(event.key() == Qt.Key_7): | ||||
|             if self.checkBox_Led7.isChecked() == True: | ||||
|                 self.checkBox_Led7.setChecked(False) | ||||
|             else: | ||||
|                 self.checkBox_Led7.setChecked(True) | ||||
|         elif(event.key() == Qt.Key_8): | ||||
|             if self.checkBox_Led8.isChecked() == True: | ||||
|                 self.checkBox_Led8.setChecked(False) | ||||
|             else: | ||||
|                 self.checkBox_Led8.setChecked(True) | ||||
| 
 | ||||
|                  | ||||
|         if event.isAutoRepeat(): | ||||
|             pass | ||||
|         else : | ||||
|             #print "You Pressed Key : ", event.key(), event.text()  | ||||
|             if event.key() == Qt.Key_W: | ||||
|                 self.on_btn_ForWard() | ||||
|                 self.Key_W=True | ||||
|             elif event.key() == Qt.Key_S: | ||||
|                 self.on_btn_BackWard() | ||||
|                 self.Key_S=True | ||||
|             elif event.key() == Qt.Key_A: | ||||
|                 self.on_btn_Turn_Left() | ||||
|                 self.Key_A=True | ||||
|             elif event.key() == Qt.Key_D:                   | ||||
|                 self.on_btn_Turn_Right() | ||||
|                 self.Key_D=True   | ||||
|             elif event.key() == Qt.Key_Space:   | ||||
|                 self.on_btn_Buzzer() | ||||
|                 self.Key_Space=True                 | ||||
| 
 | ||||
|     def keyReleaseEvent(self, event): | ||||
| 
 | ||||
|         if(event.key() == Qt.Key_W): | ||||
|             time.sleep(0.05) | ||||
|             if(event.key() == Qt.Key_W): | ||||
|                 if not(event.isAutoRepeat()) and self.Key_W==True: | ||||
|                     self.on_btn_Stop() | ||||
|                     self.Key_W=False | ||||
|         elif(event.key() == Qt.Key_A): | ||||
|             if not(event.isAutoRepeat()) and self.Key_A==True: | ||||
|                 self.on_btn_Stop() | ||||
|                 self.Key_A=False | ||||
|         elif(event.key() == Qt.Key_S): | ||||
|             if not(event.isAutoRepeat()) and self.Key_S==True: | ||||
|                 self.on_btn_Stop() | ||||
|                 self.Key_S=False | ||||
|         elif(event.key() == Qt.Key_D): | ||||
|             if not(event.isAutoRepeat()) and self.Key_D==True: | ||||
|                 self.on_btn_Stop() | ||||
|                 self.Key_D=False | ||||
|                  | ||||
|         if(event.key() == Qt.Key_Space): | ||||
|             if not(event.isAutoRepeat()) and self.Key_Space==True: | ||||
|                 self.on_btn_Buzzer() | ||||
|                 self.Key_Space=False | ||||
|          | ||||
| 
 | ||||
|          | ||||
|     def on_btn_ForWard(self): | ||||
|         self.TCP.sendData(cmd.CMD_FORWARD) | ||||
| 
 | ||||
|     def on_btn_Turn_Left(self): | ||||
|         self.TCP.sendData(cmd.CMD_TURULEFT) | ||||
| 
 | ||||
|     def on_btn_BackWard(self): | ||||
|         self.TCP.sendData(cmd.CMD_BACKWARD) | ||||
| 
 | ||||
|     def on_btn_Turn_Right(self): | ||||
|         self.TCP.sendData(cmd.CMD_TURNRIGHT) | ||||
| 
 | ||||
|     def on_btn_Stop(self): | ||||
|         self.TCP.sendData(cmd.CMD_MOTORSTOP) | ||||
| 
 | ||||
|     def on_btn_video(self): | ||||
|         if self.Btn_Video.text()=='Open Video': | ||||
|             timer.start(34) | ||||
|             self.Btn_Video.setText('Close Video') | ||||
|         elif self.Btn_Video.text()=='Close Video': | ||||
|             timer.stop() | ||||
|             self.Btn_Video.setText('Open Video') | ||||
|     def on_btn_Up(self): | ||||
|         self.servo2=self.servo2+10 | ||||
|         if self.servo2>=150: | ||||
|             self.servo2=150 | ||||
|         self.VSlider_Servo2.setValue(self.servo2) | ||||
|         self.TCP.sendData(cmd.CMD_SERVO2+str(self.servo2)) | ||||
| 
 | ||||
|         self.label_Servo2.setText("%d"%self.servo2) | ||||
|     def on_btn_Left(self): | ||||
|         self.servo1=self.servo1-10 | ||||
|         if self.servo1<=0: | ||||
|             self.servo1=0 | ||||
|         self.HSlider_Servo1.setValue(self.servo1) | ||||
|         self.TCP.sendData(cmd.CMD_SERVO1+str(self.servo1)+'#0') | ||||
| 
 | ||||
|         self.label_Servo1.setText("%d"%self.servo1) | ||||
|     def on_btn_Down(self): | ||||
|         self.servo2=self.servo2-10 | ||||
|         if self.servo2<=0: | ||||
|             self.servo2=0 | ||||
|         self.VSlider_Servo2.setValue(self.servo2) | ||||
|         self.TCP.sendData(cmd.CMD_SERVO2+str(self.servo2)) | ||||
| 
 | ||||
|         self.label_Servo2.setText("%d"%self.servo2) | ||||
| 
 | ||||
|     def on_btn_Home(self): | ||||
|         self.servo1=90 | ||||
|         self.servo2=20 | ||||
|         self.TCP.sendData(cmd.CMD_SERVO1+str(self.servo1)+'#0') | ||||
|         self.label_Servo1.setText("%d"%self.servo1) | ||||
|         self.TCP.sendData(cmd.CMD_SERVO2+str(self.servo2)) | ||||
|         self.label_Servo2.setText("%d"%self.servo2) | ||||
| 
 | ||||
|     def on_btn_Right(self): | ||||
|         self.servo1=self.servo1+10 | ||||
|         if self.servo1>=180: | ||||
|             self.servo1=180 | ||||
|         self.HSlider_Servo1.setValue(self.servo1) | ||||
|         self.TCP.sendData(cmd.CMD_SERVO1+str(self.servo1)+'#0') | ||||
| 
 | ||||
|         self.label_Servo1.setText("%d"%self.servo1) | ||||
| 
 | ||||
|          | ||||
|     def Change_Left_Right(self):#Left or Right | ||||
|         self.servo1=self.HSlider_Servo1.value() | ||||
|         self.TCP.sendData(cmd.CMD_SERVO1+str(self.servo1)+'#0') | ||||
|         self.label_Servo1.setText("%d"%self.servo1) | ||||
|          | ||||
|     def Fine_Tune_Left_Right(self):#fine tune Left or Right | ||||
|         self.label_FineServo1.setText(str(self.HSlider_FineServo1.value())) | ||||
|         data=self.servo1+self.HSlider_FineServo1.value() | ||||
|         self.TCP.sendData(cmd.CMD_SERVO1+str(data)+'#0') | ||||
| 
 | ||||
|     def Fine_Tune_Up_Down(self):#fine tune Up or Down | ||||
|         self.label_FineServo2.setText(str(self.HSlider_FineServo2.value())) | ||||
|         data=self.servo2+self.HSlider_FineServo2.value() | ||||
|         self.TCP.sendData(cmd.CMD_SERVO2+str(data)) | ||||
| 
 | ||||
|          | ||||
|     def Change_Up_Down(self):#Up or Down | ||||
|         self.servo2=self.VSlider_Servo2.value() | ||||
|         self.TCP.sendData(cmd.CMD_SERVO2+str(self.servo2)) | ||||
|         self.label_Servo2.setText("%d"%self.servo2) | ||||
| 
 | ||||
|     def windowMinimumed(self): | ||||
|         self.showMinimized() | ||||
| 
 | ||||
| 
 | ||||
|     def on_btn_Buzzer(self): | ||||
|         if self.Btn_Buzzer.text()=='Buzzer': | ||||
|             self.TCP.sendData(cmd.CMD_BUZZER_ON) | ||||
|             self.Btn_Buzzer.setText('Noise') | ||||
|         else: | ||||
|             self.TCP.sendData(cmd.CMD_BUZZER_OFF) | ||||
|             self.Btn_Buzzer.setText('Buzzer') | ||||
| 
 | ||||
|     def LedChange(self,b): | ||||
|         R=self.Color_R.text() | ||||
|         G=self.Color_G.text() | ||||
|         B=self.Color_B.text() | ||||
|         if b.text() == "Led1": | ||||
|            if b.isChecked() == True: | ||||
|                self.TCP.sendData(cmd.CMD_LED2_ON+str(R)+"#"+str(G)+"#"+str(B)) | ||||
|            else: | ||||
|                self.TCP.sendData(cmd.CMD_LED2_OFF) | ||||
|         if b.text() == "Led2": | ||||
|            if b.isChecked() == True: | ||||
|                self.TCP.sendData(cmd.CMD_LED3_ON+str(R)+"#"+str(G)+"#"+str(B)) | ||||
|            else: | ||||
|                self.TCP.sendData(cmd.CMD_LED3_OFF)                | ||||
|         if b.text() == "Led3": | ||||
|            if b.isChecked() == True: | ||||
|                self.TCP.sendData(cmd.CMD_LED4_ON+str(R)+"#"+str(G)+"#"+str(B)) | ||||
|            else: | ||||
|                self.TCP.sendData(cmd.CMD_LED4_OFF) | ||||
|         if b.text() == "Led4": | ||||
|            if b.isChecked() == True: | ||||
|                self.TCP.sendData(cmd.CMD_LED5_ON+str(R)+"#"+str(G)+"#"+str(B)) | ||||
|            else: | ||||
|                self.TCP.sendData(cmd.CMD_LED5_OFF) | ||||
|         if b.text() == "Led5": | ||||
|            if b.isChecked() == True: | ||||
|                self.TCP.sendData(cmd.CMD_LED1_ON+str(R)+"#"+str(G)+"#"+str(B)) | ||||
|            else: | ||||
|                self.TCP.sendData(cmd.CMD_LED1_OFF) | ||||
|         if b.text() == "Led6": | ||||
|            if b.isChecked() == True: | ||||
|                self.TCP.sendData(cmd.CMD_LED0_ON+str(R)+"#"+str(G)+"#"+str(B)) | ||||
|            else: | ||||
|                self.TCP.sendData(cmd.CMD_LED0_OFF) | ||||
|         if b.text() == "Led7": | ||||
|            if b.isChecked() == True: | ||||
|                self.TCP.sendData(cmd.CMD_LED7_ON+str(R)+"#"+str(G)+"#"+str(B)) | ||||
|            else: | ||||
|                self.TCP.sendData(cmd.CMD_LED7_OFF) | ||||
|         if b.text() == "Led8": | ||||
|            if b.isChecked() == True: | ||||
|                self.TCP.sendData(cmd.CMD_LED6_ON+str(R)+"#"+str(G)+"#"+str(B)) | ||||
|            else: | ||||
|                self.TCP.sendData(cmd.CMD_LED6_OFF) | ||||
|         if b.text() == "Led_Mode1": | ||||
|            if b.isChecked() == True: | ||||
|                self.checkBox_Led_Mode2.setChecked(False) | ||||
|                self.checkBox_Led_Mode3.setChecked(False) | ||||
|                self.checkBox_Led_Mode4.setChecked(False) | ||||
|                self.TCP.sendData(cmd.CMD_LED_MOD1) | ||||
|            else: | ||||
|                self.TCP.sendData(cmd.CMD_LED_OFF) | ||||
|         if b.text() == "Led_Mode2": | ||||
|            if b.isChecked() == True: | ||||
| 
 | ||||
|                self.checkBox_Led_Mode1.setChecked(False) | ||||
|                self.checkBox_Led_Mode3.setChecked(False) | ||||
|                self.checkBox_Led_Mode4.setChecked(False) | ||||
|                self.TCP.sendData(cmd.CMD_LED_MOD2) | ||||
|            else: | ||||
|                self.TCP.sendData(cmd.CMD_LED_OFF) | ||||
|         if b.text() == "Led_Mode3": | ||||
|            if b.isChecked() == True: | ||||
|                self.checkBox_Led_Mode2.setChecked(False) | ||||
|                self.checkBox_Led_Mode1.setChecked(False) | ||||
|                self.checkBox_Led_Mode4.setChecked(False) | ||||
|                self.TCP.sendData(cmd.CMD_LED_MOD3) | ||||
|            else: | ||||
|                self.TCP.sendData(cmd.CMD_LED_OFF) | ||||
|         if b.text() == "Led_Mode4": | ||||
|            if b.isChecked() == True: | ||||
|                self.checkBox_Led_Mode2.setChecked(False) | ||||
|                self.checkBox_Led_Mode3.setChecked(False) | ||||
|                self.checkBox_Led_Mode1.setChecked(False) | ||||
|                self.TCP.sendData(cmd.CMD_LED_MOD4) | ||||
|            else: | ||||
|                self.TCP.sendData(cmd.CMD_LED_OFF) | ||||
|     def on_btn_Ultrasonic(self): | ||||
|         if self.Ultrasonic.text()=="Ultrasonic": | ||||
|             self.TCP.sendData(cmd.CMD_ULTRASONIC_ON) | ||||
|         else: | ||||
|             self.TCP.sendData(cmd.CMD_ULTRASONIC_OFF) | ||||
|             self.Ultrasonic.setText("Ultrasonic") | ||||
|   | ||||
|     def on_btn_Light(self): | ||||
|         if self.Light.text() == "Light": | ||||
|             self.TCP.sendData(cmd.CMD_LIGHT_ON) | ||||
|         else: | ||||
|             self.TCP.sendData(cmd.CMD_LIGHT_OFF) | ||||
|             self.Light.setText("Light") | ||||
|   | ||||
|     def on_btn_Mode(self,Mode): | ||||
|         if Mode.text() == "M-Free": | ||||
|             if Mode.isChecked() == True: | ||||
|                 timer.start(34) | ||||
|                 self.TCP.sendData(cmd.CMD_MODE[0]) | ||||
|                  | ||||
|         if Mode.text() == "M-Light": | ||||
|             if Mode.isChecked() == True: | ||||
|                 timer.stop() | ||||
|                 self.TCP.sendData(cmd.CMD_MODE[1]) | ||||
|         if Mode.text() == "M-Sonic": | ||||
|             if Mode.isChecked() == True: | ||||
|                 timer.stop() | ||||
|                 self.TCP.sendData(cmd.CMD_MODE[2]) | ||||
|                  | ||||
|         if Mode.text() == "M-Line": | ||||
|             if Mode.isChecked() == True: | ||||
|                 timer.stop() | ||||
|                 self.TCP.sendData(cmd.CMD_MODE[3]) | ||||
|           | ||||
|                                    | ||||
|     def on_btn_Connect(self): | ||||
|         if self.Btn_Connect.text() == "Connect": | ||||
|             self.h=self.IP.text() | ||||
|             self.TCP.StartTcpClient(self.h,) | ||||
|             try: | ||||
|                 self.streaming=Thread(target=self.TCP.streaming,args=(self.h,)) | ||||
|                 self.streaming.start() | ||||
|             except: | ||||
|                 print 'video error' | ||||
|             try: | ||||
|                 self.recv=Thread(target=self.recvmassage) | ||||
|                 self.recv.start() | ||||
|             except: | ||||
|                 print 'recv error' | ||||
|             self.Btn_Connect.setText( "Disconnect") | ||||
|             print (self.h) | ||||
|         elif self.Btn_Connect.text()=="Disconnect": | ||||
|             self.Btn_Connect.setText( "Connect") | ||||
|             self.TCP.windows=0 | ||||
|             self.receflag=0 | ||||
|             try: | ||||
|                 stop_thread(self.streaming) | ||||
|                 stop_thread(self.recv) | ||||
|                 self.TCP.sendData(cmd.CMD_POWER_OFF) | ||||
|                 self.TCP.client_socket1.send(cmd.CMD_CLOSE) | ||||
|                 self.TCP.StopTcpcClient() | ||||
|             except: | ||||
|                 pass | ||||
| 
 | ||||
|           | ||||
|     def is_valid_jpg(self,jpg_file): | ||||
|         try: | ||||
|              | ||||
|             if jpg_file.split('.')[-1].lower() == 'jpg':   | ||||
|                 with open(jpg_file, 'rb') as f:   | ||||
|                     f.seek(-2, 2) | ||||
|                     buf = f.read() | ||||
|                     f.close() | ||||
|                     return buf.endswith(b'\xff\xd9')           | ||||
|             else: | ||||
|                 return false | ||||
|                  | ||||
|         except: | ||||
|             pass | ||||
| 
 | ||||
|     def is_valid_jpg1(self,jpg_file): | ||||
|         try: | ||||
|             bValid = True | ||||
|             if jpg_file.split('.')[-1].lower() == 'jpg':   | ||||
|                 with open(jpg_file, 'rb') as f: | ||||
|                     buf=f.read() | ||||
|                     if not buf.startswith(b'\xff\xd8'): | ||||
|                         bValid = False | ||||
|                     elif buf[6:10] in (b'JFIF', b'Exif'): | ||||
|                         if not buf.rstrip(b'\0\r\n').endswith(b'\xff\xd9'): | ||||
|                             bValid = False | ||||
|                     else: | ||||
|                         try: | ||||
|                             Image.open(f).verify() | ||||
|                         except: | ||||
|                             bValid = False                | ||||
|             else:   | ||||
|                 return bValid | ||||
|         except: | ||||
|             pass | ||||
|         return bValid | ||||
|      | ||||
| 
 | ||||
|     def IsValidImage(self,pathfile): | ||||
|         bValid = True | ||||
|         try: | ||||
|           Image.open(pathfile).verify() | ||||
|         except: | ||||
|           bValid = False | ||||
|         return bValid | ||||
|     def Tracking_Face(self): | ||||
|         if self.Btn_Tracking_Faces.text()=="Tracing-On": | ||||
|             self.Btn_Tracking_Faces.setText("Tracing-Off") | ||||
|         else: | ||||
|             self.Btn_Tracking_Faces.setText("Tracing-On") | ||||
|     def find_Face(self,face_x,face_y): | ||||
|         if face_x!=0 and face_y!=0: | ||||
|             offset_x=float(face_x/400-0.5)*2 | ||||
|             offset_y=float(face_y/300-0.5)*2 | ||||
|             delta_degree_x = 4.5* offset_x | ||||
|             delta_degree_y = -4.5 * offset_y | ||||
|             self.servo1=self.servo1+delta_degree_x | ||||
|             self.servo2=self.servo2+delta_degree_y | ||||
|             if offset_x > -0.15 and offset_y >-0.15 and offset_x < 0.15 and offset_y <0.15: | ||||
|                 pass | ||||
|             else: | ||||
|                 self.HSlider_Servo1.setValue(self.servo1) | ||||
|                 self.VSlider_Servo2.setValue(self.servo2) | ||||
|     def time(self): | ||||
|         self.TCP.video_Flag=False | ||||
|         if  self.is_valid_jpg1('video.jpg') and self.IsValidImage('video.jpg') and self.is_valid_jpg('video.jpg'): | ||||
|             self.label_Video.setPixmap(QtGui.QPixmap(QtCore.QString.fromUtf8('video.jpg'))) | ||||
|             if self.Btn_Tracking_Faces.text()=="Tracing-Off": | ||||
|                     self.find_Face(self.TCP.face_x,self.TCP.face_y) | ||||
|         self.TCP.video_Flag=True | ||||
|              | ||||
|          | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     app = QApplication(sys.argv) | ||||
|     myshow=mywindow() | ||||
|     myshow.show();    | ||||
|     sys.exit(app.exec_()) | ||||
|      | ||||
| 
 | ||||
| 
 | ||||
							
								
								
									
										109
									
								
								Code/Client/Video.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								Code/Client/Video.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,109 @@ | ||||
| #!/usr/bin/python  | ||||
| # -*- coding: utf-8 -*- | ||||
| import numpy as np | ||||
| import cv2 | ||||
| import socket | ||||
| import io | ||||
| import sys | ||||
| from PIL import Image | ||||
| from multiprocessing import Process | ||||
| from Command import COMMAND as cmd | ||||
| 
 | ||||
| class VideoStreaming: | ||||
|     def __init__(self): | ||||
|         self.face_cascade = cv2.CascadeClassifier(r'haarcascade_frontalface_default.xml') | ||||
|         self.video_Flag=True | ||||
|         self.connect_Flag=False | ||||
|         self.face_x=0 | ||||
|         self.face_y=0 | ||||
|     def StartTcpClient(self,IP): | ||||
|         self.client_socket1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||||
|         self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||||
|         print 'StartTcpClient' | ||||
|     def StopTcpcClient(self): | ||||
|         try: | ||||
|             self.connection.close() | ||||
|             self.client_socket.close() | ||||
|             self.client_socket1.close() | ||||
|         except: | ||||
|             pass | ||||
|      | ||||
|     def IsValidImage4Bytes(self,buf):  | ||||
|         bValid = True | ||||
|         if buf[6:10] in (b'JFIF', b'Exif'):      | ||||
|             if not buf.rstrip(b'\0\r\n').endswith(b'\xff\xd9'): | ||||
|                 bValid = False | ||||
|         else:         | ||||
|             try:   | ||||
|                 Image.open(io.BytesIO(buf)).verify()  | ||||
|             except:   | ||||
|                 bValid = False | ||||
|           | ||||
|         return bValid | ||||
| 
 | ||||
|     def face_detect(self,img): | ||||
|         if sys.platform.startswith('win'): | ||||
|             gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) | ||||
|             faces = self.face_cascade.detectMultiScale(gray,1.3,5) | ||||
|             if len(faces)>0 : | ||||
|                 for (x,y,w,h) in faces: | ||||
|                     self.face_x=float(x+w/2.0) | ||||
|                     self.face_y=float(y+h/2.0) | ||||
|                     img = cv2.circle(img, (x+w/2,y+h/2), (w+h)/4, (0, 255, 0), 2) | ||||
|             else: | ||||
|                 self.face_x=0 | ||||
|                 self.face_y=0 | ||||
|              | ||||
|         else: | ||||
|             pass | ||||
|         cv2.imwrite('video.jpg', img) | ||||
|          | ||||
|     def streaming(self,ip): | ||||
|         try: | ||||
|             stream_bytes = b' ' | ||||
|             self.client_socket.connect((ip, 8000)) | ||||
|             self.connection = self.client_socket.makefile('wb') | ||||
|             while True: | ||||
|                 try: | ||||
|                     stream_bytes += self.connection.read(1024) | ||||
|                     first = stream_bytes.find(b'\xff\xd8') | ||||
|                     last = stream_bytes.find(b'\xff\xd9') | ||||
|                     if first != -1 and last != -1 :       | ||||
|                         jpg = stream_bytes[first:last + 2] | ||||
|                         stream_bytes = stream_bytes[last + 2:] | ||||
|                         if self.IsValidImage4Bytes(jpg): | ||||
|                             image = cv2.imdecode(np.frombuffer(jpg, dtype=np.uint8), cv2.IMREAD_COLOR) | ||||
|                             if self.video_Flag: | ||||
|                                 self.face_detect(image) | ||||
|                 except: | ||||
|                     break | ||||
|         except: | ||||
|             pass | ||||
|                      | ||||
|     def sendData(self,s): | ||||
|         if self.connect_Flag: | ||||
|             self.client_socket1.send(s) | ||||
|         else: | ||||
|             pass | ||||
| 
 | ||||
|     def recvData(self): | ||||
|         data=0 | ||||
|         try: | ||||
|             data=self.client_socket1.recv(1024) | ||||
|         except: | ||||
|             pass | ||||
|         return data | ||||
| 
 | ||||
|     def socket1_connect(self,ip): | ||||
|         try: | ||||
|             self.client_socket1.connect((ip, 5000)) | ||||
|             self.connect_Flag=True | ||||
|             print "Connecttion Successful !" | ||||
|         except Exception, e: | ||||
|             print "Connect to server Faild!: Server IP is right? Server is opend?", e | ||||
|             self.connect_Flag=False | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     a=VideoStreaming() | ||||
|     pass | ||||
| 
 | ||||
							
								
								
									
										37
									
								
								Code/Server/Light.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								Code/Server/Light.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | ||||
| import time | ||||
| from Motor import * | ||||
| from ADC import * | ||||
| class Light: | ||||
|     def run(self): | ||||
|         try: | ||||
|             self.adc=Adc() | ||||
|             self.PWM=Motor() | ||||
|             self.PWM.setMotorModel(0,0,0,0) | ||||
|             while True: | ||||
|                 L = self.adc.recvADC(0) | ||||
|                 R = self.adc.recvADC(1) | ||||
|                 if L < 2.99 and R < 2.99 : | ||||
|                     self.PWM.setMotorModel(600,600,600,600) | ||||
|                      | ||||
|                 elif abs(L-R)<0.15: | ||||
|                     self.PWM.setMotorModel(0,0,0,0) | ||||
|                      | ||||
|                 elif L > 3 or R > 3: | ||||
|                     if L > R : | ||||
|                         self.PWM.setMotorModel(-1200,-1200,1400,1400) | ||||
|                          | ||||
|                     elif R > L : | ||||
|                         self.PWM.setMotorModel(1400,1400,-1200,-1200) | ||||
|                      | ||||
|         except KeyboardInterrupt: | ||||
|            led_Car.PWM.setMotorModel(0,0,0,0)  | ||||
| 
 | ||||
| if __name__=='__main__': | ||||
|     print ('Program is starting ... ') | ||||
|     led_Car=Light() | ||||
|     led_Car.run() | ||||
| 
 | ||||
| 
 | ||||
|          | ||||
|      | ||||
| 
 | ||||
							
								
								
									
										92
									
								
								Code/Server/PCA9685.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								Code/Server/PCA9685.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,92 @@ | ||||
| #!/usr/bin/python | ||||
| 
 | ||||
| import time | ||||
| import math | ||||
| import smbus | ||||
| 
 | ||||
| # ============================================================================ | ||||
| # Raspi PCA9685 16-Channel PWM Servo Driver | ||||
| # ============================================================================ | ||||
| 
 | ||||
| class PCA9685: | ||||
| 
 | ||||
|   # Registers/etc. | ||||
|   __SUBADR1            = 0x02 | ||||
|   __SUBADR2            = 0x03 | ||||
|   __SUBADR3            = 0x04 | ||||
|   __MODE1              = 0x00 | ||||
|   __PRESCALE           = 0xFE | ||||
|   __LED0_ON_L          = 0x06 | ||||
|   __LED0_ON_H          = 0x07 | ||||
|   __LED0_OFF_L         = 0x08 | ||||
|   __LED0_OFF_H         = 0x09 | ||||
|   __ALLLED_ON_L        = 0xFA | ||||
|   __ALLLED_ON_H        = 0xFB | ||||
|   __ALLLED_OFF_L       = 0xFC | ||||
|   __ALLLED_OFF_H       = 0xFD | ||||
| 
 | ||||
|   def __init__(self, address=0x40, debug=False): | ||||
|     self.bus = smbus.SMBus(1) | ||||
|     self.address = address | ||||
|     self.debug = debug | ||||
|     self.write(self.__MODE1, 0x00) | ||||
|      | ||||
|   def write(self, reg, value): | ||||
|     "Writes an 8-bit value to the specified register/address" | ||||
|     self.bus.write_byte_data(self.address, reg, value) | ||||
|        | ||||
|   def read(self, reg): | ||||
|     "Read an unsigned byte from the I2C device" | ||||
|     result = self.bus.read_byte_data(self.address, reg) | ||||
|     return result | ||||
|      | ||||
|   def setPWMFreq(self, freq): | ||||
|     "Sets the PWM frequency" | ||||
|     prescaleval = 25000000.0    # 25MHz | ||||
|     prescaleval /= 4096.0       # 12-bit | ||||
|     prescaleval /= float(freq) | ||||
|     prescaleval -= 1.0 | ||||
|     prescale = math.floor(prescaleval + 0.5) | ||||
| 
 | ||||
| 
 | ||||
|     oldmode = self.read(self.__MODE1); | ||||
|     newmode = (oldmode & 0x7F) | 0x10        # sleep | ||||
|     self.write(self.__MODE1, newmode)        # go to sleep | ||||
|     self.write(self.__PRESCALE, int(math.floor(prescale))) | ||||
|     self.write(self.__MODE1, oldmode) | ||||
|     time.sleep(0.005) | ||||
|     self.write(self.__MODE1, oldmode | 0x80) | ||||
| 
 | ||||
|   def setPWM(self, channel, on, off): | ||||
|     "Sets a single PWM channel" | ||||
|     self.write(self.__LED0_ON_L+4*channel, on & 0xFF) | ||||
|     self.write(self.__LED0_ON_H+4*channel, on >> 8) | ||||
|     self.write(self.__LED0_OFF_L+4*channel, off & 0xFF) | ||||
|     self.write(self.__LED0_OFF_H+4*channel, off >> 8) | ||||
|   def setMotorPwm(self,channel,duty): | ||||
|     self.setPWM(channel,0,duty) | ||||
|   def setServoPulse(self, channel, pulse): | ||||
|     "Sets the Servo Pulse,The PWM frequency must be 50HZ" | ||||
|     pulse = pulse*4096/20000        #PWM frequency is 50HZ,the period is 20000us | ||||
|     self.setPWM(channel, 0, int(pulse)) | ||||
| 
 | ||||
| if __name__=='__main__': | ||||
|   | ||||
|   pwm = PCA9685(0x40, debug=True) | ||||
|   pwm.setPWMFreq(50) | ||||
|   count=0; | ||||
|   while True: | ||||
|     for i in range(500,2500,10):  | ||||
|       pwm.setServoPulse(8,i)  | ||||
|       pwm.setServoPulse(9,i) | ||||
|       time.sleep(0.02)      | ||||
|      | ||||
|     for i in range(2500,500,-10): | ||||
|       pwm.setServoPulse(8,i)  | ||||
|       pwm.setServoPulse(9,i) | ||||
|       time.sleep(0.02)   | ||||
|     count=count+1 | ||||
|     if count > 5 : | ||||
|       break | ||||
|      | ||||
|        | ||||
							
								
								
									
										111
									
								
								Code/Server/Ultrasonic.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										111
									
								
								Code/Server/Ultrasonic.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,111 @@ | ||||
| import time | ||||
| from Motor import * | ||||
| import RPi.GPIO as GPIO | ||||
| from servo import * | ||||
| from PCA9685 import PCA9685 | ||||
| GPIO.setwarnings(False) | ||||
| trigger_pin = 27 | ||||
| echo_pin = 22 | ||||
| GPIO.setmode(GPIO.BCM) | ||||
| GPIO.setup(trigger_pin,GPIO.OUT) | ||||
| GPIO.setup(echo_pin,GPIO.IN) | ||||
| class Ultrasonic: | ||||
|     def send_trigger_pulse(self): | ||||
|         GPIO.output(trigger_pin,True) | ||||
|         time.sleep(0.00015) | ||||
|         GPIO.output(trigger_pin,False) | ||||
| 
 | ||||
|     def wait_for_echo(self,value,timeout): | ||||
|         count = timeout | ||||
|         while GPIO.input(echo_pin) != value and count>0: | ||||
|             count = count-1 | ||||
|              | ||||
|     def get_distance(self): | ||||
|         distance_cm=[0,0,0] | ||||
|         for i in range(3): | ||||
|             self.send_trigger_pulse() | ||||
|             self.wait_for_echo(True,10000) | ||||
|             start = time.time() | ||||
|             self.wait_for_echo(False,10000) | ||||
|             finish = time.time() | ||||
|             pulse_len = finish-start | ||||
|             distance_cm[i] = pulse_len/0.000058 | ||||
|         distance_cm=sorted(distance_cm) | ||||
|         return int(distance_cm[1]) | ||||
|     def run_motor(self,L,M,R): | ||||
|         if L < 30 and M < 30 and R <30 : | ||||
|             self.PWM.setMotorModel(-1450,-1450,-1450,-1450)  | ||||
|             time.sleep(0.1)    | ||||
|             if L < R: | ||||
|                 self.PWM.setMotorModel(1450,1450,-1450,-1450) | ||||
|             else : | ||||
|                 self.PWM.setMotorModel(-1450,-1450,1450,1450) | ||||
|         elif L < 30 and M < 30: | ||||
|             self.PWM.setMotorModel(-1450,-1450,-1450,-1450)  | ||||
|             time.sleep(0.1)  | ||||
|             PWM.setMotorModel(1500,1500,-1500,-1500) | ||||
|         elif R < 30 and M < 30: | ||||
|             self.PWM.setMotorModel(-1450,-1450,-1450,-1450)  | ||||
|             time.sleep(0.1)  | ||||
|             PWM.setMotorModel(-1500,-1500,1500,1500)     | ||||
|         elif L < 20 : | ||||
|             PWM.setMotorModel(2000,2000,-500,-500) | ||||
|             if L < 20 : | ||||
|                 PWM.setMotorModel(1500,1500,-1000,-1000) | ||||
|         elif R < 30 : | ||||
|             PWM.setMotorModel(-500,-500,2000,2000) | ||||
|             if R < 20 : | ||||
|                 PWM.setMotorModel(-1500,-1500,1500,1500) | ||||
|         elif M < 30 : | ||||
|             self.PWM.setMotorModel(-1450,-1450,-1450,-1450)  | ||||
|             time.sleep(0.1)  | ||||
|             if L < R: | ||||
|                 self.PWM.setMotorModel(1450,1450,-1450,-1450) | ||||
|             else : | ||||
|                 self.PWM.setMotorModel(-1450,-1450,1450,1450)    | ||||
|         else : | ||||
|             self.PWM.setMotorModel(600,600,600,600) | ||||
|                  | ||||
|     def run(self): | ||||
|         self.PWM=Motor() | ||||
|         self.pwm_S=Servo() | ||||
|          | ||||
|         self.pwm_S.setServoPwm(1,0,30,0) | ||||
|         R = self.get_distance() | ||||
|         time.sleep(0.2) | ||||
|          | ||||
|         self.pwm_S.setServoPwm(1,0,90,0) | ||||
|         L = self.get_distance() | ||||
|         time.sleep(0.2) | ||||
|              | ||||
|         self.pwm_S.setServoPwm(1,0,150,0) | ||||
|         M = self.get_distance() | ||||
|         time.sleep(0.2) | ||||
| 
 | ||||
|         while True: | ||||
|             self.pwm_S.setServoPwm(1,0,30,0) | ||||
|             R = self.get_distance() | ||||
|             self.run_motor(L,M,R) | ||||
|             time.sleep(0.2) | ||||
|          | ||||
|             self.pwm_S.setServoPwm(1,0,90,0) | ||||
|             L = self.get_distance() | ||||
|             self.run_motor(L,M,R) | ||||
|             time.sleep(0.2) | ||||
|          | ||||
|             self.pwm_S.setServoPwm(1,0,150,0) | ||||
|             M = self.get_distance() | ||||
|             self.run_motor(L,M,R) | ||||
|             time.sleep(0.2) | ||||
|             self.run_motor(L,M,R)   | ||||
|          | ||||
| ultrasonic=Ultrasonic()               | ||||
| # Main program logic follows: | ||||
| if __name__ == '__main__': | ||||
|     print ('Program is starting ... ') | ||||
|     try: | ||||
|         ultrasonic.run() | ||||
|     except KeyboardInterrupt:  # When 'Ctrl+C' is pressed, the child program destroy() will be  executed. | ||||
|         PWM.setMotorModel(0,0,0,0) | ||||
|         ultrasonic.pwm_S.setServoPwm(1,0,90,20) | ||||
| 
 | ||||
							
								
								
									
										
											BIN
										
									
								
								Tutorial.pdf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tutorial.pdf
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Loading…
	
		Reference in New Issue
	
	Block a user