I'm setting up my ARScene using this code which works perfectly. I'm then trying to apply a CIFilter to the selfie camera feed and set it back in real time. The only way I can access the camera feed data is through the -session didUpdateFrame method (I think?) but when I apply the filter and set it back the feed is just pure white as if I set the background.contents = [UIColor White], which I did not.
self.sceneView = [[ARSCNView alloc] initWithFrame:self.view.frame];
self.sceneView.delegate = self;
self.sceneView.showsStatistics = NO;
[self.view addSubview:self.sceneView];
SCNScene *scene = [SCNScene new];
self.sceneView.scene = scene;
ARFaceTrackingConfiguration *facetrack = [[ARFaceTrackingConfiguration alloc] init];
[self.sceneView.session runWithConfiguration:facetrack];
self.sceneView.session.delegate = self;
- (void)session:(ARSession *)session didUpdateFrame:(ARFrame *)frame {
CIImage *beginImage = [CIImage imageWithCVPixelBuffer: frame.capturedImage ];
CIFilter *filter = [CIFilter filterWithName:@"CIComicEffect" keysAndValues: kCIInputImageKey, beginImage, nil];
CIImage *outputImage = [[filter outputImage] imageByCroppingToRect:beginImage.extent];
UIImage *sat_img = [UIImage imageWithCIImage:outputImage];
self.sceneView.scene.background.contents = sat_img;
}
Is this even possible?