fixed some compilation under ubuntu
This commit is contained in:
@@ -56,6 +56,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
|
||||
#include "NCV.hpp"
|
||||
#include "NPP_staging/NPP_staging.hpp"
|
||||
@@ -2396,11 +2397,10 @@ static NCVStatus loadFromNVBIN(const std::string &filename,
|
||||
FILE *fp = fopen(filename.c_str(), "rb");
|
||||
ncvAssertReturn(fp != NULL, NCV_FILE_ERROR);
|
||||
Ncv32u fileVersion;
|
||||
fread(&fileVersion, sizeof(Ncv32u), 1, fp);
|
||||
|
||||
ncvAssertReturn(1 == fread(&fileVersion, sizeof(Ncv32u), 1, fp), NCV_FILE_ERROR);
|
||||
ncvAssertReturn(fileVersion == NVBIN_HAAR_VERSION, NCV_FILE_ERROR);
|
||||
Ncv32u fsize;
|
||||
fread_s(&fsize, sizeof(Ncv32u), sizeof(Ncv32u), 1, fp);
|
||||
ncvAssertReturn(1 == fread(&fsize, sizeof(Ncv32u), 1, fp), NCV_FILE_ERROR);
|
||||
fseek(fp, 0, SEEK_END);
|
||||
Ncv32u fsizeActual = ftell(fp);
|
||||
ncvAssertReturn(fsize == fsizeActual, NCV_FILE_ERROR);
|
||||
@@ -2409,7 +2409,7 @@ static NCVStatus loadFromNVBIN(const std::string &filename,
|
||||
fdata.resize(fsize);
|
||||
Ncv32u dataOffset = 0;
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
fread(&fdata[0], fsize, 1, fp);
|
||||
ncvAssertReturn(1 == fread(&fdata[0], fsize, 1, fp), NCV_FILE_ERROR);
|
||||
fclose(fp);
|
||||
|
||||
//data
|
||||
@@ -2458,18 +2458,17 @@ NCVStatus ncvHaarGetClassifierSize(const std::string &filename, Ncv32u &numStage
|
||||
|
||||
if (fext == "nvbin")
|
||||
{
|
||||
FILE *fp;
|
||||
fopen_s(&fp, filename.c_str(), "rb");
|
||||
FILE *fp = fopen(filename.c_str(), "rb");
|
||||
ncvAssertReturn(fp != NULL, NCV_FILE_ERROR);
|
||||
Ncv32u fileVersion;
|
||||
fread_s(&fileVersion, sizeof(Ncv32u), sizeof(Ncv32u), 1, fp);
|
||||
ncvAssertReturn(1 == fread(&fileVersion, sizeof(Ncv32u), 1, fp), NCV_FILE_ERROR);
|
||||
ncvAssertReturn(fileVersion == NVBIN_HAAR_VERSION, NCV_FILE_ERROR);
|
||||
fseek(fp, NVBIN_HAAR_SIZERESERVED, SEEK_SET);
|
||||
Ncv32u tmp;
|
||||
fread_s(&numStages, sizeof(Ncv32u), sizeof(Ncv32u), 1, fp);
|
||||
fread_s(&tmp, sizeof(Ncv32u), sizeof(Ncv32u), 1, fp);
|
||||
fread_s(&numNodes, sizeof(Ncv32u), sizeof(Ncv32u), 1, fp);
|
||||
fread_s(&numFeatures, sizeof(Ncv32u), sizeof(Ncv32u), 1, fp);
|
||||
ncvAssertReturn(1 == fread(&numStages, sizeof(Ncv32u), 1, fp), NCV_FILE_ERROR);
|
||||
ncvAssertReturn(1 == fread(&tmp, sizeof(Ncv32u), 1, fp), NCV_FILE_ERROR);
|
||||
ncvAssertReturn(1 == fread(&numNodes, sizeof(Ncv32u), 1, fp), NCV_FILE_ERROR);
|
||||
ncvAssertReturn(1 == fread(&numFeatures, sizeof(Ncv32u), 1, fp), NCV_FILE_ERROR);
|
||||
fclose(fp);
|
||||
}
|
||||
else if (fext == "xml")
|
||||
@@ -2596,8 +2595,7 @@ NCVStatus ncvHaarStoreNVBIN_host(const std::string &filename,
|
||||
dataOffset = sizeof(Ncv32u);
|
||||
*(Ncv32u *)(&fdata[0]+dataOffset) = fsize;
|
||||
|
||||
FILE *fp;
|
||||
fopen_s(&fp, filename.c_str(), "wb");
|
||||
FILE *fp = fopen(filename.c_str(), "wb");
|
||||
ncvAssertReturn(fp != NULL, NCV_FILE_ERROR);
|
||||
fwrite(&fdata[0], fsize, 1, fp);
|
||||
fclose(fp);
|
||||
|
@@ -161,20 +161,32 @@ const Ncv32u NUM_SCAN_THREADS = 256;
|
||||
const Ncv32u LOG2_NUM_SCAN_THREADS = 8;
|
||||
|
||||
|
||||
struct T_true {};
|
||||
struct T_false {};
|
||||
template <typename T, typename U> struct is_same : T_false {};
|
||||
template <typename T> struct is_same<T, T> : T_true {};
|
||||
|
||||
template <int v>
|
||||
struct Int2Type
|
||||
{
|
||||
enum { value = v };
|
||||
};
|
||||
|
||||
|
||||
template<class T_in, class T_out>
|
||||
struct _scanElemOp
|
||||
{
|
||||
template<bool tbDoSqr>
|
||||
static inline __host__ __device__ T_out scanElemOp(T_in elem);
|
||||
|
||||
template<>
|
||||
static inline __host__ __device__ T_out scanElemOp<false>(T_in elem)
|
||||
static inline __host__ __device__ T_out scanElemOp(T_in elem)
|
||||
{
|
||||
return scanElemOp_( elem, Int2Type<(int)tbDoSqr>() );
|
||||
}
|
||||
private:
|
||||
static inline __host__ __device__ T_out scanElemOp_(T_in elem,const Int2Type<0>&)
|
||||
{
|
||||
return (T_out)elem;
|
||||
}
|
||||
|
||||
template<>
|
||||
static inline __host__ __device__ T_out scanElemOp<true>(T_in elem)
|
||||
static inline __host__ __device__ T_out scanElemOp_(T_in elem, const Int2Type<1>&)
|
||||
{
|
||||
return (T_out)(elem*elem);
|
||||
}
|
||||
|
@@ -73,7 +73,7 @@ void ncvDebugOutput(const char *msg, ...)
|
||||
char buffer[K_DEBUG_STRING_MAXLEN];
|
||||
va_list args;
|
||||
va_start(args, msg);
|
||||
vsnprintf_s(buffer, K_DEBUG_STRING_MAXLEN, K_DEBUG_STRING_MAXLEN-1, msg, args);
|
||||
vsnprintf(buffer, K_DEBUG_STRING_MAXLEN, msg, args);
|
||||
va_end (args);
|
||||
debugOutputHandler(buffer);
|
||||
}
|
||||
@@ -531,6 +531,10 @@ typedef struct _NcvTimeMoment NcvTimeMoment;
|
||||
return (((double)t2->tv.tv_sec - (double)t1->tv.tv_sec) * 1000000 + (double)t2->tv.tv_usec - (double)t1->tv.tv_usec);
|
||||
}
|
||||
|
||||
double _ncvMomentsDiffToMilliseconds(NcvTimeMoment *t1, NcvTimeMoment *t2)
|
||||
{
|
||||
return ((double)t2->tv.tv_sec - (double)t1->tv.tv_sec) * 1000;
|
||||
}
|
||||
|
||||
#endif //#if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
@@ -569,4 +573,4 @@ double ncvEndQueryTimerMs(NcvTimer t)
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif /* !defined (HAVE_CUDA) */
|
||||
#endif /* !defined (HAVE_CUDA) */
|
||||
|
@@ -146,10 +146,10 @@ namespace NCVRuntimeTemplateBool
|
||||
{
|
||||
//Convenience function used by the user
|
||||
//Takes a variable argument list, transforms it into a list
|
||||
static void call(Func &functor, int dummy, ...)
|
||||
static void call(Func &functor, Ncv32u dummy, ...)
|
||||
{
|
||||
//Vector used to collect arguments
|
||||
std::vector<int> templateParamList;
|
||||
std::vector<NcvBool> templateParamList;
|
||||
|
||||
//Variable argument list manipulation
|
||||
va_list listPointer;
|
||||
@@ -157,7 +157,7 @@ namespace NCVRuntimeTemplateBool
|
||||
//Collect parameters into the list
|
||||
for(int i=0; i<NumArguments; i++)
|
||||
{
|
||||
int val = va_arg(listPointer, int);
|
||||
NcvBool val = va_arg(listPointer, NcvBool);
|
||||
templateParamList.push_back(val);
|
||||
}
|
||||
va_end(listPointer);
|
||||
@@ -168,26 +168,26 @@ namespace NCVRuntimeTemplateBool
|
||||
|
||||
//Actual function called recursively to build a typelist based
|
||||
//on a list of values
|
||||
static void call( Func &functor, std::vector<int> &templateParamList)
|
||||
static void call( Func &functor, std::vector<NcvBool> &templateParamList)
|
||||
{
|
||||
//Get current parameter value in the list
|
||||
int val = templateParamList[templateParamList.size() - 1];
|
||||
NcvBool val = templateParamList[templateParamList.size() - 1];
|
||||
templateParamList.pop_back();
|
||||
|
||||
//Select the compile time value to add into the typelist
|
||||
//depending on the runtime variable and make recursive call.
|
||||
//depending on the runtime variable and make recursive call.
|
||||
//Both versions are really instantiated
|
||||
if(val)
|
||||
if (val)
|
||||
{
|
||||
KernelCaller<
|
||||
Loki::Typelist<typename Loki::Int2Type<true>, TList >,
|
||||
Loki::Typelist<typename Loki::Int2Type<1>, TList >,
|
||||
NumArguments-1, Func >
|
||||
::call(functor, templateParamList);
|
||||
}
|
||||
else
|
||||
{
|
||||
KernelCaller<
|
||||
Loki::Typelist<typename Loki::Int2Type<false>, TList >,
|
||||
KernelCaller<
|
||||
Loki::Typelist<typename Loki::Int2Type<0>, TList >,
|
||||
NumArguments-1, Func >
|
||||
::call(functor, templateParamList);
|
||||
}
|
||||
@@ -205,7 +205,7 @@ namespace NCVRuntimeTemplateBool
|
||||
functor.call(TList()); //TList instantiated to get the method template parameter resolved
|
||||
}
|
||||
|
||||
static void call(Func &functor, std::vector<int> &templateParams)
|
||||
static void call(Func &functor, std::vector<NcvBool> &templateParams)
|
||||
{
|
||||
functor.call(TList());
|
||||
}
|
||||
|
Reference in New Issue
Block a user