Beispiel #1
0
        // Sample Data creates a time stamp, waveform and image. The time stamp
        // and waveform data are bundled together and flattened to a string.
        // This data is saved with the image in an AVI so when the AVI image is
        // read out later, the same data it was written with can also be
        // retrieved.
        private void SampleData(AviInputSession sourceSession, AviOutputSession destSession, VisionImage frame, uint frameIndex)
        {
            // Get and display  time
            string timestamp = DateTime.Now.ToString();

            form2.CurTime.Text = timestamp;

            // Read the frame
            sourceSession.ReadFrame(frame, frameIndex);

            // Get and display sample waveforms
            double[] waves = new double[3];
            waves[0]  = 5 * Math.Sin(sinPhase);
            waves[1]  = 4 * Math.Cos(cosPhase);
            waves[2]  = (new Random()).NextDouble() * 6 - 3;
            sinPhase += .1;
            cosPhase += .15;

            form2.Graph.AppendData(waves[0], waves[1], waves[2]);

            AviData data = new AviData(timestamp, waves[0], waves[1], waves[2]);

            // Flatten data to buffer
            byte[] bytes = FlattenData(data);
            destSession.WriteFrame(frame, bytes);
        }
Beispiel #2
0
        private void CopyAvi(AviInputSession source, AviOutputSession dest, out double averageFrameTime)
        {
            int totalTime = 0;

            // Grab each frame.
            VisionImage[] frames = new VisionImage[source.Frames];
            for (uint i = 0; i < source.Frames; ++i)
            {
                frames[i] = new VisionImage(ImageType.Rgb32);
                source.ReadFrame(frames[i], i);
            }

            // Convert each frame.
            int startTime = System.Environment.TickCount;

            for (int i = 0; i < source.Frames; ++i)
            {
                // Write the frame.
                dest.WriteFrame(frames[i]);
            }
            totalTime        = System.Environment.TickCount - startTime;
            averageFrameTime = ((double)totalTime) / source.Frames;
        }