Created
February 4, 2020 07:41
-
-
Save kazuya0202/1576a0cbfdc3b2a67798f8d2e3157f24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// extention of darknet/src/detector.c | |
save_image(im, "predictions"); // line: 1346 (2020/02/02) | |
// ----- add below code ----- // | |
/* please change according to your environment. */ | |
// export root path. (specified directory need to create before execute.) | |
char* rootPath = (char*)"prediction-results"; | |
/* -------------------------------------------- */ | |
// replace all backslash to slash. ('\\' -> '/') | |
char* target = input; | |
int i; | |
for (i = 0; target[i] != '/'; i++) { | |
if (target[i] == '\\') | |
target[i] = '/'; | |
} | |
// get filename. | |
char* fname = strrchr(target, '/'); | |
// calc length, allocate memory. | |
int len = strlen(fname); | |
char* buf = (char*)calloc(len, sizeof(char)); | |
// delete extension of filename. (xx.jpg -> xx) | |
for (i = 1; i < len; i++) { | |
if (fname[i] == '.') | |
break; | |
buf[i - 1] = fname[i]; | |
} | |
// calc length of exportPath. | |
len = strlen(buf) + strlen(rootPath) + 1; | |
char* exportPath = (char*)calloc(len, sizeof(char)); | |
sprintf(exportPath, "%s/%s", rootPath, buf); // format | |
// whether predictions image can save. | |
save_image(im, exportPath); | |
printf("\nSave to %s.jpg\n\n", exportPath); | |
// ----- end ----- // |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment