def __init__(self, **kwargs):
        """Read arguments (and change settings) and initialize modules."""
        # Default Data Inputs
        self.image = None
        self.plant_db = DB()

        # Default Parameter Inputs
        self.params = Parameters()
        self.params.add_missing_params('detect')

        # Load keyword argument inputs
        self._data_inputs(kwargs)
        self._parameter_inputs(kwargs)
        self.args = kwargs

        # Set remaining arguments to defaults
        self._set_defaults()

        # Changes based on inputs
        if self.args['calibration_img'] is not None:
            # self.coordinates = True
            self.args['coordinates'] = True
        if self.args['GUI']:
            self.args['save'] = False
            self.args['text_output'] = False
        if self.args['app']:
            self.args['verbose'] = False
            self.args['from_env_var'] = True
            self.plant_db.app = True

        # Remaining initialization
        self.p2c = None
        self.capture = Capture().capture
        self.final_marked_image = None
        self.plant_db.tmp_dir = None
Esempio n. 2
0
class CheckImageSaveTest(unittest.TestCase):
    """Save captured image"""
    def setUp(self):
        self.capture = Capture()
        shape = [100, 100, 3]
        self.capture.image = np.full(shape, 200, np.uint8)
        directory = os.path.dirname(os.path.realpath(__file__))[:-6] + os.sep
        self.expected_filename = directory + 'capture.jpg'

    def test_image_save(self):
        """Test image save"""
        img_filename = self.capture.save(add_timestamp=False)
        self.assertEqual(img_filename, self.expected_filename)

    def tearDown(self):
        os.remove(self.expected_filename)
Esempio n. 3
0
    def __init__(self, calibration_data):
        """Set initial attributes.

        Arguments:
            calibration_data: P2C().calibration_params JSON
        """
        self.calibration_data = calibration_data
        self.capture = Capture(directory='/tmp/').capture
        self.pattern = {
            'size': (5, 7),
            'type': cv2.CALIB_CB_ASYMMETRIC_GRID,
            'row_circle_separation': 30,
        }
        self.dot_images = {
            AXIS_INDEX['init']: {},
            AXIS_INDEX['x']: {},
            AXIS_INDEX['y']: {},
        }
        self.output_img = None
        self.center = None
        self.axis_points = None
        self.rotation_angles = []
        self.success_flag = True
Esempio n. 4
0
 def capture(self):
     """Capture image from camera."""
     image_filename = Capture().capture()
     self.plant_db.getcoordinates()
     self.images['original'] = self.load(image_filename)
Esempio n. 5
0
 def setUp(self):
     self.capture = Capture()
     shape = [100, 100, 3]
     self.capture.image = np.full(shape, 200, np.uint8)
     directory = os.path.dirname(os.path.realpath(__file__))[:-6] + os.sep
     self.expected_filename = directory + 'capture.jpg'
Esempio n. 6
0
 def test_camera_check(self):
     """Test camera check"""
     Capture().camera_check()