BradLarson / GPUImage

An open source iOS framework for GPU-based image and video processing
http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework
BSD 3-Clause "New" or "Revised" License
20.25k stars 4.61k forks source link

GPUImageRawData - Image flipped #192

Open ghost opened 12 years ago

ghost commented 12 years ago

When I render the output of a filter to the screen the image displays correctly.

When I get the raw data from GPUImageRawData using rawBytesForImage the image is fliped vertically.

I can use imageFromCurrentlyProcessedOutputWithOrientation:UIImageOrientationUp and all is ok.

If I was to post process the flipped image I would loose the speed benifit gained by using GPUImageRawData

BradLarson commented 12 years ago

What camera are you capturing an image from, the front or rear? Have you set the outputImageOrientation property on the camera to match the orientation you wish to see in your image?

ghost commented 12 years ago

Hi Brad,

I am using the rear camera with the following settings

videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition: videoCamera.outputImageOrientation = UIInterfaceOrientationLandscapeLeft;

I get the raw data like this

[imageRawData rawBytesForImage];

When I get the image using the following the image is in the correct orientation

UIImage * image = [sharpenFilter imageFromCurrentlyProcessedOutputWithOrientation:UIImageOrientationUp];

Perhaphs I am doing something wrong here..

rcodddow commented 10 years ago

I think I'm having a similar problem, Im setting things up to do some CPU processing with opencv. Right now I'm just taking the raw data output and pumping it back into raw data input like so.

camera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset1920x1080 cameraPosition:AVCaptureDevicePositionBack];
camera.outputImageOrientation = UIInterfaceOrientationPortrait;
camera.runBenchmark = YES;
camera.horizontallyMirrorRearFacingCamera = NO;

CGSize size = CGSizeMake(1920, 1080);

rawDataOutputFilter = [[GPUImageRawDataOutput alloc] initWithImageSize:size resultsInBGRAFormat:YES];

rawDataInputFilter = [[GPUImageRawDataInput alloc] initWithBytes:nil size:size];

__weak GPUImageRawDataInput *rawDataInput = rawDataInputFilter;
__weak GPUImageRawDataOutput *rawDataOutput = rawDataOutputFilter;
[rawDataOutputFilter setNewFrameAvailableBlock:^{
    [rawDataInput updateDataFromBytes:[rawDataOutput rawBytesForImage] size:size];
    [rawDataInput processData];
}];

[camera addTarget:rawDataOutput];

[rawDataInputFilter addTarget:(GPUImageView*)self.view];

[camera startCameraCapture];

Any thoughts ?