【问题标题】:Image processing in iOS + C++ in iphone appiPhone应用程序中iOS + C++中的图像处理
【发布时间】:2012-09-28 05:17:54
【问题描述】:

我的第一个问题是,如果我使用 opencv 库在 C++ 中编写一个类来检测图像中的任何对象并在 Objective-C(xcode 项目)中调用该 c++ 类,那么这种技术会起作用吗?

第二个问题是如何在我的 iphone 应用项目 中添加 c/c++ 类并在我的传统 ViewController 类中使用它。

到现在为止我做的还算不上

:使用一个 ViewController 创建了一个 TabView 应用程序。 :在该 ViewController 中添加了一个按钮。 :添加了一个 File.c 类,它只是打印字符串。 : 在我的 ViewController.h 和 ViewController.m 类中导入“File.c”

我的 ViewController.h 类

#import <UIkit/UIkit.h>
#import "file.c"

我的 ViewController.m 类

#import "FirstViewController.h"
#import "File.c"

现在,在按下按钮时,我想调用我已经添加到项目中的 C 类。 我希望得到好的和有益的答案。

问候

【问题讨论】:

  • @SpencerWong :: 如果我的 c/c++ 类只是在屏幕上打印一行并且我在 ViewController 类中添加了一个按钮,而我想要的只是按下按钮我的 C/C++ 类开始工作。那么该怎么做呢?

标签: c++ objective-c xcode class ios5


【解决方案1】:

文件.c

#ifndef testC_File_c
#define testC_File_c
#include <stdio.h>
void say_hello() {
    printf("Hello World!");
}
#endif

ViewController.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
- (IBAction) buttonDown:(id)sender;
@end

ViewController.mm

#import "ViewController.h"
#include "File.c"
@interface ViewController ()

@end

@implementation ViewController

- (IBAction) buttonDown:(id)sender
{
    say_hello();
}
- (void)viewDidLoad
{
    [super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

@end

【讨论】:

  • :: 感谢您回答我的问题。你能复习一下我的问题吗?我会感谢你的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-01-31
  • 2014-05-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-06
  • 1970-01-01
相关资源
最近更新 更多