예제 #1
0
        public Convolution2d3x3Node()
        {
            title = "3x3 2D Convolution";
            SetSize(new Vector2(224, 132));

            m_Convolution = new Convolution2D <TKernel>(new Kernel2D <TKernel>(3, 3));

            input           = VisionPort.Create <Edge, Image <TImage> >(Orientation.Horizontal, Direction.Input, Port.Capacity.Single);
            input.onUpdate += OnInputUpdate;

            input.portName       = string.Format("Image<{0}>", typeof(TImage).Name);
            input.style.fontSize = 9;

            inputContainer.Add(input);
            inputContainer.style.width = this.style.width / 2;

            output = VisionPort.Create <Edge, Image <TImage> >(Orientation.Horizontal, Direction.Output, Port.Capacity.Multi);

            output.portName       = string.Format("Image<{0}>", typeof(TImage).Name);
            output.style.fontSize = 9;

            outputContainer.Add(output);
            outputContainer.style.width = this.style.width / 2;

            SetupInputFields();
            contentContainer.Add(extensionContainer);
        }
예제 #2
0
        protected ImageMixNode(string titleLabel = "Image Mix")
        {
            SetSize(new Vector2(224, 100 + style.marginTop));
            inputContainer.style.width = 84;

            title = titleLabel;
            var pixelType = typeof(T);

            m_PortLabel = string.Format("Image<{0}>", pixelType.Name);

            input1          = VisionPort.Create <Edge, Image <T> >(Orientation.Horizontal, Direction.Input, Port.Capacity.Single);
            input1.portName = m_PortLabel;

            input2          = VisionPort.Create <Edge, Image <T> >(Orientation.Horizontal, Direction.Input, Port.Capacity.Single);
            input2.portName = m_PortLabel;

            inputContainer.Add(input1);
            inputContainer.Add(input2);

            output = VisionPort.Create <Edge, Image <T> >(Orientation.Horizontal, Direction.Output, Port.Capacity.Multi);

            output.portName                     = m_PortLabel;
            outputContainer.style.width         = 84;
            outputContainer.style.flexDirection = FlexDirection.Row;
            outputContainer.style.alignItems    = Align.Center;

            outputContainer.Add(output);

            titleButtonContainer.style.visibility = Visibility.Hidden;
            RefreshExpandedState();
        }
예제 #3
0
        public Texture2dInputNode()
        {
            SetSize(new Vector2(256, 74 + style.marginTop));
            inputContainer.style.width = 84;

            title  = "Texture Input";
            output = VisionPort.Create <Edge, Image <T> >(Orientation.Horizontal, Direction.Output, Port.Capacity.Multi);

            output.portName = string.Format("Image<{0}>", typeof(T).Name);

            outputContainer.Add(output);

            var objField = TypedObjectField <Texture2D>();

            objField.OnValueChanged(evt =>
            {
                Debug.Log("on texture input value change");
                var texture = (Texture2D)evt.newValue;
                if (texture == null)
                {
                    return;
                }

                m_Texture     = texture;
                m_Image       = new Image <T>(texture);
                output.source = m_Image;
                UpdateData();
            });


            inputContainer.Add(objField);
            titleButtonContainer.style.visibility = Visibility.Hidden;
            RefreshExpandedState();
        }
예제 #4
0
        public Texture2dDisplayNode(Texture2D texture, Rect rect)
        {
            var labelSize   = style.fontSize * 4 + 4;
            var size        = new Vector2(rect.width, rect.height + labelSize);
            var textureSize = new Vector2(rect.width, rect.height);

            SetSize(new Vector2(132, rect.height + 78 + style.marginTop));
            m_Rect          = rect;
            m_Texture       = texture;
            m_RenderTexture = new RenderTexture(m_Texture.width, m_Texture.height, 1, RenderTextureFormat.ARGBFloat);
            m_RenderTexture.enableRandomWrite = true;

            m_DisplayConversionCompute = CommonResources.RFloatToRGBAFloatCompute;

            m_ImGui = new IMGUIContainer(OnGUI);

            m_ImGui.SetSize(textureSize);
            m_ImGui.style.positionType = new StyleValue <PositionType>(PositionType.Relative);

            title           = "Image Preview";
            input           = VisionPort.Create <Edge, Image <T> >(Orientation.Horizontal, Direction.Input, Port.Capacity.Single);
            input.onUpdate += OnInputUpdate;

            input.portName = string.Format("Image<{0}>", typeof(T).Name);
            inputContainer.Add(input);

            extensionContainer.SetSize(textureSize);
            extensionContainer.Add(m_ImGui);
            extensionContainer.style.positionType = PositionType.Relative;
            contentContainer.Add(extensionContainer);
            RefreshExpandedState();
        }
예제 #5
0
        public ConstantPadNode(string titleLabel = "Constant Padding")
        {
            SetSize(new Vector2(224, 100 + style.marginTop));
            inputContainer.style.width = 84;

            // hardcode 1x1 padding for now.  TODO - make this have a UI
            pad = new Padding(1);

            title = titleLabel;
            var pixelType = typeof(T);

            m_ImageDataType = typeof(Image <T>);
            m_PortLabel     = string.Format("Image<{0}>", pixelType.Name);

            input           = VisionPort.Create <Edge, Image <T> >(Orientation.Horizontal, Direction.Input, Port.Capacity.Single);
            input.onUpdate += OnInputUpdate;

            input.portName = m_PortLabel;
            inputContainer.Add(input);

            output = VisionPort.Create <Edge, Image <T> >(Orientation.Horizontal, Direction.Output, Port.Capacity.Multi);

            output.portName                     = m_PortLabel;
            outputContainer.style.width         = 84;
            outputContainer.style.flexDirection = FlexDirection.Row;
            outputContainer.style.alignItems    = Align.Center;

            outputContainer.Add(output);

            var sizeField = new Vector2IntField();
            var sizeLabel = new Label("Pad Size");

            sizeLabel.style.minWidth = 92;

            var sizeContainer = new VisualContainer();

            sizeContainer.style.flexDirection = FlexDirection.Row;
            sizeContainer.style.flexWrap      = Wrap.NoWrap;
            sizeField.style.flexDirection     = FlexDirection.Row;
            sizeField.style.flexWrap          = Wrap.NoWrap;
            sizeField.style.maxWidth          = 128;
            sizeContainer.Add(sizeLabel);
            sizeContainer.Add(sizeField);

            extensionContainer.Add(sizeContainer);

            titleButtonContainer.style.visibility = Visibility.Hidden;
            RefreshExpandedState();
        }
        public Color24ToFloat3Node()
        {
            SetSize(new Vector2(288, 74 + style.marginTop));
            inputContainer.style.width = 84;

            title = "Color24 To Float3";

            input           = VisionPort.Create <Edge, Image <Color24> >(Orientation.Horizontal, Direction.Input, Port.Capacity.Single);
            input.onUpdate += OnInputUpdate;

            input.portName = "Image<Color24>";
            inputContainer.Add(input);

            output = VisionPort.Create <Edge, Image <float3> >(Orientation.Horizontal, Direction.Output, Port.Capacity.Multi);

            output.portName = "Image<float3>";
            outputContainer.Add(output);

            titleButtonContainer.style.visibility = Visibility.Hidden;
            RefreshExpandedState();
        }
        public FormatConversionNode()
        {
            SetSize(new Vector2(288, 74 + style.marginTop));
            inputContainer.style.width = 84;

            var fromType = typeof(TFrom);
            var toType   = typeof(TTo);

            title = string.Format("Convert {0} to {1}", fromType.Name, toType.Name);

            input           = VisionPort.Create <Edge, Image <TFrom> >(Orientation.Horizontal, Direction.Input, Port.Capacity.Single);
            input.onUpdate += OnInputUpdate;

            input.portName = string.Format("Image<{0}>", fromType.Name);
            inputContainer.Add(input);

            output = VisionPort.Create <Edge, Image <TTo> >(Orientation.Horizontal, Direction.Output, Port.Capacity.Multi);

            output.portName = string.Format("Image<{0}>", toType.Name);
            outputContainer.Add(output);

            titleButtonContainer.style.visibility = Visibility.Hidden;
            RefreshExpandedState();
        }
        public PreConvolutionPadNode(string titleLabel = "Pre-Convolution Padding")
        {
            SetSize(new Vector2(224, 100 + style.marginTop));
            inputContainer.style.width = 84;

            title = titleLabel;
            var pixelType = typeof(T);

            m_ImageDataType = typeof(Image <T>);
            m_PortLabel     = string.Format("Image<{0}>", pixelType.Name);

            var input1 = VisionPort.Create <Edge>(Orientation.Horizontal, Direction.Input, Port.Capacity.Single,
                                                  m_ImageDataType);

            input1.portName = m_PortLabel;

            inputContainer.Add(input1);

            output = VisionPort.Create <Edge>(Orientation.Horizontal, Direction.Output, Port.Capacity.Multi,
                                              m_ImageDataType);

            output.portName                     = m_PortLabel;
            outputContainer.style.width         = 84;
            outputContainer.style.flexDirection = FlexDirection.Row;
            outputContainer.style.alignItems    = Align.Center;

            outputContainer.Add(output);

            var modeField = new EnumField(ConvolutionPadMode.Same);
            var sizeField = new Vector2IntField();
            var sizeLabel = new Label("Convolution Size");

            sizeLabel.style.minWidth = 92;


            var modeContainer = new VisualContainer();

            modeContainer.style.flexDirection = FlexDirection.Row;
            modeContainer.style.flexWrap      = Wrap.NoWrap;

            /*
             * var sizeContainer = new VisualContainer();
             * sizeContainer.style.flexDirection = FlexDirection.Row;
             * sizeContainer.style.flexWrap = Wrap.NoWrap;
             * sizeField.style.flexDirection = FlexDirection.Row;
             * sizeField.style.flexWrap = Wrap.NoWrap;
             * sizeField.style.maxWidth = 128;
             * sizeContainer.Add(sizeLabel);
             * sizeContainer.Add(sizeField);
             */

            modeField.style.minWidth = 64;
            var padLabel = new Label("Pad Mode");

            padLabel.style.minWidth = 96;
            modeContainer.Add(padLabel);
            modeContainer.Add(modeField);

            //extensionContainer.Add(sizeContainer);
            extensionContainer.Add(modeContainer);

            titleButtonContainer.style.visibility = Visibility.Hidden;
            RefreshExpandedState();
        }