33 #ifndef DOXYGEN_SHOULD_SKIP_THIS 35 #import "ViewController.h" 36 #import "ImageConversion.h" 38 #import <visp3/visp.h> 41 #ifndef DOXYGEN_SHOULD_SKIP_THIS 42 @interface ViewController ()
45 @implementation ViewController
48 NSArray *process = [[NSArray alloc]initWithObjects:@"load image", @"convert to gray", @"compute gradient",
49 #if (VISP_HAVE_OPENCV_VERSION >= 0x020100)
54 @synthesize myImageView;
62 UIImage *myScreenShot = [UIImage imageNamed:@"monkey.png"];
65 self.myImageView = [[UIImageView alloc] initWithImage:myScreenShot];
68 CGRect myFrame = CGRectMake(0.0f, 0.0f,
self.myImageView.frame.size.width*2,
self.myImageView.frame.size.height*2);
69 [
self.myImageView setFrame:myFrame];
72 [
self.view addSubview:self.myImageView];
75 CGFloat posx=140, posy=350;
77 CGSize button_size = CGSizeMake( 150, 25 );
78 for (
int i=0; i<[process count]; i++) {
79 UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
80 [button addTarget:self action:@selector(checkButtonClick:) forControlEvents:UIControlEventTouchUpInside];
81 [button setTitle:[process objectAtIndex: i] forState:UIControlStateNormal];
83 button.frame = CGRectMake(posx, posy+i*padding, button_size.width, button_size.height);
84 [button setBackgroundColor:[UIColor blueColor]];
85 [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
86 button.layer.cornerRadius = 10;
87 [
self.view addSubview:button];
91 - (void) checkButtonClick:(UIButton *)paramSender{
93 UIButton *myButton = paramSender;
96 if([myButton.currentTitle isEqualToString:[process objectAtIndex: 0]]){
98 NSLog(
@"Clicked on \"%@\
" button ", [process objectAtIndex: 0]);
100 [myImageView setImage:[UIImage imageNamed:@"monkey.png"]];
102 else if([myButton.currentTitle isEqualToString:[process objectAtIndex: 1]]){
104 NSLog(
@"Clicked on \"%@\
" button ", [process objectAtIndex: 1]);
106 UIImage *img = [UIImage imageNamed:@"monkey.png"];
108 [myImageView setImage:[ImageConversion UIImageFromVpImageGray:gray]];
110 else if([myButton.currentTitle isEqualToString:[process objectAtIndex: 2]]){
112 NSLog(
@"Clicked on \"%@\
" button ", [process objectAtIndex: 2]);
114 UIImage *img = [UIImage imageNamed:@"monkey.png"];
120 [myImageView setImage:[ImageConversion UIImageFromVpImageGray:gray]];
122 #if (VISP_HAVE_OPENCV_VERSION >= 0x020100) 123 else if([myButton.currentTitle isEqualToString:[process objectAtIndex: 3]]){
125 NSLog(
@"Clicked on \"%@\
" button ", [process objectAtIndex: 3]);
127 UIImage *img = [UIImage imageNamed:@"monkey.png"];
131 [myImageView setImage:[ImageConversion UIImageFromVpImageGray:canny]];
136 - (void)didReceiveMemoryWarning {
137 [
super didReceiveMemoryWarning];
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
static void getGradX(const vpImage< unsigned char > &I, vpImage< double > &dIx)
static void canny(const vpImage< unsigned char > &I, vpImage< unsigned char > &Ic, unsigned int gaussianFilterSize, double thresholdCanny, unsigned int apertureSobel)