Beispiel #1
0
 private void OnLoadNet()
 {
     darknetParamet.bLoad      = 1;
     darknetParamet.confile    = Path.GetFullPath(Path.Combine(Application.dataPath, "../../ThirdParty/yolov3-tiny-test.cfg"));
     darknetParamet.weightfile = Path.GetFullPath(Path.Combine(Application.dataPath, "../../ThirdParty/yolov3-tiny_745000.weights"));
     darknetParamet.thresh     = 0.3f;
     darknetParamet.nms        = 0.3f;
     darknetParamet.bDraw      = 1;
     darknetParamet.drawColor  = OeipHelper.getColor(1.0f, 0.1f, 0.1f, 0.8f);
     Loom.RunAsync(() =>
     {
         cameraView.VideoPipe.UpdateDarknetParamet(ref darknetParamet);
     });
 }
Beispiel #2
0
 // Start is called before the first frame update
 void Start()
 {
     setting = SettingManager.Instance.Setting;
     OeipManager.Instance.OnLogEvent += Instance_OnLogEvent;
     //绑定Camera UI
     objBindCamera.Bind(setting.cameraSetting, cameraSelectPanel);
     objBindCamera.GetComponent <DropdownComponent>("CameraIndex").SetFillOptions(true, OeipManagerU3D.Instance.GetCameras);
     objBindCamera.GetComponent <DropdownComponent>("FormatIndex").SetFillOptions(true, OeipManagerU3D.Instance.GetFormats);
     objBindCamera.OnChangeEvent += ObjBindCamera_OnChangeEvent;
     //cameraView管线返回设置
     cameraView.VideoPipe.Pipe.OnProcessEvent += Pipe_OnProcessEvent;
     //绑定GrabCut设置
     objBindGrabcut.Bind(setting.videoParamet, grabCutPanel);
     cameraView.VideoPipe.UpdateVideoParamet(setting.videoParamet);
     objBindGrabcut.OnChangeEvent += ObjBindGrabcut_OnChangeEvent;
     //加载神经网络
     btnLoadNet.onClick.AddListener(() =>
     {
         Loom.RunAsync(() =>
         {
             darknetParamet.bLoad      = 1;
             darknetParamet.confile    = Path.GetFullPath(Path.Combine(Application.dataPath, "../../ThirdParty/yolov3-tiny-test.cfg"));
             darknetParamet.weightfile = Path.GetFullPath(Path.Combine(Application.dataPath, "../../ThirdParty/yolov3-tiny_745000.weights"));
             darknetParamet.thresh     = 0.3f;
             darknetParamet.nms        = 0.3f;
             darknetParamet.bDraw      = 1;
             darknetParamet.drawColor  = OeipHelper.getColor(1.0f, 0.1f, 0.1f, 0.8f);
             cameraView.VideoPipe.UpdateDarknetParamet(ref darknetParamet);
         });
     });
     //Grabcut 扣像
     btnGrabcut.onClick.AddListener(() =>
     {
         Loom.RunAsync(() =>
         {
             bDrawMode     = !bDrawMode;
             OeipRect rect = new OeipRect();
             if (personBox != null && personBox.Length > 0)
             {
                 rect = personBox[0].rect;
             }
             cameraView.VideoPipe.ChangeGrabcutMode(bDrawMode, ref rect);
         });
     });
 }
Beispiel #3
0
        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);
            }
        }