Sunset Lake Software - Comments for "CPU processing in between GPUImage Filters" http://www.sunsetlakesoftware.com/forum/cpu-processing-between-gpuimage-filters Comments for "CPU processing in between GPUImage Filters" en That worked great, thank you http://www.sunsetlakesoftware.com/forum/cpu-processing-between-gpuimage-filters#comment-1414 <p>That worked great, thank you very much!</p> pubDate Mon, 28 May 2012 05:32:47 +0000 dc:creator imgle68 guid false comment 1414 at http://www.sunsetlakesoftware.com You need to set a callback http://www.sunsetlakesoftware.com/forum/cpu-processing-between-gpuimage-filters#comment-1413 <p>You need to set a callback block to use with the raw data output, like in the following:</p> <p><div class="geshifilter"><pre class="geshifilter-cocoa"> [rawDataOutput setNewFrameAvailableBlock:^{ // Handle raw data processing here }];</pre></div></p> <p>Have your processing write to the bytes used for the raw data input, and then trigger the -processData within that callback block. I'd also set the originalImage to ignore the blendFilter for updates using the targetToIgnoreForUpdates property, so you don't get double updates.</p> <p>What this should do is process through the initial filters, notify your code in the block to process, have it do its work, and then have you manually trigger the raw data input to process from that point on. The raw data input should cause the blend to work on both images and you should get a proper result.</p> pubDate Mon, 28 May 2012 01:59:33 +0000 dc:creator Brad Larson guid false comment 1413 at http://www.sunsetlakesoftware.com Hi Brad, The input/output http://www.sunsetlakesoftware.com/forum/cpu-processing-between-gpuimage-filters#comment-1411 <p>Hi Brad,</p> <p>The input/output classes look great, thank you, however I am having some confusion over how to use this in the video processing pipeline. I understand how the RawDataTest example works for single image processing, but I am not sure where to put the CPU processing code in the video stream pipeline.</p> <p>For example, I am trying to implement the following pipeline that goes from camera output -&gt; luminance filter -&gt; CPU processing that modifies the raw data and creates a second image -&gt; alpha blending of these two images -&gt; display on the screen:</p> <p><div class="geshifilter"><pre class="geshifilter-cocoa"> // Set up luminance threshold and alpha blend filters luminanceFilter = [[GPUImageLuminanceThresholdFilter alloc] init]; [(GPUImageLuminanceThresholdFilter *)luminanceFilter setThreshold:0.6]; &nbsp; blendFilter = [[GPUImageAlphaBlendFilter alloc] init]; [(GPUImageAlphaBlendFilter *)blendFilter setMix:0.5]; &nbsp; // Set up videoCamera -&gt; luminance filter [videoCamera addTarget:luminanceFilter]; &nbsp; // Set up luminance filter -&gt; raw data GPUImageRawDataOutput *luminanceOutput = [[GPUImageRawDataOutput alloc] initWithImageSize:CGSizeMake(width, height) resultsInBGRAFormat:YES]; &nbsp; [luminanceFilter addTarget:luminanceOutput]; &nbsp; GLubyte *luminanceOutputBytes = [luminanceOutput rawBytesForImage]; &nbsp; // method call to do CPU processing on outputBytes void *blendFilterMaskBytes = calloc(width * height * 4, sizeof(GLubyte)); ProcessRawCameraOutput(luminanceOutputBytes, blendFilterMaskBytes); &nbsp; GPUImageRawDataInput *originalImage = [[GPUImageRawDataInput alloc] initWithBytes:luminanceOutputBytes size:CGSizeMake(width, height)]; &nbsp; GPUImageRawDataInput *imageToBlend = [[GPUImageRawDataInput alloc] initWithBytes:(GLubyte *)blendFilterMaskBytes size:CGSizeMake(width, height)]; &nbsp; // Send output of CPU processing to alpha blend filter [originalImage addTarget:blendFilter]; [imageToBlend addTarget:blendFilter]; &nbsp; // Display blended image on screen [blendFilter addTarget:imageView];</pre></div></p> <p>I've put a method call for the CPU processing directly into the pipeline setup code, but that seems like the wrong way to do it. If you could explain to me the correct way to do this for video processing I'd greatly appreciate it!</p> pubDate Sun, 27 May 2012 23:50:38 +0000 dc:creator imgle68 guid false comment 1411 at http://www.sunsetlakesoftware.com Awesome, thank you so much!! http://www.sunsetlakesoftware.com/forum/cpu-processing-between-gpuimage-filters#comment-1407 <p>Awesome, thank you so much!! I'll go take a look at that.</p> pubDate Sat, 26 May 2012 18:52:29 +0000 dc:creator imgle68 guid false comment 1407 at http://www.sunsetlakesoftware.com Sorry, forgot to update this, http://www.sunsetlakesoftware.com/forum/cpu-processing-between-gpuimage-filters#comment-1406 <p>Sorry, forgot to update this, but the GPUImageRawDataInput class has been in the framework since Tuesday. Look at the RawDataTest example for how to use this.</p> pubDate Sat, 26 May 2012 17:55:03 +0000 dc:creator Brad Larson guid false comment 1406 at http://www.sunsetlakesoftware.com That's wonderful, thank you! http://www.sunsetlakesoftware.com/forum/cpu-processing-between-gpuimage-filters#comment-1405 <p>That's wonderful, thank you! Do you have an idea of when approximately the new input class would be ready? I'd like to use GPUImage to improve performance in a demo of a project that'll be about a week from now, if possible. If (I'm guessing) the new input class won't be ready by then, do you have a suggestion on where to start if I try to hack out a way to input data back to the framework in between filters myself?</p> pubDate Sat, 26 May 2012 02:51:27 +0000 dc:creator imgle68 guid false comment 1405 at http://www.sunsetlakesoftware.com If you wait for a little bit, http://www.sunsetlakesoftware.com/forum/cpu-processing-between-gpuimage-filters#comment-1395 <p>If you wait for a little bit, I'm finalizing a new raw data input type, which should simplify the job of getting CPU-bound data to and from the framework. Right now, the GPUImageRawData class (soon to be renamed GPUImageRawDataOutput) gives you raw data output from a series of filters, but I need an input class to match that. </p> <p>These input and output classes should allow for some CPU-based processing to occur in between filter stages.</p> pubDate Mon, 21 May 2012 18:55:47 +0000 dc:creator Brad Larson guid false comment 1395 at http://www.sunsetlakesoftware.com