1
我知道它每天都會被問到的類型,但實際上每個問題的答案可能不同,而且我還沒有找到任何答案。在ViewController中使用未聲明的標識
我目前是Objective C的初學者,我正在開發一個應用程序,使用框架OpenCV
。
我一直在關注此website學習 然後我得到了我的問題。
我複製/粘貼的3個方法是在該網站給CV ::墊轉換成的UIImage和UIImage的以CV ::墊,但我不能使用它們:
我* .PCH文件:
#import <Availability.h>
#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif
#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
我ViewController.hh文件
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
- (cv::Mat)cvMatFromUIImage:(UIImage *)image;
- (cv::Mat)cvMatGrayFromUIImage:(UIImage *)image;
- (UIImage *)UIImageFromCVMat:(cv::Mat)cvMat;
@end
和我ViewController.mm文件
#import "ViewController.hh"
@interface ViewController()
@end
@implementation ViewController
- (cv::Mat)cvMatFromUIImage:(UIImage *)image
{
@@@//what is given in the linked website
return cvMat;
}
- (cv::Mat)cvMatGrayFromUIImage:(UIImage *)image
{
@@@//what is given in the linked website
return cvMat;
}
-(UIImage *)UIImageFromCVMat:(cv::Mat)cvMat
{
@@@//what is given in the linked website
return finalImage;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString* filename = [[NSBundle mainBundle] pathForResource:@"openCV" ofType:@"jpg"];
UIImage *image = [UIImage imageWithContentsOfFile:filename];
cv::Mat inputMat = cvMatFromUIImage(image);
UIImage *newImage = UIImageFromCVMat(inputMat);
self.view.backgroundColor = [UIColor colorWithPatternImage:newImage];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"HelloWorld !" message:@"Welcome to OpenCV !" delegate:self cancelButtonTitle:@"Continue" otherButtonTitles:nil, nil];
[alert show];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
@end
2個錯誤位於.mm
文件中的(void) viewDidLoad
獨自的行上,它表示cvMatFromUIImage
和UIImageFromCVMat
都未聲明。
這可能是一個愚蠢的問題,我想我錯過了什麼,但不知道是什麼。
請幫我:)
好的,非常感謝你,現在得到了一個otehr issu,但一步一步,它會沒事的^^ – Tiffado 2013-02-25 14:26:56