diff --git a/Output/Emgu.CV.UI.dll b/Output/Emgu.CV.UI.dll deleted file mode 100644 index 11bd62ef..00000000 Binary files a/Output/Emgu.CV.UI.dll and /dev/null differ diff --git a/Output/Emgu.CV.dll b/Output/Emgu.CV.dll deleted file mode 100644 index a3006b8b..00000000 Binary files a/Output/Emgu.CV.dll and /dev/null differ diff --git a/Output/Emgu.Util.dll b/Output/Emgu.Util.dll deleted file mode 100644 index 9c08a90f..00000000 Binary files a/Output/Emgu.Util.dll and /dev/null differ diff --git a/Output/Languages/Deutsch.xml b/Output/Languages/Deutsch.xml index b286b0ad..457e55b8 100644 --- a/Output/Languages/Deutsch.xml +++ b/Output/Languages/Deutsch.xml @@ -197,5 +197,7 @@ Video-Vorschau Videos während des Singens Videos der Hintergrundmusik + Webcams + Webcamfähigkeiten diff --git a/Output/Languages/English.xml b/Output/Languages/English.xml index 6037e02e..69d4536e 100644 --- a/Output/Languages/English.xml +++ b/Output/Languages/English.xml @@ -197,5 +197,7 @@ Video Preview Videos while singing Display current backgroundmusic video + Webcams + Webcamcapabilities diff --git a/Output/Themes/Ambient/Screens/ScreenOptionsVideo.xml b/Output/Themes/Ambient/Screens/ScreenOptionsVideo.xml index 0bacb58b..3cfa42b0 100644 --- a/Output/Themes/Ambient/Screens/ScreenOptionsVideo.xml +++ b/Output/Themes/Ambient/Screens/ScreenOptionsVideo.xml @@ -222,6 +222,64 @@ + + + 75 + 345 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Left + + Center + + + + Normal + + TR_SCREENO_VIDEO_WEBCAMDEVICES + + + + + + + 75 + 405 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Left + + Center + + + + Normal + + TR_SCREENO_VIDEO_WEBCAMCAPABILITIES + + + + Button @@ -497,13 +555,13 @@ 50 505 - 225 + 285 0,00 40 40 1170 - 225 + 285 0,00 40 40 @@ -539,5 +597,151 @@ 3 + + + Invisible + + SelectSlideArrowLeft + + SelectSlideArrowRight + + SelectSlide + + SelectSlideArrowLeft + + SelectSlideArrowRight + + SelectSlide + + 500 + 340 + 0,00 + 700 + 50 + + 505 + 345 + 0,00 + 40 + 40 + + 1170 + 345 + 0,00 + 40 + 40 + + + SelectSlideColor + + + SelectSlideSColor + + + SelectSlideHColor + + + ArrowColor + + + ArrowSColor + + + TextColor + + + TextSColor + + 32,00 + + 205,33 + + Normal + + Bold + + 3 + + + + Invisible + + SelectSlideArrowLeft + + SelectSlideArrowRight + + SelectSlide + + SelectSlideArrowLeft + + SelectSlideArrowRight + + SelectSlide + + 500 + 400 + 0,00 + 700 + 50 + + 505 + 405 + 0,00 + 40 + 40 + + 1170 + 405 + 0,00 + 40 + 40 + + + SelectSlideColor + + + SelectSlideSColor + + + SelectSlideHColor + + + ArrowColor + + + ArrowSColor + + + TextColor + + + TextSColor + + 32,00 + + 205,33 + + Normal + + Bold + + 3 + + + + CoverBackground + + 50 + 450 + 0,00 + 320 + 240 + + + Visible + + + + \ No newline at end of file diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index 75ed674d..35dbb5a6 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -11,6 +11,7 @@ using System.Xml.XPath; using OpenTK.Platform; using Vocaluxe.Lib.Sound; +using Vocaluxe.Lib.Webcam; namespace Vocaluxe.Base { @@ -89,7 +90,8 @@ namespace Vocaluxe.Base public enum EWebcamLib { - OpenCV + OpenCV, + AForgeNet } public enum ERecordLib @@ -261,6 +263,7 @@ namespace Vocaluxe.Base public static SMicConfig[] MicConfig; public static int MicDelay = 300; //[ms] public static EWebcamLib WebcamLib = EWebcamLib.OpenCV; + public static SWebcamConfig WebcamConfig; //Lists to save parameters and values private static List _Params = new List(); @@ -433,6 +436,13 @@ namespace Vocaluxe.Base CHelper.TryGetEnumValueFromXML("//root/Video/VideoPreview", navigator, ref VideoPreview); CHelper.TryGetEnumValueFromXML("//root/Video/VideosInSongs", navigator, ref VideosInSongs); CHelper.TryGetEnumValueFromXML("//root/Video/VideosToBackground", navigator, ref VideosToBackground); + + CHelper.TryGetEnumValueFromXML("//root/Video/WebcamLib", navigator, ref WebcamLib); + WebcamConfig = new SWebcamConfig(); + CHelper.GetValueFromXML("//root/Video/WebcamConfig/MonikerString", navigator, ref WebcamConfig.MonikerString, String.Empty); + CHelper.TryGetIntValueFromXML("//root/Video/WebcamConfig/Framerate", navigator, ref WebcamConfig.Framerate); + CHelper.TryGetIntValueFromXML("//root/Video/WebcamConfig/Width", navigator, ref WebcamConfig.Width); + CHelper.TryGetIntValueFromXML("//root/Video/WebcamConfig/Height", navigator, ref WebcamConfig.Height); #endregion Video #region Record @@ -453,9 +463,6 @@ namespace Vocaluxe.Base MicDelay = 0; if (MicDelay > 500) MicDelay = 500; - - CHelper.TryGetEnumValueFromXML("//root/Record/WebcamLib", navigator, ref WebcamLib); - #endregion Record return true; @@ -676,6 +683,18 @@ namespace Vocaluxe.Base writer.WriteComment("Show backgroundmusic videos as background: " + ListStrings(Enum.GetNames(typeof(EOffOn)))); writer.WriteElementString("VideosToBackground", Enum.GetName(typeof(EOffOn), VideosToBackground)); + writer.WriteComment("WebcamLib: " + ListStrings(Enum.GetNames(typeof(EWebcamLib)))); + writer.WriteElementString("WebcamLib", Enum.GetName(typeof(EWebcamLib), WebcamLib)); + + writer.WriteStartElement("WebcamConfig"); + + writer.WriteElementString("MonikerString", WebcamConfig.MonikerString); + writer.WriteElementString("Framerate", WebcamConfig.Framerate.ToString()); + writer.WriteElementString("Width", WebcamConfig.Width.ToString()); + writer.WriteElementString("Height", WebcamConfig.Height.ToString()); + + writer.WriteEndElement(); + writer.WriteEndElement(); #endregion Video @@ -700,9 +719,6 @@ namespace Vocaluxe.Base writer.WriteComment("Mic delay in ms. 0, 20, 40, 60 ... 500"); writer.WriteElementString("MicDelay", MicDelay.ToString()); - writer.WriteComment("WebcamLib: " + ListStrings(Enum.GetNames(typeof(EWebcamLib)))); - writer.WriteElementString("WebcamLib", Enum.GetName(typeof(EWebcamLib), WebcamLib)); - writer.WriteEndElement(); #endregion Record diff --git a/Vocaluxe/Base/CWebcam.cs b/Vocaluxe/Base/CWebcam.cs index 045ec861..78bbd2d3 100644 --- a/Vocaluxe/Base/CWebcam.cs +++ b/Vocaluxe/Base/CWebcam.cs @@ -15,15 +15,19 @@ namespace Vocaluxe.Base { switch (CConfig.WebcamLib) { - case EWebcamLib.OpenCV: - _Webcam = new COpenCV(); + case EWebcamLib.AForgeNet: + _Webcam = new CAForgeNet(); break; default: - _Webcam = new COpenCV(); + _Webcam = new CAForgeNet(); break; } _Webcam.Init(); + _Webcam.Select(CConfig.WebcamConfig); + + CConfig.WebcamConfig = _Webcam.GetConfig(); + CConfig.SaveConfig(); } public static bool GetFrame(ref STexture tex) @@ -46,5 +50,20 @@ namespace Vocaluxe.Base { _Webcam.Start(); } + + public static void Stop() + { + _Webcam.Stop(); + } + + public static void Select(SWebcamConfig c) + { + _Webcam.Select(c); + } + + public static SWebcamDevice[] GetDevices() + { + return _Webcam.GetDevices(); + } } } diff --git a/Vocaluxe/Lib/Webcam/CAForgeNet.cs b/Vocaluxe/Lib/Webcam/CAForgeNet.cs new file mode 100644 index 00000000..3e798c37 --- /dev/null +++ b/Vocaluxe/Lib/Webcam/CAForgeNet.cs @@ -0,0 +1,167 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Vocaluxe.Base; +using AForge.Video; +using System.Drawing; +using AForge.Video.DirectShow; +using System.Drawing.Imaging; +using System.Runtime.InteropServices; +using Vocaluxe.Lib.Draw; +using System.Threading; + +namespace Vocaluxe.Lib.Webcam +{ + class CAForgeNet : IWebcam + { + private Bitmap _CurrentFrame = new Bitmap(1, 1); + private List _Devices = new List(); + private bool _Paused; + private VideoCaptureDevice _Webcam; + private FilterInfoCollection _WebcamDevices; + private SWebcamConfig _Config; + + public void Close() + { + if (_Webcam != null) + { + _Webcam.SignalToStop(); + _Webcam.NewFrame -= new NewFrameEventHandler(OnFrame); + } + } + + public bool GetFrame(ref STexture Frame) + { + if ((_CurrentFrame != null) && (_Webcam != null)) + { + lock (_CurrentFrame) + { + BitmapData bitmapdata = _CurrentFrame.LockBits(new Rectangle(0, 0, _CurrentFrame.Width, _CurrentFrame.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); + byte[] data = new byte[4 * _CurrentFrame.Width * _CurrentFrame.Height]; + Marshal.Copy(bitmapdata.Scan0, data, 0, data.Length); + _CurrentFrame.UnlockBits(bitmapdata); + if (((Frame.index == -1) || (_CurrentFrame.Width != Frame.width)) || (_CurrentFrame.Height != Frame.height)) + { + CDraw.RemoveTexture(ref Frame); + Frame = CDraw.AddTexture(_CurrentFrame.Width, _CurrentFrame.Height, ref data); + } + else + { + CDraw.UpdateTexture(ref Frame, ref data); + } + } + } + return false; + } + + public bool Init() + { + _WebcamDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); + int num = 0; + foreach (FilterInfo info in _WebcamDevices) + { + SWebcamDevice device = new SWebcamDevice { + ID = num, + Name = info.Name, + MonikerString = info.MonikerString, + Capabilities = new List() + }; + num++; + VideoCaptureDevice tmpdev = new VideoCaptureDevice(info.MonikerString); + + for (int i = 0; i < tmpdev.VideoCapabilities.Length; i++ ) + { + SCapabilities item = new SCapabilities + { + Framerate = tmpdev.VideoCapabilities[i].FrameRate, + Height = tmpdev.VideoCapabilities[i].FrameSize.Height, + Width = tmpdev.VideoCapabilities[i].FrameSize.Width + }; + device.Capabilities.Add(item); + } + _Devices.Add(device); + } + return true; + } + + private void OnFrame(object sender, NewFrameEventArgs e) + { + if (!_Paused) + { + lock (_CurrentFrame) + { + _CurrentFrame = (Bitmap) e.Frame.Clone(); + } + } + } + + public void Pause() + { + if (_Webcam != null) + { + _Paused = true; + } + } + + public void Start() + { + if (_Webcam != null) + { + _Webcam.NewFrame -= new NewFrameEventHandler(OnFrame); + //Subscribe to NewFrame event + _Webcam.NewFrame += new NewFrameEventHandler(OnFrame); + _Webcam.Start(); + _Paused = false; + } + } + + public void Stop() + { + if (_Webcam != null) + { + _Webcam.SignalToStop(); + } + } + + public SWebcamDevice[] GetDevices() + { + return _Devices.ToArray(); + } + + public bool Select(SWebcamConfig Config) + { + //Close old camera connection + Close(); + + if (_WebcamDevices == null) + return false; + + //No MonikerString found, try first webcam + if (Config.MonikerString == String.Empty) + _Webcam = new VideoCaptureDevice(_WebcamDevices[0].MonikerString); + else //Found MonikerString + _Webcam = new VideoCaptureDevice(Config.MonikerString); + + if (_Webcam == null) + return false; + + if (Config.Framerate != 0 && Config.Height != 0 && Config.Width != 0) + { + _Webcam.DesiredFrameRate = Config.Framerate; + _Webcam.DesiredFrameSize = new Size(Config.Width, Config.Height); + } + + _Config.Framerate = _Webcam.DesiredFrameRate; + _Config.Height = _Webcam.DesiredFrameSize.Height; + _Config.Width = _Webcam.DesiredFrameSize.Width; + _Config.MonikerString = _Webcam.Source; + + return true; + } + + public SWebcamConfig GetConfig() + { + return _Config; + } + } +} diff --git a/Vocaluxe/Lib/Webcam/COpenCV.cs b/Vocaluxe/Lib/Webcam/COpenCV.cs deleted file mode 100644 index d6d9e032..00000000 --- a/Vocaluxe/Lib/Webcam/COpenCV.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Emgu.CV; -using Emgu.CV.Structure; -using Emgu.Util; -using Vocaluxe.Base; -using System.Drawing; -using System.Drawing.Imaging; -using System.Runtime.InteropServices; - -namespace Vocaluxe.Lib.Webcam -{ - class COpenCV : IWebcam - { - Image _CurrentFrame; - Capture _CaptureDevice; - - Object Mutex = new Object(); - - public bool Init() - { - //Create a new default Capture - _CaptureDevice = new Capture(); - if (_CaptureDevice != null) - _CaptureDevice.ImageGrabbed += OnImageGrabbed; - - return true; - } - - public void Start() - { - if (_CaptureDevice != null) - _CaptureDevice.Start(); - } - - public void Pause() - { - if (_CaptureDevice != null) - _CaptureDevice.Pause(); - } - - public void Close() - { - if(_CaptureDevice != null) - _CaptureDevice.Dispose(); - } - - public bool GetFrame(ref Draw.STexture Frame) - { - if (_CurrentFrame != null) - { - Bitmap b = _CurrentFrame.ToBitmap(); - BitmapData bd = b.LockBits(new Rectangle(0, 0, _CurrentFrame.Width, _CurrentFrame.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); - byte[] data = new byte[4 * _CurrentFrame.Width * _CurrentFrame.Height]; - Marshal.Copy(bd.Scan0, data, 0, data.Length); - - if (Frame.index == -1 || _CurrentFrame.Width != Frame.width || _CurrentFrame.Height != Frame.height) - { - CDraw.RemoveTexture(ref Frame); - Frame = CDraw.AddTexture(_CurrentFrame.Width, _CurrentFrame.Height, ref data); - } - else - { - CDraw.UpdateTexture(ref Frame, ref data); - } - - b.UnlockBits(bd); - b.Dispose(); - return true; - } - return false; - } - - public void OnImageGrabbed(object sender, EventArgs e) - { - _CurrentFrame = _CaptureDevice.RetrieveBgrFrame(); - } - } -} diff --git a/Vocaluxe/Lib/Webcam/IWebcam.cs b/Vocaluxe/Lib/Webcam/IWebcam.cs index 9a389f5a..ad937a6d 100644 --- a/Vocaluxe/Lib/Webcam/IWebcam.cs +++ b/Vocaluxe/Lib/Webcam/IWebcam.cs @@ -5,14 +5,42 @@ using Vocaluxe.Lib.Draw; namespace Vocaluxe.Lib.Webcam { + struct SWebcamDevice + { + public int ID; + public string Name; + public string MonikerString; + public List Capabilities; + } + + struct SCapabilities + { + public int Framerate; + public int Width; + public int Height; + } + + struct SWebcamConfig + { + public string MonikerString; + public int Framerate; + public int Width; + public int Height; + } + interface IWebcam { bool Init(); void Start(); void Pause(); + void Stop(); void Close(); bool GetFrame(ref STexture Frame); + SWebcamConfig GetConfig(); + SWebcamDevice[] GetDevices(); + + bool Select(SWebcamConfig sWebcamConfig); } } diff --git a/Vocaluxe/Screens/CScreenOptionsVideo.cs b/Vocaluxe/Screens/CScreenOptionsVideo.cs index fd693db6..8a2c530e 100644 --- a/Vocaluxe/Screens/CScreenOptionsVideo.cs +++ b/Vocaluxe/Screens/CScreenOptionsVideo.cs @@ -5,6 +5,7 @@ using System.Windows.Forms; using Vocaluxe.Base; using Vocaluxe.Menu; +using Vocaluxe.Lib.Webcam; namespace Vocaluxe.Screens @@ -18,9 +19,16 @@ namespace Vocaluxe.Screens private const string SelectSlideVideoPreview = "SelectSlideVideoPreview"; private const string SelectSlideVideosInSongs = "SelectSlideVideosInSongs"; private const string SelectSlideVideosToBackground = "SelectSlideVideosToBackground"; + private const string SelectSlideWebcamDevices = "SelectSlideWebcamDevices"; + private const string SelectSlideWebcamCapabilities = "SelectSlideWebcamCapabilities"; + + private const string StaticWebcamOutput = "StaticWebcamOutput"; private const string ButtonExit = "ButtonExit"; + private SWebcamConfig _Config; + Lib.Draw.STexture _WebcamTexture = new Lib.Draw.STexture(-1); + public CScreenOptionsVideo() { Init(); @@ -33,8 +41,9 @@ namespace Vocaluxe.Screens _ThemeName = "ScreenOptionsVideo"; _ScreenVersion = ScreenVersion; + _ThemeStatics = new string[] { StaticWebcamOutput }; _ThemeButtons = new string[] { ButtonExit }; - _ThemeSelectSlides = new string[] { SelectSlideVideoBackgrounds, SelectSlideVideoPreview, SelectSlideVideosInSongs, SelectSlideVideosToBackground }; + _ThemeSelectSlides = new string[] { SelectSlideVideoBackgrounds, SelectSlideVideoPreview, SelectSlideVideosInSongs, SelectSlideVideosToBackground, SelectSlideWebcamDevices, SelectSlideWebcamCapabilities }; } public override void LoadTheme() @@ -45,6 +54,23 @@ namespace Vocaluxe.Screens SelectSlides[htSelectSlides(SelectSlideVideoPreview)].SetValues((int)CConfig.VideoPreview); SelectSlides[htSelectSlides(SelectSlideVideosInSongs)].SetValues((int)CConfig.VideosInSongs); SelectSlides[htSelectSlides(SelectSlideVideosToBackground)].SetValues((int)CConfig.VideosToBackground); + + SWebcamDevice[] dev = CWebcam.GetDevices(); + foreach(SWebcamDevice d in dev) + { + SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].AddValue(d.Name); + } + int deviceNr = SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection; + for (int i = 0; i < dev[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities.Count; i++) + { + SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].AddValue(dev[deviceNr].Capabilities[i].Width.ToString() + " x " + dev[deviceNr].Capabilities[i].Height.ToString() + " @ " + dev[deviceNr].Capabilities[i].Framerate.ToString()); + } + SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection = 0; + + _Config.MonikerString = dev[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].MonikerString; + _Config.Width = dev[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities[SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection].Width; + _Config.Height = dev[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities[SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection].Height; + _Config.Framerate = dev[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities[SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection].Framerate; } public override bool HandleInput(KeyEvent KeyEvent) @@ -78,10 +104,18 @@ namespace Vocaluxe.Screens break; case Keys.Left: + if (SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selected) + OnDeviceEvent(); + if (SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selected) + OnCapabilitiesEvent(); SaveConfig(); break; case Keys.Right: + if (SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selected) + OnDeviceEvent(); + if (SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selected) + OnCapabilitiesEvent(); SaveConfig(); break; } @@ -101,6 +135,10 @@ namespace Vocaluxe.Screens if (MouseEvent.LB && IsMouseOver(MouseEvent)) { + if (SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selected) + OnDeviceEvent(); + if (SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selected) + OnCapabilitiesEvent(); SaveConfig(); if (Buttons[htButtons(ButtonExit)].Selected) { @@ -112,6 +150,8 @@ namespace Vocaluxe.Screens public override bool UpdateGame() { + CWebcam.GetFrame(ref _WebcamTexture); + Statics[htStatics(StaticWebcamOutput)].Texture = _WebcamTexture; SelectSlides[htSelectSlides(SelectSlideVideosToBackground)].Selection = (int)CConfig.VideosToBackground; return true; } @@ -119,18 +159,70 @@ namespace Vocaluxe.Screens public override bool Draw() { base.Draw(); + return true; } + public override void OnClose() + { + CWebcam.Close(); + base.OnClose(); + } + + public override void OnShow() + { + CWebcam.Close(); + CWebcam.Select(_Config); + CWebcam.Start(); + base.OnShow(); + } + private void SaveConfig() { CConfig.VideoBackgrounds = (EOffOn)SelectSlides[htSelectSlides(SelectSlideVideoBackgrounds)].Selection; CConfig.VideoPreview = (EOffOn)SelectSlides[htSelectSlides(SelectSlideVideoPreview)].Selection; CConfig.VideosInSongs = (EOffOn)SelectSlides[htSelectSlides(SelectSlideVideosInSongs)].Selection; CConfig.VideosToBackground = (EOffOn)SelectSlides[htSelectSlides(SelectSlideVideosToBackground)].Selection; + + CConfig.WebcamConfig = _Config; CBackgroundMusic.VideoEnabled = true; CConfig.SaveConfig(); } + + private void OnDeviceEvent() + { + int deviceNr = SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection; + SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Clear(); + + SWebcamDevice[] d = CWebcam.GetDevices(); + for (int i = 0; i < d[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities.Count; i++) + { + SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].AddValue(d[deviceNr].Capabilities[i].Width.ToString() + " x " + d[deviceNr].Capabilities[i].Height.ToString() + " @ " + d[deviceNr].Capabilities[i].Framerate.ToString()); + } + SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection = 0; + + _Config.MonikerString = d[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].MonikerString; + _Config.Width = d[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities[SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection].Width; + _Config.Height = d[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities[SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection].Height; + _Config.Framerate = d[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities[SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection].Framerate; + + CWebcam.Close(); + CWebcam.Select(_Config); + CWebcam.Start(); + } + + private void OnCapabilitiesEvent() + { + SWebcamDevice[] d = CWebcam.GetDevices(); + _Config.MonikerString = d[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].MonikerString; + _Config.Width = d[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities[SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection].Width; + _Config.Height = d[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities[SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection].Height; + _Config.Framerate = d[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities[SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection].Framerate; + + CWebcam.Close(); + CWebcam.Select(_Config); + CWebcam.Start(); + } } } diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 121e4dc7..d884936c 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -207,7 +207,7 @@ namespace Vocaluxe.Screens if (_Webcam) CWebcam.Start(); else - CWebcam.Pause(); + CWebcam.Stop(); break; case Keys.Enter: @@ -621,6 +621,8 @@ namespace Vocaluxe.Screens PrepareTimeLine(); CSound.Play(_CurrentStream); CSound.RecordStart(); + if(_Webcam) + CWebcam.Start(); } private void Stop() @@ -629,6 +631,8 @@ namespace Vocaluxe.Screens CGraphics.FadeTo(EScreens.ScreenScore); _FadeOut = true; + if (_Webcam) + CWebcam.Close(); } private void UpdateLyrics() diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index 111b12f7..ed6e4df2 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -141,21 +141,19 @@ + + False + ..\Output\AForge.Video.dll + False + + + False + ..\Output\AForge.Video.DirectShow.dll + False + ..\Output\Community.CsharpSqlite.dll - - False - ..\Output\Emgu.CV.dll - - - False - ..\Output\Emgu.CV.UI.dll - - - False - ..\Output\Emgu.Util.dll - ..\Output\OpenTK.dll @@ -219,7 +217,7 @@ - +