派生自 Algorithm/baseDetector

Scheaven
2021-06-03 168af40fe9a3cc81c6ee16b3e81f154780c36bdb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// Created by Scheaven on 2020/11/2.
//
 
#include "type_utils.h"
using namespace std;
/**
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<typename T>
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<typename T>
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;
}
 
char* get_subStr(std::string line, const char* split, int which)
{
    char* input = (char*)line.c_str();
    char *p = strtok(input,split);
    char* sub_str;
    int local = 0;
    while( p !=NULL )
    {
//        sscanf(p, "%s", &sub_str);
        if(local == which)
        {
            std::cout <<p<< std::endl;
            return p;
        }
        p = strtok(NULL, split);
        local++;
    }
 
    if(which>local)
        return "";
}
 
//int main(int argc, char *argv[])
//{
//    std::string line = "18eadadc-f583-4517-8c5d-e2a8cb605f97___FaceDetect___Yolo";
//    std::cout << get_subStr(line, "_", 0) << std::endl;
//    return 0;
//}