Ejemplo n.º 1
0
def run_plugin(argv=None):
    import argparse
    import itertools

    parser = argparse.ArgumentParser(description='')
    parser.add_argument('--plugin', help='name of plugin', required=True)
    parser.add_argument('--input', help='base image or video', required=True)
    parser.add_argument('--output',
                        help='result image or video',
                        required=True)
    parser.add_argument(
        '--arguments',
        nargs='+',
        default={},
        help='Additional operation/plugin arguments e.g. rotation 60')
    args = parser.parse_args()

    op = software_loader.getOperation(getOperation(args.plugin)['name'])
    parsedArgs = dict(
        itertools.izip_longest(*[iter(args.arguments)] * 2, fillvalue=""))
    for key in parsedArgs:
        parsedArgs[key] = validateAndConvertTypedValue(
            key, parsedArgs[key], op, skipFileValidation=False)

    loadPlugins()
    args, msg = callPlugin(args.plugin, openImageFile(args.input), args.input,
                           args.output, **parsedArgs)
    if msg is not None:
        print(msg)
    if args is not None:
        print('Results:')
        print(str(args))
 def test_link_tool(self):
     loadPlugins()
     model = scenario_model.loadProject(
         self.locateFile('images/sample.json'))
     model.mediaFromPlugin('OutputPNG::Foo')
     lt = model.getLinkTool('sample', 'orig_input')
     self.assertTrue(isinstance(lt, scenario_model.ImageImageLinkTool))
     mask, analysis, errors = lt.compareImages('sample', 'orig_input',
                                               model, 'OutputPng')
     self.assertTrue(len(errors) == 0)
     self.assertTrue('exifdiff' in analysis)
     self.addFileToRemove('test_sm.csv')
     model.toCSV('test_sm.csv', [
         getPathValuesFunc('arguments.purpose'),
         getPathValuesFunc('arguments.subject')
     ])
     foundPasteSplice = False
     with open('test_sm.csv', 'rb') as fp:
         reader = csv.reader(fp)
         for row in reader:
             self.assertEqual(6, len(row))
             if row[3] == 'PasteSplice':
                 foundPasteSplice = True
                 self.assertEqual('sample', row[0])
                 self.assertEqual('orig_input', row[1])
                 self.assertEqual('input_mod_1', row[2])
                 self.assertEqual('add', row[4])
                 self.assertEqual('man-made object', row[5])
     self.assertTrue(foundPasteSplice)
Ejemplo n.º 3
0
def initialize(preferences, username=None, validators=None):
    """
    :param username: optional overriding username.
    :param validators: class extending ValidationAPI
    :return:
    @type validators: list of class(ValidationAPI)
    """
    initial_user(preferences, username=username)
    initialize_validators(preferences,
                          validators=validators if validators is not None else
                          [ValidationBrowserAPI, ValidationCodeNameS3])
    loadPlugins()
Ejemplo n.º 4
0
def main():
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('--plugin', required=True, help='JSON File')
    parser.add_argument('--args',
                        required=True,
                        help='number of projects to build')
    args = parser.parse_args()
    arguments_list = args.args.split(',')
    arguments = {a.split(':')[0]: a.split(':')[1] for a in arguments_list}
    img = image_wrap.openImageFile(arguments['inputimage'])
    plugins.loadPlugins()
    plugins.callPlugin(args.plugin, img, arguments['inputimage'],
                       arguments['outputimage'], **arguments)
Ejemplo n.º 5
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--projects', help='Directory of projects')
    parser.add_argument('-cf',
                        '--completefile',
                        required=True,
                        help='Projects to Completed')
    parser.add_argument('-t',
                        '--threads',
                        required=False,
                        default=1,
                        help='Threads')
    args = parser.parse_args()
    plugins.loadPlugins()

    project_list = pick_projects(args.projects)
    processor = BatchProcessor(args.completefile,
                               project_list,
                               threads=int(args.threads))
    processor.process(rerunexif)
Ejemplo n.º 6
0
 def test_validation(self):
     self.general_setup()
     manager = plugins.loadPlugins()
     PluginDeferCaller(manager.getBroker())
     batchProject = batch_project.loadJSONGraph(
         self.locateFile(
             'tests/specifications/batch_validation_process.json'))
     be = batch_project.BatchExecutor(
         'test_projects',
         global_variables={'image_dir': self.locateFile('tests/images')})
     dir, name = be.runProjectLocally(batchProject)
     be.finish()
     self.assertTrue(dir is None)
     plugins.PluginCaller(manager.getBroker())
Ejemplo n.º 7
0
    def test_plugin(self):
        plugins.loadPlugins()
        filename = self.locateFile("tests/videos/sample1.mov")
        filename_output = os.path.join(os.path.split(filename)[0], "sample1_out.avi")
        self.filesToKill.append(filename_output)
        file = os.path.join(os.path.split(filename)[0], "sample1.csv")
        self.filesToKill.append(file)

        args, errors = plugins.callPlugin('DroneShake',
                                          None,  #image would go here for image manipulations
                                          filename,
                                          filename_output,
                                          fps=13.53,
                                          height=360,
                                          width=480)
        #  checking to make sure there are no errors
        self.assertEqual(errors, None)

        #  Get the output video to compare the height and width
        video = cv2api_delegate.videoCapture(filename_output)
        width = int(video.get(cv2api_delegate.prop_frame_width))
        height = int(video.get(cv2api_delegate.prop_frame_height))
        self.assertTrue(int(width) == 480)
        self.assertTrue(int(height) == 360)
Ejemplo n.º 8
0
 def setUp(self):
     plugins.loadPlugins()
 def setUp(self):
     plugins.loadPlugins(customFolders= [self.locateFile('tests/batch/plugins')])