我想在IOS和Android

时间:2016-09-09 11:10:53

标签: android ios gps augmented-reality

我想用增强现实和GPS创建一些Android和iOS应用程序。这个应用程序应该通过相机(如汽车,建筑物)识别大物体,并在这些物体上创建一些文字。我们有可识别的物体GPS坐标和这个地方的照片。 该应用应该像 - http://med44.com/v2/freshkills.php一样工作。

我找到了一些图书馆:

artoolkit - 免费且拥有所有乐器,但我认为编程很困难,我会花很多时间学习它

vuforia - 在我看来是编程此应用程序的最佳方式,但还没有使用GPS位置。它比其他

更容易

gimbal = vuforia + GPS,但它在俄罗斯联邦没有用。

layar - 我不明白它可以解决什么样的AR任务,但它看起来像一个Sass平台,你可以在你的应用程序中添加。看起来很棒,但我不知道:它可以解决我的编程任务吗?

arlab - 没有任何相关信息。 lybrary可以解决我的所有任务吗?

UPD:我找到了新的lybrary - wikitube,但我不知道用它来编程我的应用程序是一个好方法吗?

现在我在考虑:我可以使用哪个库进行识别并在IOS和Android上实时显示标记?

1 个答案:

答案 0 :(得分:0)

使用wikitude SDK,我最近在我的一个应用程序中实现了它,它非常适合使用云和本地识别。附件是如何通过代码使用wikitude的示例,您需要在使用以下代码之前导入他们的sdk!

#define kWTLicenseKey @"put key here"

#import "WTSimpleClientTrackerViewController.h"

#import <WikitudeNativeSDK/WikitudeNativeSDK.h>

#import "StrokedRectangle.h"
#import "ExternalRenderer.h"
#import "ScanEvent.h"
#import "CokeStudioAPI.h"

@interface WTSimpleClientTrackerViewController () <WTWikitudeNativeSDKDelegate, WTClientTrackerDelegate>

@property (nonatomic, strong) WTWikitudeNativeSDK                           *wikitudeSDK;
@property (nonatomic, strong) WTClientTracker                               *clientTracker;

@property (nonatomic, strong) EAGLContext                                   *sharedWikitudeEAGLCameraContext;

@property (nonatomic, copy) WTWikitudeUpdateHandler                         wikitudeUpdateHandler;
@property (nonatomic, copy) WTWikitudeDrawHandler                           wikitudeDrawHandler;

@property (nonatomic, assign) BOOL                                          isTracking;
@property (nonatomic, assign) BOOL                                          targetFound;
@property (nonatomic, strong) ExternalRenderer                              *renderer;
@property (nonatomic, strong) StrokedRectangle                              *renderableRectangle;

@end


@implementation WTSimpleClientTrackerViewController

#pragma mark UIViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.renderer = [[ExternalRenderer alloc] init];
    self.renderableRectangle = [[StrokedRectangle alloc] init];
    self.renderableRectangle.scale = 320.0f;

    self.wikitudeSDK = [[WTWikitudeNativeSDK alloc] initWithRenderingMode:WTRenderingMode_External delegate:self];
    [self.wikitudeSDK setLicenseKey:kWTLicenseKey];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveApplicationWillResignActiveNotification:) name:UIApplicationWillResignActiveNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveApplicationDidBecomeActiveNotification:) name:UIApplicationDidBecomeActiveNotification object:nil];
    self.navigationController.navigationBar.hidden = true;

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveApplicationDidBecomeActiveNotification:) name:kApplicationDidBecomeInActive object:nil];


}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear: animated];
    [[CokeStudioAPI sharedInstance] trackScreen:@"VR Camera"];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    [self.renderer setupRenderingWithLayer:[self.eaglView eaglLayer]];
    [self.renderer startRenderLoopWithRenderBlock:[self renderBlock]];

    [self.wikitudeSDK start:nil completion:^(BOOL isRunning, NSError * __nonnull error) {
        if ( !isRunning ) {
            NSLog(@"Wikitude SDK is not running. Reason: %@", [error localizedDescription]);
        }
        else
        {
            NSArray *paths = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask];
            NSURL *trackerURL = [[paths lastObject] URLByAppendingPathComponent:@"tracker.wtc"];

            NSURL *clientTrackerURL = trackerURL;
            self.clientTracker = [self.wikitudeSDK.trackerManager create2DClientTrackerFromURL:clientTrackerURL extendedTargets:nil andDelegate:self];
        }
    }];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];

    [self.wikitudeSDK stop];

    [self.renderer stopRenderLoop];
    [self.renderer teardownRendering];

    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
    [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];

    [self.wikitudeSDK shouldTransitionToSize:size withTransitionCoordinator:coordinator];
}

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


#pragma mark - ExternalRenderer render loop
- (ExternalRenderBlock)renderBlock
{
    return ^ (CADisplayLink *displayLink) {
        if ( self.wikitudeUpdateHandler
            &&
            self.wikitudeDrawHandler )
        {
            self.wikitudeUpdateHandler();
            self.wikitudeDrawHandler();
        }

        [self.renderer bindBuffer];

        if ( _isTracking )
        {
            [self.renderableRectangle drawInContext:[self.renderer internalContext]];
        }
    };
}

#pragma mark - Notifications
- (void)didReceiveApplicationWillResignActiveNotification:(NSNotification *)notification
{
    [self.wikitudeSDK stop];
    [self dismissViewControllerAnimated:true completion:nil];
}

- (void)didReceiveApplicationDidBecomeActiveNotification:(NSNotification *)notification
{
    [self.wikitudeSDK start:nil completion:^(BOOL isRunning, NSError * __nonnull error) {
        if ( !isRunning ) {
            NSLog(@"Wikitude SDK is not running. Reason: %@", [error localizedDescription]);
        }
    }];
}

#pragma mark - Delegation
#pragma mark WTWikitudeNativeSDKDelegte
- (void)wikitudeNativeSDK:(WTWikitudeNativeSDK * __nonnull)wikitudeNativeSDK didCreatedExternalUpdateHandler:(WTWikitudeUpdateHandler __nonnull)updateHandler
{
    self.wikitudeUpdateHandler = updateHandler;
}

- (void)wikitudeNativeSDK:(WTWikitudeNativeSDK * __nonnull)wikitudeNativeSDK didCreatedExternalDrawHandler:(WTWikitudeDrawHandler __nonnull)drawHandler
{
    self.wikitudeDrawHandler = drawHandler;
}

- (EAGLContext *)eaglContextForVideoCameraInWikitudeNativeSDK:(WTWikitudeNativeSDK * __nonnull)wikitudeNativeSDK
{
    if (!_sharedWikitudeEAGLCameraContext )
    {
        EAGLContext *rendererContext = [self.renderer internalContext];
        self.sharedWikitudeEAGLCameraContext = [[EAGLContext alloc] initWithAPI:[rendererContext API] sharegroup:[rendererContext sharegroup]];
    }
    return self.sharedWikitudeEAGLCameraContext;
}

- (CGRect)eaglViewSizeForExternalRenderingInWikitudeNativeSDK:(WTWikitudeNativeSDK * __nonnull)wikitudeNativeSDK
{
    return self.eaglView.bounds;
}

- (void)wikitudeNativeSDK:(WTWikitudeNativeSDK * __nonnull)wikitudeNativeSDK didEncounterInternalError:(NSError * __nonnull)error
{
}

#pragma mark WTClientTrackerDelegate

- (void)baseTracker:(nonnull WTBaseTracker *)baseTracker didRecognizedTarget:(nonnull WTImageTarget *)recognizedTarget
{

    _isTracking = YES;
    [self dismissViewControllerAnimated:true completion:nil];

    NSDictionary* userInfo = @{@"artistName": [NSString stringWithFormat:@"%@",[recognizedTarget name]]};
    [[NSNotificationCenter defaultCenter] postNotificationName:@"targetFound" object:self userInfo:userInfo];

}

- (void)baseTracker:(nonnull WTBaseTracker *)baseTracker didTrackTarget:(nonnull WTImageTarget *)trackedTarget
{
    [self.renderableRectangle setProjectionMatrix:trackedTarget.projection];
    [self.renderableRectangle setModelViewMatrix:trackedTarget.modelView];
}

- (void)baseTracker:(nonnull WTBaseTracker *)baseTracker didLostTarget:(nonnull WTImageTarget *)lostTarget
{
    _isTracking = NO;
}

- (IBAction)doneBtnTapped:(id)sender {
    [self dismissViewControllerAnimated:true completion:nil];
}

- (void)clientTracker:(nonnull WTClientTracker *)clientTracker didFinishedLoadingTargetCollectionFromURL:(nonnull NSURL *)URL
{
}

- (void)clientTracker:(nonnull WTClientTracker *)clientTracker didFailToLoadTargetCollectionFromURL:(nonnull NSURL *)URL withError:(nonnull NSError *)error
{
}