Skip to content

Commit

Permalink
added free_alphabet function; this function used for free alphabet. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
umbralada authored Sep 1, 2023
1 parent 30b044a commit ac4e765
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 23 deletions.
3 changes: 1 addition & 2 deletions src/coco.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,9 @@ void test_coco(char *cfgfile, char *weightfile, char *filename, float thresh)
show_image(im, "predictions");
free_image(im);
free_image(sized);

free_alphabet(alphabet);
wait_until_press_key_cv();
destroy_all_windows_cv();

if (filename) break;
}
free(boxes);
Expand Down
9 changes: 1 addition & 8 deletions src/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,7 @@ void demo(char *cfgfile, char *weightfile, float thresh, float hier_thresh, int

free_ptrs((void **)names, net.layers[net.n - 1].classes);

const int nsize = 8;
for (j = 0; j < nsize; ++j) {
for (i = 32; i < 127; ++i) {
free_image(alphabet[j][i]);
}
free(alphabet[j]);
}
free(alphabet);
free_alphabet(alphabet);
free_network(net);
//cudaProfilerStop();
}
Expand Down
12 changes: 1 addition & 11 deletions src/detector.c
Original file line number Diff line number Diff line change
Expand Up @@ -1778,17 +1778,7 @@ void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filenam
free_ptrs((void**)names, net.layers[net.n - 1].classes);
free_list_contents_kvp(options);
free_list(options);

int i;
const int nsize = 8;
for (j = 0; j < nsize; ++j) {
for (i = 32; i < 127; ++i) {
free_image(alphabet[j][i]);
}
free(alphabet[j]);
}
free(alphabet);

free_alphabet(alphabet);
free_network(net);
}

Expand Down
13 changes: 13 additions & 0 deletions src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,19 @@ image **load_alphabet()
return alphabets;
}

void free_alphabet(image **alphabet)
{
int i, j;
const int nsize = 8;
for (j = 0; j < nsize; ++j) {
for (i = 32; i < 127; ++i) {
free_image(alphabet[j][i]);
}
free(alphabet[j]);
}
free(alphabet);
}



// Creates array of detections with prob > thresh and fills best_class for them
Expand Down
1 change: 1 addition & 0 deletions src/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ image load_image(char *filename, int w, int h, int c);
image load_image_stb_resize(char *filename, int w, int h, int c);
//LIB_API image load_image_color(char *filename, int w, int h);
image **load_alphabet();
void free_alphabet(image **alphabet);

//float get_pixel(image m, int x, int y, int c);
//float get_pixel_extend(image m, int x, int y, int c);
Expand Down
4 changes: 2 additions & 2 deletions src/yolo.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,11 @@ void test_yolo(char *cfgfile, char *weightfile, char *filename, float thresh)

free_image(im);
free_image(sized);

free_alphabet(alphabet);
wait_until_press_key_cv();
destroy_all_windows_cv();

if (filename) break;
if (filename) break;
}
free(boxes);
for(j = 0; j < l.side*l.side*l.n; ++j) {
Expand Down

0 comments on commit ac4e765

Please sign in to comment.