2

私は 1 つの gpuimage イメージング アプリケーションの構築に慣れています。しかし、私はいくつかの問題を抱えています。1つ目は、フロントカメラとバックカメラを選択するときです。ボタンを数回クリックすると、アプリケーションがクラッシュします。次の問題は、カメラの画像が長く表示されることです。そして、カメラが反対方向にあった後。誰がこの問題を解決するのを手伝ってくれますか? ありがとうございました

- (void)viewDidLoad     {
    [super viewDidLoad]; 
    self.wantsFullScreenLayout = YES;
    iFlash = 1;
    hasBlur = NO;
    cropFilter = [[GPUImageCropFilter alloc] initWithCropRegion:CGRectMake(0.0f, 0.0f, 1.0f, 0.75f)];
    filter = [[GPUImageRGBFilter alloc] init];
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
        [self setUpCamera];
    });

    //cropFilter = [[GPUImageCropFilter alloc] initWithCropRegion:CGRectMake(0.0f, 0.0f, 1.0f, 0.75f)];
    filter = [[GPUImageRGBFilter alloc] init];

    [[self navigationController] setNavigationBarHidden:YES animated:NO]; 
}

- (IBAction)rotateCameraPressed:(id)sender {
    hasBlur = NO;

    if(sttRotate == 0) {
        sttRotate = 1;
        [self removeAllTargets];
        [self setUpCamera];
    }
    else if(sttRotate == 1){
        [self removeAllTargets];        
        sttRotate = 0;
        [self setUpCamera];
    }
}

- (void)setUpCamera { 
    if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
    // Has camera

        if(sttRotate == 1) { 
            stillCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPresetPhoto cameraPosition:AVCaptureDevicePositionFront];
        }
        else if(sttRotate == 0) {           
            stillCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPresetPhoto cameraPosition:AVCaptureDevicePositionBack];
        }

        stillCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
        runOnMainQueueWithoutDeadlocking(^{
            [stillCamera startCameraCapture];
            if([stillCamera.inputCamera hasFlash]){
                [self.flashToggleButton setEnabled:NO];
                [stillCamera.inputCamera lockForConfiguration:nil];
                if([stillCamera.inputCamera flashMode] == AVCaptureFlashModeOff){
                    [self.flashToggleButton setImage:[UIImage imageNamed:@"flash-off"] forState:UIControlStateNormal];
                }
                else if ([stillCamera.inputCamera flashMode] == AVCaptureFlashModeAuto){
                   [self.flashToggleButton setImage:[UIImage imageNamed:@"flash-auto"] forState:UIControlStateNormal];
                }
                else {
                [self.flashToggleButton setImage:[UIImage imageNamed:@"flash"] forState:UIControlStateNormal];
                }
                [stillCamera.inputCamera unlockForConfiguration];
                [self.flashToggleButton setEnabled:YES];
            }
            else {
                [self.flashToggleButton setEnabled:NO];
            }
            [self prepareFilter];
        });
    }
    else {
        // No camera 
        runOnMainQueueWithoutDeadlocking(^{
            [self prepareFilter];
        });
    }
}
4

0 に答える 0