Ejemplo n.º 1
0
    def getEdgePositions(self, row_rotation=0, col_rotation=0):
        self.column_wise_rotation = basic_header.constrainf(col_rotation, -90, 90)
        self.row_wise_rotation = basic_header.constrainf(row_rotation, -90, 90)

        bottom_length = top_length = self.length
        right_height = left_height = self.height

        if self.column_wise_rotation >= 0 and self.column_wise_rotation <= 90:
            bottom_length = top_length = basic_header.mapf(self.column_wise_rotation, 90, 0, 0, self.length)
            right_height = basic_header.mapf(self.column_wise_rotation, 90, 0, 0, self.height)
        elif self.column_wise_rotation <= 0 and self.column_wise_rotation >= -90:
            self.column_wise_rotation = abs(self.column_wise_rotation)
            bottom_length = top_length = basic_header.mapf(self.column_wise_rotation, 90, 0, 0, self.length)
            left_height = basic_header.mapf(self.column_wise_rotation, 90, 0, 0, self.height)

        if self.row_wise_rotation >= 0 and self.row_wise_rotation <= 90:
            top_length = basic_header.mapf(self.row_wise_rotation, 90, 0, 0, top_length)
            left_height = basic_header.mapf(self.column_wise_rotation, 90, 0, 0, left_height)
            right_height = basic_header.mapf(self.column_wise_rotation, 90, 0, 0, right_height)
        elif self.row_wise_rotation <= 0 and self.row_wise_rotation >= -90:
            self.row_wise_rotation = abs(self.row_wise_rotation)
            bottom_length = basic_header.mapf(self.row_wise_rotation, 90, 0, 0, bottom_length)
            left_height = basic_header.mapf(self.column_wise_rotation, 90, 0, 0, left_height)
            right_height = basic_header.mapf(self.column_wise_rotation, 90, 0, 0, right_height)

        c_row,c_column = self.center_position

        top_left_pos = (c_row-(left_height/2), c_column-(top_length/2))
        top_right_pos = (c_row-(right_height/2), c_column+(top_length/2))
        bottom_left_pos = (c_row+(left_height/2), c_column-(bottom_length/2))
        bottom_right_pos = (c_row+(right_height/2), c_column+(bottom_length/2))

        return [top_left_pos, top_right_pos, bottom_left_pos, bottom_right_pos]
Ejemplo n.º 2
0
    def __init__(self, fps=10):
        #Create setup variables
        self._created = False
        self.color_config = (640, 480, 30)

        #Set start frame to None
        self.next_frame = None
        self.curr_frame = None
        self.last_frame = None

        #Define buffer format for data
        self.fmt = 'B' * (self.color_config[0] * self.color_config[1] * 3)

        #Initialize this module as a rospy node
        rospy.init_node("track_moving_objects_color", anonymous=True)

        #Setup refresh rate variables
        self.fps = basic_header.constrainf(fps, 1,
                                           30)  #constrain the fps to 1-30 Hz
        self.rate = rospy.Rate(self.fps)

        #Setup publisher
        self.tracked_regions_pub = rospy.Publisher("TrackedRegions_1",
                                                   ContourData,
                                                   queue_size=10)

        #Create buffer for data to send
        self.tracked_regions_data_2_send = ContourData()

        #Setup the buffers for data to send
        self.tracked_regions_data_2_send.data_lengths = []
        self.tracked_regions_data_2_send.data = []
Ejemplo n.º 3
0
    def __init__(self, fps=7):
        #Create setup variables
        self._created = False
        self.color_config = (640, 480, 30)
        self.depth_config = (640, 480, 30)

        #Set start frames to None
        self.color_frame = None
        self.depth_frame = None

        #Initialize this module as a rospy node
        rospy.init_node("tag_objects", anonymous=True)

        #Setup publish data rate
        self.fps = basic_header.constrainf(fps, 1,
                                           30)  #constrain the fps to 1-30 Hz
        self.rate = rospy.Rate(self.fps)

        #Setup publisher
        self.tagged_objects_pub = rospy.Publisher("TaggedObjects_1",
                                                  TaggedObjects,
                                                  queue_size=10)

        #Create buffer for data to send
        self.tagged_objects = TaggedObjects()

        #Setup the buffers for data to send
        self.clearTaggedObjectsData()

        #Create and array to keep track of objects in the frame
        self.objects_buffer = []
        self.scrap_objects_buffer = []
Ejemplo n.º 4
0
    def __init__(self, fps=10, block_duration=20):
        #Create started variable
        self._started = False

        #Setup device and image data properties
        self.depth_config = (640, 480, 30)
        self.color_config = (640, 480, 30)

        self.depth_data_width = self.depth_config[0]
        self.depth_data_height = self.depth_config[1]
        self.depth_data_channel = 1

        self.color_data_width = self.color_config[0]
        self.color_data_height = self.color_config[1]
        self.color_data_channel = 3

        #Setup sound properties
        self.sound_samplerate = 44100
        self.sound_channels = 2
        self._stream_sample_duration = block_duration
        self.sound_data_height = int(self.sound_samplerate *
                                     self._stream_sample_duration / 1000.0)

        #Intialize Camera
        try:
            self.device = OrbbecDepthCamera(self.depth_config,
                                            self.color_config)
        except primesense.utils.OpenNIError:
            print "Error: No device detected"
            self.device = None

        #Intialize Mic with a callback function
        self.mic = Microphone(self.sound_channels, self.sound_samplerate,
                              self.callback)

        #Initialize this module as a ros node
        rospy.init_node('orbbec_data_publisher')

        #Setup publishers
        self.depth_data_pub = rospy.Publisher("DepthData_1",
                                              Int32Array,
                                              queue_size=10)
        self.color_data_pub = rospy.Publisher("ColorData_1",
                                              Int32Array,
                                              queue_size=10)
        self.sound_data_pub = rospy.Publisher("SoundData_1",
                                              Float32Array,
                                              queue_size=10)

        #Setup refresh rate variables
        self.fps = basic_header.constrainf(fps, 1,
                                           30)  #constrain the fps to 1-30 Hz
        self.rate = rospy.Rate(self.fps)

        #Create buffers for data to send
        self.depth_data_2_send = Int32Array()
        self.color_data_2_send = Int32Array()
        self.sound_data_2_send = Float32Array()