mirror of
https://github.com/opencv/opencv.git
synced 2026-07-28 23:03:03 +04:00
8308fbf9ba
Both functions persist/restore a window's size, position, flags, trackbar values, and zoom/pan state (Qt highgui backend only), take only a plain String argument, and were already fully documented -- but were declared CV_EXPORTS instead of CV_EXPORTS_W, so they were unreachable from Python. Sibling Qt-only functions in the same header (displayOverlay, displayStatusBar) already follow the CV_EXPORTS_W + runtime "not implemented without Qt" convention this change follows. Adds a Python test that exercises namedWindow + save/loadWindowParameters and gracefully skips when no GUI backend or no Qt support is present, consistent with how other environment-dependent tests in this suite (e.g. CUDA) skip rather than fail. Verified locally: built opencv_python3 from this branch (WITH_QT=OFF) and confirmed cv2.saveWindowParameters / cv2.loadWindowParameters are present on the built module and correctly raise the expected "compiled without QT support" error, proving the binding reaches the C++ layer end-to-end.
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
#!/usr/bin/env python
|
|
from __future__ import print_function
|
|
|
|
import cv2 as cv
|
|
|
|
from tests_common import NewOpenCVTests
|
|
|
|
|
|
class window_parameters_test(NewOpenCVTests):
|
|
|
|
def test_save_load_window_parameters(self):
|
|
window_name = "test_save_load_window_parameters"
|
|
try:
|
|
cv.namedWindow(window_name, cv.WINDOW_NORMAL)
|
|
except cv.error:
|
|
self.skipTest("No GUI backend available in this build/environment")
|
|
|
|
try:
|
|
# Should not raise when the library is built with a backend that
|
|
# supports persisting window state (currently: Qt).
|
|
cv.saveWindowParameters(window_name)
|
|
cv.loadWindowParameters(window_name)
|
|
except cv.error as e:
|
|
# Expected on builds without Qt support (see NO_QT_ERR_MSG in window.cpp)
|
|
self.skipTest("saveWindowParameters/loadWindowParameters require the Qt "
|
|
"highgui backend: " + str(e))
|
|
finally:
|
|
cv.destroyWindow(window_name)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
NewOpenCVTests.bootstrap()
|