Giter Site home page Giter Site logo

calonso / ios-arkit Goto Github PK

View Code? Open in Web Editor NEW
87.0 11.0 35.0 214 KB

iOS Location based Augmented Reality engine

Home Page: https://github.com/calonso/ios-arkit

License: MIT License

Objective-C 100.00%
augmented-reality-engine objective-c ios-lib ios-demo

ios-arkit's Introduction

iOS Augmented Reality Engine

I'm glad to share this engine that I've been developing from time to time with all of you. It's based on the iPhone ARKit.

##Core Features:

  • Fully compatible with all versions of iOS from 5.0 onwards.
  • Supports all orientations.
  • Scales and rotates displayed objects based on distance and orientation.
  • Allows user interaction with displayed objects.
  • Displayed objects positions are updated live (According to the user’s position).
  • Supports and distinguishes front looking as well as floor looking .
  • Allows any custom overlay views.
  • Builtin support for radar view.
  • Fully customisable.

##Usage:

First you need to copy and paste the folder ARKit and all its contents into your project. Then implement the ARViewDelegate in any of your classes.

#import "ARKit.h"

#pragma mark - ARViewDelegate protocol Methods

- (ARObjectView *)viewForCoordinate:(ARGeoCoordinate *)coordinate floorLooking:(BOOL)floorLooking {
  ARObjectView *view = nil;

  if (floorLooking) {
    // Build the floor looking view
  } else {
    // Build the front looking view
  }
  return view;

}

- (void) itemTouchedWithIndex:(NSInteger)index {
   // An item has been touched. React accordingly (if necessary)
}

- (void) didChangeLooking:(BOOL)floorLooking {
  if (floorLooking) {
    // The user has began looking at the floor    
  } else {
    // The user has began looking front
  }
}

This class is now ready to provide the information that the engine requires and also to respond to user's interaction. Now, to instantiate the engine and show the augmented reality view:

// Create the location
CLLocation *location = [[CLLocation alloc] initWithLatitude:51.500622 longitude:-0.126662];
ARGeoCoordinate *london = [ARGeoCoordinate coordinateWithLocation:location];
london.dataObject = @"London";

// Given that self is the ARViewDelegate
ARKitConfig *config = [ARKitConfig defaultConfigFor:self];

// Instantiate the engine
ARKitEngine *engine = [[ARKitEngine alloc] initWithConfig:config];
// Provide coordinates to show
[engine addCoordinates:@[london]];
// And fire it up!
[engine startListening];

At this moment you should be enjoying a fully featured augmented reality view showing the view you provided in your viewForCoordinate implementation when you head your device to London city! And when the sad moment of shutting down the augmented reality view comes, then simply...

[engine hide];

And that's all!! For more information on how to add custom overlay views, configure the radar position, start the engine in different orientations or better understanding of the front/floor looking feature, please run the provided example project.

For iOS 8 Support

Add these keys in Info.plist of your app

  • NSLocationWhenInUseUsageDescription (String - iOS) describes the reason why the app accesses the user’s location normally while running in the foreground. Include this key when your app uses location services to track the user’s current location directly. This key does not support using location services to monitor regions or monitor the user’s location using the significant location change service. The system includes the value of this key in the alert panel displayed to the user when requesting permission to use location services.This key is required when you use the requestWhenInUseAuthorization method of the CLLocationManager class to request authorization for location services. If the key is not present when you call the requestWhenInUseAuthorization method without including this key, the system ignores your request.This key is supported in iOS 8.0 and later. If your Info.plist file includes both this key and the NSLocationUsageDescription key, the system uses this key and ignores the NSLocationUsageDescription key.

  • NSLocationAlwaysUsageDescription (String - iOS) describes the reason why the app accesses the user’s location information. Include this key when your app uses location services in a potentially nonobvious way while running in the foreground or the background. For example, a social app might include this key when it uses location information to track the user’s location and display other users that are nearby. In this case, the fact that the app is tracking the user’s location might not be readily apparent. The system includes the value of this key in the alert panel displayed to the user when requesting permission to use location services. This key is required when you use the requestAlwaysAuthorization method of the CLLocationManager class to request authorization for location services. If this key is not present and you call the requestAlwaysAuthorization method, the system ignores your request and prevents your app from using location services.This key is supported in iOS 8.0 and later. If your Info.plist file includes both this key and the NSLocationUsageDescription key, the system uses this key and ignores the NSLocationUsageDescription key.

[Reference Source: Apple Documentation] (https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html)

Acknowledgements

  • Zac White. For his awesome iPhone ARKit that I used as the starting point for this engine.

ios-arkit's People

Contributors

calonso avatar prajeetshrestha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ios-arkit's Issues

How to save and load an object which was created by using ARKit ?

Hi guys, below scenario is possible or not ?

Scenario ::

  • I want to create a object where i pointed by AR.
  • I want to save SCNNode object which is created, I did by using NSUserdefaults.
  • I want to show the object which is saved when i relaunching my app.

Problems ::

I have created an object where i need even i saved but the problem is, It creating everywhere when i relaunching my app. I want to be unique object as where i created at the same location.

What is my idea to solve this problem ::

I was getting device location (latitude,longitude) along AR giving distances from device to object when i hit the screen. Also i did calculate the latitude and longitude of object place by using longitude, latitude(device location) and distance. Afterwards, set the radius as 30m from device location then in b/w if any object was created recreated the SCNNode.

Help ::

Is it possible to do, what i expected by using above idea ? If YES guide me How? :), if NO please guide me How ? :|

ar

Distance between pois

Hi i want to implement a function that will receive the distance between pois , and to show all the pois which radius is less that 2km ,and also the radar to setup . The problem that i can't get the idea how to setup it , i want to pass some pois in radius 2km , and one more which range is 2.100km and if i pass the 100meters i want to show the 2.100km poi , and the distanced poi from backside to remove . Could you help me with an idea ? I will be very thankfull 👍

Portrait & landscape view on the run time

The engine starts using either portrait view or landscape view configuration from taking rotation/orientation status of the main view controller. So, if I Start AR with portrait view & then rotate the device to landscape, then it does not start listening based on landscape configuration.
It would be great if the engine restarts/listens while changing device orientation/rotation (portrait to landscape to portrait) on the run time.

Overlap

Hello,

First I want to thank you for good project! I am a fairly beginner, and my question is, do you have any good guidance/solution for overlapping objects behind eachother? For example, maybe put then above or generate a list or something?

Thank you for any advice and support!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.