-
Notifications
You must be signed in to change notification settings - Fork 308
Add support for compressed NPZ file #1885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ter, compilation gives:
<>/visp/tutorial/misc/npz/tutorial-npz.cpp: In function ‘int main()’:
<>/visp/tutorial/misc/npz/tutorial-npz.cpp:61:25: error: call of overloaded ‘npz_save(const std::string&, const std::string&, __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type*, <brace-enclosed initializer list>, const char [2])’ is ambiguous
61 | visp::cnpy::npz_save(npz_filename, identifier, &vec_save_string[0], { vec_save_string.size() }, "w");
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from <>/visp/tutorial/misc/npz/tutorial-npz.cpp:42:
<>/visp/modules/core/include/visp3/core/vpIoTools.h:297:27: note: candidate: ‘void visp::cnpy::npz_save(const std::string&, std::string, const T*, const std::vector<long unsigned int>&, const std::string&, bool) [with T = char; std::string = std::__cxx11::basic_string<char>]’
297 | template<typename T> void npz_save(const std::string &zipname, std::string fname, const T *data, const std::vector<size_t> &shape,
| ^~~~~~~~
<>/visp/modules/core/include/visp3/core/vpIoTools.h:190:18: note: candidate: ‘void visp::cnpy::npz_save(const std::string&, const std::string&, const std::string&, const std::string&, bool)’
190 | VISP_EXPORT void npz_save(const std::string &zipname, const std::string &fname, const std::string &data,
| ^~~~~~~~
<>/visp/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-save.cpp: In function ‘int main(int, char**)’:
<>/visp/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-save.cpp:115:23: error: call of overloaded ‘npz_save(std::string&, const char [12], __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type*, <brace-enclosed initializer list>, const char [2])’ is ambiguous
115 | visp::cnpy::npz_save(npz_filename, "camera_name", &vec_camera_name[0], { vec_camera_name.size() }, "w"); // overwrite
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from <>/visp/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-save.cpp:3:
<>/visp/modules/core/include/visp3/core/vpIoTools.h:297:27: note: candidate: ‘void visp::cnpy::npz_save(const std::string&, std::string, const T*, const std::vector<long unsigned int>&, const std::string&, bool) [with T = char; std::string = std::__cxx11::basic_string<char>]’
297 | template<typename T> void npz_save(const std::string &zipname, std::string fname, const T *data, const std::vector<size_t> &shape,
| ^~~~~~~~
<>/visp/modules/core/include/visp3/core/vpIoTools.h:190:18: note: candidate: ‘void visp::cnpy::npz_save(const std::string&, const std::string&, const std::string&, const std::string&, bool)’
190 | VISP_EXPORT void npz_save(const std::string &zipname, const std::string &fname, const std::string &data,
| ^~~~~~~~
Add support for ZIP64 compression when using npz_save(), see: rogersce/cnpy#103
See NumPy doc: https://numpy.org/doc/stable/reference/generated/numpy.savez_compressed.html
…mPy numpy.savez_compressed() function.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1885 +/- ##
==========================================
+ Coverage 48.42% 48.58% +0.15%
==========================================
Files 532 532
Lines 69216 69293 +77
Branches 32369 32402 +33
==========================================
+ Hits 33521 33667 +146
- Misses 25176 31481 +6305
+ Partials 10519 4145 -6374 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@s-trinh Thanks for this PR. produce a warning with Xcode when building a project for iOS Since I'm not familiar with this code, could you investigate... As a starting point I'm wondering if the function |
…igned long' to 'uint_32_t' (aka 'unsigned int')" Original code defines `mz_ulong` as unsigned long: https://github.com/BinomialLLC/basis_universal/blob/135435c036e4233461822cb0d438ce7439eca734/encoder/basisu_miniz.h#L96-L97 Data type range from https://en.cppreference.com/w/cpp/language/types.html where ulong is 32-bits or 64-bits on LP64.
|
visp/modules/core/include/visp3/core/vpIoTools.h Lines 64 to 78 in 838e63a
https://en.cppreference.com/w/cpp/language/types.html
stb implementation of crc32: |
/home/runner/work/visp/visp/modules/detection/src/tag/vpDetectorAprilTag.cpp: In member function 'void vpDetectorAprilTag::loadConfigFile(const std::string&)':
/home/runner/work/visp/visp/modules/detection/src/tag/vpDetectorAprilTag.cpp:1792:60: warning: unused parameter 'configFile' [-Wunused-parameter]
1792 | void vpDetectorAprilTag::loadConfigFile(const std::string &configFile)
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
|
@s-trinh Thanks |

Thanks to: rogersce/cnpy#103
lagadic/visp-images#34
Reading npz from numpy.savez_compressed works except somehow for string data.
Writing compressed npz file from ViSP can be read from NumPy.
Some functions should not be exposed to the user, e.g.
compressData(),BigEndianTest(),parse_npy_header(), ..., withVISP_EXPORT. But removing them is not easy since I don't know how to handle this kind of thing at a library level.Rename to
npz_save_str()for string parameter/data, otherwise when adding a bool parameter for compression flag:I suspect before when using
brace-enclosed initializer listit was maybe not calling the intended function.