派生自 Algorithm/baseDetector

Scheaven
2021-06-03 168af40fe9a3cc81c6ee16b3e81f154780c36bdb
lib/detecter_tools/darknet/utils.c
@@ -260,11 +260,17 @@
void replace_image_to_label(const char* input_path, char* output_path)
{
    find_replace(input_path, "/images/train2014/", "/labels/train2014/", output_path);    // COCO
    find_replace(output_path, "/images/val2014/", "/labels/val2014/", output_path);        // COCO
    find_replace(input_path, "/images/train2017/", "/labels/train2017/", output_path);    // COCO
    find_replace(output_path, "/images/val2017/", "/labels/val2017/", output_path);        // COCO
    find_replace(output_path, "/JPEGImages/", "/labels/", output_path);    // PascalVOC
    find_replace(output_path, "\\images\\train2017\\", "\\labels\\train2017\\", output_path);    // COCO
    find_replace(output_path, "\\images\\val2017\\", "\\labels\\val2017\\", output_path);        // COCO
    find_replace(output_path, "\\images\\train2014\\", "\\labels\\train2014\\", output_path);    // COCO
    find_replace(output_path, "\\images\\val2014\\", "\\labels\\val2014\\", output_path);        // COCO
    find_replace(output_path, "/images/train2014/", "/labels/train2014/", output_path);    // COCO
    find_replace(output_path, "/images/val2014/", "/labels/val2014/", output_path);        // COCO
    find_replace(output_path, "\\JPEGImages\\", "\\labels\\", output_path);    // PascalVOC
    //find_replace(output_path, "/images/", "/labels/", output_path);    // COCO
    //find_replace(output_path, "/VOC2007/JPEGImages/", "/VOC2007/labels/", output_path);        // PascalVOC
@@ -328,19 +334,19 @@
void malloc_error()
{
    fprintf(stderr, "xMalloc error\n");
    fprintf(stderr, "xMalloc error - possibly out of CPU RAM \n");
    exit(EXIT_FAILURE);
}
void calloc_error()
{
    fprintf(stderr, "Calloc error\n");
    fprintf(stderr, "Calloc error - possibly out of CPU RAM \n");
    exit(EXIT_FAILURE);
}
void realloc_error()
{
    fprintf(stderr, "Realloc error\n");
    fprintf(stderr, "Realloc error - possibly out of CPU RAM \n");
    exit(EXIT_FAILURE);
}
@@ -578,12 +584,10 @@
    int j;
    memset(avg, 0, els*sizeof(float));
    for(j = 0; j < n; ++j){
        #pragma omp parallel for
        for(i = 0; i < els; ++i){
            avg[i] += a[j][i];
        }
    }
    #pragma omp parallel for
    for(i = 0; i < els; ++i){
        avg[i] /= n;
    }
@@ -644,8 +648,8 @@
    for(i = 0; i < n; ++i){
        a[i] = (a[i] - mu)/sigma;
    }
    mu = mean_array(a,n);
    sigma = sqrt(variance_array(a,n));
    //mu = mean_array(a,n);
    //sigma = sqrt(variance_array(a,n));
}
void translate_array(float *a, int n, float s)
@@ -1032,3 +1036,19 @@
    return mkdir(path, mode);
#endif
}
unsigned long custom_hash(char *str)
{
    unsigned long hash = 5381;
    int c;
    while (c = *str++)
        hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
    return hash;
}
bool is_live_stream(const char * path){
    const char *url_schema = "://";
    return (NULL != strstr(path, url_schema));
}