public PrimaryVideoStreamInfo(MemoryStream ms) : base(StreamType.PrimaryVideo)
        {
            readStreamAttribute(ms);

            //StreamAttribute
            byte[]       attributeBuffer = ms.ReadFixedLengthByteArray(ms.ReadInt8());
            MemoryStream ms2             = new MemoryStream(attributeBuffer);

            VideoCodec = (StreamModel.VideoCodec)ms2.ReadInt8();
            int value = ms2.ReadInt8();

            VideoResolution = (VideoResolution)(value >> 4);
            FrameRate frameRate = (FrameRate)(value & 0x0f);

            switch (frameRate)
            {
            case StreamModel.FrameRate._23_076: FrameRate = 23.976; break;

            case StreamModel.FrameRate._24: FrameRate = 24; break;

            case StreamModel.FrameRate._25: FrameRate = 25; break;

            case StreamModel.FrameRate._29_976: FrameRate = 29.976; break;

            case StreamModel.FrameRate._50: FrameRate = 50; break;

            case StreamModel.FrameRate._59_94: FrameRate = 59.94; break;

            default: throw new NotImplementedException(frameRate.ToString());
            }
            ms2.Position += 3;
        }
Example #2
0
        public void InitVideoCapture(int videoDeviceID, FrameRate framerate, Resolution resolution,
                                     ImageFormat format, bool grayscale)
        {
            if (cameraInitialized)
            {
                return;
            }

            this.resolution    = resolution;
            this.grayscale     = grayscale;
            this.frameRate     = framerate;
            this.videoDeviceID = videoDeviceID;
            this.format        = format;

            ColorImageFormat colorFormat = ColorImageFormat.Undefined;

            switch (resolution)
            {
            case Resolution._640x480:
                cameraWidth  = 640;
                cameraHeight = 480;
                colorFormat  = ColorImageFormat.RgbResolution640x480Fps30;
                break;

            default:
                throw new GoblinException(resolution.ToString() + " is not supported by Kinect video. The only " +
                                          "supported resolution is 640x480");
            }

            if (framerate != FrameRate._30Hz)
            {
                throw new GoblinException(framerate.ToString() + " is not supported by Kinect video. The only supported " +
                                          "frame rate is 30 Hz");
            }

            sensor = (from sensorToCheck in KinectSensor.KinectSensors
                      where sensorToCheck.Status == KinectStatus.Connected
                      select sensorToCheck).ElementAtOrDefault(videoDeviceID);

            sensor.ColorStream.Enable(colorFormat);

            sensor.Start();

            if (depthStreamEnabled)
            {
                sensor.AllFramesReady += new EventHandler <AllFramesReadyEventArgs>(AllImagesReady);
            }
            else
            {
                sensor.ColorFrameReady += new EventHandler <ColorImageFrameReadyEventArgs>(VideoImageReady);
            }

            if (UsedForCalibration)
            {
                videoData = new int[cameraWidth * cameraHeight];
            }

            cameraInitialized = true;
        }
Example #3
0
 private static void Validate(FrameRate frameRate)
 {
     if (!Enum.IsDefined(typeof(FrameRate), frameRate))
     {
         throw new ArgumentOutOfRangeException(
                   frameRate.ToString(),
                   "Value should be defined in the FrameRate enum.");
     }
 }
Example #4
0
 public void UpdatePreview()
 {
     if (_formLoading)
     {
         return;
     }
     if (VixenSystem.Elements.ElementsHaveState)
     {
         OnRenderFrame();
         _needsUpdate            = true;
         toolStripStatusFPS.Text = FrameRate.ToString();
     }
     else
     {
         if (_needsUpdate)
         {
             OnRenderFrame();
             _needsUpdate = false;
         }
         toolStripStatusFPS.Text = @"0";
     }
 }
Example #5
0
        ///
        ///<summary>
        /// Save the animation to a xml node
        /// </summary>
        ///
        public bool Save(XmlWriter xml)
        {
            if (xml == null)
            {
                return(false);
            }


            xml.WriteStartElement(XmlTag);
            xml.WriteAttributeString("name", Name);


            xml.WriteStartElement("framerate");
            xml.WriteAttributeString("value", FrameRate.ToString());
            xml.WriteEndElement();


            xml.WriteStartElement("tileset");
            xml.WriteAttributeString("name", TileSetName);
            xml.WriteEndElement();

            xml.WriteStartElement("loop");
            xml.WriteAttributeString("value", Type.ToString());
            xml.WriteEndElement();


            foreach (int id in Frames)
            {
                xml.WriteStartElement("tile");
                xml.WriteAttributeString("id", id.ToString());
                xml.WriteEndElement();
            }


            xml.WriteEndElement();

            return(true);
        }
Example #6
0
        private void RenderOverlays()
        {
            //Initialize openGL
            SetBlendFunc();
            PushMatrix(MatrixMode.Projection);
            Matrix4D.CreateOrthographicOffCenter(0.0f, Screen.Width, Screen.Height, 0.0f, -1.0f, 1.0f, out CurrentProjectionMatrix);
            PushMatrix(MatrixMode.Modelview);
            CurrentViewMatrix = Matrix4D.Identity;

            CultureInfo culture = CultureInfo.InvariantCulture;

            if (OptionInterface)
            {
                string[][] keys;

                if (VisibleObjects.Objects.Count == 0 && ObjectManager.AnimatedWorldObjectsUsed == 0)
                {
                    keys = new[] { new[] { "F7" }, new[] { "F8" }, new[] { "F10" } };
                    Keys.Render(4, 4, 20, Fonts.SmallFont, keys);
                    OpenGlString.Draw(Fonts.SmallFont, "Open one or more objects", new Vector2(32, 4), TextAlignment.TopLeft, TextColor);
                    OpenGlString.Draw(Fonts.SmallFont, "Display the options window", new Vector2(32, 24), TextAlignment.TopLeft, TextColor);
                    OpenGlString.Draw(Fonts.SmallFont, "Display the train settings window", new Vector2(32, 44), TextAlignment.TopLeft, TextColor);
                    OpenGlString.Draw(Fonts.SmallFont, $"v{Application.ProductVersion}", new Vector2(Screen.Width - 8, Screen.Height - 20), TextAlignment.TopLeft, TextColor);
                    if (Interface.LogMessages.Count == 1)
                    {
                        Keys.Render(4, 64, 20, Fonts.SmallFont, new[] { new[] { "F9" } });

                        if (Interface.LogMessages[0].Type != MessageType.Information)
                        {
                            OpenGlString.Draw(Fonts.SmallFont, "Display the 1 error message recently generated.", new Vector2(32, 64), TextAlignment.TopLeft, new Color128(1.0f, 0.5f, 0.5f));
                        }
                        else
                        {
                            //If all of our messages are information, then print the message text in grey
                            OpenGlString.Draw(Fonts.SmallFont, "Display the 1 message recently generated.", new Vector2(32, 64), TextAlignment.TopLeft, TextColor);
                        }
                    }
                    else if (Interface.LogMessages.Count > 1)
                    {
                        Keys.Render(4, 64, 20, Fonts.SmallFont, new[] { new[] { "F9" } });
                        bool error = Interface.LogMessages.Any(x => x.Type != MessageType.Information);

                        if (error)
                        {
                            OpenGlString.Draw(Fonts.SmallFont, $"Display the {Interface.LogMessages.Count.ToString(culture)} error messages recently generated.", new Vector2(32, 64), TextAlignment.TopLeft, new Color128(1.0f, 0.5f, 0.5f));
                        }
                        else
                        {
                            OpenGlString.Draw(Fonts.SmallFont, $"Display the {Interface.LogMessages.Count.ToString(culture)} messages recently generated.", new Vector2(32, 64), TextAlignment.TopLeft, TextColor);
                        }
                    }
                }
                else
                {
                    OpenGlString.Draw(Fonts.SmallFont, $"Position: {Camera.AbsolutePosition.X.ToString("0.00", culture)}, {Camera.AbsolutePosition.Y.ToString("0.00", culture)}, {Camera.AbsolutePosition.Z.ToString("0.00", culture)}", new Vector2((int)(0.5 * Screen.Width - 88), 4), TextAlignment.TopLeft, TextColor);
                    OpenGlString.Draw(Fonts.SmallFont, $"Renderer: {(AvailableNewRenderer ? "New (GL 3.0)" : "Old (GL 1.2)")}", new Vector2((int)(0.5 * Screen.Width - 88), 24), TextAlignment.TopLeft, TextColor);
                    keys = new[] { new[] { "F5" }, new[] { "F7" }, new[] { "del" }, new[] { "F8" }, new[] { "F10" } };
                    Keys.Render(4, 4, 24, Fonts.SmallFont, keys);
                    OpenGlString.Draw(Fonts.SmallFont, "Reload the currently open objects", new Vector2(32, 4), TextAlignment.TopLeft, TextColor);
                    OpenGlString.Draw(Fonts.SmallFont, "Open additional objects", new Vector2(32, 24), TextAlignment.TopLeft, TextColor);
                    OpenGlString.Draw(Fonts.SmallFont, "Clear currently open objects", new Vector2(32, 44), TextAlignment.TopLeft, TextColor);
                    OpenGlString.Draw(Fonts.SmallFont, "Display the options window", new Vector2(32, 64), TextAlignment.TopLeft, TextColor);
                    OpenGlString.Draw(Fonts.SmallFont, "Display the train settings window", new Vector2(32, 84), TextAlignment.TopLeft, TextColor);

                    keys = new[] { new[] { "F" }, new[] { "N" }, new[] { "L" }, new[] { "G" }, new[] { "B" }, new[] { "I" }, new[] { "R" } };
                    Keys.Render(Screen.Width - 20, 4, 16, Fonts.SmallFont, keys);
                    keys = new[] { new[] { "F11" } };
                    Keys.Render(Screen.Width - 36, 124, 32, Fonts.SmallFont, keys);
                    keys = new[] { new[] { "R" } };
                    Keys.Render(Screen.Width - 20, 144, 16, Fonts.SmallFont, keys);
                    OpenGlString.Draw(Fonts.SmallFont, $"WireFrame: {(OptionWireFrame ? "on" : "off")}", new Vector2(Screen.Width - 28, 4), TextAlignment.TopRight, TextColor);
                    OpenGlString.Draw(Fonts.SmallFont, $"Normals: {(OptionNormals ? "on" : "off")}", new Vector2(Screen.Width - 28, 24), TextAlignment.TopRight, TextColor);
                    OpenGlString.Draw(Fonts.SmallFont, $"Lighting: {(Program.LightingTarget == 0 ? "night" : "day")}", new Vector2(Screen.Width - 28, 44), TextAlignment.TopRight, TextColor);
                    OpenGlString.Draw(Fonts.SmallFont, $"Grid: {(OptionCoordinateSystem ? "on" : "off")}", new Vector2(Screen.Width - 28, 64), TextAlignment.TopRight, TextColor);
                    OpenGlString.Draw(Fonts.SmallFont, $"Background: {GetBackgroundColorName()}", new Vector2(Screen.Width - 28, 84), TextAlignment.TopRight, TextColor);
                    OpenGlString.Draw(Fonts.SmallFont, "Hide interface:", new Vector2(Screen.Width - 28, 104), TextAlignment.TopRight, TextColor);
                    OpenGlString.Draw(Fonts.SmallFont, $"{(RenderStatsOverlay ? "Hide" : "Show")} renderer statistics", new Vector2(Screen.Width - 44, 124), TextAlignment.TopRight, TextColor);
                    OpenGlString.Draw(Fonts.SmallFont, "Switch renderer type:", new Vector2(Screen.Width - 28, 144), TextAlignment.TopRight, TextColor);

                    keys = new[] { new[] { null, "W", null }, new[] { "A", "S", "D" } };
                    Keys.Render(4, Screen.Height - 40, 16, Fonts.SmallFont, keys);

                    keys = new[] { new[] { null, "↑", null }, new[] { "←", "↓", "→" } };
                    Keys.Render((int)(0.5 * Screen.Width - 28), Screen.Height - 40, 16, Fonts.SmallFont, keys);

                    keys = new[] { new[] { null, "8", "9" }, new[] { "4", "5", "6" }, new[] { null, "2", "3" } };
                    Keys.Render(Screen.Width - 60, Screen.Height - 60, 16, Fonts.SmallFont, keys);

                    if (Interface.LogMessages.Count == 1)
                    {
                        Keys.Render(4, 112, 20, Fonts.SmallFont, new[] { new[] { "F9" } });

                        if (Interface.LogMessages[0].Type != MessageType.Information)
                        {
                            OpenGlString.Draw(Fonts.SmallFont, "Display the 1 error message recently generated.", new Vector2(32, 112), TextAlignment.TopLeft, new Color128(1.0f, 0.5f, 0.5f));
                        }
                        else
                        {
                            //If all of our messages are information, then print the message text in grey
                            OpenGlString.Draw(Fonts.SmallFont, "Display the 1 message recently generated.", new Vector2(32, 112), TextAlignment.TopLeft, TextColor);
                        }
                    }
                    else if (Interface.LogMessages.Count > 1)
                    {
                        Keys.Render(4, 112, 20, Fonts.SmallFont, new[] { new[] { "F9" } });
                        bool error = Interface.LogMessages.Any(x => x.Type != MessageType.Information);

                        if (error)
                        {
                            OpenGlString.Draw(Fonts.SmallFont, $"Display the {Interface.LogMessages.Count.ToString(culture)} error messages recently generated.", new Vector2(32, 112), TextAlignment.TopLeft, new Color128(1.0f, 0.5f, 0.5f));
                        }
                        else
                        {
                            OpenGlString.Draw(Fonts.SmallFont, $"Display the {Interface.LogMessages.Count.ToString(culture)} messages recently generated.", new Vector2(32, 112), TextAlignment.TopLeft, TextColor);
                        }
                    }

                    if (RenderStatsOverlay)
                    {
                        Keys.Render(4, Screen.Height - 126, 116, Fonts.SmallFont, new[] { new[] { "Renderer Statistics" } });
                        OpenGlString.Draw(Fonts.SmallFont, $"Total static objects: {VisibleObjects.Objects.Count}", new Vector2(4, Screen.Height - 112), TextAlignment.TopLeft, Color128.White, true);
                        OpenGlString.Draw(Fonts.SmallFont, $"Total animated objects: {ObjectManager.AnimatedWorldObjectsUsed}", new Vector2(4, Screen.Height - 100), TextAlignment.TopLeft, Color128.White, true);
                        OpenGlString.Draw(Fonts.SmallFont, $"Current frame rate: {FrameRate.ToString("0.0", culture)}fps", new Vector2(4, Screen.Height - 88), TextAlignment.TopLeft, Color128.White, true);
                        OpenGlString.Draw(Fonts.SmallFont, $"Total opaque faces: {VisibleObjects.OpaqueFaces.Count}", new Vector2(4, Screen.Height - 76), TextAlignment.TopLeft, Color128.White, true);
                        OpenGlString.Draw(Fonts.SmallFont, $"Total alpha faces: {VisibleObjects.AlphaFaces.Count}", new Vector2(4, Screen.Height - 64), TextAlignment.TopLeft, Color128.White, true);
                    }
                }
            }

            // finalize
            PopMatrix(MatrixMode.Projection);
            PopMatrix(MatrixMode.Modelview);
        }
Example #7
0
        private void RenderOverlays()
        {
            //Initialize openGL
            SetBlendFunc();
            PushMatrix(MatrixMode.Projection);
            Matrix4D.CreateOrthographicOffCenter(0.0f, Screen.Width, Screen.Height, 0.0f, -1.0f, 1.0f, out CurrentProjectionMatrix);
            PushMatrix(MatrixMode.Modelview);
            CurrentViewMatrix = Matrix4D.Identity;

            CultureInfo culture = CultureInfo.InvariantCulture;

            // marker
            if (OptionInterface)
            {
                int y = 150;

                foreach (Texture t in Marker.MarkerTextures)
                {
                    if (Program.CurrentHost.LoadTexture(t, OpenGlTextureWrapMode.ClampClamp))
                    {
                        int w = t.Width;
                        int h = t.Height;
                        GL.Color4(1.0, 1.0, 1.0, 1.0);
                        Rectangle.Draw(t, new Vector2(Screen.Width - w - 8, y), new Vector2(w, h));
                        y += h + 8;
                    }
                }
            }

            if (!Program.CurrentlyLoading)
            {
                string[][] keys;

                if (VisibleObjects.Objects.Count == 0 && ObjectManager.AnimatedWorldObjectsUsed == 0)
                {
                    keys = new[] { new[] { "F7" }, new[] { "F8" } };
                    Keys.Render(4, 4, 20, Fonts.SmallFont, keys);
                    OpenGlString.Draw(Fonts.SmallFont, "Open route", new Point(32, 4), TextAlignment.TopLeft, Color128.White);
                    OpenGlString.Draw(Fonts.SmallFont, "Display the options window", new Point(32, 24), TextAlignment.TopLeft, Color128.White);
                    OpenGlString.Draw(Fonts.SmallFont, $"v{Application.ProductVersion}", new Point(Screen.Width - 8, Screen.Height - 20), TextAlignment.TopLeft, Color128.White);
                }
                else if (OptionInterface)
                {
                    // keys
                    keys = new[] { new[] { "F5" }, new[] { "F7" }, new[] { "F8" } };
                    Keys.Render(4, 4, 24, Fonts.SmallFont, keys);
                    OpenGlString.Draw(Fonts.SmallFont, "Reload route", new Point(32, 4), TextAlignment.TopLeft, Color128.White, true);
                    OpenGlString.Draw(Fonts.SmallFont, "Open route", new Point(32, 24), TextAlignment.TopLeft, Color128.White, true);
                    OpenGlString.Draw(Fonts.SmallFont, "Display the options window", new Point(32, 44), TextAlignment.TopLeft, Color128.White, true);

                    keys = new[] { new[] { "F" }, new[] { "N" }, new[] { "E" }, new[] { "C" }, new[] { "M" }, new[] { "I" } };
                    Keys.Render(Screen.Width - 20, 4, 16, Fonts.SmallFont, keys);
                    OpenGlString.Draw(Fonts.SmallFont, "WireFrame:", new Point(Screen.Width - 32, 4), TextAlignment.TopRight, Color128.White, true);
                    OpenGlString.Draw(Fonts.SmallFont, "Normals:", new Point(Screen.Width - 32, 24), TextAlignment.TopRight, Color128.White, true);
                    OpenGlString.Draw(Fonts.SmallFont, "Events:", new Point(Screen.Width - 32, 44), TextAlignment.TopRight, Color128.White, true);
                    OpenGlString.Draw(Fonts.SmallFont, "CPU:", new Point(Screen.Width - 32, 64), TextAlignment.TopRight, Color128.White, true);
                    OpenGlString.Draw(Fonts.SmallFont, "Mute:", new Point(Screen.Width - 32, 84), TextAlignment.TopRight, Color128.White, true);
                    OpenGlString.Draw(Fonts.SmallFont, "Hide interface:", new Point(Screen.Width - 32, 104), TextAlignment.TopRight, Color128.White, true);
                    OpenGlString.Draw(Fonts.SmallFont, $"{(RenderStatsOverlay ? "Hide" : "Show")} renderer statistics", new Point(Screen.Width - 32, 124), TextAlignment.TopRight, Color128.White, true);
                    OpenGlString.Draw(Fonts.SmallFont, $"Switch renderer type:", new Point(Screen.Width - 32, 144), TextAlignment.TopRight, Color128.White, true);

                    keys = new[] { new[] { "F10" } };
                    Keys.Render(Screen.Width - 32, 124, 30, Fonts.SmallFont, keys);

                    keys = new[] { new[] { "R" } };
                    Keys.Render(Screen.Width - 20, 144, 16, Fonts.SmallFont, keys);

                    keys = new[] { new[] { null, "W", null }, new[] { "A", "S", "D" } };
                    Keys.Render(4, Screen.Height - 40, 16, Fonts.SmallFont, keys);

                    keys = new[] { new[] { null, "↑", null }, new[] { "←", "↓", "→" } };
                    Keys.Render(0 * Screen.Width - 48, Screen.Height - 40, 16, Fonts.SmallFont, keys);

                    keys = new[] { new[] { "P↑" }, new[] { "P↓" } };
                    Keys.Render((int)(0.5 * Screen.Width + 32), Screen.Height - 40, 24, Fonts.SmallFont, keys);

                    keys = new[] { new[] { null, "/", "*" }, new[] { "7", "8", "9" }, new[] { "4", "5", "6" }, new[] { "1", "2", "3" }, new[] { null, "0", "." } };
                    Keys.Render(Screen.Width - 60, Screen.Height - 100, 16, Fonts.SmallFont, keys);

                    if (Program.JumpToPositionEnabled)
                    {
                        OpenGlString.Draw(Fonts.SmallFont, "Jump to track position:", new Point(4, 80), TextAlignment.TopLeft, Color128.White, true);

                        double distance;

                        if (double.TryParse(Program.JumpToPositionValue, out distance))
                        {
                            if (distance < Program.MinimumJumpToPositionValue - 100)
                            {
                                OpenGlString.Draw(Fonts.SmallFont, (Environment.TickCount % 1000 <= 500 ? $"{Program.JumpToPositionValue}_" : Program.JumpToPositionValue), new Point(4, 100), TextAlignment.TopLeft, Color128.Red, true);
                            }
                            else
                            {
                                OpenGlString.Draw(Fonts.SmallFont, (Environment.TickCount % 1000 <= 500 ? $"{Program.JumpToPositionValue}_" : Program.JumpToPositionValue), new Point(4, 100), TextAlignment.TopLeft, distance > Program.CurrentRoute.Tracks[0].Elements[Program.CurrentRoute.Tracks[0].Elements.Length - 1].StartingTrackPosition + 100 ? Color128.Red : Color128.Yellow, true);
                            }
                        }
                    }

                    // info
                    double x = 0.5 * Screen.Width - 256.0;
                    OpenGlString.Draw(Fonts.SmallFont, $"Position: {GetLengthString(Camera.Alignment.TrackPosition)} (X={GetLengthString(Camera.Alignment.Position.X)}, Y={GetLengthString(Camera.Alignment.Position.Y)}), Orientation: (Yaw={(Camera.Alignment.Yaw * 57.2957795130824).ToString("0.00", culture)}°, Pitch={(Camera.Alignment.Pitch * 57.2957795130824).ToString("0.00", culture)}°, Roll={(Camera.Alignment.Roll * 57.2957795130824).ToString("0.00", culture)}°)", new Point((int)x, 4), TextAlignment.TopLeft, Color128.White, true);
                    OpenGlString.Draw(Fonts.SmallFont, $"Radius: {GetLengthString(CameraTrackFollower.CurveRadius)}, Cant: {(1000.0 * CameraTrackFollower.CurveCant).ToString("0", culture)} mm, Adhesion={(100.0 * CameraTrackFollower.AdhesionMultiplier).ToString("0", culture)}" + " , Rain intensity= " + CameraTrackFollower.RainIntensity + "%", new Point((int)x, 20), TextAlignment.TopLeft, Color128.White, true);
                    OpenGlString.Draw(Fonts.SmallFont, $"Renderer: {(AvailableNewRenderer ? "New (GL 3.0)" : "Old (GL 1.2)")}", new Point((int)x, 40), TextAlignment.TopLeft, Color128.White, true);

                    if (Program.CurrentStation >= 0)
                    {
                        StringBuilder t = new StringBuilder();
                        t.Append(Program.CurrentRoute.Stations[Program.CurrentStation].Name);

                        if (Program.CurrentRoute.Stations[Program.CurrentStation].ArrivalTime >= 0.0)
                        {
                            t.Append($", Arrival: {GetTime(Program.CurrentRoute.Stations[Program.CurrentStation].ArrivalTime)}");
                        }

                        if (Program.CurrentRoute.Stations[Program.CurrentStation].DepartureTime >= 0.0)
                        {
                            t.Append($", Departure: {GetTime(Program.CurrentRoute.Stations[Program.CurrentStation].DepartureTime)}");
                        }

                        if (Program.CurrentRoute.Stations[Program.CurrentStation].OpenLeftDoors & Program.CurrentRoute.Stations[Program.CurrentStation].OpenRightDoors)
                        {
                            t.Append(", [L][R]");
                        }
                        else if (Program.CurrentRoute.Stations[Program.CurrentStation].OpenLeftDoors)
                        {
                            t.Append(", [L][-]");
                        }
                        else if (Program.CurrentRoute.Stations[Program.CurrentStation].OpenRightDoors)
                        {
                            t.Append(", [-][R]");
                        }
                        else
                        {
                            t.Append(", [-][-]");
                        }

                        switch (Program.CurrentRoute.Stations[Program.CurrentStation].StopMode)
                        {
                        case StationStopMode.AllStop:
                            t.Append(", Stop");
                            break;

                        case StationStopMode.AllPass:
                            t.Append(", Pass");
                            break;

                        case StationStopMode.PlayerStop:
                            t.Append(", Player stops - others pass");
                            break;

                        case StationStopMode.PlayerPass:
                            t.Append(", Player passes - others stop");
                            break;
                        }

                        switch (Program.CurrentRoute.Stations[Program.CurrentStation].Type)
                        {
                        case StationType.ChangeEnds:
                            t.Append(", Change ends");
                            break;

                        case StationType.Jump:
                            t.Append(", then Jumps to " + Program.CurrentRoute.Stations[Program.CurrentRoute.Stations[Program.CurrentStation].JumpIndex].Name);
                            break;
                        }

                        t.Append(", Ratio=").Append((100.0 * Program.CurrentRoute.Stations[Program.CurrentStation].PassengerRatio).ToString("0", culture)).Append("%");

                        OpenGlString.Draw(Fonts.SmallFont, t.ToString(), new Point((int)x, 60), TextAlignment.TopLeft, Color128.White, true);
                    }

                    if (Interface.LogMessages.Count == 1)
                    {
                        keys = new[] { new[] { "F9" } };
                        Keys.Render(4, 72, 24, Fonts.SmallFont, keys);

                        if (Interface.LogMessages[0].Type != MessageType.Information)
                        {
                            OpenGlString.Draw(Fonts.SmallFont, "Display the 1 error message recently generated.", new Point(32, 72), TextAlignment.TopLeft, Color128.Red, true);
                        }
                        else
                        {
                            //If all of our messages are information, then print the message text in grey
                            OpenGlString.Draw(Fonts.SmallFont, "Display the 1 message recently generated.", new Point(32, 72), TextAlignment.TopLeft, Color128.White, true);
                        }
                    }
                    else if (Interface.LogMessages.Count > 1)
                    {
                        Keys.Render(4, 72, 24, Fonts.SmallFont, new[] { new[] { "F9" } });
                        bool error = Interface.LogMessages.Any(m => m.Type != MessageType.Information);

                        if (error)
                        {
                            OpenGlString.Draw(Fonts.SmallFont, $"Display the {Interface.LogMessages.Count} error messages recently generated.", new Point(32, 72), TextAlignment.TopLeft, Color128.Red, true);
                        }
                        else
                        {
                            OpenGlString.Draw(Fonts.SmallFont, $"Display the {Interface.LogMessages.Count} messages recently generated.", new Point(32, 72), TextAlignment.TopLeft, Color128.White, true);
                        }
                    }

                    if (RenderStatsOverlay)
                    {
                        Keys.Render(4, Screen.Height - 126, 116, Fonts.SmallFont, new[] { new[] { "Renderer Statistics" } });
                        OpenGlString.Draw(Fonts.SmallFont, $"Total static objects: {VisibleObjects.Objects.Count}", new Point(4, Screen.Height - 112), TextAlignment.TopLeft, Color128.White, true);
                        OpenGlString.Draw(Fonts.SmallFont, $"Total animated objects: {ObjectManager.AnimatedWorldObjectsUsed}", new Point(4, Screen.Height - 100), TextAlignment.TopLeft, Color128.White, true);
                        OpenGlString.Draw(Fonts.SmallFont, $"Current frame rate: {FrameRate.ToString("0.0", culture)}fps", new Point(4, Screen.Height - 88), TextAlignment.TopLeft, Color128.White, true);
                        OpenGlString.Draw(Fonts.SmallFont, $"Total opaque faces: {VisibleObjects.OpaqueFaces.Count}", new Point(4, Screen.Height - 76), TextAlignment.TopLeft, Color128.White, true);
                        OpenGlString.Draw(Fonts.SmallFont, $"Total alpha faces: {VisibleObjects.AlphaFaces.Count}", new Point(4, Screen.Height - 64), TextAlignment.TopLeft, Color128.White, true);
                    }
                }
            }

            // finalize
            PopMatrix(MatrixMode.Projection);
            PopMatrix(MatrixMode.Modelview);
        }
Example #8
0
 /// <summary>
 /// Write a header: the first line is framerate
 /// </summary>
 /// <param name="file">Output file</param>
 public override void writeHeader(StreamWriter file)
 {
     // In the number there has to be point. Therefore CultureInof en-US (in some locals there coma).
     file.WriteLine("{1}{1}" + FrameRate.ToString("0.000", new CultureInfo("en-US")));
 }
Example #9
0
 /// <summary>
 /// Returns a string that represents the current object.
 /// </summary>
 /// <returns>A string that represents the current object.</returns>
 /// <since_tizen> 3 </since_tizen>
 public override string ToString()
 => $@"MimeType={ MimeType.ToString() }, Size=({ Size.ToString() }), FrameRate=
         { FrameRate.ToString() }, BitRate={ BitRate.ToString() }, MaxBps = { MaxBps.ToString() }";
Example #10
0
        private void ParseProgram(byte[] buffer)
        {
            MemoryStream ms = new MemoryStream(buffer);

            ms.Position++;
            byte numPrograms = ms.ReadInt8();

            Programs = new Program[numPrograms];
            for (int i = 0; i < numPrograms; i++)
            {
                Programs[i] = new Program();
                Programs[i].ProgramSequenceStart = ms.ReadInt32BE();
                Programs[i].ProgramMapPid        = ms.ReadUInt16BE();
                Programs[i].NumStreams           = ms.ReadInt8();
                Programs[i].NumGroups            = ms.ReadInt8();
                Programs[i].ProgramStreams       = new ProgramStream[Programs[i].NumStreams];
                for (int j = 0; j < Programs[i].NumStreams; j++)
                {
                    ushort PID       = ms.ReadUInt16BE();
                    int    len       = ms.ReadInt8();
                    int    pos       = (int)ms.Position;
                    byte   codecType = ms.ReadInt8();
                    switch (codecType)
                    {
                    case 0x01:
                    case 0x02:
                    case 0x1b:
                    case 0xea:
                        VideoProgramStream child = new VideoProgramStream();
                        child.VideoCodec = (VideoCodec)codecType;
                        int value = ms.ReadInt8();
                        child.VideoResolution = (VideoResolution)(value >> 4);
                        FrameRate frameRate = (FrameRate)(value & 0x0f);
                        switch (frameRate)
                        {
                        case PlaylistModel.StreamModel.FrameRate._23_076: child.FrameRate = 23.976; break;

                        case PlaylistModel.StreamModel.FrameRate._24: child.FrameRate = 24; break;

                        case PlaylistModel.StreamModel.FrameRate._25: child.FrameRate = 25; break;

                        case PlaylistModel.StreamModel.FrameRate._29_976: child.FrameRate = 29.976; break;

                        case PlaylistModel.StreamModel.FrameRate._50: child.FrameRate = 50; break;

                        case PlaylistModel.StreamModel.FrameRate._59_94: child.FrameRate = 59.94; break;

                        default: throw new NotImplementedException(frameRate.ToString());
                        }
                        Programs[i].ProgramStreams[j] = child;
                        break;

                    case 0x03:
                    case 0x04:
                    case 0x80:
                    case 0x81:
                    case 0x82:
                    case 0x83:
                    case 0x84:
                    case 0x85:
                    case 0x86:
                    case 0xa1:
                    case 0xa2:
                        AudioProgramStream child2 = new AudioProgramStream();
                        child2.AudioCodec = (AudioCodec)codecType;
                        int value2 = ms.ReadInt8();
                        child2.AudioPresentationMode = (AudioPresentationMode)(value2 >> 4);
                        SamplingRate samplingRate = (SamplingRate)(value2 & 0x0f);
                        switch (samplingRate)
                        {
                        case SamplingRate._48: child2.PrimarySamplingRate = 48000; break;

                        case SamplingRate._96: child2.PrimarySamplingRate = 96000; break;

                        case SamplingRate._192: child2.PrimarySamplingRate = 192000; break;

                        default: throw new NotImplementedException(samplingRate.ToString());
                        }
                        child2.LanguageCode           = ms.ReadFixedLengthString(3);
                        Programs[i].ProgramStreams[j] = child2;
                        break;

                    case 0x90:
                    case 0x91:
                    case 0xa0:
                        GraphicsProgramStream child3 = new GraphicsProgramStream();
                        child3.LanguageCode           = ms.ReadFixedLengthString(3);
                        Programs[i].ProgramStreams[j] = child3;
                        break;

                    case 0x92:
                        SubtitleProgramStream child4 = new SubtitleProgramStream();
                        child4.CharCode               = ms.ReadInt8();
                        child4.LanguageCode           = ms.ReadFixedLengthString(3);
                        Programs[i].ProgramStreams[j] = child4;
                        break;

                    default:
                        Debug.WriteLine(String.Format("Unknown codec type: {0}", codecType));
                        break;
                    }

                    ms.Position = pos + len;
                    Programs[i].ProgramStreams[j].PID = PID;
                }
            }
        }
Example #11
0
    private void CompleteVideoLoad(bool useBT709)
    {
        // Gather properties
        Volume          = _volume;
        Width           = AVProWindowsMediaPlugin.GetWidth(_movieHandle);
        Height          = AVProWindowsMediaPlugin.GetHeight(_movieHandle);
        FrameRate       = AVProWindowsMediaPlugin.GetFrameRate(_movieHandle);
        DurationSeconds = AVProWindowsMediaPlugin.GetDurationSeconds(_movieHandle);
        DurationFrames  = AVProWindowsMediaPlugin.GetDurationFrames(_movieHandle);

        AVProWindowsMediaPlugin.VideoFrameFormat sourceFormat = (AVProWindowsMediaPlugin.VideoFrameFormat)AVProWindowsMediaPlugin.GetFormat(_movieHandle);
        Debug.Log(string.Format("[AVProWindowsMedia] Loaded video '{0}' ({1}x{2} @ {3} fps) {4} frames, {5} seconds - format: {6}", Filename, Width, Height, FrameRate.ToString("F2"), DurationFrames, DurationSeconds.ToString("F2"), sourceFormat.ToString()));

        // Create format converter
        if (Width < 0 || Width > 4096 || Height < 0 || Height > 4096)
        {
            Debug.LogWarning("[AVProWindowsMedia] invalid width or height");
            Width = Height = 0;
            if (_formatConverter != null)
            {
                _formatConverter.Dispose();
                _formatConverter = null;
            }
        }
        else
        {
            bool isTopDown = AVProWindowsMediaPlugin.IsOrientedTopDown(_movieHandle);

            if (_formatConverter == null)
            {
                _formatConverter = new AVProWindowsMediaFormatConverter();
            }
            if (!_formatConverter.Build(_movieHandle, Width, Height, sourceFormat, useBT709, false, isTopDown))
            {
                Debug.LogWarning("[AVProWindowsMedia] unable to convert video format");
                Width = Height = 0;
                if (_formatConverter != null)
                {
                    _formatConverter.Dispose();
                    _formatConverter = null;
                }
                // TODO: close movie here?
            }
        }

        PreRoll();
    }
Example #12
0
        public void InitVideoCapture(int videoDeviceID, FrameRate framerate, Resolution resolution,
                                     ImageFormat format, bool grayscale)
        {
            if (cameraInitialized)
            {
                return;
            }

            this.resolution    = resolution;
            this.grayscale     = grayscale;
            this.frameRate     = framerate;
            this.videoDeviceID = videoDeviceID;
            this.format        = format;

            switch (resolution)
            {
            case Resolution._160x120:
                cameraWidth  = 160;
                cameraHeight = 120;
                break;

            case Resolution._320x240:
                cameraWidth  = 320;
                cameraHeight = 240;
                break;

            case Resolution._640x480:
                cameraWidth  = 640;
                cameraHeight = 480;
                break;

            case Resolution._800x600:
                cameraWidth  = 800;
                cameraHeight = 600;
                break;

            case Resolution._1024x768:
                cameraWidth  = 1024;
                cameraHeight = 768;
                break;

            case Resolution._1280x1024:
                cameraWidth  = 1280;
                cameraHeight = 960;
                break;

            case Resolution._1600x1200:
                cameraWidth  = 1600;
                cameraHeight = 1200;
                break;
            }

            ManagedBusManager busMgr = new ManagedBusManager();
            uint numCameras          = busMgr.GetNumOfCameras();

            if (videoDeviceID >= numCameras || videoDeviceID < 0)
            {
                throw new GoblinException("VideoDeviceID: " + videoDeviceID + " is out of range. There are only " +
                                          numCameras + " point grey camera(s) connected");
            }

            ManagedPGRGuid guid   = busMgr.GetCameraFromIndex((uint)videoDeviceID);
            InterfaceType  ifType = busMgr.GetInterfaceTypeFromGuid(guid);

            if (ifType == InterfaceType.GigE)
            {
                camera = new ManagedGigECamera();
            }
            else
            {
                camera = new ManagedCamera();
            }

            camera.Connect(guid);

            processedImage = new ManagedImage();
            pixelData      = new byte[cameraWidth * cameraHeight * 3];

            VideoMode currentVideoMode = VideoMode.NumberOfVideoModes;

            FlyCapture2Managed.FrameRate currentFrameRate = FlyCapture2Managed.FrameRate.NumberOfFrameRates;

            FlyCapture2Managed.FrameRate desiredFrameRate = FlyCapture2Managed.FrameRate.NumberOfFrameRates;

            switch (frameRate)
            {
            case FrameRate._15Hz:
                desiredFrameRate = FlyCapture2Managed.FrameRate.FrameRate15;
                break;

            case FrameRate._30Hz:
                desiredFrameRate = FlyCapture2Managed.FrameRate.FrameRate30;
                break;

            case FrameRate._60Hz:
                desiredFrameRate = FlyCapture2Managed.FrameRate.FrameRate60;
                break;

            case FrameRate._120Hz:
                desiredFrameRate = FlyCapture2Managed.FrameRate.FrameRate120;
                break;

            case FrameRate._240Hz:
                desiredFrameRate = FlyCapture2Managed.FrameRate.FrameRate240;
                break;

            default:
                throw new GoblinException(framerate.ToString() + " is not supported");
            }

            try
            {
                ((ManagedCamera)camera).GetVideoModeAndFrameRate(ref currentVideoMode, ref currentFrameRate);

                if (!isVideoModeSet)
                {
                    videoMode = currentVideoMode;
                }

                bool supported = ((ManagedCamera)camera).GetVideoModeAndFrameRateInfo(videoMode, desiredFrameRate);

                if (supported)
                {
                    ((ManagedCamera)camera).SetVideoModeAndFrameRate(videoMode, desiredFrameRate);
                }
                else
                {
                    Log.Write(desiredFrameRate.ToString() + " is not supported in " + videoMode.ToString() + " mode");
                }
            }
            catch (Exception exp)
            {
                Log.Write(exp.Message + ": " + exp.StackTrace);
            }

            camera.StartCapture(OnImageGrabbed);

            cameraInitialized = true;
        }
Example #13
0
    private void CompleteVideoLoad(bool useBT709, bool ignoreFlips, FilterMode textureFilterMode, TextureWrapMode textureWrapMode)
    {
        RequiresFlipY = false;
        Loop          = false;
        Volume        = _volume;

        // Gather properties
        Width           = AVProWindowsMediaPlugin.GetWidth(_movieHandle);
        Height          = AVProWindowsMediaPlugin.GetHeight(_movieHandle);
        FrameRate       = AVProWindowsMediaPlugin.GetFrameRate(_movieHandle);
        DurationSeconds = AVProWindowsMediaPlugin.GetDurationSeconds(_movieHandle);
        DurationFrames  = AVProWindowsMediaPlugin.GetDurationFrames(_movieHandle);

        AVProWindowsMediaPlugin.VideoFrameFormat sourceFormat = (AVProWindowsMediaPlugin.VideoFrameFormat)AVProWindowsMediaPlugin.GetFormat(_movieHandle);

        if (AVProWindowsMediaManager.Instance._logVideoLoads)
        {
            Debug.Log(string.Format("[AVProWindowsMedia] Loaded video '{0}' ({1}x{2} @ {3} fps) {4} frames, {5} seconds - format: {6}", Filename, Width, Height, FrameRate.ToString("F2"), DurationFrames, DurationSeconds.ToString("F2"), sourceFormat.ToString()));
        }

        // Create format converter
        bool hasVideo = (Width > 0 && Width <= 8192 || Height > 0 && Height <= 8192);

        if (!hasVideo)
        {
            Width = Height = 0;
            if (_formatConverter != null)
            {
                _formatConverter.Dispose();
                _formatConverter = null;
            }
        }
        else
        {
            bool isTopDown = AVProWindowsMediaPlugin.IsOrientedTopDown(_movieHandle);

            if (_formatConverter == null)
            {
                _formatConverter = new AVProWindowsMediaFormatConverter();
            }

            bool flipX = false;
            bool flipY = isTopDown;
            if (ignoreFlips)
            {
                if (flipY)
                {
                    RequiresFlipY = true;
                }

                flipX = flipY = false;
            }
            if (!_formatConverter.Build(_movieHandle, Width, Height, sourceFormat, useBT709, flipX, flipY, textureFilterMode, textureWrapMode))
            {
                Debug.LogError("[AVProWindowsMedia] unable to convert video format");
                Width = Height = 0;
                if (_formatConverter != null)
                {
                    _formatConverter.Dispose();
                    _formatConverter = null;
                    Close();
                }
            }
        }

        PreRoll();
    }