示例#1
0
    void ClipGUI(TreeViewItem <VideoDataTreeElement> item)
    {
        TrainActionLabel d = item.data.occurences[0];

        GUILayout.Label("Clip item", EditorStyles.boldLabel);
        GUILayout.BeginVertical();
        NamedLabel("Video id", d.video_id);
        NamedLabel("Narration", d.narration);
        NamedLabel("Start frame", d.start_frame.ToString());
        NamedLabel("Stop frame", d.stop_frame.ToString());
        NamedLabel("Duration", string.Format("{0:0.##} seconds", ((float)(d.stop_frame - d.start_frame) / 30f)));
        if (GUILayout.Button("Play Clip"))
        {
            VideoPlayerWindow.GetWindow <VideoPlayerWindow>().PlayClip(d);
        }
        GUILayout.EndVertical();
    }
示例#2
0
    void Start()
    {
        manager = FindObjectOfType <GameManager>();
        source  = GetComponent <AudioSource>();

        List <TrainActionLabel> actions = TrainActionLabel.RetrieveFromDataset(dataset.text);


        narrationStrings         = new List <string>();
        videoDictionary          = new Dictionary <string, List <VideoData> >();
        player.prepareCompleted += (x) => {
            PreparationComplete();
        };

        int count = 0;

        foreach (TrainActionLabel act in actions)
        {
            if (!narrationStrings.Contains(act.narration))
            {
                narrationStrings.Add(act.narration);
            }

            VideoData data = new VideoData();
            data.video_id   = act.video_id;
            data.start_time = act.start_frame / 60.0;
            data.stop_time  = act.stop_frame / 60.0;
            data.unique_id  = count;
            data.narration  = act.narration.ToLower().Trim();
            count++;

            if (act.narration == act.verb || act.verb == "video" || act.noun == "video" || act.narration.Contains("video") || act.narration.Contains("recording"))
            {
                // Debug.Log("SKIPPED " + act.narration);
            }
            else
            {
                if (!videoDictionary.ContainsKey(data.narration))
                {
                    videoDictionary[data.narration] = new List <VideoData>();
                }

                videoDictionary[data.narration].Add(data);
            }
        }
    }
    public void PlayClip(TrainActionLabel d)
    {
        if (!isInit)
        {
            Init();
        }

        string path = Application.streamingAssetsPath + "/processed" + d.video_id + "_compressed_sobel_bw.mp4";

        if (!System.IO.File.Exists(path))
        {
            path = "http://psycho.sandgardeners.com/kitchen/processed" + d.video_id + "_compressed_sobel_bw.mp4";
        }
        current    = d;
        player.url = path;
        player.Play();
        targetFrame  = d.stop_frame;
        player.frame = d.start_frame;
    }
示例#4
0
    public static List <TrainActionLabel> TALFromText(string text)
    {
        List <TrainActionLabel> results = new List <TrainActionLabel>();

        string[] rows = text.Split('\n');
        foreach (string r in rows)
        {
            string[]         datas = r.Split(',');
            TrainActionLabel tal   = new TrainActionLabel();
            tal.video_id    = datas[0];
            tal.narration   = datas[1];
            tal.start_frame = int.Parse(datas[2]);
            tal.stop_frame  = int.Parse(datas[3]);
            tal.verb        = datas[4];
            tal.verb_class  = int.Parse(datas[5]);
            tal.noun        = datas[6];
            tal.noun_class  = int.Parse(datas[7]);
            results.Add(tal);
        }
        return(results);
    }
    void OnGUI()
    {
        if (!isInit)
        {
            Init();
        }
        else
        {
            GUILayout.BeginArea(new Rect(20, 10, position.width - 20, 80));
            if (current != null)
            {
                GUILayout.Label("Currently playing : " + current.video_id);
            }
            else
            {
                GUILayout.Label("None playing");
            }
            GUILayout.EndArea();

            EditorGUI.DrawPreviewTexture(new Rect(0, 90, Mathf.Min(position.width, 1280), Mathf.Min(position.height, 1080)), texture, null, ScaleMode.ScaleToFit);
            if (player != null && player.frame >= targetFrame)
            {
                player.Stop();
                if (multipleClips && clipIndex < currentClips.Count)
                {
                    PlayClip(currentClips[clipIndex++]);
                }
                else
                {
                    current = null;
                    texture.Release();
                }
            }
            Repaint();
        }
    }
示例#6
0
    void CellGUI(Rect cellRect, UnityEditor.TreeViewExamples.TreeViewItem <VideoDataTreeElement> item, MyColumns column, ref RowGUIArgs args)
    {
        // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
        CenterRectUsingSingleLineHeight(ref cellRect);

        switch (column)
        {
        case MyColumns.Narration:
        {
            args.rowRect = cellRect;
            base.RowGUI(args);
        }
        break;

        case MyColumns.Verb:
        {
            string value = item.data.display_verb;
            if (item.depth == 0 && showControls)
            {
                value = "";
            }
            DefaultGUI.LabelRightAligned(cellRect, value, args.selected, args.focused);

            break;
        }

        case MyColumns.Noun:
        {
            string value = item.data.display_noun;
            if (item.depth == 0 && showControls)
            {
                value = "";
            }
            DefaultGUI.LabelRightAligned(cellRect, value, args.selected, args.focused);
            break;
        }

        case MyColumns.Occurences:
        {
            int    occurences = item.data.display_occurences_count;
            string value;
            if (occurences == -1)
            {
                TrainActionLabel v = item.data.occurences[0];
                value = string.Format("{0:0.##} seconds", ((float)(v.stop_frame - v.start_frame) / 30f));
            }
            else
            {
                value = occurences.ToString();
            }

            DefaultGUI.LabelRightAligned(cellRect, value, args.selected, args.focused);
        }
        break;

        case MyColumns.PlayVideo:
        {
            if (item.depth == 2)
            {
                if (GUI.Button(cellRect, "Play"))
                {
                    VideoPlayerWindow.GetWindow <VideoPlayerWindow>().PlayClip(item.data.occurences[0]);
                }
            }
        }
        break;
        }
    }