So there's this component of Xamarin.ios, GPUImage, that was originally in objective c and now uses bindings to work in C#.
I can't seem to get a working subclass of one of its classes, GPUImageThreeInputFilter
, which is supposed to accept a string that then gets processed as glsl. This is what the class looks like:
using Foundation;
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace GPUImage.Filters
{
[Register ("GPUImageThreeInputFilter", true)]
public class GPUImageThreeInputFilter : GPUImageTwoInputFilter
{
//
// Static Fields
//
[CompilerGenerated]
private static readonly IntPtr class_ptr;
[CompilerGenerated]
private static NSString _ThreeInputTextureVertexShaderString;
//
// Static Properties
//
[Field ("kGPUImageThreeInputTextureVertexShaderString", "__Internal")]
public static NSString ThreeInputTextureVertexShaderString {
get;
}
//
// Properties
//
public override IntPtr ClassHandle {
get;
}
//
// Constructors
//
[Export ("init"), EditorBrowsable (EditorBrowsableState.Advanced), CompilerGenerated]
public GPUImageThreeInputFilter ();
[EditorBrowsable (EditorBrowsableState.Advanced), CompilerGenerated]
protected GPUImageThreeInputFilter (NSObjectFlag t);
[EditorBrowsable (EditorBrowsableState.Advanced), CompilerGenerated]
protected internal GPUImageThreeInputFilter (IntPtr handle);
//
// Methods
//
[Export ("disableThirdFrameCheck"), CompilerGenerated]
public virtual void DisableThirdFrameCheck ();
}
}
I've created a subclass of this:
public class ImageProcess : GPUImageThreeInputFilter
{
public static new NSString ThreeInputTextureVertexShaderString =
((NSString)(" varying highp vec2 textureCoordinate;" +
" varying highp vec2 textureCoordinate2;" +
" varying highp vec2 textureCoordinate3;" +
"" +
" uniform sampler2D inputImageTexture;" +
" uniform sampler2D inputImageTexture2;" +
" uniform sampler2D inputImageTexture3;" +
"" +
" void main()" +
" {" +
" lowp vec4 one = texture2D(inputImageTexture, textureCoordinate);" +
" lowp vec4 two = texture2D(inputImageTexture2, textureCoordinate2);" +
" lowp vec4 three = texture2D(inputImageTexture3, textureCoordinate3);" +
" lowp vec4 out;" +
" float maxone = one.r + one.g + one.b;" +
" float maxtwo = two.r + two.g + two.b;" +
" float maxthree = three.r + three.g + three.b;" +
" if (maxone >= maxtwo && maxone >= maxthree)" +
" {" +
" out.r = one.r;" +
" out.b = one.b;" +
" out.g = one.g;" +
" };" +
" if (maxtwo >= maxone && maxtwo >= maxthree)" +
" {" +
" out.r = two.r;" +
" out.b = two.b;" +
" out.g = two.g;" +
" };" +
" if (maxthree >= maxtwo && maxthree >= maxone)" +
" {" +
" out.r = three.r;" +
" out.b = three.b;" +
" out.g = three.g;" +
" };" +
" out.a = 1.0;" +
" gl_FragColor = out;" +
" }"));
}
Use of the subclass:
var firstFilter = new ImageProcess();
first.AddTarget(firstFilter); // first, second, and third
first.ProcessImage(); // are unique GPUImagePicture
second.AddTarget(firstFilter); // values (pictures) defined
second.ProcessImage(); // somewhere else.
third.AddTarget(firstFilter);
third.ProcessImage();
firstFilter.UseNextFrameForImageCapture();
firstFilter.AddTarget(output); // outputs the end result to
// the screen
The subclass should get the brightest pixels of three images and return an image from that. Instead, it is only returning the first image again because the string is not registering in the subclass.
So, I'm asking, what should a proper subclass of this look like, and where should the NSString
it accepts go? I haven't run across a class like this before. Thanks
Update:
I'm using and repurposing the method found here for now, however all the calls made for a processed color array take about four to five minutes where this would take a few seconds at most, so I will still try to solve this at some point.