예제 #1
0
class ObjectRecognitionTests(unittest.TestCase):
    def setUp(self):
        self.ch = RappPlatformAPI()

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

    def test_cat_test(self):
        imagepath = path.join(self.pkgDir, 'test_data', 'cat.jpg')

        validResponse = {
            'object_class': 'boa constrictor, Constrictor constrictor',
            'error': ''
        }

        response = self.ch.objectRecognitionCaffe(imagepath)

        self.assertEqual(response, validResponse)

    def test_wrongPath(self):
        imagepath = path.join(self.pkgDir, '', 'cat.jpg')
        response = self.ch.objectRecognitionCaffe(imagepath)
        self.assertNotEqual(response['error'], u'')

    def test_wrongPathType(self):
        imagepath = 3
        response = self.ch.objectRecognitionCaffe(imagepath)
        self.assertNotEqual(response['error'], u'')
class ObjectRecognitionTests(unittest.TestCase):

    def setUp(self):
        self.ch = RappPlatformAPI()
        
        rospack = rospkg.RosPack()
        self.pkgDir = rospack.get_path('rapp_testing_tools')

    def test_cat_test(self):
        imagepath = path.join(self.pkgDir, 'test_data', 'cat.jpg')
        
        validResponse = {
            'object_class': 'boa constrictor, Constrictor constrictor',
            'error': ''
            }

        response = self.ch.objectRecognitionCaffe(imagepath)
        
        self.assertEqual(response, validResponse)

    def test_wrongPath(self):
        imagepath = path.join(self.pkgDir, '', 'cat.jpg')
        response = self.ch.objectRecognitionCaffe(imagepath)
        self.assertNotEqual(response['error'], u'')

    def test_wrongPathType(self):
        imagepath = 3 
        response = self.ch.objectRecognitionCaffe(imagepath)
        self.assertNotEqual(response['error'], u'')
예제 #3
0
    def RappObjectRecCaffe(self, imageString, image):

        path = imageORimageString(imageString, image)  #path of saved image.
        ch = RappPlatformAPI(address=addr)
        response = ch.objectRecognitionCaffe(
            path)  # Use the server's path 	of the image.
        return response
예제 #4
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'],
                    640.0,