rogersce / cnpy

library to read/write .npy and .npz files in C/C++
MIT License
1.34k stars 301 forks source link

error: no matching function for call to ‘npy_save #31

Closed ccs-ros closed 6 years ago

ccs-ros commented 6 years ago

I encouraged a problem when i make the dvs-panotracking,here is the error message:

/home/ccs/dvs-panotracking/src/common.cpp:131:63: error: no matching function for call to ‘npy_save(std::basic_string, float, const unsigned int [2], int)’ cnpy::npy_save(filename + ".npy",in_cpu.data(),shape,2); ^ In file included from /home/ccs/dvs-panotracking/src/common.cpp:20:0: /usr/local/include/cnpy.h:88:31: note: candidate: template void cnpy::npy_save(std::string, const T, std::vector, std::string) template void npy_save(std::string fname, const T data, const std::vect ^ /usr/local/include/cnpy.h:88:31: note: template argument deduction/substitution failed: /home/ccs/dvs-panotracking/src/common.cpp:131:63: note: cannot convert ‘shape’ (type ‘const unsigned int [2]’) to type ‘std::vector’ cnpy::npy_save(filename + ".npy",in_cpu.data(),shape,2); ^ In file included from /home/ccs/dvs-panotracking/src/common.cpp:20:0: /usr/local/include/cnpy.h:223:31: note: candidate: template void cnpy::npy_save(std::string, std::vector, std::string) template void npy_save(std::string fname, const std::vector data, std ^ /usr/local/include/cnpy.h:223:31: note: template argument deduction/substitution failed: /home/ccs/dvs-panotracking/src/common.cpp:131:63: note: mismatched types ‘std::vector’ and ‘float’ cnpy::npy_save(filename + ".npy",in_cpu.data(),shape,2); ^ /home/ccs/dvs-panotracking/src/common.cpp: In function ‘void saveState(std::string, const ImageGpu_8u_C4*)’: /home/ccs/dvs-panotracking/src/common.cpp:148:38: warning: narrowing conversion of ‘sz.intn<2>::.special::intn<2>::width’ from ‘int’ to ‘unsigned int’ inside { } [-Wnarrowing] const unsigned int shape[] = {sz.width,sz.height}; ^ /home/ccs/dvs-panotracking/src/common.cpp:148:47: warning: narrowing conversion of ‘sz.intn<2>::.special::intn<2>::height’ from ‘int’ to ‘unsigned int’ inside { } [-Wnarrowing] const unsigned int shape[] = {sz.width,sz.height}; ^ make[2]: [CMakeFiles/dvs-tracking-common.dir/common.cpp.o] Error 1 make[1]: [CMakeFiles/dvs-tracking-common.dir/all] Error 2 make: *** [all] Error 2

please give me some solusions,thank you very much!

rogersce commented 6 years ago

I think this is pointing to your problem:

/usr/local/include/cnpy.h:88:31: note: template argument deduction/substitution failed: /home/ccs/dvs-panotracking/src/common.cpp:131:63: note: cannot convert ‘shape’ (type ‘const unsigned int [2]’) to type ‘std::vector’

you can try something like this to fix:

std::vector<size_t> vec_shape(shape,shape+2); cnpy::npy_save(filename + ".npy",in_cpu.data(),vec_shape,2);

ccs-ros commented 6 years ago

@rogersce thank you for your answer,i have solved the problem.thank you!