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 BlendViewPipe(OeipPipe pipe) { this.Pipe = pipe; InputMain = pipe.AddLayer("input main", OeipLayerType.OEIP_INPUT_LAYER); InputAux = pipe.AddLayer("input aux", OeipLayerType.OEIP_INPUT_LAYER); BlendIndex = pipe.AddLayer("blend", OeipLayerType.OEIP_BLEND_LAYER); OutGpuIndex = pipe.AddLayer("out tex", OeipLayerType.OEIP_OUTPUT_LAYER); int rgb2Yuv = pipe.AddLayer("rgba2yuv", OeipLayerType.OEIP_RGBA2YUV_LAYER); OutYuvIndex = pipe.AddLayer("out yuv tex", OeipLayerType.OEIP_OUTPUT_LAYER); pipe.ConnectLayer(BlendIndex, InputMain, 0, 0); pipe.ConnectLayer(BlendIndex, InputAux, 0, 1); //混合显示的位置 blendParamet.rect.centerX = 0.7f; blendParamet.rect.centerY = 0.7f; blendParamet.rect.width = 0.5f; blendParamet.rect.height = 0.5f; blendParamet.opacity = 0.0f; pipe.UpdateParamet(BlendIndex, blendParamet); //要求输入的是显存数据 InputParamet inParamet = new InputParamet(); inParamet.bGpu = 1; inParamet.bCpu = 0; pipe.UpdateParamet(InputMain, inParamet); pipe.UpdateParamet(InputAux, inParamet); RGBA2YUVParamet yuvParamet = new RGBA2YUVParamet(); yuvParamet.yuvType = YUVFMT; Pipe.UpdateParamet(rgb2Yuv, yuvParamet); }
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); } }