@@ -1134,54 +1134,54 @@ static void saveParam(const ARParam *param, ARdouble err_min, ARdouble err_avg,
1134
1134
1135
1135
} else {
1136
1136
1137
- bool goodWrite = true ;
1138
-
1139
1137
// Get main device identifier and focal length from video module.
1140
1138
char *device_id = NULL ;
1139
+ char *name = NULL ;
1141
1140
char *focal_length = NULL ;
1142
1141
1143
1142
AR2VideoParamT *vid = vs->getAR2VideoParam ();
1144
1143
if (ar2VideoGetParams (vid, AR_VIDEO_PARAM_DEVICEID, &device_id) < 0 || !device_id) {
1145
1144
ARLOGe (" Error fetching camera device identification.\n " );
1146
- goodWrite = false ;
1145
+ }
1146
+ if (ar2VideoGetParams (vid, AR_VIDEO_PARAM_NAME, &name) < 0 || !name) {
1147
+ ARLOGe (" Error fetching camera name.\n " );
1147
1148
}
1148
1149
1149
- if (goodWrite) {
1150
- if (vid->module == AR_VIDEO_MODULE_AVFOUNDATION) {
1151
- int focalPreset;
1152
- ar2VideoGetParami (vid, AR_VIDEO_PARAM_AVFOUNDATION_FOCUS_PRESET, &focalPreset);
1153
- switch (focalPreset) {
1154
- case AR_VIDEO_AVFOUNDATION_FOCUS_MACRO:
1155
- focal_length = strdup (" 0.01" );
1156
- break ;
1157
- case AR_VIDEO_AVFOUNDATION_FOCUS_0_3M:
1158
- focal_length = strdup (" 0.3" );
1159
- break ;
1160
- case AR_VIDEO_AVFOUNDATION_FOCUS_1_0M:
1161
- focal_length = strdup (" 1.0" );
1162
- break ;
1163
- case AR_VIDEO_AVFOUNDATION_FOCUS_INF:
1164
- focal_length = strdup (" 1000000.0" );
1165
- break ;
1166
- default :
1167
- break ;
1168
- }
1169
- }
1170
- if (!focal_length) {
1171
- // Not known at present, so just send 0.000.
1172
- focal_length = strdup (" 0.000" );
1150
+ if (vid->module == AR_VIDEO_MODULE_AVFOUNDATION) {
1151
+ int focalPreset;
1152
+ ar2VideoGetParami (vid, AR_VIDEO_PARAM_AVFOUNDATION_FOCUS_PRESET, &focalPreset);
1153
+ switch (focalPreset) {
1154
+ case AR_VIDEO_AVFOUNDATION_FOCUS_MACRO:
1155
+ focal_length = strdup (" 0.01" );
1156
+ break ;
1157
+ case AR_VIDEO_AVFOUNDATION_FOCUS_0_3M:
1158
+ focal_length = strdup (" 0.3" );
1159
+ break ;
1160
+ case AR_VIDEO_AVFOUNDATION_FOCUS_1_0M:
1161
+ focal_length = strdup (" 1.0" );
1162
+ break ;
1163
+ case AR_VIDEO_AVFOUNDATION_FOCUS_INF:
1164
+ focal_length = strdup (" 1000000.0" );
1165
+ break ;
1166
+ default :
1167
+ break ;
1173
1168
}
1174
1169
}
1170
+ if (!focal_length) {
1171
+ // Not known at present, so just send 0.000.
1172
+ focal_length = strdup (" 0.000" );
1173
+ }
1175
1174
1176
- if (goodWrite && gCalibrationSave ) {
1175
+ if (gCalibrationSave ) {
1177
1176
1178
1177
// Assemble the filename.
1179
1178
char calibrationSavePathname[SAVEPARAM_PATHNAME_LEN];
1180
1179
snprintf (calibrationSavePathname, SAVEPARAM_PATHNAME_LEN, " %s/camera_para-" , gCalibrationSaveDir );
1181
1180
size_t len = strlen (calibrationSavePathname);
1182
1181
int i = 0 ;
1183
- while (device_id[i] && (len + i + 2 < SAVEPARAM_PATHNAME_LEN)) {
1184
- calibrationSavePathname[len + i] = (device_id[i] == ' /' || device_id[i] == ' \\ ' ? ' _' : device_id[i]);
1182
+ const char *identifier = (device_id ? device_id : (name ? name : " " ));
1183
+ while (identifier[i] && (len + i + 2 < SAVEPARAM_PATHNAME_LEN)) {
1184
+ calibrationSavePathname[len + i] = (identifier[i] == ' /' || identifier[i] == ' \\ ' ? ' _' : identifier[i]);
1185
1185
i++;
1186
1186
}
1187
1187
calibrationSavePathname[len + i] = ' \0 ' ;
@@ -1203,7 +1203,7 @@ static void saveParam(const ARParam *param, ARdouble err_min, ARdouble err_avg,
1203
1203
}
1204
1204
1205
1205
// Check for early exit.
1206
- if (!goodWrite || !gCalibrationServerUploadURL ) {
1206
+ if (!gCalibrationServerUploadURL || !device_id ) {
1207
1207
if (remove (paramPathname) < 0 ) {
1208
1208
ARLOGe (" Error removing temporary file '%s'.\n " , paramPathname);
1209
1209
ARLOGperror (NULL );
@@ -1220,6 +1220,7 @@ static void saveParam(const ARParam *param, ARdouble err_min, ARdouble err_avg,
1220
1220
// Open the file.
1221
1221
snprintf (indexPathname, SAVEPARAM_PATHNAME_LEN, " %s/%s/%06d-index" , arUtilGetResourcesDirectoryPath (AR_UTIL_RESOURCES_DIRECTORY_BEHAVIOR_USE_APP_CACHE_DIR), QUEUE_DIR, ID);
1222
1222
FILE *fp;
1223
+ bool goodWrite = true ;
1223
1224
if (!(fp = fopen (indexPathname, " wb" ))) {
1224
1225
ARLOGe (" Error opening upload index file '%s'.\n " , indexPathname);
1225
1226
goodWrite = false ;
0 commit comments