コード例 #1
0
        def update(self, observable, arg):
            #            print("New 2D Point Observer in Point 3D")
            if isinstance(observable.outer, Camera):
                #TODO check if this point could be owned by this user, if yes add it to the list
                temp2D = observable.outer.points2D[-1]

                # User is lost and receive new 2D Point
                if self.outer.pointLost:

                    # 1: Check if new 2D Point comes from same camera as another 2D Point used here (if yes, discard)
                    for point in self.outer.points2D:
                        if point.camera == temp2D.camera:
                            print "2D Point from same camera : Replace"
                            self.outer.delete(point)
                            # Add the New 2D Point to this 3D Point
                            self.outer.add(temp2D)
                            # Add Observer for position update on last 2D Point added from Camera
                            observable.outer.points2D[
                                -1].positionUpdateNotifier.addObserver(
                                    self.outer.point2DUpdateObserver)
                            return

                    # Add the point to the user if user doesn't have 2 2D Points
                    if len(self.outer.points2D) < 2:
                        # Add the New 2D Point to this 3D Point
                        self.outer.add(temp2D)
                        # Add Observer for position update on last 2D Point added from Camera
                        observable.outer.points2D[
                            -1].positionUpdateNotifier.addObserver(
                                self.outer.point2DUpdateObserver)
                        return

                # User is not lost and receive new 2D Point
                else:
                    # 1: Check if new 2D Point comes from same camera as another 2D Point used here (if yes, discard)
                    for point in self.outer.points2D:
                        if point.camera == temp2D.camera:
                            print "2D Point discard : same camera"
                            return

                    # 2: Calculate 3D Point position with new 2D point and check position difference (yes difference too high, discard)
                    for point in self.outer.points2D:
                        temp3D = compute.calculate3DPosition(point, temp2D)
                        distance = self.outer.distance(temp3D[0, 0],
                                                       temp3D[1, 0], temp3D[2,
                                                                            0])
                        print distance
                        if (distance > self.outer.MAX_DISTANCE_ERROR *
                                self.outer.MAX_DISTANCE_ERROR):
                            print "2D Point discard : too far"
                            return

                    # If we get there, user is not lost, and new point is OK
                    # Add the New 2D Point to this 3D Point
                    print "Adding new 2D Point to 3D Point"
                    self.outer.add(temp2D)
                    # Add Observer for position update on last 2D Point added from Camera
                    observable.outer.points2D[
                        -1].positionUpdateNotifier.addObserver(
                            self.outer.point2DUpdateObserver)
コード例 #2
0
ファイル: Point3D.py プロジェクト: prabindh/VrTracker
        def update(self, observable, arg):
#            print("Position update Observer in Point 3D")
            #TODO Calculate 3D position
            if len(self.outer.points2D) > 1:
                new3Dposition = compute.calculate3DPosition(self.outer.points2D[len(self.outer.points2D)-1], self.outer.points2D[len(self.outer.points2D)-2])
                self.outer.user.sendPositionUpdate(new3Dposition)
                self.outer.lastXYZ = [new3Dposition[0,0], new3Dposition[1,0], new3Dposition[2,0]]
            else:
                self.outer.pointLost = True
コード例 #3
0
        def update(self, observable, arg):
            if len(self.outer.points2D) > 1:
                #                print "COUNT : " + str(len(self.outer.points2D))

                # elif len(self.outer.points2D) > 2:
                list3DPositions = np.array([], dtype=np.float32).reshape(0, 3)

                # Calculate all 3D positions from all combinations of 2D pairs
                # and average those positions.
                # print "====================== 2D UPDATE OBSERVER ======================"
                errorPair = []
                for i in range(0, len(self.outer.points2D) - 1):
                    for j in range(i + 1, len(self.outer.points2D)):
                        value = compute.calculate3DPosition(
                            self.outer.points2D[i], self.outer.points2D[j])
                        value = value.reshape(1, 3)
                        #			print value
                        if self.outer.distance(
                                value[0, 0], value[0, 1], value[0, 2]
                        ) > self.outer.MAX_DISTANCE_ERROR * self.outer.MAX_DISTANCE_ERROR:
                            print "TOO FAR"
                            if i in errorPair:
                                self.outer.delete(self.outer.points2D[i])
                                return
                            elif j in errorPair:
                                self.outer.delete(self.outer.points2D[j])
                                return
                            else:
                                errorPair.append(i)
                                errorPair.append(j)

                        else:
                            list3DPositions = np.append(list3DPositions,
                                                        value,
                                                        axis=0)

                list3DPositions = np.average(list3DPositions, axis=0)

                #u print "LIST : " + str( list3DPositions)
                # List of 10 last positions
                while np.ma.size(self.outer.buffer3DPositions, 0) >= 10:
                    self.outer.buffer3DPositions = np.delete(
                        self.outer.buffer3DPositions, 0, 0)

                self.outer.buffer3DPositions = np.append(
                    self.outer.buffer3DPositions, [list3DPositions], axis=0)
                #print self.outer.buffer3DPositions

                smoothedPosition = self.outer.smooth(
                    self.outer.buffer3DPositions)
                # print "SMOOTHED : " + str(smoothedPosition)
                self.outer.user.sendPositionUpdate(smoothedPosition)
                self.outer.lastXYZ = smoothedPosition
            else:
                #print "3D point LOST"
                self.outer.pointLost = True
                self.outer.user.tag.debugUserLost()
コード例 #4
0
ファイル: Point3D.py プロジェクト: prabindh/VrTracker
        def update(self, observable, arg):
#            print("New 2D Point Observer in Point 3D")
            if isinstance(observable.outer, Camera):
                #TODO check if this point could be owned by this user, if yes add it to the list
                temp2D = observable.outer.points2D[-1]

                # User is lost and receive new 2D Point
                if self.outer.pointLost:

                    # 1: Check if new 2D Point comes from same camera as another 2D Point used here (if yes, discard)
                    for point in self.outer.points2D:
                        if point.camera == temp2D.camera:
                            print "2D Point from same camera : Replace"
                            self.outer.delete(point)
                            # Add the New 2D Point to this 3D Point
                            self.outer.add(temp2D)
                            # Add Observer for position update on last 2D Point added from Camera
                            observable.outer.points2D[-1].positionUpdateNotifier.addObserver(self.outer.point2DUpdateObserver)
                            return

                    # Add the point to the user if user doesn't have 2 2D Points
                    if len(self.outer.points2D) < 2:
                        # Add the New 2D Point to this 3D Point
                        self.outer.add(temp2D)
                        # Add Observer for position update on last 2D Point added from Camera
                        observable.outer.points2D[-1].positionUpdateNotifier.addObserver(self.outer.point2DUpdateObserver)
                        return


                # User is not lost and receive new 2D Point
                else:
                    # 1: Check if new 2D Point comes from same camera as another 2D Point used here (if yes, discard)
                    for point in self.outer.points2D:
                        if point.camera == temp2D.camera:
                            print "2D Point discard : same camera"
                            return


                    # 2: Calculate 3D Point position with new 2D point and check position difference (yes difference too high, discard)
                    for point in self.outer.points2D:
                        temp3D = compute.calculate3DPosition(point, temp2D)
                        distance = self.outer.distance(temp3D[0,0], temp3D[1,0], temp3D[2,0])
                        print distance
                        if(distance > self.outer.MAX_DISTANCE_ERROR*self.outer.MAX_DISTANCE_ERROR):
                            print "2D Point discard : too far"
                            return

                    # If we get there, user is not lost, and new point is OK
                    # Add the New 2D Point to this 3D Point
                    print "Adding new 2D Point to 3D Point"
                    self.outer.add(temp2D)
                    # Add Observer for position update on last 2D Point added from Camera
                    observable.outer.points2D[-1].positionUpdateNotifier.addObserver(self.outer.point2DUpdateObserver)
コード例 #5
0
ファイル: Point3D.py プロジェクト: JulesThuillier/VrTracker
        def update(self, observable, arg):
            if isinstance(observable.outer, Camera):
                temp2D = observable.outer.points2D[-1]

                # User is lost and receive new 2D Point
                if self.outer.pointLost:

                    # 1: Check if new 2D Point comes from same camera as another 2D Point used here (if yes, discard)
                    for point in self.outer.points2D:
                        if point.camera.macadress == temp2D.camera.macadress:
                           # print "2D Point from same camera : Replace - " + point.camera.macadress
                            self.outer.delete(point)
                            # Add the New 2D Point to this 3D Point
                            self.outer.add(temp2D)
                            # Add Observer for position update on last 2D Point added from Camera
                            observable.outer.points2D[-1].positionUpdateNotifier.addObserver(self.outer.point2DUpdateObserver)
                            return

                    # Add the point to the user if user doesn't have 2 2D Points
                    if len(self.outer.points2D) < 2:
                        #print "Adding new 2D Point to 3D Point"
                        # Add the New 2D Point to this 3D Point
                        self.outer.add(temp2D)
                        # Add Observer for position update on last 2D Point added from Camera
                        observable.outer.points2D[-1].positionUpdateNotifier.addObserver(self.outer.point2DUpdateObserver)
                        return


                # User is not lost and receive new 2D Point
                else:
                    # 1: Check if new 2D Point comes from same camera as another 2D Point used here (if yes, discard)
                    for point in self.outer.points2D:
                        if point.camera == temp2D.camera:
                           # print "2D Point discard : same camera - " + point.camera.macadress
                            return

                    # 2: Calculate 3D Point position with new 2D point and check position difference (yes difference too high, discard)
                    for point in self.outer.points2D:
                        if point.isLost() ==  False and point.camera.macadress != temp2D.camera.macadress:
                            temp3D = compute.calculate3DPosition(point, temp2D)
                            distance = self.outer.distance(temp3D[0,0], temp3D[1,0], temp3D[2,0])
                          #  print "DISTANCE : " + str(distance)
                            if(distance > self.outer.MAX_DISTANCE_ERROR*self.outer.MAX_DISTANCE_ERROR):
                               # print "2D Point discard : too far"
                                #Todo Get this back working
                                return

                    # If we get there, user is not lost, and new point is OK
                    # Add the New 2D Point to this 3D Point
                    print "Adding new 2D Point to 3D Point"
                    self.outer.add(temp2D)
                    # Add Observer for position update on last 2D Point added from Camera
                    observable.outer.points2D[-1].positionUpdateNotifier.addObserver(self.outer.point2DUpdateObserver)
コード例 #6
0
 def update(self, observable, arg):
     #            print("Position update Observer in Point 3D")
     #TODO Calculate 3D position
     if len(self.outer.points2D) > 1:
         new3Dposition = compute.calculate3DPosition(
             self.outer.points2D[len(self.outer.points2D) - 1],
             self.outer.points2D[len(self.outer.points2D) - 2])
         self.outer.user.sendPositionUpdate(new3Dposition)
         self.outer.lastXYZ = [
             new3Dposition[0, 0], new3Dposition[1, 0], new3Dposition[2,
                                                                     0]
         ]
     else:
         self.outer.pointLost = True
コード例 #7
0
ファイル: Point3D.py プロジェクト: JulesThuillier/VrTracker
        def update(self, observable, arg):
            if len(self.outer.points2D) > 1 :
#                print "COUNT : " + str(len(self.outer.points2D))

             # elif len(self.outer.points2D) > 2:
                list3DPositions = np.array([], dtype=np.float32).reshape(0,3)

                # Calculate all 3D positions from all combinations of 2D pairs
                # and average those positions.
               # print "====================== 2D UPDATE OBSERVER ======================"
                errorPair = []
                for i in range(0, len(self.outer.points2D)-1):
                    for j in range(i+1, len(self.outer.points2D)):
                        value = compute.calculate3DPosition(self.outer.points2D[i], self.outer.points2D[j])
                        value = value.reshape(1,3)
#			print value
                        if self.outer.distance(value[0,0], value[0,1], value[0,2]) > self.outer.MAX_DISTANCE_ERROR*self.outer.MAX_DISTANCE_ERROR:
                            print "TOO FAR"
                            if i in errorPair:
                                self.outer.delete(self.outer.points2D[i])
                                return
                            elif j in errorPair:
                                self.outer.delete(self.outer.points2D[j])
                                return
                            else:
                                errorPair.append(i)
                                errorPair.append(j)

                        else:
                            list3DPositions = np.append(list3DPositions, value, axis=0)


                list3DPositions =  np.average(list3DPositions, axis=0)

               #u print "LIST : " + str( list3DPositions)
                # List of 10 last positions
                while np.ma.size(self.outer.buffer3DPositions, 0) >= 10:
                    self.outer.buffer3DPositions = np.delete(self.outer.buffer3DPositions, 0, 0)

                self.outer.buffer3DPositions = np.append(self.outer.buffer3DPositions, [list3DPositions], axis=0)
                #print self.outer.buffer3DPositions

                smoothedPosition = self.outer.smooth(self.outer.buffer3DPositions)
               # print "SMOOTHED : " + str(smoothedPosition)
                self.outer.user.sendPositionUpdate(smoothedPosition)
                self.outer.lastXYZ = smoothedPosition
            else:
                #print "3D point LOST"
                self.outer.pointLost = True
                self.outer.user.tag.debugUserLost()
コード例 #8
0
        def update(self, observable, arg):
            if isinstance(observable.outer, Camera):
                temp2D = observable.outer.points2D[-1]

                # User is lost and receive new 2D Point
                if self.outer.pointLost:

                    # 1: Check if new 2D Point comes from same camera as another 2D Point used here (if yes, discard)
                    for point in self.outer.points2D:
                        if point.camera.macadress == temp2D.camera.macadress:
                            # print "2D Point from same camera : Replace - " + point.camera.macadress
                            self.outer.delete(point)
                            # Add the New 2D Point to this 3D Point
                            self.outer.add(temp2D)
                            # Add Observer for position update on last 2D Point added from Camera
                            observable.outer.points2D[
                                -1].positionUpdateNotifier.addObserver(
                                    self.outer.point2DUpdateObserver)
                            return

                    # Add the point to the user if user doesn't have 2 2D Points
                    if len(self.outer.points2D) < 2:
                        #print "Adding new 2D Point to 3D Point"
                        # Add the New 2D Point to this 3D Point
                        self.outer.add(temp2D)
                        # Add Observer for position update on last 2D Point added from Camera
                        observable.outer.points2D[
                            -1].positionUpdateNotifier.addObserver(
                                self.outer.point2DUpdateObserver)
                        return

                # User is not lost and receive new 2D Point
                else:
                    # 1: Check if new 2D Point comes from same camera as another 2D Point used here (if yes, discard)
                    for point in self.outer.points2D:
                        if point.camera == temp2D.camera:
                            # print "2D Point discard : same camera - " + point.camera.macadress
                            return

                    # 2: Calculate 3D Point position with new 2D point and check position difference (yes difference too high, discard)
                    for point in self.outer.points2D:
                        if point.isLost(
                        ) == False and point.camera.macadress != temp2D.camera.macadress:
                            temp3D = compute.calculate3DPosition(point, temp2D)
                            distance = self.outer.distance(
                                temp3D[0, 0], temp3D[1, 0], temp3D[2, 0])
                            #  print "DISTANCE : " + str(distance)
                            if (distance > self.outer.MAX_DISTANCE_ERROR *
                                    self.outer.MAX_DISTANCE_ERROR):
                                # print "2D Point discard : too far"
                                #Todo Get this back working
                                return

                    # If we get there, user is not lost, and new point is OK
                    # Add the New 2D Point to this 3D Point
                    print "Adding new 2D Point to 3D Point"
                    self.outer.add(temp2D)
                    # Add Observer for position update on last 2D Point added from Camera
                    observable.outer.points2D[
                        -1].positionUpdateNotifier.addObserver(
                            self.outer.point2DUpdateObserver)