def take_pictures(self): """ Init Client socket and connect to the raspberry ip Send instruction to raspberry pi Check the return message from the raspberry pi, which means images transmitting is done Conduct human detection and display the results on the image views Toggle buttons and navigatable status cam0: left cam1: right """ self.client_intr = Client(self.raspberry_ip, self.port_intr) self.client_intr.hand_shake('T' + self.local_ip) check_call([ 'scp', '-q', 'pi@' + self.raspberry_ip + ':~/cam0.jpeg', 'pi@' + self.raspberry_ip + ':~/cam1.jpeg', './images/' ]) self.name1 = './images/left_' + str(self.image_number) + '.jpeg' self.name2 = './images/right_' + str(self.image_number) + '.jpeg' os.rename('./images/cam0.jpeg', self.name1) os.rename('./images/cam1.jpeg', self.name2) self.image_number += 1 # Calibration self.point_cloud.load_image(self.name1, self.name2) image_list = self.point_cloud.rectify_image() self.rectangle_coor_list = People_Detect.detect_image_list( image_list[:1], [self.name1]) self._views_showImage(self.view_cam1, self.name1) self._views_showImage(self.view_cam0, self.name2) self.btn_navigate.setEnabled(True) self.navigatable = True
def stop_preview(self): """ Send instruction to the raspberry pi to stop preview Terminate the mplayer process and close the socket connection at the server side Toggle buttons """ self.client_intr = Client(self.raspberry_ip, self.port_intr) self.client_intr.hand_shake('P') self.mplayer_t.stop() self.server_video.close() self.btn_start.setEnabled(True) self.btn_stop.setEnabled(False)
def start_preview(self): """ Set a server socket Init a Client socket and connect to the raspberry ip Send instruction to raspberry pi, and get ready to receive the video file Start another thread which runs mplayer locally Keep reading video data and pipe them to mplayer Toggle buttons """ self.server_video = Server(self.port_video) self.client_intr = Client(self.raspberry_ip, self.port_intr) self.client_intr.hand_shake('S' + self.local_ip) self.server_video.receive_file() self.mplayer_t = Threading_Mplayer(self.server_video) self.mplayer_t.start() self.btn_start.setEnabled(False) self.btn_stop.setEnabled(True) self.btn_takePics.setEnabled(True)