Skip to content

Commit

Permalink
Model Compiler - OpenCV 4 Support (#796) (#798)
Browse files Browse the repository at this point in the history
* Model Compiler - OpenCV 4 Support

* OpenCV 4 - Updates
  • Loading branch information
kiritigowda authored Mar 28, 2022
1 parent dc9c69a commit bf890ca
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions model_compiler/python/nnir_to_openvx.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,19 @@ def generateCMakeFiles(graph,outputFolder):
add_executable(anntest anntest.cpp)
if(OpenCV_FOUND)
target_compile_definitions(anntest PUBLIC ENABLE_OPENCV=1)
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(anntest ${OpenCV_LIBRARIES})
if(${OpenCV_VERSION_MAJOR} EQUAL 3 OR ${OpenCV_VERSION_MAJOR} EQUAL 4)
target_compile_definitions(anntest PUBLIC ENABLE_OPENCV=1)
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(anntest ${OpenCV_LIBRARIES})
if(${OpenCV_VERSION_MAJOR} EQUAL 4)
target_compile_definitions(anntest PUBLIC USE_OPENCV_4=1)
else()
target_compile_definitions(anntest PUBLIC USE_OPENCV_4=0)
endif()
else()
target_compile_definitions(anntest PUBLIC ENABLE_OPENCV=0)
message("-- NOTE: anntest -- OpenCV Version-${OpenCV_VERSION_MAJOR}.${OpenCV_VERSION_MINOR}.X Not Supported")
endif()
else(OpenCV_FOUND)
target_compile_definitions(anntest PUBLIC ENABLE_OPENCV=0)
endif(OpenCV_FOUND)
Expand Down Expand Up @@ -1980,6 +1990,9 @@ def generateTestCPP(graph,argmaxOutput,fileName,virtual_tensor_flag):
#include <opencv/cv.h>
#include <opencv/highgui.h>
using namespace cv;
#if USE_OPENCV_4
#define CV_LOAD_IMAGE_COLOR IMREAD_COLOR
#endif
#endif
#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; } }
Expand Down

0 comments on commit bf890ca

Please sign in to comment.