Simple resize test

Former-commit-id: b88d461cff
pull/1161/head
Dakota Benjamin 2016-02-19 14:00:05 -05:00
rodzic b4aefdb665
commit d2e2e5bea6
3 zmienionych plików z 38 dodań i 77 usunięć

Wyświetl plik

@ -7,7 +7,7 @@ from opendm import system
from opendm import io
from opendm import types
class ODMResizeCell(ecto.Cell):
class ODMResizeCell(ecto.Cell):
def declare_params(self, params):
params.declare("resize_to", "resizes images by the largest side", 2400)

Wyświetl plik

@ -1,48 +1,46 @@
import sys
import unittest
from opendm import config
from opendm import context
import ecto
from scripts.odm_app import ODMApp
from scripts.resize import ODMResizeCell
err = sys.stderr
# Fixture functions
app = None
def setup_odm():
# initialize ecto
global app
app = ODMApp(args=config.args)
plasm = ecto.Plasm()
plasm.insert(app)
err.write('MODULE SETUP\n')
def teardown_odm():
# teardown ecto
err.write('MODULE TEARDOWN\n')
# The tests
def test_config():
# check the args
test_args = 'tests/test_data' # sample test args
assert test_args == config.args.get('project_path')
class TestResize:
def __init__(self):
# Initialize whatever
from ecto.opts import scheduler_options, run_plasm
#
class TestResize(unittest.TestCase):
'''
Tests the resize function
'''
def setUp(self):
#call cell
resizeCell = ODMResizeCell()
# Run tests
self.parser = config.parser
scheduler_options(self.parser)
self.options = self.parser.parse_args()
self.options.project_path = context.tests_data_path
self.app, self.plasm = self.appSetup(self.options)
print 'Run Setup: Initial Run'
run_plasm(self.options, self.plasm)
def tearDown(self):
#teardown functions
def test_resize(self):
# rerun resize cell and set params
self.options.rerun = 'resize'
self.options.resize_to = 1600
print "Run Test 1: Rerun resize: %s" % self.options.resize_to
# rebuild app
self.app, self.plasm = self.appSetup(self.options)
run_plasm(self.options, self.plasm)
# assert each image is sized to the option.resize_to
print "Run Test 1: Check that the resize happens"
if self.app.resize.outputs.photos[0].height > self.app.resize.outputs.photos[0].width:
self.assertEquals(self.app.resize.outputs.photos[0].height, self.options.resize_to)
else:
self.assertEquals(self.app.resize.outputs.photos[0].width, self.options.resize_to)
# assert proper config/args
def appSetup(self, options):
app = ODMApp(args=vars(options))
plasm = ecto.Plasm()
plasm.insert(app)
return app, plasm
# Check images in images_resize
# Check images are resized (imagemagick?)
if __name__ == '__main__':
unittest.main()

Wyświetl plik

@ -1,37 +0,0 @@
from opendm import config
from opendm import context
from opendm import log
from opendm import system
import sys
import ecto
from scripts.odm_app import ODMApp
from scripts.opensfm import ODMOpenSfMCell
app = None
def setup_prematching(self):
args = {'end_with':'resize','project_path':'tests/test_data'}
global app
app = ODMApp(args=config.args)
def teardown_prematching(self):
# Delete the test folders
# if folders exist
# delete all but "images" folder
def setUp():
# create opensfm cell
# opensfm = ODMOpenSfMCell(use_exif_size=False,
# feature_process_size=config.args['resize_to'],
# feature_min_frames=config.args['min_num_features'],
# processes=context.num_cores,
# matching_gps_neighbors=config.args['matcher_k']),
def test_prematching_config():
# assert that relevant run args are what they say they are
def test_opensfm_config_file(self):
# assert that the args i nthe opensfm config file match those it is set to
# when metcher_distance > 0
# when the arg is out of bounds