Ejemplo n.º 1
0
        public void SetFrame(int frame)
        {
            CurrentHotFrame = null;

            if ((frame >= 0) && (frame < dataStream.DataLines.Count()))
            {
                if (frame != currentFrame)
                {
                    if (frameBox.Image != null)
                    {
                        frameBox.Image.Dispose();
                    }
                    ImageDataLine dataLine = (ImageDataLine)dataStream.DataLines[frame];
                    String        fileName = dataLine.ImageFileName;

                    if (Path.GetExtension(fileName) == ".yuv")
                    {
                        frameBox.Image = YUVConverter.Convert(project.Folder + "\\" + dataStream.SubFolder + "\\" + fileName, logger);
                    }
                    else
                    {
                        frameBox.Image = Image.FromFile(project.Folder + "\\" + dataStream.SubFolder + "\\" + fileName);
                    }

                    frameBox.ZoomToFit();
                    frameBox.Refresh();
                    currentFrame = frame;

                    //some UI stuff
                    lblStatus.Text = dataLine.TimeType.ToString() + " " + dataLine.TimeStamp.ToString("yyyy-MM-dd HH:mm:ss.fff") + " #: " + currentFrame;
                    trackBar.Value = currentFrame;
                }
            }
            else
            {
                frameBox.Image = null;
                if (frame < 0)
                {
                    currentFrame   = 0;
                    trackBar.Value = 0;
                }
                else if (frame > dataStream.DataLines.Count())
                {
                    currentFrame   = dataStream.DataLines.Count() - 1;
                    trackBar.Value = trackBar.Maximum;
                }

                //some UI stuff
                toolStripStatus.Text = "Outside of the stream time limits.";
            }
        }
Ejemplo n.º 2
0
        private void YUVConverterWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            String sourceFolder = @"E:\CAR\2017_08_28_1\Cameras\PTGREY";
            String dstFolder    = @"E:\CAR\2017_08_28_1\Cameras\PTGREY";

            //string[] files = Directory.GetFiles(folder, "*.yuv", SearchOption.AllDirectories).OrderBy(f => f.LastWriteTime);
            DirectoryInfo directoryInfo = new DirectoryInfo(sourceFolder);
            var           files         = directoryInfo.GetFiles("*.yuv", SearchOption.AllDirectories).OrderBy(t => t.LastWriteTime).ToList();

            int[] fileIds = new int[100];
            for (int i = 0; i < 100; i++)
            {
                fileIds[i] = 1;
            }

            int fi = 0;

            foreach (FileInfo file in files)
            {
                ConsoleLogger.WriteLineInfo(" ");
                int camId = System.Convert.ToInt32(file.Name.Substring(1, 1));

                string dstFolderFile = dstFolder + "\\PTGREY" + camId;
                if (!Directory.Exists(dstFolderFile))
                {
                    Directory.CreateDirectory(dstFolderFile);
                }

                String dstFile = dstFolderFile + "\\A" + camId + "-" + fileIds[camId].ToString().PadLeft(5, '0');

                if (File.Exists(dstFile + ".bmp"))
                {
                    ConsoleLogger.WriteLineInfo("" + dstFile + " [(" + fi + "/" + files.Count() + ")" + ((double)fi / (double)files.Count() * 100.0).ToString("0.0") + "%] FILE EXISTS. SKIP.");
                    Thread.Sleep(100);
                }
                else
                {
                    ConsoleLogger.WriteLineInfo("" + dstFile + " [(" + fi + "/" + files.Count() + ")" + ((double)fi / (double)files.Count() * 100.0).ToString("0.0") + "%]");
                    Bitmap bmp = YUVConverter.Convert(file.FullName, dstFile, ConsoleLogger);
                    bmp.Dispose();
                }

                fileIds[camId]++;
                fi++;
            }
        }
Ejemplo n.º 3
0
        private void openYUVFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = Project.Folder;
            openFileDialog.Filter           = "txt files (*.yuv)|*.txt|All files (*.*)|*.*";
            openFileDialog.FilterIndex      = 2;
            openFileDialog.RestoreDirectory = true;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                String filePath = openFileDialog.FileName;
                String path     = Path.GetDirectoryName(filePath);
                String filename = Path.GetFileNameWithoutExtension(filePath);
                String dstFile  = path + "\\" + filename + ".bmp";

                toolStripProgressBar.Visible = true;
                BackgroundWorker worker = new BackgroundWorker();
                Bitmap           result = null;
                worker.DoWork += delegate(object bgworker, DoWorkEventArgs bge)
                {
                    result = YUVConverter.Convert(filePath, dstFile, ConsoleLogger);
                };

                worker.RunWorkerCompleted += delegate(object bgworker, RunWorkerCompletedEventArgs bge)
                {
                    toolStripProgressBar.Visible = false;
                    if (result != null)
                    {
                        SingleImageWnd form = new SingleImageWnd(result);
                        form.MdiParent = this;
                        form.Show();
                    }
                };

                worker.RunWorkerAsync();
            }
        }