21 #include <x86intrin.h> 23 #include <opencv2/core/mat.hpp> 29 const std::vector<float>& mean,
32 net_width_(net_dim.first),
33 net_height_(net_dim.second),
50 cv::cvtColor(resized, colored, CV_BGR2RGB);
53 colored.convertTo(converted, CV_32FC3);
55 using TensorIt = cv::MatConstIterator_<cv::Vec3f>;
57 for (TensorIt it = converted.begin<cv::Vec3f>(); it != converted.end<cv::Vec3f>(); ++it)
66 r16 = _cvtss_sh(r32, 0);
67 g16 = _cvtss_sh(g32, 0);
68 b16 = _cvtss_sh(b32, 0);
100 t1 = (t3 == 0 ? 0 : t1);
102 *(
reinterpret_cast<uint32_t*
>(out)) = t1;
107 uint32_t inu = *(
reinterpret_cast<uint32_t*
>(&in));
111 t1 = inu & 0x7fffffff;
112 t2 = inu & 0x80000000;
113 t3 = inu & 0x7f800000;
117 t1 = (t3 < 0x38800000) ? 0 : t1;
118 t1 = (t3 > 0x47000000) ? 0x7bff : t1;
119 t1 = (t3 == 0 ? 0 : t1);
121 *(
reinterpret_cast<uint16_t*
>(out)) = t1;
static void fp16tofp32(float *__restrict out, uint16_t in)
Tensor(const std::pair< int, int > &net_dim, const std::vector< float > &mean, const float &scale)
static void fp32tofp16(uint16_t *__restrict out, float in)
void loadImageData(const cv::Mat &image)
std::vector< uint16_t > tensor_
std::vector< float > mean_