我正在使用iOS 5.1在Xcode 4.2中开发Vuforia SDK 1.5.9中的示例应用程序。在那个版本中,我无法自己创建可跟踪的数据集 - 我必须使用Qualcomm的在线解决方案。有没有人知道或有人试图从远程位置下载数据集?所以你像往常一样生成它们但是从服务器下载到应用程序中,所以我可以选择下载哪个并在飞行中使用?
昨天我已经快速尝试了这个:
-(void)setupMarkers{
NSString *filePathX;
//connect to the remot location
NSURL *urlD = [NSURL URLWithString:[NSString stringWithFormat:@"%@/frames.dat",kURLServer]];
NSData *urlData = [NSData dataWithContentsOfURL:urlD];
if ( urlData )
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"frames.dat"];
[urlData writeToFile:filePath atomically:YES];
}
NSURL *urlX = [NSURL URLWithString:[NSString stringWithFormat:@"%@/frames.xml",kURLServer]];
NSData *urlDataX = [NSData dataWithContentsOfURL:urlX];
if ( urlDataX )
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"frames.xml"];
[urlDataX writeToFile:filePath atomically:YES];
filePathX = filePath;
}
//put them into markersArray
[self.markersArray addObject:filePathX];
}
我知道这很难看,但正如我所说的那样,这是一次快速尝试,但它根本不起作用。我知道有新的Vuforia SDK 2.0带云和东西,但afaik我将不得不使用iOS6& Xcode 4.5 - 现在不适合我。
答案 0 :(得分:1)
其实我的"快速尝试"毕竟不是那么糟糕:) 这就是我的所作所为:
我改为 - (QCAR :: DataSet *)loadDataSet:(NSString *)dataSetPath一行:
// Load the data set from the App Bundle
// If the DataSet were in the Documents folder we'd use STORAGE_ABSOLUTE and the full path
if (!theDataSet->load([dataSetPath cStringUsingEncoding:NSASCIIStringEncoding], QCAR::DataSet::STORAGE_ABSOLUTE))//STORAGE_APPRESOURCE)){
...
}
就像一个魅力:)
P.S。如果有人能提出更好的答案,我会等一会儿;)