Skip to content

Commit 0cdb423

Browse files
committed
Save calibration if local saving is enabled, even if we have no device_id.
1 parent ae74790 commit 0cdb423

File tree

4 files changed

+46
-35
lines changed

4 files changed

+46
-35
lines changed

calib_camera.cpp

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,54 +1134,54 @@ static void saveParam(const ARParam *param, ARdouble err_min, ARdouble err_avg,
11341134

11351135
} else {
11361136

1137-
bool goodWrite = true;
1138-
11391137
// Get main device identifier and focal length from video module.
11401138
char *device_id = NULL;
1139+
char *name = NULL;
11411140
char *focal_length = NULL;
11421141

11431142
AR2VideoParamT *vid = vs->getAR2VideoParam();
11441143
if (ar2VideoGetParams(vid, AR_VIDEO_PARAM_DEVICEID, &device_id) < 0 || !device_id) {
11451144
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");
11471148
}
11481149

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;
11731168
}
11741169
}
1170+
if (!focal_length) {
1171+
// Not known at present, so just send 0.000.
1172+
focal_length = strdup("0.000");
1173+
}
11751174

1176-
if (goodWrite && gCalibrationSave) {
1175+
if (gCalibrationSave) {
11771176

11781177
// Assemble the filename.
11791178
char calibrationSavePathname[SAVEPARAM_PATHNAME_LEN];
11801179
snprintf(calibrationSavePathname, SAVEPARAM_PATHNAME_LEN, "%s/camera_para-", gCalibrationSaveDir);
11811180
size_t len = strlen(calibrationSavePathname);
11821181
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]);
11851185
i++;
11861186
}
11871187
calibrationSavePathname[len + i] = '\0';
@@ -1203,7 +1203,7 @@ static void saveParam(const ARParam *param, ARdouble err_min, ARdouble err_avg,
12031203
}
12041204

12051205
// Check for early exit.
1206-
if (!goodWrite || !gCalibrationServerUploadURL) {
1206+
if (!gCalibrationServerUploadURL || !device_id) {
12071207
if (remove(paramPathname) < 0) {
12081208
ARLOGe("Error removing temporary file '%s'.\n", paramPathname);
12091209
ARLOGperror(NULL);
@@ -1220,6 +1220,7 @@ static void saveParam(const ARParam *param, ARdouble err_min, ARdouble err_avg,
12201220
// Open the file.
12211221
snprintf(indexPathname, SAVEPARAM_PATHNAME_LEN, "%s/%s/%06d-index", arUtilGetResourcesDirectoryPath(AR_UTIL_RESOURCES_DIRECTORY_BEHAVIOR_USE_APP_CACHE_DIR), QUEUE_DIR, ID);
12221222
FILE *fp;
1223+
bool goodWrite = true;
12231224
if (!(fp = fopen(indexPathname, "wb"))) {
12241225
ARLOGe("Error opening upload index file '%s'.\n", indexPathname);
12251226
goodWrite = false;

macOS/artoolkitX Camera Calibration Utility.xcodeproj/project.pbxproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@
858858
4A9141F81DF6450200DF4FEE /* Project object */ = {
859859
isa = PBXProject;
860860
attributes = {
861-
LastUpgradeCheck = 0920;
861+
LastUpgradeCheck = 0930;
862862
ORGANIZATIONNAME = artoolkitx.org;
863863
TargetAttributes = {
864864
4A9141FF1DF6450200DF4FEE = {
@@ -952,13 +952,15 @@
952952
CLANG_WARN_BOOL_CONVERSION = YES;
953953
CLANG_WARN_COMMA = YES;
954954
CLANG_WARN_CONSTANT_CONVERSION = YES;
955+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
955956
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
956957
CLANG_WARN_DOCUMENTATION_COMMENTS = NO;
957958
CLANG_WARN_EMPTY_BODY = YES;
958959
CLANG_WARN_ENUM_CONVERSION = YES;
959960
CLANG_WARN_INFINITE_RECURSION = YES;
960961
CLANG_WARN_INT_CONVERSION = YES;
961962
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
963+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
962964
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
963965
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
964966
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -1014,13 +1016,15 @@
10141016
CLANG_WARN_BOOL_CONVERSION = YES;
10151017
CLANG_WARN_COMMA = YES;
10161018
CLANG_WARN_CONSTANT_CONVERSION = YES;
1019+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
10171020
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
10181021
CLANG_WARN_DOCUMENTATION_COMMENTS = NO;
10191022
CLANG_WARN_EMPTY_BODY = YES;
10201023
CLANG_WARN_ENUM_CONVERSION = YES;
10211024
CLANG_WARN_INFINITE_RECURSION = YES;
10221025
CLANG_WARN_INT_CONVERSION = YES;
10231026
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
1027+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
10241028
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
10251029
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
10261030
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

macOS/artoolkitX Camera Calibration Utility.xcodeproj/xcshareddata/xcschemes/artoolkitX Camera Calibration Utility.xcscheme

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0920"
3+
LastUpgradeVersion = "0930"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,7 +26,6 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
language = ""
3029
shouldUseLaunchSchemeArgsEnv = "YES">
3130
<Testables>
3231
</Testables>
@@ -46,7 +45,6 @@
4645
buildConfiguration = "Release"
4746
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4847
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
49-
language = ""
5048
launchStyle = "0"
5149
useCustomWorkingDirectory = "NO"
5250
ignoresPersistentStateOnLaunch = "NO"

0 commit comments

Comments
 (0)