def __init__(self):
        self.activeSensors = {}
        self.initialSensors = {}
        self.sensorCnt = 0
        self.currentBirds = 0
        self.min_confidence = 0.2
        self.DEBUGFLAG = False
        self.dirname = os.path.dirname(__file__)
        self.weightPath = os.path.join(self.dirname,
                                       "yolo-coco/yolov3-tiny.weights")
        self.configPath = os.path.join(self.dirname,
                                       "yolo-coco/yolov3-tiny.cfg")
        self.labelsPath = os.path.join(self.dirname, "yolo-coco/coco.names")
        self.LABELS = open(self.labelsPath).read().strip().split("\n")
        self.net = cv2.dnn.readNetFromDarknet(self.configPath, self.weightPath)
        self.ln = self.net.getLayerNames()
        self.ln = [
            self.ln[i[0] - 1] for i in self.net.getUnconnectedOutLayers()
        ]
        AbstractRaspberryPi.__init__(self, "pi2", 5555, 5560)

        for s in self.initialSensors:
            self.add_sensor(self.initialSensors[s], s)
        self.show()
        # communication
        self.sender = AbstractSender(self.s_port)
        self.senderW = AbstractSender(5561)
        self.senderC = AbstractSender(5562)
        self.receiver = AbstractReceiver(self.r_port)
        self.lock = threading.Lock()
        threading.Thread(target=self.receiver_thread).start()
        threading.Thread(target=self.firstSend_thread).start()
Example #2
0
    def __init__(self):
        self.activeSensors = {}
        self.initialSensors = {
            "gyro": GyroSensor,
            "camera": CameraSensor,
            "distance": DistanceSensor
        }
        self.sensorCnt = 0
        AbstractRaspberryPi.__init__(self, "pi2", 5556, 5555)

        self.camera_start_time = time.time()
        self.cs = self.activeSensors['camera']

        self.regularDistance = 100

        self.peopleCounter = PeopleTracker()
        # if you want to write a debug video (into 'out_video.mp4') set this to true
        # self.peopleCounter.writeVideo = True
        self.peopleCounter.setup()

        # Subscribe to frames of the cameraSensor and delegate
        self.cs.subject.subscribe(on_next=self.on_img_received,
                                  on_completed=self.on_last_image,
                                  on_error=lambda err: print("errored"))
        self.peopleCounter.subject.subscribe(on_next=self.on_people_moved)
Example #3
0
    def __init__(self):
        self.activeSensors = {}
        self.initialSensors = {"gesture": GestureSensor, "display": Display}
        self.sensorCnt = 0
        AbstractRaspberryPi.__init__(self, "pi1", 5555, 5556)

        self.current_people = 3
        self.activeSensors["display"].on(f"currently {self.current_people} at the stop.")
Example #4
0
    def __init__(self):
        self.activeSensors = {}
        self.initialSensors = {"weight": WeightSensor, "servo": Servo}
        self.sensorCnt = 0
        AbstractRaspberryPi.__init__(self, "piW", 5560, 5561)

        for s in self.initialSensors:
            self.add_sensor(self.initialSensors[s], s)

        self.show()

        # communication
        self.sender = AbstractSender(self.s_port)
        self.receiver = AbstractReceiver(self.r_port)
        self.lock = threading.Lock()
        threading.Thread(target=self.receiver_thread).start()

        # start sampling
        threading.Thread(target=self.sampling_thread).start()
Example #5
0
    def __init__(self):
        self.activeSensors = {}
        self.initialSensors = {"camera": CameraSensor}
        self.sensorCnt = 0
        AbstractRaspberryPi.__init__(self, "piC", 5560, 5562)

        for s in self.initialSensors:
            self.add_sensor(self.initialSensors[s], s)

        self.show()

        # TODO: path to video / cam index
        self.activeSensors["camera"].videoPath = ""
        self.activeSensors["camera"].camIndex = 0

        # communication
        self.sender = AbstractSender(self.s_port)
        self.receiver = AbstractReceiver(self.r_port)
        self.lock = threading.Lock()
        threading.Thread(target=self.receiver_thread).start()

        # start sampling
        threading.Thread(target=self.sampling_thread).start()