Reputation: 2357
I need to compile OpenCV 2.4.5 with Visual Studio 2012. In particular I'm interested in the compilation of gpu module with Cuda 5.0.
To enable CUDA compilation in VS2012 I followed this guide.
I use CMake to create VS2012 solution, then for each .cu file I change element type from "Custom build rule" to "CUDA C/C++"
I can compile the majority of project files but on some files I've got an annoying problem.
For example fgd_bgfg.cu cause
error C2039: 'ParameterType': is not a member of 'cv::gpu::device::TypeTraits'
But in type_traits.hpp I can read
typedef typename type_traits_detail::Select<IsSimpleParameter<UnqualifiedType>::value,
T, typename type_traits_detail::AddParameterType<T>::type>::type ParameterType;
This is a really annoying problem I can't get rid of!
I can't believe no one has already built opencv with VS2012 and GPU, some advice?
Upvotes: 4
Views: 2392
Reputation: 51
It looks like the CUDA compiler can't deal with the template traits technique. A simple way is specifying the TypeTraits template with three primitive types: double, float, int. I'm not sure this way is correct, but the CUDA compiler won't complain.
The code lists here:
template<> struct TypeTraits<double>
{
typedef type_traits_detail::UnConst<double>::type NonConstType;
typedef type_traits_detail::UnVolatile<double>::type NonVolatileType;
typedef type_traits_detail::UnVolatile<typename type_traits_detail::UnConst<double>::type>::type UnqualifiedType;
typedef type_traits_detail::PointerTraits<double>::type PointeeType;
typedef type_traits_detail::ReferenceTraits<double>::type ReferredType;
enum { isConst = type_traits_detail::UnConst<double>::value };
enum { isVolatile = type_traits_detail::UnVolatile<double>::value };
enum { isReference = type_traits_detail::ReferenceTraits<double>::value };
enum { isPointer = type_traits_detail::PointerTraits<typename type_traits_detail::ReferenceTraits<double>::type>::value };
enum { isUnsignedInt = type_traits_detail::IsUnsignedIntegral<double>::value };
enum { isSignedInt = type_traits_detail::IsSignedIntergral<double>::value };
enum { isIntegral = type_traits_detail::IsIntegral<double>::value };
enum { isFloat = type_traits_detail::IsFloat<double>::value };
enum { isArith = isIntegral || isFloat };
enum { isVec = type_traits_detail::IsVec<double>::value };
typedef double ParameterType;
};
template<> struct TypeTraits<float>
{
typedef type_traits_detail::UnConst<float>::type NonConstType;
typedef type_traits_detail::UnVolatile<float>::type NonVolatileType;
typedef type_traits_detail::UnVolatile<typename type_traits_detail::UnConst<float>::type>::type UnqualifiedType;
typedef type_traits_detail::PointerTraits<float>::type PointeeType;
typedef type_traits_detail::ReferenceTraits<float>::type ReferredType;
enum { isConst = type_traits_detail::UnConst<float>::value };
enum { isVolatile = type_traits_detail::UnVolatile<float>::value };
enum { isReference = type_traits_detail::ReferenceTraits<float>::value };
enum { isPointer = type_traits_detail::PointerTraits<typename type_traits_detail::ReferenceTraits<float>::type>::value };
enum { isUnsignedInt = type_traits_detail::IsUnsignedIntegral<float>::value };
enum { isSignedInt = type_traits_detail::IsSignedIntergral<float>::value };
enum { isIntegral = type_traits_detail::IsIntegral<float>::value };
enum { isFloat = type_traits_detail::IsFloat<float>::value };
enum { isArith = isIntegral || isFloat };
enum { isVec = type_traits_detail::IsVec<float>::value };
typedef float ParameterType;
};
template<> struct TypeTraits<int>
{
typedef type_traits_detail::UnConst<int>::type NonConstType;
typedef type_traits_detail::UnVolatile<int>::type NonVolatileType;
typedef type_traits_detail::UnVolatile<typename type_traits_detail::UnConst<int>::type>::type UnqualifiedType;
typedef type_traits_detail::PointerTraits<int>::type PointeeType;
typedef type_traits_detail::ReferenceTraits<int>::type ReferredType;
enum { isConst = type_traits_detail::UnConst<int>::value };
enum { isVolatile = type_traits_detail::UnVolatile<int>::value };
enum { isReference = type_traits_detail::ReferenceTraits<int>::value };
enum { isPointer = type_traits_detail::PointerTraits<typename type_traits_detail::ReferenceTraits<int>::type>::value };
enum { isUnsignedInt = type_traits_detail::IsUnsignedIntegral<int>::value };
enum { isSignedInt = type_traits_detail::IsSignedIntergral<int>::value };
enum { isIntegral = type_traits_detail::IsIntegral<int>::value };
enum { isFloat = type_traits_detail::IsFloat<int>::value };
enum { isArith = isIntegral || isFloat };
enum { isVec = type_traits_detail::IsVec<int>::value };
typedef int ParameterType;
};
copy the code in type_traits.hpp, behind the original TypeTraits definition. Build...then prey.
Good luck! :-D
Upvotes: 1