aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-03-22 16:21:16 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-03-22 16:21:16 +0200
commit3de0d44f88b713e7b018f470c7bd318a775345b7 (patch)
tree7b5b2a1b50e4a9ab9e2f55269dd666133fd97e5e /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels
parente4498de8bf54d586d5af7d119b7c33ad4c0031b5 (diff)
downloadTango-3de0d44f88b713e7b018f470c7bd318a775345b7.tar.gz
Tango-3de0d44f88b713e7b018f470c7bd318a775345b7.zip
Implemented video recording on Data Capture Module!
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs34
1 files changed, 33 insertions, 1 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs
index 9062da11a..b3d717263 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs
@@ -7,6 +7,7 @@ using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
+using System.Windows.Media.Imaging;
using Tango.Core.Commands;
using Tango.Integration.Diagnostics;
using Tango.Integration.Operation;
@@ -89,6 +90,16 @@ namespace Tango.MachineStudio.DataCapture.ViewModels
/// </summary>
public IMachineOperator MachineOperator { get; set; }
+ private List<CaptureDevice> _captureDevices;
+ /// <summary>
+ /// Gets or sets the capture devices.
+ /// </summary>
+ public List<CaptureDevice> CaptureDevices
+ {
+ get { return _captureDevices; }
+ set { _captureDevices = value; RaisePropertyChangedAuto(); }
+ }
+
#endregion
#region Commands
@@ -172,7 +183,7 @@ namespace Tango.MachineStudio.DataCapture.ViewModels
MediaSeekForwardCommand = new RelayCommand(MediaSeekForward, () => !Recorder.IsRecording && Player.IsPlaying);
MediaSeekBackwardCommand = new RelayCommand(MediaSeekBackward, () => !Recorder.IsRecording && Player.IsPlaying);
MediaSeekCommand = new RelayCommand<double>(MediaSeek, (x) => Player.IsPlaying);
- MediaSeekHoldCommand = new RelayCommand(MediaSeekHold,() => Player.IsPlaying);
+ MediaSeekHoldCommand = new RelayCommand(MediaSeekHold, () => Player.IsPlaying);
_recordingsFolder = Path.Combine(SettingsManager.DefaultFolder, "Recordings");
Directory.CreateDirectory(_recordingsFolder);
@@ -184,6 +195,8 @@ namespace Tango.MachineStudio.DataCapture.ViewModels
_recordingBarItem = new BarItem(_notification, new RecordingBarView() { DataContext = this });
_playerBarItem = new BarItem(_notification, new PlayingBarView() { DataContext = this });
+ CaptureDevices = VideoCaptureProvider.AvailableCaptureDevices.ToList();
+
LoadRecordings();
}
@@ -204,6 +217,14 @@ namespace Tango.MachineStudio.DataCapture.ViewModels
if (Recorder.IsRecording)
{
Recorder.Write(frame);
+
+ Task.Factory.StartNew(() =>
+ {
+ CaptureDevices.First().Invoke(() =>
+ {
+ Recorder.Write(CaptureDevices.Where(x => x.VideoSource != null).Select(x => x.VideoSource.GetAsFrozen() as BitmapSource));
+ });
+ });
}
}
}
@@ -289,6 +310,8 @@ namespace Tango.MachineStudio.DataCapture.ViewModels
Player = player;
Player.FrameReceived += Player_FrameReceived;
}
+
+ CaptureDevices.ForEach(x => x.DisableSourceUpdate());
}
private void Player_FrameReceived(object sender, DataFileFrame frame)
@@ -296,6 +319,14 @@ namespace Tango.MachineStudio.DataCapture.ViewModels
if (_frameProvider.Disable)
{
_frameProvider.PushFrame(frame.PushDiagnosticsResponse);
+
+ CaptureDevices.First().BeginInvoke(() =>
+ {
+ for (int i = 0; i < frame.VideoFrames.Count; i++)
+ {
+ CaptureDevices[i].VideoSource = frame.VideoFrames[i].ToByteArray().ToBitmapSource();
+ }
+ });
}
}
@@ -339,6 +370,7 @@ namespace Tango.MachineStudio.DataCapture.ViewModels
else if (Player.IsPlaying)
{
await Player.Stop();
+ CaptureDevices.ForEach(x => x.EnableSourceUpdate());
_frameProvider.Disable = false;
_playerBarItem.Pop();
}