Compares a source image (src_img, which is a vtkImageData) with the saved image file whose name is given in the second argument. If the image file does not exist the image is generated and stored. If not the source image is compared to that of the figure. This function also handles
(src_img, img_fname, threshold=0.05)
| 313 | return None |
| 314 | |
| 315 | def compareImageWithSavedImage(src_img, img_fname, threshold=0.05): |
| 316 | """Compares a source image (src_img, which is a vtkImageData) with |
| 317 | the saved image file whose name is given in the second argument. |
| 318 | If the image file does not exist the image is generated and |
| 319 | stored. If not the source image is compared to that of the |
| 320 | figure. This function also handles multiple images and finds the |
| 321 | best matching image. |
| 322 | """ |
| 323 | global _NO_IMAGE, VTK_TEMP_DIR |
| 324 | if _NO_IMAGE: |
| 325 | return |
| 326 | |
| 327 | # create the testing class to do the work |
| 328 | rtTester = vtkTesting() |
| 329 | |
| 330 | # Set the controller if possible |
| 331 | try: |
| 332 | rtTester.SetController(_GetController()) |
| 333 | except: |
| 334 | pass |
| 335 | |
| 336 | # Add temp directory to the arguments |
| 337 | if len(VTK_TEMP_DIR) != 0: |
| 338 | rtTester.AddArgument("-T") |
| 339 | rtTester.AddArgument(VTK_TEMP_DIR) |
| 340 | # Add image file name to the arguments |
| 341 | rtTester.AddArgument("-V") |
| 342 | rtTester.AddArgument(img_fname) |
| 343 | |
| 344 | output_string = reference("") |
| 345 | result = rtTester.RegressionTest(src_img, threshold, output_string) |
| 346 | |
| 347 | # If the test failed, raise an exception |
| 348 | if result == vtkTesting.FAILED: |
| 349 | raise RuntimeError(output_string.get()) |
| 350 | # If the test passed, print the output |
| 351 | else: |
| 352 | print(output_string.get()) |
| 353 | |
| 354 | def compareImage(renwin, img_fname, threshold=0.05): |
| 355 | """Compares renwin's (a vtkRenderWindow) contents with the image |
no test coverage detected