예제 #1
0
    def RappFaceDetection(self, imageString, image):

        path = imageORimageString(imageString, image)  #path of saved image.
        ch = RappPlatformAPI(address=addr)
        response = ch.faceDetection(
            path)  # Use the server's path of the image.
        return response
예제 #2
0
class FaceDetectionTests(unittest.TestCase):
    def setUp(self):
        self.ch = RappPlatformAPI()

        rospack = rospkg.RosPack()
        self.pkgDir = rospack.get_path('rapp_testing_tools')

    def test_closeStraight(self):
        imagepath = path.join(self.pkgDir, 'test_data', 'face_samples',
                              'klpanagi_close_straight.jpg')
        response = self.ch.faceDetection(imagepath)

        valid_faces = [{
            'up_left_point': {
                'y': 450.0,
                'x': 640.0
            },
            'down_right_point': {
                'y': 662.0,
                'x': 852.0
            }
        }]

        self.assertEqual(response['error'], u'')
        self.assertEqual(response['faces'], valid_faces)

    def test_lenna(self):
        imagepath = path.join(self.pkgDir, 'test_data', 'Lenna.png')
        response = self.ch.faceDetection(imagepath)

        valid_faces = [{
            'up_left_point': {
                'y': 201.0,
                'x': 213.0
            },
            'down_right_point': {
                'y': 378.0,
                'x': 390.0
            }
        }]

        self.assertEqual(response['error'], u'')
        self.assertEqual(response['faces'], valid_faces)

    def test_multipleFaces(self):
        imagepath = path.join(self.pkgDir, 'test_data', 'face_samples', \
                'multi_faces_frames', 'multi_faces.jpg')
        response = self.ch.faceDetection(imagepath)

        self.assertEqual(response['error'], u'')
        self.assertEqual(len(response['faces']), 3)

    def test_notExistentFile(self):
        imagepath = path.join(self.pkgDir, 'face_samples', \
                'multi_faces_frames', 'multi_faces.jpg')
        response = self.ch.faceDetection(imagepath)

        self.assertNotEqual(response['error'], u'')

    def test_erroneousFileType(self):
        imagepath = 3
        response = self.ch.faceDetection(imagepath)

        self.assertNotEqual(response['error'], u'')
예제 #3
0
        # Delay to stabilize the head
        time.sleep(1)

        image_name = "img_" + str(i * 3 + j) + ".jpg"
        # Capture an image from the NAO cameras
        rh.vision.capturePhoto("/home/nao/" + image_name, "front", "640x480")
        # Get the photo to the PC
        rh.utilities.moveFileToPC("/home/nao/" + image_name, \
            home + image_name)
        
        imageFilepath = home + image_name
        
        # Get the responses
        qr_resp = ch.qrDetection(imageFilepath)
        face_resp = ch.faceDetection(imageFilepath, False)
        obj_resp = ch.objectRecognitionCaffe(imageFilepath)

        # Prints for debugging purposes
        print str(global_counter) + ": " + str(qr_resp)
        print str(global_counter) + ": " + str(face_resp)
        print str(global_counter) + ": " + str(obj_resp)
        print "\n"

        # Store the objects and the respective head angles
        # Store the unique QR codes
        if len(qr_resp['qr_centers']) != 0:
            # Transform Image-frame angles to NAO-frame
            obj_frame_ang = pointToRads(
                    qr_resp['qr_centers'][0]['x'],
                    qr_resp['qr_centers'][0]['y'],