コード例 #1
0
ファイル: Program.cs プロジェクト: malirezai/slalom
        private static string CreateImage(string jsonPath, double clOffset, double rope,
                                          CourseCoordinates coords)
        {
            CoursePass        pass;
            CoursePassFactory factory = new CoursePassFactory();

            factory.CenterLineDegreeOffset = clOffset;
            factory.RopeLengthOff          = rope;
            factory.Course55Coordinates    = coords;

            if (jsonPath.StartsWith("http"))
            {
                pass = factory.FromUrl(jsonPath);
            }
            else
            {
                pass = factory.FromFile(jsonPath);
            }

            if (pass == null)
            {
                throw new ApplicationException($"Unable to create a pass for {jsonPath}");
            }

            string          imagePath = GetImagePath(jsonPath);
            CoursePassImage image     = new CoursePassImage(pass);
            Bitmap          bitmap    = image.Draw();

            bitmap.Save(imagePath, ImageFormat.Png);

            Logger.Log(string.Format("Gate precision == {0} for {1}", pass.GetGatePrecision(), jsonPath));
            Logger.Log("Wrote image to: " + imagePath);

            return(imagePath);
        }
コード例 #2
0
ファイル: ImageController.cs プロジェクト: malirezai/slalom
        private Bitmap GetImage(string jsonUrl, double clOffset, double rope)
        {
            Storage storage = new Storage();
            string  http    = storage.BlobStorageUri.Replace("https:", "http:");
            string  https   = storage.BlobStorageUri;

            if (!(jsonUrl.StartsWith(http) || jsonUrl.StartsWith(https)))
            {
                if (jsonUrl.StartsWith("/"))
                {
                    jsonUrl = jsonUrl.TrimStart('/');
                }
                jsonUrl = storage.BlobStorageUri + "ski/" + jsonUrl;
            }

            CoursePassFactory factory = new CoursePassFactory()
            {
                CenterLineDegreeOffset = clOffset,
                RopeLengthOff          = rope,
                Course = GetCourseFromMetadata(storage, jsonUrl)
            };
            CoursePass pass = factory.FromUrl(jsonUrl);

            if (pass == null)
            {
                throw new ApplicationException($"Unable to create a pass for {jsonUrl}");
            }

            CoursePassImage image  = new CoursePassImage(pass);
            Bitmap          bitmap = image.Draw();

            return(bitmap);
        }
コード例 #3
0
        private static string DownloadAndCreateImage(string url)
        {
            string          localPath = Storage.DownloadVideo(url);
            string          json      = Extract.ExtractMetadata(localPath);
            CoursePass      pass      = CoursePassFactory.FromJson(json);
            CoursePassImage image     = new CoursePassImage(pass);
            Bitmap          bitmap    = image.Draw();
            string          imagePath = localPath.Replace(".MP4", ".png");

            bitmap.Save(imagePath, ImageFormat.Png);
            return(imagePath);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: malirezai/slalom
        private static string DownloadAndCreateImage(string url)
        {
            string     localPath = Storage.DownloadVideo(url);
            string     json      = Extract.ExtractMetadata(localPath);
            CoursePass pass      = new CoursePassFactory().FromJson(json);

            if (pass == null)
            {
                throw new ApplicationException($"Unable to create a pass for {url}");
            }

            CoursePassImage image     = new CoursePassImage(pass);
            Bitmap          bitmap    = image.Draw();
            string          imagePath = localPath.Replace(".MP4", ".png");

            bitmap.Save(imagePath, ImageFormat.Png);
            return(imagePath);
        }
コード例 #5
0
        private static string CreateImage(string jsonPath, double clOffset, double rope)
        {
            CoursePass pass;

            if (jsonPath.StartsWith("http"))
            {
                pass = CoursePassFactory.FromUrl(jsonPath, clOffset, rope);
            }
            else
            {
                pass = CoursePassFactory.FromFile(jsonPath, clOffset, Rope.Off(rope));
            }

            string          imagePath = GetImagePath(jsonPath);
            CoursePassImage image     = new CoursePassImage(pass);
            Bitmap          bitmap    = image.Draw();

            bitmap.Save(imagePath, ImageFormat.Png);

            Console.WriteLine("Gate precision == {0} for {1}", pass.GetGatePrecision(), jsonPath);

            return(imagePath);
        }