//解析.cfg文件static void app_parse_cfg_file(AppObj *obj, vx_char *cfg_file_name){ FILE *fp = fopen(cfg_file_name, "r"); vx_char line_str[1024]; vx_char *token; if(fp==NULL) { printf("# ERROR: Unable to open config file [%s]\n", cfg_file_name); exit(0); } while(fgets(line_str, sizeof(line_str), fp)!=NULL) { vx_char s[]=" \t"; if (strchr(line_str, '#')) { continue; } /* get the first token */ token = strtok(line_str, s); if(token != NULL) { if(strcmp(token, "tidl_config")==0) { token = strtok(NULL, s); if(token != NULL) { token[strlen(token)-1]=0; strcpy(obj->tidlObj.config_file_path, token); } } else if(strcmp(token, "tidl_network")==0) { token = strtok(NULL, s); if(token != NULL) { token[strlen(token)-1]=0; strcpy(obj->tidlObj.network_file_path, token); /* for testing if relevant */ if(strstr(obj->tidlObj.network_file_path, "u16") != NULL) { obj->test_case = 1; } else { obj->test_case = 0; } } } else if(strcmp(token, "input_file_path")==0) { token = strtok(NULL, s); if(token != NULL) { token[strlen(token)-1]=0; strcpy(obj->input_file_path, token); } } else if(strcmp(token, "output_file_path")==0) { token = strtok(NULL, s); if(token != NULL) { token[strlen(token)-1]=0; strcpy(obj->output_file_path, token); } } else if(strcmp(token, "start_frame")==0) { token = strtok(NULL, s); if(token != NULL) { obj->start_frame = atoi(token); } } else if(strcmp(token, "num_frames")==0) { token = strtok(NULL, s); if(token != NULL) { obj->num_frames = atoi(token); } } else if(strcmp(token, "in_size")==0) { vx_int32 width, height; token = strtok(NULL, s); if(token != NULL) { width = atoi(token); obj->scalerObj.input.width = width; token = strtok(NULL, s); if(token != NULL) { if (token[strlen(token)-1] == '\n') token[strlen(token)-1]=0; height = atoi(token); obj->scalerObj.input.height = height; } } } else if(strcmp(token, "dl_size")==0) { vx_int32 width, height; token = strtok(NULL, s); if(token != NULL) { width = atoi(token); obj->scalerObj.output1.width = width; token = strtok(NULL, s); if(token != NULL) { if(token[strlen(token)-1] == '\n') token[strlen(token)-1]=0; height = atoi(token); obj->scalerObj.output1.height = height; } } } else if(strcmp(token, "out_size")==0) { vx_int32 width, height; token = strtok(NULL, s); if(token != NULL) { width = atoi(token); obj->scalerObj.output2.width = width; token = strtok(NULL, s); if(token != NULL) { if(token[strlen(token)-1] == '\n') token[strlen(token)-1]=0; height = atoi(token); obj->scalerObj.output2.height = height; } } } else if(strcmp(token, "num_classes")==0) { token = strtok(NULL, s); if(token != NULL) { obj->postProcObj.viz_params.num_classes[0] = atoi(token); } } else if(strcmp(token, "en_out_img_write")==0) { token = strtok(NULL, s); if(token != NULL) { obj->en_out_img_write = atoi(token); } } else if(strcmp(token, "display_option")==0) { token = strtok(NULL, s); if(token != NULL) { obj->displayObj.display_option = atoi(token); } } else if(strcmp(token, "delay_in_msecs")==0) { token = strtok(NULL, s); if(token != NULL) { token[strlen(token)-1]=0; obj->delay_in_msecs = atoi(token); if(obj->delay_in_msecs > 2000) obj->delay_in_msecs = 2000; } } else if(strcmp(token, "num_iterations")==0) { token = strtok(NULL, s); if(token != NULL) { token[strlen(token)-1]=0; obj->num_iterations = atoi(token); if(obj->num_iterations == 0) obj->num_iterations = 1; } } else if(strcmp(token, "is_interactive")==0) { token = strtok(NULL, s); if(token != NULL) { token[strlen(token)-1]=0; obj->is_interactive = atoi(token); if(obj->is_interactive > 1) obj->is_interactive = 1; } } } } fclose(fp);}