gpt4 book ai didi

这个基类的 C# 子类?

转载 作者:行者123 更新时间:2023-11-30 18:16:42 25 4
gpt4 key购买 nike

Xamarin.ios 的这个组件 GPUImage 最初位于 objective-c 中,现在使用绑定(bind)在 C# 中工作。

我似乎无法获得其中一个类 GPUImageThreeInputFilter 的工作子类,它应该接受一个字符串,然后将其作为 glsl 进行处理。 这是类的样子:

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 ();
}
}

我已经创建了这个的子类:

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;" +
" }"));
}

子类的使用:

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

子类应该获取三个图像中最亮的像素并从中返回一个图像。相反,它仅再次返回第一张图像,因为该字符串未在子类中注册。

所以,我想问的是,它的适当子类应该是什么样的,它接受的 NSString 应该放在哪里?我以前没有遇到过这样的类(class)。谢谢

更新:

我正在使用并重新利用找到的方法 here目前,所有针对处理过的颜色数组的调用大约需要四到五分钟,而这最多需要几秒钟,所以我仍然会在某个时候尝试解决这个问题。

最佳答案

您的自定义类“GPUImageThreeInputFilter”已派生来自基类 GPUImageTwoInputFilter

这是你的意图吗?也许您应该以不同的方式命名您的自定义类,并使其继承自 GPUImageThreeInputFilter 类。

关于这个基类的 C# 子类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45951321/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com