def createScene(self, stepNum): bundleFile = os.path.abspath(self.config.NVMFileName) imgDir = os.path.abspath(self.config.SRCImageDirName) outDir = os.path.abspath(self.config.NVMOutputDirName) if False == os.path.isfile(bundleFile): log("Step %d - SceneCreation cannot begin because the NVM file %s is missing." % (stepNum, bundleFile)) log("Processing will not proceed.") return -stepNum if False == os.path.isdir(imgDir): log("Step %d - SceneCreation cannot beging because the image directory %s cannot be found." % (stepNum, imgDir)) log("Processing will not proceed.") return -stepNum log("Creating scene with bundleFile %s." % (bundleFile)) log("Output will be written to %s." % (outDir)) boxm2_batch.not_verbose() boxm2_batch.register_processes() boxm2_batch.register_datatypes() # class used for python/c++ pointers in database class dbvalue: def __init__(self, index, type): self.id = index # unsigned integer self.type = type # string # run process boxm2_batch.init_process("boxm2BundleToSceneProcess") boxm2_batch.set_input_string(0, bundleFile) boxm2_batch.set_input_string(1, imgDir) boxm2_batch.set_input_string(2, self.config.NVMAppModel) boxm2_batch.set_input_string(3, self.config.NVMNobsModel) boxm2_batch.set_input_int(4, 8) boxm2_batch.set_input_string(5, outDir) boxm2_batch.run_process() (scene_id, scene_type) = boxm2_batch.commit_output(0) uscene = dbvalue(scene_id, scene_type) (scene_id, scene_type) = boxm2_batch.commit_output(1) rscene = dbvalue(scene_id, scene_type) return 0
import boxm2_batch boxm2_batch.not_verbose(); boxm2_batch.register_processes(); boxm2_batch.register_datatypes(); class dbvalue: def __init__(self, index, type): self.id = index # unsigned integer self.type = type # string ################################################### # Vil loading and saving ################################################### def load_image(file_path) : boxm2_batch.init_process("vilLoadImageViewProcess"); boxm2_batch.set_input_string(0, file_path); boxm2_batch.run_process(); (id,type) = boxm2_batch.commit_output(0); (ni_id, ni_type) = boxm2_batch.commit_output(1); (nj_id, nj_type) = boxm2_batch.commit_output(2); ni = boxm2_batch.get_output_unsigned(ni_id); nj = boxm2_batch.get_output_unsigned(nj_id); img = dbvalue(id,type); boxm2_batch.remove_data(ni_id) boxm2_batch.remove_data(nj_id) return img, ni, nj; def save_image(img, file_path) : assert not isinstance(list, tuple) boxm2_batch.init_process("vilSaveImageViewProcess"); boxm2_batch.set_input_from_db(0,img);
############################################################################# # Register Script to ensure boxm2_batch processes are only registered once # # to use our boxm2 python binding, be sure to add: # <vxl_build_root>/lib/:<vxl_src_root>/contrib/brl/bseg/boxm2/pyscripts/ # to your PYTHONPATH environment variable. ############################################################################# import boxm2_batch boxm2_batch.not_verbose() boxm2_batch.register_processes() boxm2_batch.register_datatypes() smart_register = False #Set to True to enable smart_register #class used for python/c++ pointers in database class dbvalue(object): def __init__(self, index, type): self.id = index # unsigned integer self.type = type # string def __del__(self): if smart_register and not hasattr(self, '__ref__'): #__ref__ is only an attr if it's a copy, don't remove_data on delete boxm2_batch.remove_data(self.id) def __copy__(self): import copy x = dbvalue(self.id, self.type)