MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / svm_load_model

Function svm_load_model

ml/src/svm.cpp:3138–3403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3136}
3137
3138svm_model*
3139svm_load_model(const char* model_file_name)
3140{
3141 FILE* fp = fopen(model_file_name, "rbe");
3142
3143 if (fp == nullptr)
3144 return nullptr;
3145
3146 // read parameters
3147
3148 auto* model = Malloc(svm_model, 1);
3149
3150 svm_parameter& param = model->param;
3151
3152 model->rho = nullptr;
3153
3154 model->probA = nullptr;
3155
3156 model->probB = nullptr;
3157
3158 model->label = nullptr;
3159
3160 model->nSV = nullptr;
3161
3162 model->scaling = Malloc(struct svm_node, 1);
3163
3164 model->scaling[0].index = -1;
3165
3166 char cmd[81];
3167
3168 while (true) {
3169 int res = fscanf(fp, "%80s", cmd);
3170
3171 if (res > 0 && strcmp(cmd, "svm_type") == 0) {
3172 res = fscanf(fp, "%80s", cmd);
3173
3174 int i = 0;
3175 for (i = 0; svm_type_table[i]; i++) {
3176 if (res > 0 && strcmp(svm_type_table[i], cmd) == 0) {
3177 param.svm_type = i;
3178 break;
3179 }
3180 }
3181
3182 if (svm_type_table[i] == nullptr) {
3183 fprintf(stderr, "unknown svm type.\n");
3184 free(model->rho);
3185 free(model->label);
3186 free(model->nSV);
3187 free(model->scaling);
3188 free(model);
3189 return nullptr;
3190 }
3191 }
3192 else if (res > 0 && strcmp(cmd, "kernel_type") == 0) {
3193 res = fscanf(fp, "%80s", cmd);
3194
3195 int i = 0;

Callers 1

loadClassifierModelMethod · 0.85

Calls 2

ignoreFunction · 0.85
readlineFunction · 0.85

Tested by

no test coverage detected