Skip to content

Commit bf890ca

Browse files
authored
Model Compiler - OpenCV 4 Support (#796) (#798)
* Model Compiler - OpenCV 4 Support * OpenCV 4 - Updates
1 parent dc9c69a commit bf890ca

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

model_compiler/python/nnir_to_openvx.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,19 @@ def generateCMakeFiles(graph,outputFolder):
161161
162162
add_executable(anntest anntest.cpp)
163163
if(OpenCV_FOUND)
164-
target_compile_definitions(anntest PUBLIC ENABLE_OPENCV=1)
165-
include_directories(${OpenCV_INCLUDE_DIRS})
166-
target_link_libraries(anntest ${OpenCV_LIBRARIES})
164+
if(${OpenCV_VERSION_MAJOR} EQUAL 3 OR ${OpenCV_VERSION_MAJOR} EQUAL 4)
165+
target_compile_definitions(anntest PUBLIC ENABLE_OPENCV=1)
166+
include_directories(${OpenCV_INCLUDE_DIRS})
167+
target_link_libraries(anntest ${OpenCV_LIBRARIES})
168+
if(${OpenCV_VERSION_MAJOR} EQUAL 4)
169+
target_compile_definitions(anntest PUBLIC USE_OPENCV_4=1)
170+
else()
171+
target_compile_definitions(anntest PUBLIC USE_OPENCV_4=0)
172+
endif()
173+
else()
174+
target_compile_definitions(anntest PUBLIC ENABLE_OPENCV=0)
175+
message("-- NOTE: anntest -- OpenCV Version-${OpenCV_VERSION_MAJOR}.${OpenCV_VERSION_MINOR}.X Not Supported")
176+
endif()
167177
else(OpenCV_FOUND)
168178
target_compile_definitions(anntest PUBLIC ENABLE_OPENCV=0)
169179
endif(OpenCV_FOUND)
@@ -1980,6 +1990,9 @@ def generateTestCPP(graph,argmaxOutput,fileName,virtual_tensor_flag):
19801990
#include <opencv/cv.h>
19811991
#include <opencv/highgui.h>
19821992
using namespace cv;
1993+
#if USE_OPENCV_4
1994+
#define CV_LOAD_IMAGE_COLOR IMREAD_COLOR
1995+
#endif
19831996
#endif
19841997
19851998
#define ERROR_CHECK_OBJECT(obj) { vx_status status = vxGetStatus((vx_reference)(obj)); if(status != VX_SUCCESS) { vxAddLogEntry((vx_reference)context, status , "ERROR: failed with status = (%d) at " __FILE__ "#%d\\n", status, __LINE__); return status; } }

0 commit comments

Comments
 (0)