Example #1
0
        """ This method creates image buffers with the specified \a width, \a height and number of
            color channels \a channels.

        @param width    - integer specifying the width of the image   (default: 320)
        @param height   - integer specifying the height of the image  (default: 240)
        @param channels - integer specifying number of color channels (default: 3)
        @return image, buffer array
        """

        if channels == 1:
            buf_image = yarp.ImageFloat()
            buf_image.resize(width, height)

            buf_array = np.zeros((height, width), dtype = np.float32)

        else:
            buf_image = yarp.ImageRgb()
            buf_image.resize(width, height)

            buf_array = np.zeros((height, width, channels), dtype = np.uint8)

        buf_image.setExternal( buf_array,
                               buf_array.shape[1],
                               buf_array.shape[0] )

        return buf_image, buf_array


if __name__ == '__main__':
    main(JDVideo)
Example #2
0
            # parse lines
            for line in file_handle.read().split('\n'):

                line = line.strip()

                # ignore empty
                if not line:
                    continue

                # new pattern name
                elif line.startswith('['):
                    name = line[1:line.index(']')].strip()
                    self.patterns[name] = []

                # new step
                elif '\t' in line:
                    joint, position = line.split('\t')
                    self.patterns[name].append( (int(joint), int(position)) )

            names = self.patterns.keys()
            names.sort()

            print 'Patterns loaded'
            print '==============='
            for name in names:
                print name, len(self.patterns[name])


if __name__ == '__main__':
    main(JDModule)
Example #3
0

    def respond(self, command, reply):
        """ This is the respond hook method which gets called upon receiving a bottle via RPC port.

        @param command - input bottle
        @param reply - output bottle
        @return boolean
        """
        if command.get(0).toString() == 'neutral':
            self.JD.rgbEyes.setArray(Emotions.NEUT)

        elif command.get(0).toString() == 'happy':
            self.JD.rgbEyes.setArray(Emotions.HAPP)

        elif command.get(0).toString() == 'dizzy':

            for array in Emotions.DIZZ:
                self.JD.rgbEyes.setArray(array)
            for array in Emotions.DIZZ:
                self.JD.rgbEyes.setArray(array)
            self.JD.rgbEyes.setArray(Emotions.NEUT)

        # reply with success
        reply.addString('nack')
        return True


if __name__ == '__main__':
    main(Emotions)
    
Example #4
0
            # parse lines
            for line in file_handle.read().split('\n'):

                line = line.strip()

                # ignore empty
                if not line:
                    continue

                # new pattern name
                elif line.startswith('['):
                    name = line[1:line.index(']')].strip()
                    self.patterns[name] = []

                # new step
                elif '\t' in line:
                    joint, position = line.split('\t')
                    self.patterns[name].append((int(joint), int(position)))

            names = self.patterns.keys()
            names.sort()

            print 'Patterns loaded'
            print '==============='
            for name in names:
                print name, len(self.patterns[name])


if __name__ == '__main__':
    main(JDModule)
Example #5
0
    def createImageBuffer(width=320, height=240, channels=3):
        """ This method creates image buffers with the specified \a width, \a height and number of
            color channels \a channels.

        @param width    - integer specifying the width of the image   (default: 320)
        @param height   - integer specifying the height of the image  (default: 240)
        @param channels - integer specifying number of color channels (default: 3)
        @return image, buffer array
        """

        if channels == 1:
            buf_image = yarp.ImageFloat()
            buf_image.resize(width, height)

            buf_array = np.zeros((height, width), dtype=np.float32)

        else:
            buf_image = yarp.ImageRgb()
            buf_image.resize(width, height)

            buf_array = np.zeros((height, width, channels), dtype=np.uint8)

        buf_image.setExternal(buf_array, buf_array.shape[1],
                              buf_array.shape[0])

        return buf_image, buf_array


if __name__ == '__main__':
    main(JDVideo)
Example #6
0
        # pick first face
        faces = bottle.get(1).asList()
        face  = faces.get(0).asList()

        center_x = face.get(1).asInt()
        center_y = face.get(2).asInt()

        print center_x, center_y,

        center_x -= 160

        z = 1.0
        x = (center_x * 0.5) / 320
        y = 0.0

        print z, x, y

        bottle = yarp.Bottle()
        bottle.clear()

        bottle.addDouble(0.0)
        bottle.addDouble(x)
        bottle.addDouble(0.0)
        bottle.addDouble(-1.0)
        self.positionOutPort.write(bottle)


if __name__ == '__main__':
    main(JDFollowFace)
Example #7
0
        # pick first face
        faces = bottle.get(1).asList()
        face = faces.get(0).asList()

        center_x = face.get(1).asInt()
        center_y = face.get(2).asInt()

        print center_x, center_y,

        center_x -= 160

        z = 1.0
        x = (center_x * 0.5) / 320
        y = 0.0

        print z, x, y

        bottle = yarp.Bottle()
        bottle.clear()

        bottle.addDouble(0.0)
        bottle.addDouble(x)
        bottle.addDouble(0.0)
        bottle.addDouble(-1.0)
        self.positionOutPort.write(bottle)


if __name__ == '__main__':
    main(JDFollowFace)