RaspberryPi/Autonomous/SoloRPi3_Method/autonomous.py
def start(self):
        """
        Starts Autonomous mode - records video, predicts, and executes motor on prediction
        """
        start_new_thread(self._pollDistance, ())

        # initialize the camera and grab a reference to the raw camera capture
        camera = PiCamera()
        camera.resolution = (320, 240)
        camera.framerate = 30
        rawCapture = PiRGBArray(camera, size=(320, 240))

        try:
            for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
                # raw NumPy array representing the image
                image = frame.array
                if (self._isPredicting and self.uss_distance > self.uss_thresholdDistance): #Only predict if boolean = true and distance > 15 cm
                    prediction = self._networkModel.predict(image[120:240])  # predict on lower half of image only
                    self.__executePrediction(prediction)

                # clear the stream in preparation for the next frame -- IMPORTANT
                rawCapture.truncate(0)
                # if cv2.waitKey(1) & 0xFF == ord("q"):
                #     break

        except Exception as e:
            print("---EXCEPTION OCCURED-----\n{}".format(e))
        finally:
            cv2.destroyAllWindows()
            camera.close()
            print("closing recording")

        Starts Autonomous mode - records video, predicts, and executes motor on prediction
        
Starts Autonomous mode - records video, predicts, and executes motor on prediction
Starts Autonomous mode - records video predicts and executes motor on prediction
def start(self):
        start_new_thread(self._pollDistance, ())
        camera = PiCamera()
        camera.resolution = (320, 240)
        camera.framerate = 30
        rawCapture = PiRGBArray(camera, size=(320, 240))
        try:
            for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
                image = frame.array
                if (self._isPredicting and self.uss_distance > self.uss_thresholdDistance): 
                    prediction = self._networkModel.predict(image[120:240])  
                    self.__executePrediction(prediction)
                rawCapture.truncate(0)
        except Exception as e:
            print("---EXCEPTION OCCURED-----\n{}".format(e))
        finally:
            cv2.destroyAllWindows()
            camera.close()
            print("closing recording")
def start ( self ) : start_new_thread ( self . _pollDistance , ( ) ) camera = PiCamera ( ) camera . resolution = ( 320 , 240 ) camera . framerate = 30 rawCapture = PiRGBArray ( camera , size = ( 320 , 240 ) ) try : for frame in camera . capture_continuous ( rawCapture , format = "bgr" , use_video_port = True ) : image = frame . array if ( self . _isPredicting and self . uss_distance > self . uss_thresholdDistance ) : prediction = self . _networkModel . predict ( image [ 120 : 240 ] ) self . __executePrediction ( prediction ) rawCapture . truncate ( 0 ) except Exception as e : print ( "---EXCEPTION OCCURED-----\n{}" . format ( e ) ) finally : cv2 . destroyAllWindows ( ) camera . close ( ) print ( "closing recording" )
Starts Autonomous mode - records video, predicts, and executes motor on prediction
Starts Autonomous mode - records video predicts and executes motor on prediction
"""
        Starts Autonomous mode - records video, predicts, and executes motor on prediction
        """ # initialize the camera and grab a reference to the raw camera capture # raw NumPy array representing the image #Only predict if boolean = true and distance > 15 cm # predict on lower half of image only # clear the stream in preparation for the next frame -- IMPORTANT # if cv2.waitKey(1) & 0xFF == ord("q"): #     break
self