Esempio n. 1
0
    def test(self):
        model = incoming_image()
        model.time_stamp = 1547453775.2
        model.focal_length = 16.0
        model.image_path = '/im/a/totally/real/path/i/swear.jpg'
        model.manual_tap = False
        model.autonomous_tap = False

        truncateTable('incoming_image')
        dao = IncomingImageDAO(defaultConfigPath())
        self.assertIsNotNone(dao)

        # test with empty table

        self.assertIsNone(dao.getImage(1))

        resultingId = dao.addImage(model)
        self.assertNotEqual(resultingId, -1)

        resultingModel = dao.getImage(resultingId)

        self.assertIsNotNone(resultingModel)
        self.assertAlmostEqual(resultingModel.time_stamp, model.time_stamp)
        self.assertEqual(resultingModel.focal_length, model.focal_length)
        self.assertEqual(resultingModel.image_path, model.image_path)
        self.assertEqual(resultingModel.manual_tap, model.manual_tap)
        self.assertEqual(resultingModel.autonomous_tap, model.autonomous_tap)
Esempio n. 2
0
    def test(self):
        truncateTable('incoming_image')
        dao = IncomingImageDAO(defaultConfigPath())
        self.assertIsNotNone(dao)

        # test with empty table
        self.assertIsNone(dao.getNextImage(True))
        self.assertIsNone(dao.getNextImage(False))

        model = incoming_image()
        model.time_stamp = 1547453775.2
        model.focal_length = 16.0
        model.image_path = '/im/a/totally/real/path/i/swear.jpg'
        model.manual_tap = False
        model.autonomous_tap = False
        resultingId = dao.addImage(model)
        self.assertNotEqual(resultingId, -1)

        # identical timestamps should make no difference
        model.focal_length = 16.0
        model.image_path = '/im/a/totally/real/path/2/i/swear.jpg'
        resultingId2 = dao.addImage(model)
        self.assertNotEqual(resultingId2, -1)

        resultModel = dao.getNextImage(True)
        self.assertIsNotNone(resultModel)
        self.assertEqual(resultModel.image_id, resultingId)
        self.assertTrue(resultModel.manual_tap)
        self.assertFalse(resultModel.autonomous_tap)

        resultModel = dao.getNextImage(True)
        self.assertIsNotNone(resultModel)
        self.assertEqual(resultModel.image_id, resultingId2)
        self.assertTrue(resultModel.manual_tap)
        self.assertFalse(resultModel.autonomous_tap)

        resultModel = dao.getNextImage(False)
        self.assertIsNotNone(resultModel)
        self.assertEqual(resultModel.image_id, resultingId)
        self.assertTrue(resultModel.manual_tap)
        self.assertTrue(resultModel.autonomous_tap)

        resultModel = dao.getNextImage(True)
        self.assertIsNone(resultModel)

        resultModel = dao.getNextImage(False)
        self.assertIsNotNone(resultModel)
        self.assertEqual(resultModel.image_id, resultingId2)
        self.assertTrue(resultModel.manual_tap)
        self.assertTrue(resultModel.autonomous_tap)

        resultModel = dao.getNextImage(False)
        self.assertIsNone(resultModel)
Esempio n. 3
0
    def test(self):
        truncateTable('incoming_image')
        truncateTable('cropped_autonomous')
        truncateTable('outgoing_autonomous')
        dao = OutgoingAutonomousDAO(defaultConfigPath())

        testIns = outgoing_autonomous()
        testIns.crop_id = 42
        testIns.shape = 'circle'
        testIns.background_color = 'white'
        testIns.alphanumeric = 'A'
        testIns.alphanumeric_color = 'black'
        self.assertNotEqual(dao.addClassification(testIns), -1)

        dao = CroppedAutonomousDAO(defaultConfigPath())
        model = cropped_autonomous()
        model.image_id = 123
        model.time_stamp = 1547453775.2
        model.cropped_path = '/im/a/totally/real/cropped/path/i/swear.jpg'
        model.crop_coordinate_br = "(12, 34)"
        model.crop_coordinate_tl = "(56, 78)"
        self.assertNotEqual(dao.addImage(model), -1)

        dao = IncomingImageDAO(defaultConfigPath())
        model = incoming_image()
        model.time_stamp = 1547453775.2
        model.focal_length = 16.0
        model.image_path = '/im/a/totally/real/path/i/swear.jpg'
        model.manual_tap = True
        model.autonomous_tap = True
        resultingId = dao.addImage(model)
        self.assertNotEqual(resultingId, -1)

        util = UtilDAO(defaultConfigPath())
        util.resetAutonomousDB()

        resultingModel = dao.getImage(resultingId)
        self.assertIsNotNone(resultingModel)
        self.assertFalse(resultingModel.autonomous_tap)
        self.assertTrue(resultingModel.manual_tap)
        self.assertEqual(resultingModel.image_path, model.image_path)
        self.assertEqual(resultingModel.focal_length, model.focal_length)

        dao = CroppedAutonomousDAO(defaultConfigPath())
        self.assertEqual(len(dao.getAll()), 0)

        dao = OutgoingAutonomousDAO(defaultConfigPath())
        self.assertEqual(len(dao.getAll()), 0)
Esempio n. 4
0
    def getAll(self):
        """
        Get info on all images currently in the table. Currently just used
        for testing
        """
        selectAllSql = """SELECT image_id, date_part('epoch', time_stamp), focal_length, image_path, manual_tap, autonomous_tap 
            FROM incoming_image;"""

        cur = self.conn.cursor()
        cur.execute(selectAllSql)
        results = []
        for row in cur:
            incomingImg = incoming_image(row)
            results.append(incomingImg)

        return results
def setupIncomingImageTable(rawImgPath):
    dao = IncomingImageDAO(defaultConfigPath())
    incModel = incoming_image()
    incModel.focal_length = 16.0
    incModel.time_stamp = 1547453775.2
    incModel.image_path = rawImgPath
    incModel.manual_tap = False
    incModel.autonomous_tap = False
    incImageId1 = dao.addImage(incModel)
    assert incImageId1 != -1

    # just gonna use a slightly different number so we can tell the difference between the two inserts
    incModel.focal_length = 17.0
    incImageId2 = dao.addImage(incModel)
    assert incImageId2 != -1
    return (incImageId1, incImageId2)
Esempio n. 6
0
    def __init__(self):
        print("Startup NEW (Mar 2020) ros imaging handler...")
        currentPath = os.path.dirname(os.path.realpath(__file__))
        self.configPath = rospy.get_param('~config_path', defaultConfigPath())

        self.bridge = CvBridge()

        # gps ingestion setup:
        self.gps_dao_ = IncomingGpsDAO(self.configPath)
        self.gps_subscriber_ = rospy.Subscriber('/gps',
                                                GPS,
                                                self.gpsCallback,
                                                queue_size=10)
        # self.gps_subscriber_ = rospy.Subscriber('/state', State, self.gpsCallback, queue_size=10)
        self.gps_msg_ = incoming_gps()

        # imaging ingestion setup:
        self.img_dao_ = IncomingImageDAO(self.configPath)
        self.img_subscriber_ = rospy.Subscriber(
            "/a6000_ros_node/img/compressed",
            CompressedImgWithMeta,
            self.imgCallback,
            queue_size=10)
        self.img_msg_ = incoming_image()
        self.img_msg_.focal_length = 16.0  # this is a safe starting assumption == fully zoomed out on a6000
        self.img_msg_.manual_tap = False
        self.img_msg_.autonomous_tap = False

        # state ingestion setup:
        self.state_dao_ = IncomingStateDAO(self.configPath)
        self.state_subscriber_ = rospy.Subscriber('/state',
                                                  State,
                                                  self.stateCallback,
                                                  queue_size=10)
        self.state_msg_ = incoming_state()
        self.state_interval_ = 0

        basePath = createNewBaseImgDir()
        print("Base dir for images:: {}".format(basePath))

        # service for completed targets. Once a target has gone through the entire
        # system, the server puts the finished target in a table and marks it ready for submission
        self.submit_image_ = None
        print("ROS subscribers are all setup!")

        self.geod = Geodesic.WGS84
Esempio n. 7
0
    def getImage(self, id):
        """
        Attempts to get the image with the specified id

        @type id: int
        @param id: The id of the image to try and retrieve

        @rtype: incoming_image
        @return: An incoming_image with the info for that image if successfully found, otherwise None
        """
        selectImgById = """SELECT image_id, date_part('epoch', time_stamp), focal_length, image_path, manual_tap, autonomous_tap 
            FROM incoming_image 
            WHERE image_id = %s 
            LIMIT 1;"""
        selectedImage = super(IncomingImageDAO, self).basicTopSelect(selectImgById, (id,))
        
        if selectedImage is None:
            return None
        return incoming_image(selectedImage)