ardupilot/Tools/ArdupilotMegaPlanner/Utilities/Video.cs
Michael Oborne 512c46a86a APM Planner 1.1.87
add popouts in config/setup
add more text to hud heading nw,ne,sw,se
add 5 m filter to antenna tracker
add refresh param buttons
remove the word old, as people still want it.
modify telem playback interface with slider bars
add posible fix to bad grid spacing
move mavlink code.
2012-05-20 14:47:20 +08:00

79 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AForge;
using AForge.Video;
using AForge.Video.DirectShow;
namespace ArdupilotMega.Utilities
{
public class Video
{
private static FilterInfoCollection videoDevices;
private static AsyncVideoSource asyncSource;
public static bool isRunning { get { if (asyncSource == null) return false; return asyncSource.IsRunning; } }
public static List<string> getDevices()
{
List<string> list = new List<string>();
// Get the collection of video devices
videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach (FilterInfo dev in videoDevices)
{
list.Add(dev.Name);
}
return list;
}
public static void Start(VideoCaptureDevice videoSource)
{
videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
//VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[Device].MonikerString);
videoSource.DesiredFrameRate = 25;
asyncSource = new AsyncVideoSource(videoSource, true);
asyncSource.NewFrame += new NewFrameEventHandler(asyncSource_NewFrame);
asyncSource.Start();
}
static void asyncSource_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
//GCSViews.FlightData.cam_camimage(eventArgs.Frame);
if (MainV2.instance.IsDisposed)
Dispose();
}
public static void Stop()
{
Dispose();
}
/// <summary> release everything. </summary>
public static void Dispose()
{
try
{
asyncSource.Stop();
asyncSource = null;
}
catch { }
asyncSource_NewFrame(null, new NewFrameEventArgs(null));
}
~Video()
{
Dispose();
}
}
}