Ejemplo n.º 1
0
        /// <summary>
        /// Set hotframe for all IStreamWindow
        /// </summary>
        /// <param name="frame">Hotframe object</param>
        public void SetHotFrame(HotFrame frame)
        {
            foreach (Form form in mainForm.MdiChildren)
            {
                if ((!form.IsDisposed) && (form is IStreamWindow))
                {
                    IStreamWindow streamForm = form as IStreamWindow;
                    if (streamForm.HasToSetFrame)
                    {
                        streamForm.SetHotFrame(frame);
                        Form streamFormAsForm = streamForm as Form;
                        streamFormAsForm.Refresh();
                    }
                }
            }

            SetTrackBarTime(frame.Timestamp);
            CurrentHotFrame = frame;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Set frame by time for all IStreamWindow
        /// </summary>
        /// <param name="time">Time</param>
        public void SetFrameByTime(DateTime time)
        {
            if ((time < minTime) || (time > maxTime))
            {
                timer.Stop();
                return;
            }

            foreach (Form form in mainForm.MdiChildren)
            {
                if ((!form.IsDisposed) && (form is IStreamWindow))
                {
                    IStreamWindow streamForm = form as IStreamWindow;
                    if (streamForm.HasToSetFrame)
                    {
                        streamForm.SetFrameByTime(time);
                        Form streamFormAsForm = streamForm as Form;
                        streamFormAsForm.Refresh();
                    }
                }
            }
            CurrentTime = time;
        }
Ejemplo n.º 3
0
        private void timer_Tick(object sender, EventArgs e)
        {
            NextFrame();

            // Recording mode
            if (tsbRecord.Text == recordButtonTextStop)
            {
                Bitmap snapshot = TakeSnapshot();
                try
                {
                    videoWriter.WriteVideoFrame(snapshot);
                    snapshot.Dispose();
                }
                catch
                {
                    //...
                }
            }

            // Exporting video
            if (tsbExportVideo.Text == saveButtonTextStop)
            {
                HotFrame frame = new HotFrame(this.CurrentTime);
                foreach (Form form in mainForm.MdiChildren)
                {
                    if ((!form.IsDisposed) && (form is IStreamWindow))
                    {
                        IStreamWindow streamWnd = form as IStreamWindow;
                        streamWnd.SetHotFrame(frame);
                    }
                }

                var annot = frame.Timestamp.ToString("HH_mm_ss_fff");
                MatlabExporter.ExportHotFrame(exportFolder, annot, frame, MatlabExporterOptions.Overwrite, mainForm.ConsoleLogger);
            }
        }
Ejemplo n.º 4
0
        public Bitmap TakeSnapshot()
        {
            string[] order = { "GPR1", "NIKON", "SON2", "CAN1", "VHDL", "S5", "SEPT", "PTGREY1", "CAS2" };
            string[] title = { "GoPro/F", "NIKON/F", "Sony/F", "Canon/S", "LiDAR", "Samsung/F", "GPS", "PTGREY/R", "Casio/R" };

            int sub_img_width  = 640;
            int sub_img_height = 480;

            Bitmap img = new Bitmap(sub_img_width * 3, sub_img_height * 3);

            using (Graphics g = Graphics.FromImage(img))
            {
                int x = 0;
                int y = 0;

                // reorder datastreams
                List <IStreamWindow> winds = new List <IStreamWindow>();
                int i = 0;
                foreach (string strStream in order)
                {
                    foreach (Form form in mainForm.MdiChildren)
                    {
                        if ((!form.IsDisposed) && (form is IStreamWindow))
                        {
                            IStreamWindow streamWnd = form as IStreamWindow;
                            if (streamWnd.DataStream.ShortName == strStream)
                            {
                                try
                                {
                                    Image snapshot = streamWnd.GetSnapshot();
                                    if (snapshot != null)
                                    {
                                        try
                                        {
                                            ResizeBilinear filter   = new ResizeBilinear(sub_img_width, sub_img_height);
                                            Bitmap         newImage = filter.Apply((Bitmap)snapshot);
                                            g.DrawImage(newImage, x, y, sub_img_width, sub_img_height);
                                            //g.FillRectangle(new SolidBrush(Color.White), x, y, 150, 30);
                                            g.DrawString(title[i], new Font("Arial", 30), Brushes.Blue, new PointF(x, y));
                                        }
                                        catch (Exception ex)
                                        {
                                            throw ex;
                                        }

                                        //if (strStream == "SEPT") snapshot.Dispose();
                                    }
                                    break;
                                } catch (Exception ex)
                                {
                                    if (mainForm.Console != null)
                                    {
                                        mainForm.Console.Write("Error: " + ex.Message);
                                    }
                                    timer.Stop();
                                }
                            }
                        }
                    }


                    i++;
                    x += sub_img_width;
                    if (x >= sub_img_width * 3)
                    {
                        x  = 0;
                        y += sub_img_height;
                    }
                }
            }

            return(img);
        }