How to use opencv C++ API in deepstream-app?

Hi team,

I have been using opencv c API for a while since deepstream-app was written in c language. However opencv c API is not supported now and I need to use opencv c++ API instead. And I saw some posts about cropping frame and saving images used cv::imwrite() and etc., which are only supported in opencv c++ API. So would you please help advise how to use opencv c++ API in deepstream-app codes ASAP? Anything need to be modified in MakeFile? Thanks a lot!

I used gcc compiler and x11 to compile deepstream-app codes and app runs ok. If I changed from #include “oepncv/cv.h” to #include “opencv/cv.hpp”, it will prompt error as below:

/usr/local/include/opencv2/core.hpp:49:4: error: #error core.hpp header must be compiled as C++
error core.hpp header must be compiled as C++

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) GPU GeForce RTX 2080 Ti
• DeepStream Version 4.0.2
• JetPack Version (valid for Jetson only) N/A
• TensorRT Version 6.0.1.5
• NVIDIA GPU Driver Version (valid for GPU only) 435.21

@goodafterfive

Try to compile your source code using a C++ compiler (for example: g++).
This CMakeList may be helpful for you as a reference to add OpenCV dependencies into your compile/build env.

cmake_minimum_required(VERSION 2.6)
project(mtcnn_c)

SET(CMAKE_C_COMPILER g++)
SET(CMAK_CXX_COMPILER g++)
add_compile_options(-std=c++11)
add_compile_options(-m64)

include_directories(
    ${mtcnn_c_SOURCE_DIR}/include/ 
    /usr/local/cuda/include)
link_directories(
    ${mtcnn_c_SOURCE_DIR}/lib/
    /usr/local/cuda/lib64)

add_executable(mtcnn_c main.cpp )
target_link_libraries(mtcnn_c 
    -lcaffe 
    -lboost_system 
    -lboost_filesystem
    -lopencv_core 
    -lopencv_highgui 
    -lopencv_imgproc
    -lglog
    -lgflags
    -lprotobuf
    -lm
    -lhdf5
    -lhdf5_hl
)

#install(TARGETS mtcnn_c RUNTIME DESTINATION bin)