我打算预加载我在应用程序中存储的所有图像。预加载图像涉及:
我在创建包含CvSeq *键和CvSeq * descs的字典时遇到问题。 请建议如何在NSMutableDictionary中存储这些值。
-(void) preloadImages:(NSMutableDictionary *)dictionary{
NSArray *d = [[NSBundle mainBundle] pathsForResourcesOfType:@"png" inDirectory:nil];
CvSURFParams params = cvSURFParams(500, 1);
CvMemStorage* storage = cvCreateMemStorage(0);
for( int i=0;i<[d count];i++){
NSString *searchForMe = @"myapp.app/1";
NSString *s = [[NSString alloc] initWithString:[d objectAtIndex:i]];
NSRange range = [s rangeOfString:searchForMe];
if( range.location != NSNotFound ){
NSMutableDictionary *surfDict = [[NSMutableDictionary alloc] init];
NSString *substring = [s substringFromIndex:range.location];
substring = [substring stringByReplacingOccurrencesOfString:@"myapp.app/" withString:@""];
UIImage *testImage = [UIImage imageNamed:substring];
IplImage *iplTestImage = [OpenCVUtilities CreateGRAYIplImageFromUIImage:testImage];
CvSeq *keys = 0 ;
CvSeq *descs = 0;
cvExtractSURF( iplTestImage, 0, &keys, &descs, storage, params );
[surfDict setObject:(id)testImage forKey:@"uiImage"];
NSLog(@"Image name : %@", substring);
[dictionary setObject:surfDict forKey:[NSString stringWithFormat:@"%d",i]];
[dictionary setObject:(NSObject *)keys forKey:@"keys"]; // error here
[dictionary setObject:(NSObject *)descs forKey:@"descs"]; // error here
[surfDict release];
}
}
}
答案 0 :(得分:0)
创建一个具有cvseq类型的实例变量的类,将cvseq添加到该对象,并将该类添加到字典中。