iOS ARToolKit Xcode实现 [英] iOS ARToolKit Xcode Implementation

查看:142
本文介绍了iOS ARToolKit Xcode实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将



到目前为止我一直在尝试...



内部共享>包装,我运行了以下命令,这似乎可以正常运行而没有任何错误。

  bash ARToolKit5iOS-bin.sh 

然后我尝试导入lib并将目录包括到我的Xcode项目中。



问题



这是我的项目的内容> ViewController.m

  #import ViewController.h 
#import< AR / ar.h>

@interface ViewController()

@end

@implementation ViewController

-(void)viewDidLoad {
[super viewDidLoad];
//加载视图后进行其他任何设置,通常是从笔尖进行。
}

-(void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
//处理所有可以重新创建的资源。
}

@end

如您在在以下屏幕截图中,尝试导入AR工具包时发生错误。



我不是Objective-c开发人员,所以我在这里错过了什么?



解决方案

您可以创建一个框架目标,并单独构建一个框架,稍后将其放入您的应用程序中(该框架也将与Swift应用程序一起使用)。为此,您需要按照以下步骤开始:


  1. 下载ARToolKit5-bin-5.3.2-iOS.tar.gz并解压缩

  2. 打开ARToolKit5iOS.xcodeproj

  3. 在Xcode中转到文件->新建->目标

  4. 选择Cocoa Touch Framework,输入产品名称,将语言设置为Objective-C,将在应用程序中嵌入设置为无

  5. 转到ARFramework目标构建阶段,您将根据ARApp目标对其进行配置:


    • 在目标依赖项的构建阶段中添加:AR,ARIICP,ARvideo,ARgsub_es2
    • 在编译源中添加
    • 在编译源中添加:ARAppCore /EAGLView.m、ARApp/ARViewController.m、ARView.m

    • 在带有库的链接二进制文件中添加:Accelerate.framework,libAR.a,libARICP.a,libARvideo.a,libARgsub_es2。 a


  6. 转到构建设置并将自动引用计数设置为否

  7. 创建新的PCH文件(前缀标头)为您的Framework目标

  8. 在构建设置中设置预编译前缀标头为YES,并在前缀标头中设置您创建的PCH文件的路径

  9. 在已创建的PCH文件中,添加导入: #import< Foundation / Foundation.h> #import< UIKit / UIKit.h>

  10. 如果您的框架需要启用位码然后在框架目标的构建设置和目标中设置启用位码:AR,ARCICP,ARvideo,ARgsub_es2

  11. 您的框架目标现在应该可以成功构建,因此您可以检查Product->在框架上构建target

请注意,在您添加到框架的ARApp的ARViewController.m中,有两个硬编码的camera_para.dat和hiro路径。此示例中检测hiro标记所需的patt文件。为了解决这个问题,您可以例如将这两个文件添加到您的应用程序中,然后编辑ARViewController.m以在主捆绑包中进行搜索,例如,将其加载到ARViewController.m中的编辑行如下:

  char * patt_name = [[NSBundle mainBundle] pathForResource:@ hiro ofType:@ patt]。UTF8String; 

  char * cparam_name = [[NSBundle mainBundle] pathForResource:@ camera_para ofType:@ dat]。UTF8String; 

或根据需要实施一些自定义阅读。在故事板上的应用程序中,将viewcontroller类设置为ARViewController即可,框架现在应该可以正常工作,并在自定义应用程序中扫描hiro标记,并在其顶部显示一个多维数据集。还要注意,这仅是如何将ARApp功能复制到可附加到您的应用程序的框架中的示例,并且此框架将没有任何可见的接口,因此这只是将其与基本单项集成所需的基本工作。标记检测功能。


I'm trying to implement ARToolKit into an Objective-c iOS app.

I have downloaded the ARToolKit SDK and I see the following contents. The ARToolKit5 directory is for Mac OSX, so I have left this one closed. ARToolKit5iOS is the directory that I have tried to import into my Xcode project.

What I have tried so far...

Inside share > packaging, I ran the following command and this seemed to run correctly without any errors.

bash ARToolKit5iOS-bin.sh

Then I tried to import the lib and include directories into my Xcode project.

The problem

Here is the contents of my project > ViewController.m

#import "ViewController.h"
#import <AR/ar.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

As you can see in the following screenshot, the error occurs whilst trying to import the AR toolkit.

I am not an Objective-c developer, so what am I missing here?

解决方案

You can create a framework target and separately build a framework that you will later put into your application (which will also work with a swift app). To do this you will need to start as follow:

  1. Download ARToolKit5-bin-5.3.2-iOS.tar.gz and unpack it.
  2. Open ARToolKit5iOS.xcodeproj
  3. In Xcode go to File -> New -> Target
  4. Choose Cocoa Touch Framework, enter Product Name, set language to Objective-C, set Embeed in Aplication to None
  5. Go to ARFramework target Build Phases, you will configure it according to ARApp target that is:
    • in Build Phases in Target Dependencies add: AR, ARICP, ARvideo, ARgsub_es2
    • in Compile Sources add: ARAppCore/EAGLView.m, ARApp/ARViewController.m, ARView.m
    • in Link Binary With Libraries add: Accelerate.framework, libAR.a, libARICP.a, libARvideo.a, libARgsub_es2.a
  6. Go to Build Settings and set Automatic Reference Counting to No
  7. Create new PCH File (prefix header) for you Framework target
  8. In Build Settings set Precompile Prefix Header to YES and in Prefix Header set path to PCH file that you have created
  9. In created PCH file add imports: #import <Foundation/Foundation.h> and #import <UIKit/UIKit.h>
  10. If your framework need to be bitcode enabled then set Enable Bitcode in Build Settings of you framework target and targets: AR, ARICP, ARvideo, ARgsub_es2
  11. Your framework target should now Build successfully so you can check Product -> Build on your framework target

Note that in ARViewController.m from ARApp that you added to the framework there are two hardcoded paths to camera_para.dat and hiro.patt files which are needed in this example to detect hiro marker. To solve this you can for example add those two files to you application and edit ARViewController.m to search them in main bundle so for example edit lines that load them in the ARViewController.m to:

char *patt_name = [[NSBundle mainBundle] pathForResource:@"hiro" ofType:@"patt"].UTF8String;

and

char *cparam_name = [[NSBundle mainBundle] pathForResource:@"camera_para" ofType:@"dat"].UTF8String;

or implement some custom reading depending on your needs. In your app on storyboard set viewcontroller class to ARViewController and thats it, framework should now work fine and scan hiro marker in your custom app and show a cube on top of it. Also note that this is just an example of how to copy ARApp functionality into framework that can be attached in your app and this framework will not have any visible interfaces so this is just the basic work you will need to do to integrate it with basic single marker detection functionality.

这篇关于iOS ARToolKit Xcode实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆