Esempio n. 1
0
        # If in Wizard of Oz test mode
        if wizardOfOz:
            pupilL, pupilR, pupilV = OzMovePupils(pupilL, pupilR, pupilV)
            if disp.numberOfActivations != lastNumberOfActivations:
                timestamp = dt.datetime.now()
                logfile.write(
                    f"{timestamp}: Activation! Number of activations: {disp.numberOfActivations}\n"
                )
                lastNumberOfActivations = disp.numberOfActivations
                pygame.event.post(happyevent)

                frame, x, y, h, w = sh.take()
                frame = frame[y:(y + h), x - 30:(x + w + 30)]
                bubbles.append(
                    trackeduser.TrackedUser(
                        finalSurface, int(100), int(top_screen_height + 60),
                        BubbleUpdate, frame))  # Adds face to bubbles list
                pygame.time.set_timer(PHOTOEVENT, int(1000 / BubbleUpdate))

        elif receiver.poll():
            trackedList, peopleCount, frame = receiver.recv()
            trackedList = {k: v for (k, v) in trackedList.items() if v[4] > 5}

            if runInteraction:
                keys = trackedList.keys()  # IDs of currently tracked people
                recurrents = set(keys) & set(
                    prevKeys
                )  # IDs of people present during last interaction and now
                if not interactionWait and not flow.is_alive() and trackedList:
                    recurrentsVideo = set(keys) & set(videoKeys)
                    #interactionItems = []
Esempio n. 2
0
                                            args=interactionItems)
                    flow.start()
                    interactionItems = []
            if waitTimer > 0:
                interactionWait = True
                pygame.time.set_timer(INTERACTIONEVENT, waitTimer, True)

            # Gaze calculation and control
            if trackedList:
                if largeScreen and lastNumberOfActivations != disp.numberOfActivations:
                    userID = max(trackedList.items(), key=lambda i: i[1][2])[0]
                    (x, y, w, h, n, u, c) = trackedList.get(userID)
                    frame = frame[y:(y + h), x - 30:(x + w + 30)]
                    bubbles.append(
                        trackeduser.TrackedUser(
                            finalSurface, frame, int(100),
                            int(largeSize[1] * 0.9),
                            BubbleUpdate))  # Adds face to bubbles list
                    pygame.time.set_timer(PHOTOEVENT, int(1000 / BubbleUpdate))
                if gazeAtClosest:
                    if altTrackID == 0:  # Determine ID of closest person
                        trackID = max(trackedList.items(),
                                      key=lambda i: i[1][2])[0]
                        altTrackID = trackID
                    elif trackID not in trackedList:  # If we lose track of ID, look at the new closest
                        trackID = max(trackedList.items(),
                                      key=lambda i: i[1][2])[0]
                else:
                    if altTrackID == 0:  # Determine ID of random person
                        peopleList = list(trackedList.keys())
                        if len(
                                peopleList