// Start is called before the first frame update void Awake() { pipe = OeipManager.Instance.CreatePipe <OeipPipe3D>(OeipGpgpuType.OEIP_CUDA); InputIndex = pipe.AddLayer("input", OeipLayerType.OEIP_INPUT_LAYER); int mapIndex = pipe.AddLayer("map", OeipLayerType.OEIP_MAPCHANNEL_LAYER); int r2y = pipe.AddLayer("rgba2yuv", OeipLayerType.OEIP_RGBA2YUV_LAYER); OutputIndex = pipe.AddLayer("output", OeipLayerType.OEIP_OUTPUT_LAYER); InputParamet input = new InputParamet(); input.bCpu = 0; input.bGpu = 1; pipe.UpdateParamet(InputIndex, input); if (pipe.GpgpuType == OeipGpgpuType.OEIP_CUDA) { MapChannelParamet mp = new MapChannelParamet(); mp.blue = 0; mp.green = 1; mp.red = 2; mp.alpha = 3; pipe.UpdateParamet(mapIndex, mp); } RGBA2YUVParamet rp = new RGBA2YUVParamet(); rp.yuvType = yUVFMT; pipe.UpdateParamet(r2y, rp); OutputParamet op = new OutputParamet(); op.bCpu = 1; op.bGpu = 0; pipe.UpdateParamet(OutputIndex, op); }
public void SetOutput(bool bCpu = false, bool bGpu = true) { //返回CPU还是GPU数据 IsCpu = bCpu; IsGpu = bGpu; OutputParamet outputParamet = new OutputParamet(); outputParamet.bGpu = bGpu ? 1 : 0; outputParamet.bCpu = bCpu ? 1 : 0; Pipe.UpdateParamet(OutIndex, outputParamet); }
public OeipLivePipe(OeipPipe pipe) { this.Pipe = pipe; //添加输入层 InputIndex = pipe.AddLayer("input", OeipLayerType.OEIP_INPUT_LAYER); Yuv2Rgba = pipe.AddLayer("yuv2rgba", OeipLayerType.OEIP_YUV2RGBA_LAYER); OutIndex = pipe.AddLayer("out put", OeipLayerType.OEIP_OUTPUT_LAYER); OutputParamet outputParamet = new OutputParamet(); outputParamet.bGpu = IsGpu ? 1 : 0; outputParamet.bCpu = 1; pipe.UpdateParamet(OutIndex, outputParamet); }
public OeipVideoPipe(OeipPipe pipe) { this.Pipe = pipe; //添加输入层 InputIndex = pipe.AddLayer("input", OeipLayerType.OEIP_INPUT_LAYER); //如果输入格式是YUV Yuv2Rgba = pipe.AddLayer("yuv2rgba", OeipLayerType.OEIP_YUV2RGBA_LAYER); //如果输入格式是BGR MapChannel = pipe.AddLayer("map channel", OeipLayerType.OEIP_MAPCHANNEL_LAYER); //mapChannel与yuv2rgba同级 pipe.ConnectLayer(MapChannel, InputIndex); //经过大小变化 //ResizeIndex = pipe.AddLayer("resize", OeipLayerType.OEIP_RESIZE_LAYER); //ResizeParamet rp = new ResizeParamet(); //rp.width = 1920; //rp.height = 1080; //pipe.UpdateParamet(ResizeIndex, rp); //如果显示格式要求BRG OutMap = pipe.AddLayer("out map channel", OeipLayerType.OEIP_MAPCHANNEL_LAYER); //输出层 OutIndex = pipe.AddLayer("out put", OeipLayerType.OEIP_OUTPUT_LAYER); SetOutput(IsGpu, IsCpu); OutputParamet outputParamet = new OutputParamet(); //输出YUV格式,为了推出流 Rgba2Yuv = pipe.AddLayer("rgba2yuv", OeipLayerType.OEIP_RGBA2YUV_LAYER); RGBA2YUVParamet yuvParamet = new RGBA2YUVParamet(); yuvParamet.yuvType = YUVFMT; Pipe.UpdateParamet(Rgba2Yuv, yuvParamet); //输出第二个流,YUV流,用于推送数据 pipe.ConnectLayer(Rgba2Yuv, OutMap); OutYuvIndex = pipe.AddLayer("out put yuv", OeipLayerType.OEIP_OUTPUT_LAYER); outputParamet.bGpu = 0; outputParamet.bCpu = 1; Pipe.UpdateParamet(OutYuvIndex, outputParamet); InputParamet input = new InputParamet(); input.bCpu = 1; input.bGpu = 0; Pipe.UpdateParamet(InputIndex, input); if (pipe.GpgpuType == OeipGpgpuType.OEIP_DX11) { int yuv2rgba2 = pipe.AddLayer("yuv2rgba 2", OeipLayerType.OEIP_YUV2RGBA_LAYER); YUV2RGBAParamet yparamet = new YUV2RGBAParamet(); yparamet.yuvType = YUVFMT; Pipe.UpdateParamet(yuv2rgba2, yparamet); MattingOutIndex = pipe.AddLayer("matting out put", OeipLayerType.OEIP_OUTPUT_LAYER); outputParamet.bGpu = 1; outputParamet.bCpu = 0; Pipe.UpdateParamet(MattingOutIndex, outputParamet); } if (pipe.GpgpuType == OeipGpgpuType.OEIP_CUDA) { //神经网络层 DarknetIndex = pipe.AddLayer("darknet", OeipLayerType.OEIP_DARKNET_LAYER); pipe.ConnectLayer(DarknetIndex, OutMap); darknetParamet.bLoad = 1; darknetParamet.confile = "../../ThirdParty/yolov3-tiny-test.cfg"; darknetParamet.weightfile = "../../ThirdParty/yolov3-tiny_745000.weights"; darknetParamet.thresh = 0.3f; darknetParamet.nms = 0.3f; darknetParamet.bDraw = 1; darknetParamet.drawColor = OeipHelper.getColor(0.1f, 1.0f, 0.1f, 0.1f); Pipe.UpdateParametStruct(DarknetIndex, darknetParamet); //Grab cut扣像层 GrabcutIndex = pipe.AddLayer("grab cut", OeipLayerType.OEIP_GRABCUT_LAYER); grabcutParamet.bDrawSeed = 0; grabcutParamet.iterCount = 1; grabcutParamet.seedCount = 1000; grabcutParamet.count = 250; grabcutParamet.gamma = 90.0f; grabcutParamet.lambda = 450.0f; grabcutParamet.rect = new OeipRect(); Pipe.UpdateParamet(GrabcutIndex, grabcutParamet); //GuiderFilter GuiderFilterIndex = pipe.AddLayer("guider filter", OeipLayerType.OEIP_GUIDEDFILTER_LAYER); guidedFilterParamet.zoom = 8; guidedFilterParamet.softness = 5; guidedFilterParamet.eps = 0.000001f; guidedFilterParamet.intensity = 0.2f; Pipe.UpdateParamet(GuiderFilterIndex, guidedFilterParamet); //输出第三个流,网络处理层流 MattingOutIndex = pipe.AddLayer("matting out put", OeipLayerType.OEIP_OUTPUT_LAYER); outputParamet.bGpu = 1; outputParamet.bCpu = 0; Pipe.UpdateParamet(MattingOutIndex, outputParamet); } }