// Метод перематывает видео к нужному кадру и соответственно
        // обновляет состояние интерфейса на форме
        private bool VideoMoveTo(int iframe)
        {
            if (!context.isVideo)
            {
                throw new Exception("No video loaded!");
            }

            if (iframe < 0 || iframe >= context.VideoFramesCount)
            {
                return(false);
            }

            double positionMs = iframe *
                                context.VideoDurationMs / context.VideoFramesCount;

            // Перематываем видеофайл
            IntPtr hBitmap;
            int    newframe;
            int    errcode;

            errcode = OcvWrapper.VideoSeek(context.videoHandle, positionMs,
                                           out hBitmap, out newframe);
            if (errcode != 0)
            {
                MessageBox.Show("Unable to seek position in video!", "Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            // Сохраняем информацию о текущей позиции видео в полях класса
            context.VideoFrameCurrent = newframe - 1;
            frameCurr = Image.FromHbitmap(hBitmap);

            // Отображаем информацию о текущей позиции видео на форме
            VideoNavigatorUpdate();
            PictureRedraw();
            return(true);
        }
Exemple #2
0
        // Метод перематывает видео до нужной позиции
        private void GoToPosition(double video_time_ms)
        {
            // Перематываем видеофайл
            IntPtr hBitmap;
            int    iframe;
            int    errcode;

            errcode = OcvWrapper.VideoSeek(videoHandle, video_time_ms, out hBitmap, out iframe);
            if (errcode != 0)
            {
                MessageBox.Show("Unable to seek position in video!", "Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Сохраняем информацию о текущей позиции видео в полях класса
            ixFrameCurr = iframe;
            frameCurr   = Image.FromHbitmap(hBitmap);

            // Отображаем информацию о текущей позиции видео на форме
            txtCurrentFrame.Text = ixFrameCurr.ToString();
            pictureBox1.Image    = frameCurr;
        }