0
분명히이 코드는 마지막 줄에 cvCvtColor() 오류가 있습니다. 무엇이 잘못 되었습니까? 이 기능에서 향상시킬 수있는 것이 있습니까?pbm 파일을 IplImage로 변환
+(IplImage*) LoadPbmAsIplImage: (NSString*) fileName{
NSString *filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"pbm"];
NSData *data = [NSData dataWithContentsOfFile:filePath];
NSString *content = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSArray *lines = [content componentsSeparatedByString:@"\n"];
NSString *secondLine = [lines objectAtIndex:1]; //because first line (index 0) contains meta data
int width = [secondLine length];
int height = [lines count]-1;
Mat *mat = new Mat(width, height, CV_8UC4);
MatIterator_<uint> it = mat->begin<uint>();
for (int i=0; i<[lines count]; i++){
for (int j=0; j<[[lines objectAtIndex:i] length]; j++){
int pixelValue = 0;
if ([[lines objectAtIndex:i] characterAtIndex:j] == '1'){
pixelValue = 255;
}
*it = pixelValue;
}
}
IplImage iplImage = *mat;
IplImage* rv = cvCreateImage(cvSize(iplImage.width, iplImage.height), IPL_DEPTH_8U, 3);
cvCvtColor(mat, rv, CV_RGBA2BGR);
return rv;
}
입력 해 주셔서 감사합니다. 우선, pbm에서 IplImage로 변환하는 것이 가장 중요합니다. 일단 완료되면 정리 및 최적화를 진행할 것입니다. 문제는 지금 내가 ImageView에서 볼 때 정크 모호한 추상적 인 이미지를 얻는 것입니다. – Haoest