Code Monkey home page Code Monkey logo

iphone-ar-toolkit's Introduction

iPhone Augmented Reality Toolkit

Overview

This version of the iPhone ARKit is a forked version of the ARKit started on GitHub by Zac White, then forked by jjamminjim. I have made several improvements, which include a new customisable radar control, easier integration, better orientation / screen size detection.

Screenshots

Vertical Horizontal 1

Goals of the project

  • Not depended on a specific View Controller or the main App Delegate. (Completed) [jjamminjim]
  • Ability to use both the Landscape and Portrait modes. (Completed) [jjamminjim]
  • Use CoreLocation coordinates and update location as the user moves around. (Completed) [jjamminjim]
  • Ability to add different type of views to augment. (Completed) [jjamminjim]
  • Ability to touch any of the augment views to handle other tasks. (Completed) [jjamminjim]
  • Convert to ARC / remove deallocs (Completed)
  • Improve the markers (aesthetically) (Completed)
  • Add a Radar Control (Completed)

In the pipeline

  • iOS 5 Support
  • Better callout placement
  • API for useful data to be built in (such as country lists)

iPhone ARKit's APIs are modeled after MapKit's. For an overview of MapKit, please read the documentation for more information.

How to Use

Firstly, copy the contents of the ARKit directory into your project. Then make sure you have the following frameworks linked:

  • QuartzCore
  • MapKit
  • CoreLocation
  • AVFoundation

Include ARKit.h

Open the .h file of the view controller you are going to use to display the augmented reality view. In here, add #import "ARKit.h"

Implement delegate methods

Now open the .m file for the same UIViewController and implement the following two methods:

- (NSMutableArray *)geoLocations This must return an array of ARGeoCoordinate's. For example:

- (NSMutableArray *)geoLocations
	NSMutableArray 	*locationArray = [[NSMutableArray alloc] init];
	ARGeoCoordinate *tempCoordinate;
	CLLocation     	*tempLocation;

	tempLocation = [[CLLocation alloc] initWithLatitude:39.550051 longitude:-105.782067];
	tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation locationTitle:@"Denver"];
	[locationArray addObject:tempCoordinate];

	tempLocation = [[CLLocation alloc] initWithLatitude:45.523875 longitude:-122.670399];
	tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation locationTitle:@"Portland"];
	[locationArray addObject:tempCoordinate];

	return locationArray;
}

- (void)locationClicked:(ARGeoCoordinate *)coordinate This is to handle the taps on the locations. You can do whatever you wish within this method.

Display the augmented reality view

To display the augmented reality view (typically from a button) use:

if([ARKit deviceSupportsAR]){
	_arViewController = [[ARViewController alloc] initWithDelegate:self];
	[_arViewController setModalTransitionStyle: UIModalTransitionStyleFlipHorizontal];
	[self presentViewController:_arViewController animated:YES completion:nil];
}

ARKit Options

There are a few options I've added in for turning things on/off, colourising the radar, setting the range etc... They are as follows:

  • setDebugMode: bool - toggles debug mode on or off. Not really that useful. Default: NO.
  • setShowsRadar: bool - toggles the radar on or off. Default: YES.
  • setScaleViewsBasedOnDistance: bool - toggles whether to scale the popups based on their distance from you. Default: YES.
  • setMinimumScaleFactor: float - sets the minimum scale factor for the popups. Default: 0.5.
  • setRotateViewsBasedOnPerspective: bool - slightly rotates the popups based on the perspective. Default: YES.
  • setRadarPointColour: UIColor - sets the colour of the points on the radar. Default: White.
  • setRadarBackgroundColour: UIColor - sets the background colour of the radar. Default: Transparent green.
  • setRadarViewportColour: UIColor - sets the viewport colour of the radar. Default: Less transparent green.
  • setRadarRange: float - sets the range of the radar (in km). Default 20.0.
  • setOnlyShowItemsWithinRadarRange: bool - toggles whether to show all popups, or hide the ones beyond the range of the radar. Default: NO.

Example

This example will change the default look of the radar, limit the range to 4000km and hide any coordinates that would appear outside of this range.

if([ARKit deviceSupportsAR]){
	_arViewController = [[ARViewController alloc] initWithDelegate:self];
	[_arViewController setRadarBackgroundColour:[UIColor blackColor]];
	[_arViewController setRadarViewportColour:[UIColor colorWithWhite: 0.0 alpha:0.5]];
	[_arViewController setRadarPointColour:[UIColor whiteColor]];
	[_arViewController setRadarRange:4000.0];
	[_arViewController setOnlyShowItemsWithinRadarRange:YES];
	[_arViewController setModalTransitionStyle: UIModalTransitionStyleFlipHorizontal];
	[self presentViewController:_arViewController animated:YES completion:nil];
}

Current Status

The ARKit is targeting the iOS6 SDK.

Acknowledgements

I would like to thank Zac White for starting the initial project and giving me the ability to fork his code and make the changes I see to make an awesome ARKit. I would also like to thank Jim Boyd for allowing me to fork his code (and all the people who have helped him get the ARKit repo to where it was when I forked it).

MIT License

Copyright (c) 2013 Ed Rackham (edrackham.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

iphone-ar-toolkit's People

Contributors

a1phanumeric avatar argami avatar baalexander avatar markrickert avatar mtigas avatar nielswh avatar zac 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

Watchers

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

iphone-ar-toolkit's Issues

Has anyone used it with Parse?

Hello guys,

Has anyone used the AR-toolkit with Parse?

I am trying to populate the array with some data coming from Parse, but it did not work.

As I am a newbie, I might be passing some wrong argument to some variables.

In Parse's data browser I can create a class, and then create an object on my code, using its PFObject class.

For each class, in Parse's data browse, I can get values from keys, and the key which inherits from Parse's PFGeoPoint class already contains latitude and longitude.

arclass

I am trying the following:

PFObject *coordinates = [PFObject objectWithClassName:@"location"];
NSMutableArray *locationArray = [[NSMutableArray alloc] init];
ARGeoCoordinate *tempCoordinate;
CLLocation       *tempLocation;


tempLocation = [[CLLocation alloc] init];
tempLocation = [coordinates objectForKey:@"shopsLocation"];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation locationTitle:[coordinates objectForKey:@"description"]];
[locationArray addObject:tempCoordinate];

I am not finding a way to pass latitude and longitude to tempLocation using {initWithLatitude: longitude:}

tempLocation = [[CLLocation alloc] initWithLatitude:51.500152 longitude:-0.126236];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation locationTitle:@"London"];
[locationArray addObject:tempCoordinate];

as this key "shopsLocation" already contain both.

I really appreciate your help, and thanks for sharing this great library.

Retain loops

Hi,

AugmentedRealityController and ARViewController are not being deallocated beacuse of these retain loops:

AugmentedRealityController should have "rootViewController" set to weak to avoid retain loop with ARViewController.
@Property (nonatomic, weak) UIViewController *rootViewController;

Delegate in MarkerView should also be declared as weak:
__weak id _delegate;

location points(white color dots) not showing in the radar view

location points(white color dots) not showing in the radar view.
ar_locationdots

For your reference i used the following locations:

My current location - 12.829251,80.216331

  • (NSMutableArray *)geoLocations{

    NSMutableArray *locationArray = [[NSMutableArray alloc] init];
    ARGeoCoordinate *tempCoordinate;
    CLLocation *tempLocation;

    tempLocation = [[CLLocation alloc] initWithLatitude:12.829251 longitude:80.216331];
    tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation locationTitle:@"Denver"];
    [locationArray addObject:tempCoordinate];

    tempLocation = [[CLLocation alloc] initWithLatitude:12.827326 longitude:80.219271];
    tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation locationTitle:@"Portland"];
    [locationArray addObject:tempCoordinate];

    tempLocation = [[CLLocation alloc] initWithLatitude:12.826489 longitude:80.219207];
    tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation locationTitle:@"Chicago"];
    [locationArray addObject:tempCoordinate];

    tempLocation = [[CLLocation alloc] initWithLatitude:12.831929 longitude:80.223799];
    tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation locationTitle:@"Austin"];
    [locationArray addObject:tempCoordinate];
    return locationArray;
    }.

please help me to solve this issue

Fast moving markers

Hi everyone,

when i hold the phone in my hand its very hard to keep the markers with minimal movement on the screen. They are moving very fast to each direction. Is there a way to slow their movements?

Thanks

View Controller Doesn't Respect the Parent View Controller's Size

It looks like the ARViewController is mean to be run full screen, but when putting it inside of another viewController or a UINavigationController, it should position elements correctly inside the parent view controller's view.

Screenshots with highlighted positioning issues:

IMG_4982

IMG_4983

How to reload ARViewController view ?

I want to remove old locations from my ARViewController and want to add some new location in the view. how can i achieve this ?

I have tried to remove old locations with this method but it is not removing my old location.

  • (void)removeCoordinate:(ARGeoCoordinate *)coordinate

Can any one help me for this ?

Camera Quality

It appears as though the image being piped through the ARViewController is not running at the full resolution of the camera. It's very pixelated.

Screenshot - you can see the pixelation on the edge of the computer monitor:
IMG_4981

Orientation disabled for the whole app , after presented ARViewcontroller

Hi ,
Orientation disabled for the whole app , after presented ARViewcontroller. please help me to solve this issue.

if([ARKit deviceSupportsAR]){
_arViewController = [[ARViewController alloc] initWithDelegate:self];
[_arViewController setModalTransitionStyle: UIModalTransitionStyleFlipHorizontal];
[self presentViewController:_arViewController animated:YES completion:nil];
}

found some hint and trying to solve
http://stackoverflow.com/questions/4574693/ios-device-orientation-disregarding-orientation-lock

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.