[Enhancement] Require OpenCV >= 4 for cpp_api tests, remove legacy OpenCV 3 build support - #507
Open
levxn wants to merge 6 commits into
Open
[Enhancement] Require OpenCV >= 4 for cpp_api tests, remove legacy OpenCV 3 build support#507levxn wants to merge 6 commits into
levxn wants to merge 6 commits into
Conversation
sruthi0107
previously approved these changes
Aug 14, 2026
Contributor
There was a problem hiding this comment.
OpenCV>=4, Build succeeds and all 21/21 ctests pass. With OpenCV 3.x, ctests degrade gracefully to a warning and 21/21 pass. Tested on gfx1100:
Running tests...
Test project /home/sruthi/rocAL/build-pr-507
Start 1: basic_test_cpu
1/21 Test #1: basic_test_cpu ..................... Passed 2.30 sec
Start 2: basic_test_gpu
2/21 Test #2: basic_test_gpu ..................... Passed 0.37 sec
Start 3: basic_test_gray
3/21 Test #3: basic_test_gray .................... Passed 0.31 sec
Start 4: basic_test_rgb
4/21 Test #4: basic_test_rgb ..................... Passed 0.36 sec
Start 5: dataloader_multithread_cpu
5/21 Test #5: dataloader_multithread_cpu ......... Passed 2.48 sec
Start 6: dataloader_multithread_gpu
6/21 Test #6: dataloader_multithread_gpu ......... Passed 2.73 sec
Start 7: performance_tests_cpu
7/21 Test #7: performance_tests_cpu .............. Passed 1.51 sec
Start 8: performance_tests_gpu
8/21 Test #8: performance_tests_gpu .............. Passed 0.39 sec
Start 9: performance_tests_with_depth_cpu
9/21 Test #9: performance_tests_with_depth_cpu ... Passed 1.56 sec
Start 10: performance_tests_with_depth_gpu
10/21 Test #10: performance_tests_with_depth_gpu ... Passed 0.54 sec
Start 11: unit_tests_cpu
11/21 Test #11: unit_tests_cpu ..................... Passed 13.02 sec
Start 12: unit_tests_gpu
12/21 Test #12: unit_tests_gpu ..................... Passed 8.98 sec
Start 13: unit_tests_gray
13/21 Test #13: unit_tests_gray .................... Passed 3.73 sec
Start 14: video_tests_ffmpeg
14/21 Test #14: video_tests_ffmpeg ................. Passed 48.37 sec
Start 15: video_tests_rocdecode
15/21 Test #15: video_tests_rocdecode .............. Passed 15.88 sec
Start 16: basic_test_rocjpeg_gray
16/21 Test #16: basic_test_rocjpeg_gray ............ Passed 0.41 sec
Start 17: basic_test_rocjpeg_rgb
17/21 Test #17: basic_test_rocjpeg_rgb ............. Passed 0.45 sec
Start 18: serialization_test_cpu
18/21 Test #18: serialization_test_cpu ............. Passed 1.19 sec
Start 19: serialization_test_gpu
19/21 Test #19: serialization_test_gpu ............. Passed 0.34 sec
Start 20: checkpoint_save
20/21 Test #20: checkpoint_save .................... Passed 1.99 sec
Start 21: checkpoint_restore
21/21 Test #21: checkpoint_restore ................. Passed 2.24 sec
100% tests passed out of 21
Total Test time (real) = 109.18 sec```
Collaborator
|
@levxn please address the review comments |
levxn
commented
Aug 20, 2026
|
|
||
| list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../cmake) | ||
|
|
||
| find_package(OpenCV QUIET) |
Member
Author
There was a problem hiding this comment.
confirmed from other CI that
-- WARNING: OpenCV Not Found -- No Display Support
So OpenCV_FOUND is false and OpenCV_VERSION_MAJOR was never set
levxn
commented
Aug 20, 2026
| message("-- WARNING: OpenCV Found -- Version-${OpenCV_VERSION_MAJOR}.${OpenCV_VERSION_MINOR}.X Not Supported") | ||
| target_compile_definitions(${PROJECT_NAME} PUBLIC ENABLE_OPENCV=0) | ||
| endif() | ||
| if(OpenCV_FOUND AND ${OpenCV_VERSION_MAJOR} GREATER_EQUAL 4) |
Member
Author
There was a problem hiding this comment.
when it reaches here, due to this it throws error
CMake Error at CMakeLists.txt:59 (if):
if given arguments:
"OpenCV_FOUND" "AND" "GREATER_EQUAL" "4"
Unknown arguments specified
Member
Author
There was a problem hiding this comment.
@LakshmiKumar23 shall I revert it back to how it was earlier?
Contributor
There was a problem hiding this comment.
Sure, turns out CMake doesn't take the false as a short circuit like C++. Let's revert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Fixes #433: Removes compiling option to build from older versions of OpenCV < 4
Technical Details
Updated all
tests/cpp_api/*/CMakeLists.txtto requireOpenCV_VERSION_MAJOR GREATER_EQUAL 4instead of allowingEQUAL 3 OR EQUAL 4, and removed theUSE_OPENCV_4compile-time toggle. In the corresponding.cppfiles, the old-API compatibility macros (CV_LOAD_IMAGE_COLOR,CV_BGR2GRAY,CV_RGB2BGR,CV_FONT_HERSHEY_SIMPLEX,CV_FILLED,CV_WINDOW_AUTOSIZE,cvDestroyWindow) are now defined unconditionally rather than gated behind#if USE_OPENCV_4, since there is no longer an OpenCV-3 code path to branch on. Also removed the legacy#include <opencv/highgui.h>fallback include that was only reachable in the OpenCV-3 branch.Affected:
basic_test,dataloader,dataloader_multithread,dataloader_tf,external_source,image_augmentation,multiple_dataloaders_test,performance_tests,performance_tests_with_depth,unit_tests,video_tests.serialization_testwas already OpenCV-4-only and required no changes.Test Plan
Configured and built each
tests/cpp_api/*project individually against the system OpenCV (4.6.x) and confirmed the CMake version check now only accepts 4+, with no leftover OpenCV-3/USE_OPENCV_4references:Test Result
All 11 updated cpp_api test projects configured and built cleanly against OpenCV 4.6.x, each reporting:
for:
basic_test,dataloader,dataloader_tf,dataloader_multithread,external_source,multiple_dataloaders_test,performance_tests,performance_tests_with_depth,unit_tests,video_tests,image_augmentation.Follow-up grep confirms the CMake
OpenCV_VERSION_MAJORcheck now only appears asGREATER_EQUAL 4(includingserialization_test, unchanged), with zero remaining hits forUSE_OPENCV_4or any OpenCV-3-only code path.