def test_geometric_calibrator(self): print("Testing geometric calibrator") # Link a "camera" to the geometric calibrator splash.set_world_attribute("addObject", ["image_list", "image_list"]) splash.set_world_attribute("link", ["image_list", "geometricCalibrator"]) sleep(1) splash.set_object_attribute( "image_list", "file", f"{SplashTestCase.test_dir}/../../assets/captured_patterns/") # Start the calibration splash.set_object_attribute("geometricCalibrator", "calibrate", "true") sleep(1) # Position 1 splash.set_object_attribute("geometricCalibrator", "nextPosition", "true") sleep(20) # Position 2 splash.set_object_attribute("geometricCalibrator", "nextPosition", "true") sleep(20) # Position 3 splash.set_object_attribute("geometricCalibrator", "nextPosition", "true") sleep(20) splash.set_object_attribute("geometricCalibrator", "finalizeCalibration", "true") # Wait for the calibration process to execute sleep(30)
def splash_init() -> None: parser = argparse.ArgumentParser() parser.add_argument('--pattern', dest='pattern', type=str, default="test*.py") parser.add_argument('--list', dest='list', action='store_true', default=False) args = parser.parse_args() if args.list is True: files = [ file for file in os.listdir(TEST_CASES_PATH) if os.path.isfile(os.path.join(TEST_CASES_PATH, file)) and file.startswith("test_") ] print("\n=========================") print("List of Python test files") for file in files: print(f"- {file}") print("\n") else: runTests(pattern=args.pattern) splash.set_world_attribute("quit", [])
def tearDownClass(cls): """ Reload the default configuration """ splash.set_world_attribute( "loadProject", f"{SplashTestCase.test_dir}/../integrationTests_project.json") sleep(2.0)
def run(): splash.set_world_attribute("replaceObject", ["image", "image_v4l2", "object"]) splash.set_object_attribute("image", "doCapture", 1) sleep(1.0) splash.set_object_attribute("image", "captureSize", [2048, 2048]) sleep(1.0) splash.set_object_attribute("image", "captureSize", [640, 480]) sleep(1.0) splash.set_object_attribute("image", "doCapture", 0) splash.set_world_attribute("replaceObject", ["image", "image", "object"])
def test_image_v4l2(self): print("Test V4L2 capture") splash.set_world_attribute("replaceObject", ["image", "image_v4l2", "image", "object"]) splash.set_object_attribute("image", "doCapture", 1) sleep(1.0) splash.set_object_attribute("image", "captureSize", [2048, 2048]) sleep(1.0) splash.set_object_attribute("image", "captureSize", [640, 480]) sleep(1.0) splash.set_object_attribute("image", "doCapture", 0)
def run(): splash.set_world_attribute("replaceObject", ["image", "image_ffmpeg", "object"]) splash.set_object_attribute("image", "file", "./assets/tornado_h264.mov") sleep(10.0) splash.set_object_attribute("image", "file", "./assets/tornado_hap.mov") sleep(10.0) splash.set_object_attribute("image", "file", "./assets/tornado_hap_alpha.mov") sleep(10.0) splash.set_object_attribute("image", "file", "./assets/tornado_hap_q.mov") sleep(10.0) splash.set_world_attribute("replaceObject", ["image", "image", "object"])
def test_replace_image(self): print("Replace the Image object multiple times") image_file = f"{SplashTestCase.test_dir}/../../../data/share/splash/color_map.png" video_file = f"{SplashTestCase.test_dir}/../../assets/tornado_h264.mov" for i in range(5): splash.set_world_attribute("replaceObject", ["image", "image", "image", "object"]) sleep(0.5) splash.set_object_attribute("image", "file", image_file) sleep(2.0) splash.set_world_attribute( "replaceObject", ["image", "image_ffmpeg", "image", "object"]) sleep(0.5) splash.set_object_attribute("image", "file", video_file) sleep(2.0)
def test_link_object_image(self): print("---> Linking object and image") splash.set_world_attribute("unlink", ["image", "object"]) sleep(1.0) splash.set_world_attribute("link", ["image", "object"]) sleep(1.0) splash.set_world_attribute("unlink", ["image", "object"]) sleep(1.0) splash.set_world_attribute("link", ["image", "object"]) sleep(1.0)
def test_virtual_probe(self): print("Test VirtualProbe object") splash.set_world_attribute("addObject", ["virtual_probe", "probe"]) splash.set_world_attribute("sendAllScenes", ["unlink", "object", "camera"]) splash.set_world_attribute("sendAllScenes", ["link", "object", "probe"]) splash.set_world_attribute("sendAllScenes", ["link", "probe", "camera"])
def link_object_image(): print("---> Linking object and image") splash.set_world_attribute("unlink", ["image", "object"]) sleep(1.0) splash.set_world_attribute("link", ["image", "object"]) sleep(1.0) splash.set_world_attribute("unlink", ["image", "object"]) sleep(1.0) splash.set_world_attribute("link", ["image", "object"]) sleep(1.0)
def test_codecs(self): print("Testing video codecs") splash.set_world_attribute( "replaceObject", ["image", "image_ffmpeg", "image", "object"]) sleep(2.0) splash.set_object_attribute( "image", "file", f"{SplashTestCase.test_dir}/../../assets/tornado_h264.mov") sleep(10.0) splash.set_object_attribute( "image", "file", f"{SplashTestCase.test_dir}/../../assets/tornado_hap.mov") sleep(10.0) splash.set_object_attribute( "image", "file", f"{SplashTestCase.test_dir}/../../assets/tornado_hap_alpha.mov") sleep(10.0) splash.set_object_attribute( "image", "file", f"{SplashTestCase.test_dir}/../../assets/tornado_hap_q.mov") sleep(10.0)
def runTests(): import imp import os import pytests # This is to get the path to the tests path = pytests.__path__._path[0] for name in os.listdir(path): if name.find(".py") == -1 or name.find(".py") != len(name) - 3: continue print("\n==========", name, "==========") print("Press a key to continue") input() filepath = path + "/" + name src = imp.load_source("data", path, open(filepath)) if 'run' not in dir(src): print("File " + name + " has no run() method") if 'description' not in dir(src): print("No description available") else: print(src.description) try: src.run() except Exception as e: print("Exception caught: ", str(e)) splash.set_world_attribute( "loadProject", os.path.dirname(os.path.realpath(__file__)) + "/integrationTests_project.json") splash.set_world_attribute("quit", [])
def runTests(): import imp import os import pytests # This is to get the path to the tests path = pytests.__path__._path[0] for name in os.listdir(path): if name.find(".py") == -1 or name.find(".py") != len(name) - 3: continue print("\n==========", name, "==========") print("Press a key to continue") input() filepath = path + "/" + name src = imp.load_source("data", path, open(filepath)) if 'run' not in dir(src): print("File " + name + " has no run() method") if 'description' not in dir(src): print("No description available") else: print(src.description) try: src.run() except Exception as e: print("Exception caught: ", str(e)) splash.set_world_attribute("loadProject", os.path.dirname(os.path.realpath(__file__)) + "/integrationTests_project.json") splash.set_world_attribute("quit", [])
def run(): for i in range(5): filename = os.path.dirname( os.path.abspath(__file__)) + "/../data/color_map.png" splash.set_world_attribute("replaceObject", ["image", "image", "object"]) splash.set_object_attribute("image", "file", filename) sleep(1.0) splash.set_world_attribute("replaceObject", ["image", "image_ffmpeg", "object"]) sleep(1.0) splash.set_world_attribute("replaceObject", ["image", "image", "object"])
def test_link_window_image(self): print("---> Linking window and image") splash.set_world_attribute("unlink", ["cam1", "win1"]) splash.set_world_attribute("link", ["image", "win1"]) sleep(1.0) splash.set_world_attribute("unlink", ["image", "win1"]) sleep(1.0) splash.set_world_attribute("link", ["image", "win1"]) sleep(1.0) splash.set_world_attribute("unlink", ["image", "win1"]) sleep(1.0) splash.set_world_attribute("link", ["cam1", "win1"]) sleep(1.0)
def run(): projectFilePath = "/tmp/splashProject.json" splash.set_world_attribute("saveProject", [projectFilePath]) splash.set_world_attribute("loadProject", [projectFilePath])
def run(): splash.set_world_attribute("addObject", ["virtual_probe", "probe"]) splash.set_world_attribute("sendAllScenes", ["unlink", "object", "camera"]) splash.set_world_attribute("sendAllScenes", ["link", "object", "probe"]) splash.set_world_attribute("sendAllScenes", ["link", "probe", "camera"])
def test_project(self): print("Testing saving and loading a project") projectFilePath = "/tmp/splashProject.json" splash.set_world_attribute("saveProject", [projectFilePath]) splash.set_world_attribute("loadProject", [projectFilePath])
def link_window_image(): print("---> Linking window and image") splash.set_world_attribute("unlink", ["cam1", "win1"]) splash.set_world_attribute("link", ["image", "win1"]) sleep(1.0) splash.set_world_attribute("unlink", ["image", "win1"]) sleep(1.0) splash.set_world_attribute("link", ["image", "win1"]) sleep(1.0) splash.set_world_attribute("unlink", ["image", "win1"]) sleep(1.0) splash.set_world_attribute("link", ["cam1", "win1"]) sleep(1.0)