You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
667 B
24 lines
667 B
#ifndef __OPENCV_DNN_TEST_NPY_BLOB_HPP__ |
|
#define __OPENCV_DNN_TEST_NPY_BLOB_HPP__ |
|
#include "test_precomp.hpp" |
|
#include "cnpy.h" |
|
|
|
inline cv::dnn::Blob blobFromNPY(const cv::String &path) |
|
{ |
|
cnpy::NpyArray npyBlob = cnpy::npy_load(path.c_str()); |
|
cv::dnn::BlobShape shape((int)npyBlob.shape.size(), (int*)&npyBlob.shape[0]); |
|
|
|
cv::dnn::Blob blob(shape); |
|
blob.fill(shape, CV_32F, npyBlob.data); |
|
|
|
npyBlob.destruct(); |
|
return blob; |
|
} |
|
|
|
inline void saveBlobToNPY(cv::dnn::Blob &blob, const cv::String &path) |
|
{ |
|
cv::dnn::BlobShape shape = blob.shape(); |
|
cnpy::npy_save(path.c_str(), blob.ptr<float>(), (unsigned*)&shape[0], shape.dims()); |
|
} |
|
|
|
#endif
|
|
|