コード例 #1
0
    def run(self):
        parser = self.create_parser()
        options, args = parser.parse_args()

        if options.NAME and 'unknown' in self.name:
            self.name = options.NAME
        if options.DESCRIPTION:
            self.description = options.DESCRIPTION

        self.process_args_and_options(args, options)

        store(
            data_class='ServiceStart',
            data=dict(
                host=self.host,
                ip=self.ip,
                name=self.name,
                description=self.description
            )
        )

        try:
            self.execute(args, options)
        except KeyboardInterrupt:
            self.terminate()
コード例 #2
0
 def register(self):
     self.streaming_document = store(
         data_class="ServiceStreamingData",
         data=dict(
             host=self.host,
             ip=self.ip,
             name=self.name,
             url=self.url,
             description=self.description
         )
     )
コード例 #3
0
    def sonification(self):
        self.set_status(STATUS.PLAYING)
        self.log(msg="ready to sonification!")
        hand = HandFeature(image_points=average_points(self.hand_frames))
        send_sonification_to_max(hand)
        sound_duration = 20
        self.log(msg="time taken {}".format(time.time() - self.start_time))

        self.log(msg="sleeping till sounds end")
        self.post_message(state="PLAYING", value=hand.uid)
        time.sleep(sound_duration)

        store(data_class="OneHandFeatures",
              data=dict(uid=hand.uid,
                        touch_session_id=self.session_id,
                        image_points=hand.image_points,
                        hand_print=False,
                        shared=False))
        for picture in self.hand_frames:
            picture.save()

        self.post_message(state="GREETINGS", value=hand.uid)
        time.sleep(10)
        self.reset()
コード例 #4
0
 def set_status(self, status):
     if isinstance(status, str):
         status = STATUS[status]
     if self.status_document is None:
         self.status_document = store(
             data_class='ServiceStatus',
             data=dict(
                 host=self.host,
                 ip=self.ip,
                 name=self.name,
                 status=self.status.name,
                 description=self.description
             )
         )
     self.status = status
     self.status_document.status = self.status.name
     self.status_document.create_time = datetime.now()
     self.status_document.save()
     self.osc_client.send_message(settings.SERVICE_OSC_STATUS_ADDRESS.format(self.name), self.status.name)
コード例 #5
0
    def fetch_data(self):

        # HACK! import hands from manosola
        cursor = self.onehand_remote.find(
            {"create_time": {
                "$gte": self.last_update
            }})
        onehand_local = OneHandFeatures.get_collection()
        for data in cursor:
            if not data.get("hand_print"):
                continue
            if onehand_local.count_documents({"_id": data.get("_id")}) > 0:
                continue
            data['shared'] = False
            hand = store(data_class=OneHandFeatures, data=data, force=True)
            self.log("unburied hand {} from manosola pit".format(hand.uid))
            # break

        super().fetch_data()
コード例 #6
0
for filename in os.listdir(IMAGES_DIRECTORY):
    src_image = os.path.join(IMAGES_DIRECTORY, filename)
    frame = cv2.imread(src_image)
    frame_copy = frame.copy()
    image_points, processed_frame = extractor.process_frame(frame_copy)
    cv2.imshow('hand feature keypoints + skeleton', rescale_frame(processed_frame))

    print("processed image {}".format(src_image))
    if image_points is None:
        continue

    data = dict(
        src=filename,
        hand=True,
        image_points=image_points,
        features=""
    )

    store(data_class=OneHandPicture, data=data, publish_after=False)

    if extractor.live_output:
        key = cv2.waitKey(0)



        if key == 27:
            cv2.destroyAllWindows()
            break
        else:
            continue
コード例 #7
0
async def hand_on_callback(session_id, status):
    store(data_class="OneHandTouch",
          data=dict(session_id=session_id, status=status))
    print("Touch {} {}".format(session_id, status))
コード例 #8
0
def trigger_touch_event(session_id, status):
    print("Touch {} {}".format(session_id, status))
    store(data_class="OneHandTouch", data=dict(session_id=session_id, status=status))