We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Thanks for the great library. While I have been able to load a numpy file, how do I convert it to opencv Mat format. Thanks!
The text was updated successfully, but these errors were encountered:
Add cnpy.cpp and cnpy.h to visual stuido, and remove the relevant code of zlib
Sorry, something went wrong.
Here's an example of how to load a 3D matrix from .npy to OpenCV.
void cnpy2opencv_3d(std::string const& data_fname, cv::Mat& out) { // Load the data from file cnpy::NpyArray npy_data = cnpy::npy_load(data_fname); // Get pointer to data float* ptr = npy_data.data<float>(); // Get the shape of data int dim_1 = npy_data.shape[0]; int dim_2 = npy_data.shape[1]; int dim_3 = npy_data.shape[2]; int size[3] = { dim_1, dim_2, dim_3 }; out = cv::Mat(3, size, CV_32F, ptr).clone(); } int main() { cv::Mat test_data; cnpy2opencv_2d("test_data.npy", test_data); }
Want to load a image in opencv Mat with c++, and save a .npy file. how to do it?
No branches or pull requests
Thanks for the great library. While I have been able to load a numpy file, how do I convert it to opencv Mat format.
Thanks!
The text was updated successfully, but these errors were encountered: