promet / PRAugmentedReality

iOS Augmented Reality Framework
http://praugmentedreality.com/
MIT License
606 stars 162 forks source link

Newbie programmer doesn't understand how to setup #32

Closed babyghost-ys closed 11 years ago

babyghost-ys commented 11 years ago

Hi,

I am trying to write an app with AR support. And I am so happy to find a simple library like this.

Sadly, I couldn't understand how to setup the ARdata. What would be the type of ARdata?

Here is how I setup the library to my existing project

  1. Copy the whole library in the "class" folder of the zip file to my app.
  2. "Start the general process" as described in the main view controller
  3. Define the ARdata and ARobject like below,

    ARObject _arObject; NSArray arData;

  4. Add the data to the AR object after loading the XML from the internet (i is the index added to the for loop),

    Lat = [[[[[self rssParser]rssItems]objectAtIndex:i]lat] floatValue]; Lng = [[[[[self rssParser]rssItems]objectAtIndex:i]lng] floatValue]; // Creates a marker in the center of the map. GMSMarker *marker = [[GMSMarker alloc] init]; marker.position = CLLocationCoordinate2DMake(Lat, Lng); marker.title = [[[[self rssParser]rssItems]objectAtIndex:i]header]; marker.snippet = [[[[self rssParser]rssItems]objectAtIndex:i]desc];

[_arObject initWithId:i title:marker.title address:marker.snippet coordinates:coordinates andCurrentLocation:coordinates]; arData = [[_arObject getARObjectData] allValues]; [arController startARWithData:arData];

  1. Copy the related delegate methods in the main controller,
    • (void)arControllerDidSetupAR:(UIView )arView withCameraLayer:(AVCaptureVideoPreviewLayer)cameraLayer { [self.view.layer addSublayer:cameraLayer]; [self.view addSubview:arView]; }
    • (void)arControllerUpdateFrame:(CGRect)arViewFrame { [[self.view viewWithTag:AR_VIEW_TAG] setFrame:arViewFrame]; }
    • (void)gotProblemIn:(NSString)problemOrigin withDetails:(NSString)details { NSLog(@"Error in %@: %@", problemOrigin, details); }
  2. And nothing happens. I tried to look at the NSLog, but nothing is printed.

Could you please guide me how to present the AR view controller by pressing a button in the Main View controller? Thanks.

babyghost-ys commented 11 years ago

I tried to copy the ARView.h and ARView.m to my project from sample, but it said no data. How could I initiate the data? I have already got the coordinates, title and properties, like what I talked above.

Lat = [[[[[self rssParser]rssItems]objectAtIndex:i]lat] floatValue]; Lng = [[[[[self rssParser]rssItems]objectAtIndex:i]lng] floatValue]; // Creates a marker in the center of the map. GMSMarker *marker = [[GMSMarker alloc] init]; marker.position = CLLocationCoordinate2DMake(Lat, Lng); marker.title = [[[[self rssParser]rssItems]objectAtIndex:i]header]; marker.snippet = [[[[self rssParser]rssItems]objectAtIndex:i]desc];

glesage commented 11 years ago

Hi babyghost666,

I think the issue is that you give all the values of a single ARObject instead of an array of ARObject:

arData = [[_arObject getARObjectData] allValues];
[arController startARWithData:arData];

While arData should have an array of dictionaries of ARObjects... does that make sense? So:

arData = [NSArray arrayWithObject:_arObject getARObjectData]];
[arController startARWithData:arData];

Make sure you refer to the Wiki guide: ARData and data structures

babyghost-ys commented 11 years ago

Hi glesage,

Thanks for answering. Nice people over StackOverflow has already helped me to solve the problem. Thanks anyway.

glesage commented 11 years ago

Alright cool could you link up the URL of the answer on stackoverflow here (so others can see it too) Thanks! (:

babyghost-ys commented 11 years ago

Here you go,

http://stackoverflow.com/questions/18043143/only-the-last-value-of-nsmutabledictionary-is-added-to-nsmutablearray

Thanks for the great cocoa control, by the way!

ghost commented 10 years ago

Please I have the same problem regarding setting up the praugmentedreality framework. I just have the radar on camera view. how do you make it work ?