test_disparity.py 858 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python
  2. import cv2 as cv
  3. import numpy as np
  4. from tests_common import NewOpenCVTests
  5. class disparity_test(NewOpenCVTests):
  6. def test_disp(self):
  7. # readGT
  8. ret,GT = cv.ximgproc.readGT(self.find_file("cv/disparityfilter/GT.png"))
  9. self.assertEqual(ret, 0) # returns 0 on success!
  10. self.assertFalse(np.shape(GT) == ())
  11. # computeMSE
  12. left = cv.imread(self.find_file("cv/disparityfilter/disparity_left_raw.png"), cv.IMREAD_UNCHANGED)
  13. self.assertFalse(np.shape(left) == ())
  14. left = np.asarray(left, dtype=np.int16)
  15. mse = cv.ximgproc.computeMSE(GT, left, (0, 0, GT.shape[1], GT.shape[0]))
  16. # computeBadPixelPercent
  17. bad = cv.ximgproc.computeBadPixelPercent(GT, left, (0, 0, GT.shape[1], GT.shape[0]), 24)
  18. if __name__ == '__main__':
  19. NewOpenCVTests.bootstrap()