Cannot use sampleUffSSD with opencv

Hi, i need your help
I am using sampleUffSSD example in the tensorrt samples directory but when i import opencv there are bunch of errors appearing.

sudo make -j8
…/Makefile.config:5: CUDA_INSTALL_DIR variable is not specified, using /usr/local/cuda by default, use CUDA_INSTALL_DIR=<cuda_directory> to change.
…/Makefile.config:8: CUDNN_INSTALL_DIR variable is not specified, using $CUDA_INSTALL_DIR by default, use CUDNN_INSTALL_DIR=<cudnn_directory> to change.
:
:
Compiling: sampleUffSSD.cpp
Compiling: sampleUffSSD.cpp
sampleUffSSD.cpp:124:32: error: template argument 2 is invalid
std::vector<std::pair<int64_t, DataType>>
^~~~~~~~
sampleUffSSD.cpp:124:40: error: template argument 1 is invalid
std::vector<std::pair<int64_t, DataType>>
^~
sampleUffSSD.cpp:124:40: error: template argument 2 is invalid
sampleUffSSD.cpp: In function ‘int calculateBindingBufferSizes(const nvinfer1::ICudaEngine&, int, int)’:
sampleUffSSD.cpp:127:36: error: template argument 2 is invalid
std::vector<std::pair<int64_t, DataType>> sizes;
^~~~~~~~
sampleUffSSD.cpp:127:44: error: template argument 1 is invalid
std::vector<std::pair<int64_t, DataType>> sizes;
^~
sampleUffSSD.cpp:127:44: error: template argument 2 is invalid
sampleUffSSD.cpp:131:9: error: reference to ‘DataType’ is ambiguous
DataType dtype = engine.getBindingDataType(i);
^~~~~~~~
In file included from /usr/include/opencv2/core.hpp:56:0,
from /usr/include/opencv2/opencv.hpp:52,
from sampleUffSSD.cpp:1:
/usr/include/opencv2/core/traits.hpp:112:30: note: candidates are: template class cv::DataType
template class DataType
^~~~~~~~
In file included from BatchStreamPPM.h:8:0,
from sampleUffSSD.cpp:13:
/usr/include/aarch64-linux-gnu/NvInfer.h:122:12: note: enum class nvinfer1::DataType
enum class DataType : int
^~~~~~~~
sampleUffSSD.cpp:134:15: error: request for member ‘push_back’ in ‘sizes’, which is of non-class type ‘int’
sizes.push_back(std::make_pair(eltCount, dtype));
^~~~~~~~~
sampleUffSSD.cpp:134:50: error: ‘dtype’ was not declared in this scope
sizes.push_back(std::make_pair(eltCount, dtype));
^~~~~
sampleUffSSD.cpp:134:50: note: suggested alternative: ‘wctype’
sizes.push_back(std::make_pair(eltCount, dtype));
^~~~~
wctype
sampleUffSSD.cpp: In function ‘void doInference(nvinfer1::IExecutionContext&, float*, float*, int*, int)’:
sampleUffSSD.cpp:211:36: error: template argument 2 is invalid
std::vector<std::pair<int64_t, DataType>> buffersSizes = calculateBindingBufferSizes(engine, nbBindings, batchSize);
^~~~~~~~
sampleUffSSD.cpp:211:44: error: template argument 1 is invalid
std::vector<std::pair<int64_t, DataType>> buffersSizes = calculateBindingBufferSizes(engine, nbBindings, batchSize);
^~
sampleUffSSD.cpp:211:44: error: template argument 2 is invalid
sampleUffSSD.cpp:215:48: error: invalid types ‘int[int]’ for array subscript
auto bufferSizesOutput = buffersSizes[i];
^
sampleUffSSD.cpp: At global scope:
sampleUffSSD.cpp:454:25: error: reference to ‘DataType’ is ambiguous
bool supportsFormat(DataType type, PluginFormat format) const override
^~~~~~~~
In file included from /usr/include/opencv2/core.hpp:56:0,
from /usr/include/opencv2/opencv.hpp:52,
from sampleUffSSD.cpp:1:
/usr/include/opencv2/core/traits.hpp:112:30: note: candidates are: template class cv::DataType
template class DataType
^~~~~~~~
In file included from BatchStreamPPM.h:8:0,
from sampleUffSSD.cpp:13:
/usr/include/aarch64-linux-gnu/NvInfer.h:122:12: note: enum class nvinfer1::DataType
enum class DataType : int
^~~~~~~~
sampleUffSSD.cpp:454:25: error: ‘DataType’ has not been declared
bool supportsFormat(DataType type, PluginFormat format) const override
^~~~~~~~
sampleUffSSD.cpp:454:10: error: ‘bool FlattenConcat::supportsFormat(int, nvinfer1::PluginFormat) const’ marked ‘override’, but does not override
bool supportsFormat(DataType type, PluginFormat format) const override
^~~~~~~~~~~~~~
sampleUffSSD.cpp: In member function ‘bool FlattenConcat::supportsFormat(int, nvinfer1::PluginFormat) const’:
sampleUffSSD.cpp:456:25: error: reference to ‘DataType’ is ambiguous
return (type == DataType::kFLOAT && format == PluginFormat::kNCHW);
^~~~~~~~
In file included from /usr/include/opencv2/core.hpp:56:0,
from /usr/include/opencv2/opencv.hpp:52,
from sampleUffSSD.cpp:1:
/usr/include/opencv2/core/traits.hpp:112:30: note: candidates are: template class cv::DataType
template class DataType
^~~~~~~~
In file included from BatchStreamPPM.h:8:0,
from sampleUffSSD.cpp:13:
/usr/include/aarch64-linux-gnu/NvInfer.h:122:12: note: enum class nvinfer1::DataType
enum class DataType : int
^~~~~~~~
sampleUffSSD.cpp: In member function ‘virtual nvinfer1::IPluginV2* FlattenConcat::clone() const’:
sampleUffSSD.cpp:467:110: error: invalid new-expression of abstract class type ‘FlattenConcat’
return new FlattenConcat(mFlattenedInputSize.data(), mFlattenedInputSize.size(), mFlattenedOutputSize);
^
sampleUffSSD.cpp:289:7: note: because the following virtual functions are pure within ‘FlattenConcat’:
class FlattenConcat : public IPluginV2
^~~~~~~~~~~~~
In file included from BatchStreamPPM.h:8:0,
from sampleUffSSD.cpp:13:
/usr/include/aarch64-linux-gnu/NvInfer.h:2750:18: note: virtual bool nvinfer1::IPluginV2::supportsFormat(nvinfer1::DataType, nvinfer1::PluginFormat) const
virtual bool supportsFormat(DataType type, PluginFormat format) const = 0;
^~~~~~~~~~~~~~
sampleUffSSD.cpp: In member function ‘virtual nvinfer1::IPluginV2* FlattenConcatPluginCreator::createPlugin(const char*, const nvinfer1::PluginFieldCollection*)’:
sampleUffSSD.cpp:527:34: error: invalid new-expression of abstract class type ‘FlattenConcat’
return new FlattenConcat();
^
sampleUffSSD.cpp: In member function ‘virtual nvinfer1::IPluginV2* FlattenConcatPluginCreator::deserializePlugin(const char*, const void*, size_t)’:
sampleUffSSD.cpp:533:58: error: invalid new-expression of abstract class type ‘FlattenConcat’
return new FlattenConcat(serialData, serialLength);
^
sampleUffSSD.cpp:124:32: error: template argument 2 is invalid
std::vector<std::pair<int64_t, DataType>>
^~~~~~~~
sampleUffSSD.cpp:124:40: error: template argument 1 is invalid
std::vector<std::pair<int64_t, DataType>>
^~
sampleUffSSD.cpp:124:40: error: template argument 2 is invalid
sampleUffSSD.cpp: In function ‘int calculateBindingBufferSizes(const nvinfer1::ICudaEngine&, int, int)’:
sampleUffSSD.cpp:127:36: error: template argument 2 is invalid
std::vector<std::pair<int64_t, DataType>> sizes;
^~~~~~~~
sampleUffSSD.cpp:127:44: error: template argument 1 is invalid
std::vector<std::pair<int64_t, DataType>> sizes;
^~
sampleUffSSD.cpp:127:44: error: template argument 2 is invalid
sampleUffSSD.cpp:131:9: error: reference to ‘DataType’ is ambiguous
DataType dtype = engine.getBindingDataType(i);
^~~~~~~~
In file included from /usr/include/opencv2/core.hpp:56:0,
from /usr/include/opencv2/opencv.hpp:52,
from sampleUffSSD.cpp:1:
/usr/include/opencv2/core/traits.hpp:112:30: note: candidates are: template class cv::DataType
template class DataType
^~~~~~~~
In file included from BatchStreamPPM.h:8:0,
from sampleUffSSD.cpp:13:
/usr/include/aarch64-linux-gnu/NvInfer.h:122:12: note: enum class nvinfer1::DataType
enum class DataType : int
^~~~~~~~
sampleUffSSD.cpp:134:15: error: request for member ‘push_back’ in ‘sizes’, which is of non-class type ‘int’
sizes.push_back(std::make_pair(eltCount, dtype));
^~~~~~~~~
sampleUffSSD.cpp:134:50: error: ‘dtype’ was not declared in this scope
sizes.push_back(std::make_pair(eltCount, dtype));
^~~~~
sampleUffSSD.cpp:134:50: note: suggested alternative: ‘wctype’
sizes.push_back(std::make_pair(eltCount, dtype));
^~~~~
wctype
sampleUffSSD.cpp: In function ‘void doInference(nvinfer1::IExecutionContext&, float*, float*, int*, int)’:
sampleUffSSD.cpp:211:36: error: template argument 2 is invalid
std::vector<std::pair<int64_t, DataType>> buffersSizes = calculateBindingBufferSizes(engine, nbBindings, batchSize);
^~~~~~~~
sampleUffSSD.cpp:211:44: error: template argument 1 is invalid
std::vector<std::pair<int64_t, DataType>> buffersSizes = calculateBindingBufferSizes(engine, nbBindings, batchSize);
^~
sampleUffSSD.cpp:211:44: error: template argument 2 is invalid
sampleUffSSD.cpp:215:48: error: invalid types ‘int[int]’ for array subscript
auto bufferSizesOutput = buffersSizes[i];
^
sampleUffSSD.cpp: At global scope:
sampleUffSSD.cpp:454:25: error: reference to ‘DataType’ is ambiguous
bool supportsFormat(DataType type, PluginFormat format) const override
^~~~~~~~
In file included from /usr/include/opencv2/core.hpp:56:0,
from /usr/include/opencv2/opencv.hpp:52,
from sampleUffSSD.cpp:1:
/usr/include/opencv2/core/traits.hpp:112:30: note: candidates are: template class cv::DataType
template class DataType
^~~~~~~~
In file included from BatchStreamPPM.h:8:0,
from sampleUffSSD.cpp:13:
/usr/include/aarch64-linux-gnu/NvInfer.h:122:12: note: enum class nvinfer1::DataType
enum class DataType : int
^~~~~~~~
sampleUffSSD.cpp:454:25: error: ‘DataType’ has not been declared
bool supportsFormat(DataType type, PluginFormat format) const override
^~~~~~~~
sampleUffSSD.cpp:454:10: error: ‘bool FlattenConcat::supportsFormat(int, nvinfer1::PluginFormat) const’ marked ‘override’, but does not override
bool supportsFormat(DataType type, PluginFormat format) const override
^~~~~~~~~~~~~~
sampleUffSSD.cpp: In member function ‘bool FlattenConcat::supportsFormat(int, nvinfer1::PluginFormat) const’:
sampleUffSSD.cpp:456:25: error: reference to ‘DataType’ is ambiguous
return (type == DataType::kFLOAT && format == PluginFormat::kNCHW);
^~~~~~~~
In file included from /usr/include/opencv2/core.hpp:56:0,
from /usr/include/opencv2/opencv.hpp:52,
from sampleUffSSD.cpp:1:
/usr/include/opencv2/core/traits.hpp:112:30: note: candidates are: template class cv::DataType
template class DataType
^~~~~~~~
In file included from BatchStreamPPM.h:8:0,
from sampleUffSSD.cpp:13:
/usr/include/aarch64-linux-gnu/NvInfer.h:122:12: note: enum class nvinfer1::DataType
enum class DataType : int
^~~~~~~~
sampleUffSSD.cpp: In member function ‘virtual nvinfer1::IPluginV2* FlattenConcat::clone() const’:
sampleUffSSD.cpp:467:110: error: invalid new-expression of abstract class type ‘FlattenConcat’
(mFlattenedInputSize.data(), mFlattenedInputSize.size(), mFlattenedOutputSize);
^
sampleUffSSD.cpp:289:7: note: because the following virtual functions are pure within ‘FlattenConcat’:
class FlattenConcat : public IPluginV2
^~~~~~~~~~~~~
In file included from BatchStreamPPM.h:8:0,
from sampleUffSSD.cpp:13:
/usr/include/aarch64-linux-gnu/NvInfer.h:2750:18: note: virtual bool nvinfer1::IPluginV2::supportsFormat(nvinfer1::DataType, nvinfer1::PluginFormat) const
virtual bool supportsFormat(DataType type, PluginFormat format) const = 0;
^~~~~~~~~~~~~~
sampleUffSSD.cpp: In member function ‘virtual nvinfer1::IPluginV2* FlattenConcatPluginCreator::createPlugin(const char*, const nvinfer1::PluginFieldCollection*)’:
sampleUffSSD.cpp:527:34: error: invalid new-expression of abstract class type ‘FlattenConcat’
return new FlattenConcat();
^
sampleUffSSD.cpp: In member function ‘virtual nvinfer1::IPluginV2* FlattenConcatPluginCreator::deserializePlugin(const char*, const void*, size_t)’:
sampleUffSSD.cpp:533:58: error: invalid new-expression of abstract class type ‘FlattenConcat’
return new FlattenConcat(serialData, serialLength);
^
…/Makefile.config:159: recipe for target ‘…/…/bin/chobj/sampleUffSSD.o’ failed
make: *** […/…/bin/chobj/sampleUffSSD.o] Error 1
make: *** Waiting for unfinished jobs…
…/Makefile.config:166: recipe for target ‘…/…/bin/dchobj/sampleUffSSD.o’ failed
make: *** […/…/bin/dchobj/sampleUffSSD.o] Error 1

please help me what to do ?

i tried adding opencv path like:

OBJDIR =(call concat,(OUTDIR),/chobj)
DOBJDIR =(call concat,(OUTDIR),/dchobj)
OPENCV = pkg-config opencv --cflags --libs
COMMON_LIBS = -lcudnn -lcublas -lcudart
ifneq ((TARGET), qnx) ifneq ((ANDROID),1)
COMMON_LIBS += -lrt -ldl -lpthread
endif
endif
ifeq ((ANDROID),1) COMMON_LIBS += -lculibos -llog endif LIBS =-lnvinfer -lnvparsers -lnvinfer_plugin -lnvonnxparser (COMMON_LIBS)
DLIBS =-lnvinfer -lnvparsers -lnvinfer_plugin -lnvonnxparser (COMMON_LIBS) OBJS =(patsubst %.cpp, (OBJDIR)/%.o, (wildcard .cpp (addsuffix /*.cpp, (EXTRA_DIRECTORIES))))
DOBJS =(patsubst %.cpp, (DOBJDIR)/%.o, (wildcard *.cpp (addsuffix /
.cpp, (EXTRA_DIRECTORIES)))) CUOBJS =(patsubst %.cu, (OBJDIR)/%.o, (wildcard .cu (addsuffix /*.cu, (EXTRA_DIRECTORIES))))
CUDOBJS =(patsubst %.cu, (DOBJDIR)/%.o, (wildcard *.cu (addsuffix /
.cu, $(EXTRA_DIRECTORIES))))

CFLAGS=(COMMON_FLAGS) (OPENCV)
CFLAGSD=(COMMON_FLAGS) -g (OPENCV)
LFLAGS=(COMMON_LD_FLAGS) (OPENCV)
LFLAGSD=(COMMON_LD_FLAGS) (OPENCV)

but there is no change ;(((

I think opencv libraries are mixing up with other libraries, however i dont know how to fix this ;(

Sorry guys, I solved it bu just deleting using namespace std;