2017-09-03 19:42:55 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
import numpy as np
|
2017-12-11 17:55:03 +08:00
|
|
|
import cv2 as cv
|
2017-09-03 19:42:55 +08:00
|
|
|
|
|
|
|
from tests_common import NewOpenCVTests
|
|
|
|
|
|
|
|
class Bindings(NewOpenCVTests):
|
|
|
|
|
|
|
|
def test_inheritance(self):
|
2017-12-11 17:55:03 +08:00
|
|
|
bm = cv.StereoBM_create()
|
2017-09-03 19:42:55 +08:00
|
|
|
bm.getPreFilterCap() # from StereoBM
|
|
|
|
bm.getBlockSize() # from SteroMatcher
|
|
|
|
|
2017-12-11 17:55:03 +08:00
|
|
|
boost = cv.ml.Boost_create()
|
2017-09-03 19:42:55 +08:00
|
|
|
boost.getBoostType() # from ml::Boost
|
|
|
|
boost.getMaxDepth() # from ml::DTrees
|
|
|
|
boost.isClassifier() # from ml::StatModel
|
|
|
|
|
2018-04-04 02:16:34 +08:00
|
|
|
|
|
|
|
def test_redirectError(self):
|
|
|
|
try:
|
|
|
|
cv.imshow("", None) # This causes an assert
|
|
|
|
self.assertEqual("Dead code", 0)
|
2018-06-04 22:58:06 +08:00
|
|
|
except cv.error as _e:
|
2018-04-04 02:16:34 +08:00
|
|
|
pass
|
|
|
|
|
|
|
|
handler_called = [False]
|
|
|
|
def test_error_handler(status, func_name, err_msg, file_name, line):
|
|
|
|
handler_called[0] = True
|
|
|
|
|
|
|
|
cv.redirectError(test_error_handler)
|
|
|
|
try:
|
|
|
|
cv.imshow("", None) # This causes an assert
|
|
|
|
self.assertEqual("Dead code", 0)
|
2018-06-04 22:58:06 +08:00
|
|
|
except cv.error as _e:
|
2018-04-04 02:16:34 +08:00
|
|
|
self.assertEqual(handler_called[0], True)
|
|
|
|
pass
|
|
|
|
|
|
|
|
cv.redirectError(None)
|
|
|
|
try:
|
|
|
|
cv.imshow("", None) # This causes an assert
|
|
|
|
self.assertEqual("Dead code", 0)
|
2018-06-04 22:58:06 +08:00
|
|
|
except cv.error as _e:
|
2018-04-04 02:16:34 +08:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
2017-09-03 19:42:55 +08:00
|
|
|
if __name__ == '__main__':
|
2017-09-03 20:01:25 +08:00
|
|
|
NewOpenCVTests.bootstrap()
|