// // Created by Scheaven on 2020/1/3. // #include "reid_utils.h" //import torch // //a=torch.Tensor([[1,2,3],[4,5,6]]) //b=torch.Tensor([[7,8,9],[10,11,12]]) //d=torch.stack( (a,b) ,dim = 1) // //print(d) //template //unsigned char * ReID_Utils::T2bytes(T u) //{ // int n = sizeof(T); // unsigned char* b = new unsigned char[n]; // memcpy(b, &u, n); // return b; //} // //template //T ReID_Utils::bytes2T(unsigned char *bytes) //{ // T res = 0; // int n = sizeof(T); // memcpy(&res, bytes, n); // return res; //} unsigned char * ReID_Utils::T2bytes(float u) { int n = sizeof(u); unsigned char* b = new unsigned char[n]; memcpy(b, &u, n); return b; } float ReID_Utils::bytes2T(unsigned char *bytes) { float res = 0; int n = sizeof(res); memcpy(&res, bytes, n); return res; } void *ReID_Utils::normalize(unsigned char *vsrc, int w, int h, int chan){ float *data = (float*)malloc(h*w*chan*sizeof(float)); int size = w*h; int size2 = size*2; unsigned char *srcData = (unsigned char*)vsrc; for(int i = 0;i