我正在下载特定的targets.xml文件,我想访问此文件以与Vuforia SDK一起使用。该文件将下载到应用程序的文档目录中,如下所示:
if fileManager.fileExists(atPath: destinationURLForFile.path){
}
else{
do {
try fileManager.moveItem(at: location, to: destinationURLForFile)
}catch{
print("An error occurred while moving file to destination url")
}
}
现在我想访问此文件以与Vuforia一起使用。我知道这应该通过在加载函数中使用STORAGE_ABSOLUTE来完成。
// Load the data set from the app's resources location
if (!dataSet->load([dataFile cStringUsingEncoding:NSASCIIStringEncoding], Vuforia::
STORAGE_ABSOLUTE)) {
NSLog(@"ERROR: failed to load data set");
objectTracker->destroyDataSet(dataSet);
dataSet = NULL;
ret = NO;
} else {
// Activate the data set
if (objectTracker->activateDataSet(dataSet)) {
NSLog(@"INFO: successfully activated data set");
}
else {
NSLog(@"ERROR: failed to activate data set");
ret = NO;
}
}
但是我得到了错误,我将xml文件命名为' targets'。也许你们知道我忘记了什么?
2017-01-31 20:12:39.262178 VidPlayback[243:5487] ERROR/AR(243)
2017-01-32 20:12:39: Failed to load dataset 'targets.xml'.
2017-01-31 20:12:39.262191 VidPlayback[243:5487] ERROR: failed to load data set
编辑:修复它!
使用此链接:https://developer.vuforia.com/forum/qcar-api/remote-dataset-ios-sdk
更改loadAndActivateImageTrackerDataSet函数中的默认代码:
if (!dataSet->load([dataFile cStringUsingEncoding:NSASCIIStringEncoding], Vuforia::
STORAGE_ABSOLUTE))
用这个:
NSString *fullPath = [NSString stringWithFormat:@"%@/Documents/%@", NSHomeDirectory(), dataFile];
// Load the data set from the app's resources location
if (!dataSet->load([fullPath cStringUsingEncoding:NSASCIIStringEncoding], Vuforia::STORAGE_ABSOLUTE)){