iOS + C++ 中的图像处理在 iphone 应用程序中

Image processing in iOS + C++ in iphone app

本文关键字:iphone 应用程序 图像处理 C++ iOS      更新时间:2023-10-16

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

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

到目前为止,我所做的是

:创建了一个具有一个视图控制器的 TabView 应用程序。:在该视图控制器中添加了一个按钮。:添加了一个 File.c 类,它只是打印字符串。:在我的ViewController.h和ViewController.m类中导入了"File.c",例如

MY ViewController.h 类

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

MY ViewController.m 类

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

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

问候

File.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