Beispiel #1
0
        static void Main()
        {
            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
            Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";runtimes/win10-x64/"); //only needed if projects are directly referenced

            //var reader = new CameraCapture(0); //capture from camera
            var reader = new FileCapture(Path.Combine(getResourceDir(), "Welcome.mp4"));

            reader.Open();

            var writer = new VideoWriter(@"output.avi", reader.FrameSize, /*reader.FrameRate does not work Cameras*/ 30); //TODO: bug: FPS does not work for cameras

            writer.Open();

            Bgr <byte>[,] frame = null;
            do
            {
                reader.ReadTo(ref frame);
                if (frame == null)
                {
                    break;
                }

                using (var uFrame = frame.Lock())
                { writer.Write(uFrame); }

                frame.Show(autoSize: true);
            }while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape));

            reader.Dispose();
            writer.Dispose();

            ImageUI.CloseAll();
        }
Beispiel #2
0
        static void Main()
        {
            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
            Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";runtimes/win10-x64/"); //only needed if projects are directly referenced

            Console.WriteLine("Press ESC to stop playing");

            //var reader = new CameraCapture(0); //capture from camera
            //(reader as CameraCapture).FrameSize = new Size(640, 480);

            var reader = new FileCapture(Path.Combine(getResourceDir(), "Welcome.mp4")); //capture from video

            //var reader = new ImageDirectoryCapture(Path.Combine(getResourceDir(), "Sequence"), "*.jpg");
            reader.Open();

            Bgr <byte>[,] frame = null;
            do
            {
                reader.ReadTo(ref frame);
                if (frame == null)
                {
                    break;
                }

                frame.Show(autoSize: true);
            }while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape));

            reader.Dispose();
            ImageUI.CloseAll();
        }
Beispiel #3
0
 /// <summary>
 /// Unsubscribe function for the image UI element.
 /// </summary>
 /// <param name="imageUI">Image UI Element</param>
 public void UnsubscribeImageUI(MobileUI imageUI)
 {
     //only the interface that subscribed can unsubscribe
     if (imageUI == this.imageManagerReference)
     {
         imageManagerReference = null;
     }
 }
        public RenderPreviewUI()
        {
            imageUI = new ImageUI {
                KeepAspect = false
            };

            Add(imageUI);
        }
Beispiel #5
0
        public static ImageUI NewImageUI(Texture2D texture, Vector2 scale, string name = UIBaser.UIDefaultName, string desctiption = "")
        {
            ImageUI image = new ImageUI(texture, scale)
            {
                Name        = name,
                Description = desctiption
            };

            return(image);
        }
Beispiel #6
0
        public static ImageUI NewImageUI(string name = UIBaser.UIDefaultName, string desctiption = "")
        {
            ImageUI image = new ImageUI()
            {
                Name        = name,
                Description = desctiption
            };

            return(image);
        }
Beispiel #7
0
        /// <summary>
        /// Info String drawn at the bottom of the Preview
        /// </summary>

        public override string GetInfoString()
        {
            ImageUI image  = target as ImageUI;
            Sprite  sprite = image.sprite;

            int x = (sprite != null) ? Mathf.RoundToInt(sprite.rect.width) : 0;
            int y = (sprite != null) ? Mathf.RoundToInt(sprite.rect.height) : 0;

            return(string.Format("Image Size: {0}x{1}", x, y));
        }
Beispiel #8
0
 // Start is called before the first frame update
 void Start()
 {
     shotsRemaining = maxShots;
     rhinosInLevel  = GameObject.FindGameObjectsWithTag("CagedRhinos").Length;
     rhinosSaved    = 0;
     ImageUI[] stuff = GetComponents <ImageUI>();
     rhinos         = stuff[0];
     shots          = stuff[1];
     rhinos.max     = rhinosInLevel;
     rhinos.current = 0;
     shots.max      = maxShots;
     shots.current  = shotsRemaining;
 }
Beispiel #9
0
        private static void extractVideo(string fileName)
        {
            //get output dir (same as file name and in the same folder as video)
            var    fileInfo      = new FileInfo(fileName);
            var    fileNameNoExt = fileInfo.Name.Replace(fileInfo.Extension, String.Empty);
            string outputDir     = Path.Combine(fileInfo.DirectoryName, fileNameNoExt);

            //open video
            var reader = new FileCapture(fileName);

            reader.Open();

            reader.SaveFrames(outputDir, "{0}.jpg", p => Console.Write($"\rExtracting: {(int)(p * 100)} %"));
            ImageUI.CloseAll();
        }
Beispiel #10
0
        public static void Main()
        {
            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
            Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";runtimes/win10-x64/"); //only needed if projects are directly referenced


            var sourceName = String.Empty;

            //video over pipe (direct link and Youtube) (do not support seek)
            //var pipeName = new Uri("http://trailers.divx.com/divx_prod/divx_plus_hd_showcase/BigBuckBunny_DivX_HD720p_ASP.divx").NamedPipeFromVideoUri(); //web-video
            var pipeName = new Uri("https://www.youtube.com/watch?v=Vpg9yizPP_g").NamedPipeFromYoutubeUri(); //Youtube
            sourceName = String.Format(@"\\.\pipe\{0}", pipeName);

            //video http link (Supports seek)
            //sourceName = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4";

            //---------------------------------------------
            ImageStreamReader reader = new FileCapture(sourceName);
            reader.Open();

            //seek if you can
            if(reader.CanSeek)
                reader.Seek((int)(reader.Length * 0.25), System.IO.SeekOrigin.Begin);

            //read video frames
            Bgr<byte>[,] frame = null;
            while(true)
            {
                reader.ReadTo(ref frame);
                if (frame == null)
                    break;

                frame.Show(autoSize: false);
                Console.Write($"\r Received: {reader.Position * 100 / reader.Length}%");
            }
            Console.WriteLine("The end.");

            //---------------------------------------------------------------------------
            ImageUI.CloseAll();
            Console.WriteLine("Downloading video...");

            string fileExtension;
            var downloadPipeName = new Uri("https://www.youtube.com/watch?v=Vpg9yizPP_g").NamedPipeFromYoutubeUri(out fileExtension); //Youtube

            downloadPipeName.SaveNamedPipeStream("out" + fileExtension);
            Console.WriteLine("Video saved.");
            Process.Start("out" + fileExtension); //open local file
        }
Beispiel #11
0
        static void Main()
        {
            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
            Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";runtimes/win10-x64/"); //only needed if projects are directly referenced

            Console.WriteLine("Press ESC to stop playing");

            List <CameraCapture> captures = new List <CameraCapture>();

            var cameraCount = CameraCapture.CameraCount;

            if (cameraCount == 0)
            {
                Console.WriteLine("No camera device is present.");
                return;
            }

            //initialize
            for (int camIdx = 0; camIdx < cameraCount; camIdx++)
            {
                var cap = new CameraCapture(camIdx);
                cap.Open();

                captures.Add(cap);
            }

            //grab frames
            Bgr <byte>[][,] frames = new Bgr <byte> [cameraCount][, ];
            do
            {
                for (int camIdx = 0; camIdx < cameraCount; camIdx++)
                {
                    captures[camIdx].ReadTo(ref frames[camIdx]);
                    if (frames[camIdx] == null)
                    {
                        break;
                    }

                    frames[camIdx].Show(String.Format("Camera {0}", camIdx), autoSize: true);
                }
            }while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape));

            //dispose
            captures.ForEach(x => x.Dispose());
            ImageUI.CloseAll();
        }
Beispiel #12
0
        /// <summary>
        /// Draw the Image preview.
        /// </summary>

        public override void OnPreviewGUI(Rect rect, GUIStyle background)
        {
            ImageUI image = target as ImageUI;

            if (image == null)
            {
                return;
            }

            Sprite sf = image.sprite;

            if (sf == null)
            {
                return;
            }

            SpriteDrawUtility.DrawSprite(sf, rect, image.canvasRenderer.GetColor());
        }
Beispiel #13
0
        protected override void OnEnable()
        {
            base.OnEnable();

            image = target as ImageUI;

            //m_SpriteContent = EditorGUIUtility.IconContent("Source Image");
            //m_SpriteTypeContent = EditorGUIUtility.IconContent("Image Type");
            //m_ClockwiseContent = EditorGUIUtility.IconContent("Clockwise");

            m_Sprite         = serializedObject.FindProperty("m_Sprite");
            m_Type           = serializedObject.FindProperty("m_Type");
            m_FillCenter     = serializedObject.FindProperty("m_FillCenter");
            m_FillMethod     = serializedObject.FindProperty("m_FillMethod");
            m_FillOrigin     = serializedObject.FindProperty("m_FillOrigin");
            m_FillClockwise  = serializedObject.FindProperty("m_FillClockwise");
            m_FillAmount     = serializedObject.FindProperty("m_FillAmount");
            m_PreserveAspect = serializedObject.FindProperty("m_PreserveAspect");

            m_ShowType = new AnimBool(m_Sprite.objectReferenceValue != null);
            m_ShowType.valueChanged.AddListener(Repaint);

            var typeEnum = (ImageUI.Type)m_Type.enumValueIndex;

            m_ShowSlicedOrTiled = new AnimBool(!m_Type.hasMultipleDifferentValues && typeEnum == ImageUI.Type.Sliced);
            m_ShowSliced        = new AnimBool(!m_Type.hasMultipleDifferentValues && typeEnum == ImageUI.Type.Sliced);
            m_ShowTiled         = new AnimBool(!m_Type.hasMultipleDifferentValues && typeEnum == ImageUI.Type.Tiled);
            m_ShowFilled        = new AnimBool(!m_Type.hasMultipleDifferentValues && typeEnum == ImageUI.Type.Filled);
            m_ShowSlicedOrTiled.valueChanged.AddListener(Repaint);
            m_ShowSliced.valueChanged.AddListener(Repaint);
            m_ShowTiled.valueChanged.AddListener(Repaint);
            m_ShowFilled.valueChanged.AddListener(Repaint);

            m_AlphaHitTestMinimumThreshold = serializedObject.FindProperty("m_AlphaHitTestMinimumThreshold");

            SetShowNativeSize(true);
        }
Beispiel #14
0
        public App()
        {
            InitializeComponent();

            MainPage = new ImageUI();
        }
Beispiel #15
0
 /// <summary>
 /// Subscribe function for the image UI element.
 /// </summary>
 /// <param name="imageUI">Image UI Element</param>
 public void SubscribeImageUI(ImageUI imageUI)
 {
     this.imageManagerReference = imageUI;
 }
Beispiel #16
0
        /// <summary>
        /// Sprites's custom properties based on the type.
        /// </summary>

        protected void TypeGUI()
        {
            EditorGUILayout.PropertyField(m_Type);

            ++EditorGUI.indentLevel;
            {
                ImageUI.Type typeEnum = (ImageUI.Type)m_Type.enumValueIndex;

                bool showSlicedOrTiled = (!m_Type.hasMultipleDifferentValues && (typeEnum == ImageUI.Type.Sliced || typeEnum == ImageUI.Type.Tiled));
                if (showSlicedOrTiled && targets.Length > 1)
                {
                    showSlicedOrTiled = targets.Select(obj => obj as ImageUI).All(img => img.hasBorder);
                }

                m_ShowSlicedOrTiled.target = showSlicedOrTiled;
                m_ShowSliced.target        = (showSlicedOrTiled && !m_Type.hasMultipleDifferentValues && typeEnum == ImageUI.Type.Sliced);
                m_ShowTiled.target         = (showSlicedOrTiled && !m_Type.hasMultipleDifferentValues && typeEnum == ImageUI.Type.Tiled);
                m_ShowFilled.target        = (!m_Type.hasMultipleDifferentValues && typeEnum == ImageUI.Type.Filled);

                ImageUI image = target as ImageUI;
                if (EditorGUILayout.BeginFadeGroup(m_ShowSlicedOrTiled.faded))
                {
                    if (image.hasBorder)
                    {
                        EditorGUILayout.PropertyField(m_FillCenter);
                    }
                }
                EditorGUILayout.EndFadeGroup();

                if (EditorGUILayout.BeginFadeGroup(m_ShowSliced.faded))
                {
                    if (image.sprite != null && !image.hasBorder)
                    {
                        EditorGUILayout.HelpBox("This Image doesn't have a border.", MessageType.Warning);
                    }
                }
                EditorGUILayout.EndFadeGroup();

                if (EditorGUILayout.BeginFadeGroup(m_ShowTiled.faded))
                {
                    if (image.sprite != null && !image.hasBorder && (image.sprite.texture.wrapMode != TextureWrapMode.Repeat || image.sprite.packed))
                    {
                        EditorGUILayout.HelpBox("It looks like you want to tile a sprite with no border. It would be more efficient to modify the Sprite properties, clear the Packing tag and set the Wrap mode to Repeat.", MessageType.Warning);
                    }
                }
                EditorGUILayout.EndFadeGroup();

                if (EditorGUILayout.BeginFadeGroup(m_ShowFilled.faded))
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(m_FillMethod);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_FillOrigin.intValue = 0;
                    }
                    switch ((ImageUI.FillMethod)m_FillMethod.enumValueIndex)
                    {
                    case ImageUI.FillMethod.Horizontal:
                        m_FillOrigin.intValue = (int)(ImageUI.OriginHorizontal)EditorGUILayout.EnumPopup("Fill Origin", (ImageUI.OriginHorizontal)m_FillOrigin.intValue);
                        break;

                    case ImageUI.FillMethod.Vertical:
                        m_FillOrigin.intValue = (int)(ImageUI.OriginVertical)EditorGUILayout.EnumPopup("Fill Origin", (ImageUI.OriginVertical)m_FillOrigin.intValue);
                        break;

                    case ImageUI.FillMethod.Radial90:
                        m_FillOrigin.intValue = (int)(ImageUI.Origin90)EditorGUILayout.EnumPopup("Fill Origin", (ImageUI.Origin90)m_FillOrigin.intValue);
                        break;

                    case ImageUI.FillMethod.Radial180:
                        m_FillOrigin.intValue = (int)(ImageUI.Origin180)EditorGUILayout.EnumPopup("Fill Origin", (ImageUI.Origin180)m_FillOrigin.intValue);
                        break;

                    case ImageUI.FillMethod.Radial360:
                        m_FillOrigin.intValue = (int)(ImageUI.Origin360)EditorGUILayout.EnumPopup("Fill Origin", (ImageUI.Origin360)m_FillOrigin.intValue);
                        break;
                    }
                    EditorGUILayout.PropertyField(m_FillAmount);
                    if ((ImageUI.FillMethod)m_FillMethod.enumValueIndex > ImageUI.FillMethod.Vertical)
                    {
                        EditorGUILayout.PropertyField(m_FillClockwise);
                    }
                }
                EditorGUILayout.EndFadeGroup();
            }
            --EditorGUI.indentLevel;
        }