promet / PRAugmentedReality

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

Interface orientation #31

Closed fabiomassimo closed 11 years ago

fabiomassimo commented 11 years ago

Don't know if it is also linked to ARC / non ARC issue but I was trying to add rotate orientation feature by adding this snippet of code:

-(void)startCamera { [...]
    switch ([[UIApplication sharedApplication] statusBarOrientation]) {
        case (UIInterfaceOrientationLandscapeLeft):{
            [cameraLayer.connection setVideoOrientation:AVCaptureVideoOrientationLandscapeLeft];
        }
            break;
        case (UIInterfaceOrientationLandscapeRight):{
            [cameraLayer.connection setVideoOrientation:AVCaptureVideoOrientationLandscapeRight];
        }
            break;
        default:
            [cameraLayer.connection setVideoOrientation:AVCaptureVideoOrientationPortrait];
            break;
    }
     CGRect layerRect = CGRectMake(0, 0,
                              deviceScreenResolution.width,
                              deviceScreenResolution.height);
    [cameraLayer setBounds:layerRect];
    [cameraLayer setPosition:CGPointMake(CGRectGetMidX(layerRect),CGRectGetMidY(layerRect))];
}

and this new function:

-(void)updateARwithScreenSize:(CGSize) screenSize {
    [cameraSession stopRunning];
    [refreshTimer invalidate];

    deviceScreenResolution = screenSize;

    locTries = 0;
    dataTries = 0;

    [self initAndAllocContainers];
    [self startPosMonitoring];
    [self startCamera];
}

but it crashes and console output is:

malloc: * mmap(size=231432192) failed (error code=12) * error: can't allocate region *\ set a breakpoint in malloc_error_break to debug

Thanks again for all.

glesage commented 11 years ago

Hey,

Uhm yea thats going to be a little more complex... I've never tried adding landscape orientation to it.

Unfortunately I'm leaving for vacation in a few days so I don't think I'll have too much time to look at this :/ I'll try a few things though

Maybe experiment with a few things.. the memory management lacks some stuff for re-usability (right now you can't really turn AR on and Off unless you release or dismisss the view which is calling everything... --> that triggers all the deallocs and releases)

Hope that helps

glesage commented 11 years ago

Any updates on this?

glesage commented 11 years ago

This issue will be the up to date one https://github.com/promet/PRAugmentedReality/issues/34