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 defined(VISP_HAVE_OPENCV)
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 else if([myButton.currentTitle isEqualToString:[process objectAtIndex: 3]]){
124 NSLog(
@"Clicked on \"%@\
" button ", [process objectAtIndex: 3]);
126 UIImage *img = [UIImage imageNamed:@"monkey.png"];
130 [myImageView setImage:[ImageConversion UIImageFromVpImageGray:canny]];
134 - (void)didReceiveMemoryWarning {
135 [
super didReceiveMemoryWarning];
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
static void canny(const vpImage< unsigned char > &I, vpImage< unsigned char > &Ic, const unsigned int &gaussianFilterSize, const float &thresholdCanny, const unsigned int &apertureSobel)
static void getGradX(const vpImage< unsigned char > &I, vpImage< FilterType > &dIx, const vpImage< bool > *p_mask=nullptr)