diff --git a/README.md b/README.md
index 7a1a3d6..9d24623 100644
--- a/README.md
+++ b/README.md
@@ -58,14 +58,11 @@ This sensor exposes the name of the currently focused window.
### WebcamActive
-This sensor shows if the webcam is currently being used. It has two detection modes:
-
-- Registry - this is the preferred method. This will work from Windows 10 version 1903 and higher.
-- OpenCV - this method tries to access the webcam and if that fails, it assumes it is currently in use. This will flash the webcam activity light at every update interval. It also uses more CPU cycles and memory.
+This sensor shows if the webcam is currently being used. It uses the Windows registry to check will work from Windows 10 version 1903 and higher.
### MicrophoneActive
-This sensor shows if the microphone is currently being used. It uses the Windows registry to check and wil work from Windows 10 version 1903 and higher.
+This sensor shows if the microphone is currently being used. It uses the Windows registry to check and will work from Windows 10 version 1903 and higher.
### CPULoad
diff --git a/UserInterface/ViewModels/AddSensorViewModel.cs b/UserInterface/ViewModels/AddSensorViewModel.cs
index 944af8d..e3303f6 100644
--- a/UserInterface/ViewModels/AddSensorViewModel.cs
+++ b/UserInterface/ViewModels/AddSensorViewModel.cs
@@ -9,7 +9,6 @@ namespace UserInterface.ViewModels
public class AddSensorViewModel : ViewModelBase
{
private AvailableSensors selectedType;
- private WebcamDetectionMode selectedDetectionMode;
private string description;
private bool showQueryInput;
@@ -32,7 +31,6 @@ namespace UserInterface.ViewModels
public AvailableSensors SelectedType { get => selectedType; set => this.RaiseAndSetIfChanged(ref selectedType, value); }
- public WebcamDetectionMode SelectedDetectionMode { get => selectedDetectionMode; set => this.RaiseAndSetIfChanged(ref selectedDetectionMode, value); }
public string Name { get; set; }
public string Query { get; set; }
diff --git a/UserInterface/Views/AddSensorDialog.axaml b/UserInterface/Views/AddSensorDialog.axaml
index 3832423..10d62ec 100644
--- a/UserInterface/Views/AddSensorDialog.axaml
+++ b/UserInterface/Views/AddSensorDialog.axaml
@@ -26,8 +26,6 @@
Window name
This is case-insensitive and loosely matched. A window called "Spotify Premium" will match "spotify" or "premium".
- Detection mode
-
-
+
diff --git a/UserInterface/Views/AddSensorDialog.axaml.cs b/UserInterface/Views/AddSensorDialog.axaml.cs
index 8bdb602..c13c2ec 100644
--- a/UserInterface/Views/AddSensorDialog.axaml.cs
+++ b/UserInterface/Views/AddSensorDialog.axaml.cs
@@ -29,9 +29,6 @@ namespace UserInterface.Views
this.comboBox = this.FindControl("ComboBox");
this.comboBox.Items = Enum.GetValues(typeof(AvailableSensors)).Cast();
- this.comboBox = this.FindControl("DetectionModeComboBox");
- this.comboBox.Items = Enum.GetValues(typeof(WebcamDetectionMode)).Cast();
-
// register IPC clients
ServiceProvider serviceProvider = new ServiceCollection()
.AddNamedPipeIpcClient("addsensor", pipeName: "pipeinternal")
@@ -51,7 +48,7 @@ namespace UserInterface.Views
public async void Save(object sender, RoutedEventArgs args)
{
var item = ((AddSensorViewModel)this.DataContext);
- dynamic model = new { item.Name, item.Query, item.UpdateInterval, item.WindowName, DetectionMode = item.SelectedDetectionMode };
+ dynamic model = new { item.Name, item.Query, item.UpdateInterval, item.WindowName};
string json = JsonSerializer.Serialize(model);
await this.client.InvokeAsync(x => x.AddSensor(item.SelectedType, json));
Close();
diff --git a/hass-workstation-service/Communication/InterProcesCommunication/InterProcessApi.cs b/hass-workstation-service/Communication/InterProcesCommunication/InterProcessApi.cs
index 27f2ad7..088a94e 100644
--- a/hass-workstation-service/Communication/InterProcesCommunication/InterProcessApi.cs
+++ b/hass-workstation-service/Communication/InterProcesCommunication/InterProcessApi.cs
@@ -1,4 +1,4 @@
-using hass_workstation_service.Communication.InterProcesCommunication.Models;
+using hass_workstation_service.Communication.InterProcesCommunication.Models;
using hass_workstation_service.Communication.NamedPipe;
using hass_workstation_service.Communication.Util;
using hass_workstation_service.Data;
@@ -107,20 +107,7 @@ namespace hass_workstation_service.Communication.InterProcesCommunication
sensorToCreate = new ActiveWindowSensor(this._publisher, (int)model.UpdateInterval, model.Name);
break;
case AvailableSensors.WebcamActiveSensor:
- DetectionMode detectionMode;
- switch ((WebcamDetectionMode)model.DetectionMode)
- {
- case WebcamDetectionMode.Registry:
- detectionMode = DetectionMode.Registry;
- break;
- case WebcamDetectionMode.OpenCV:
- detectionMode = DetectionMode.OpenCV;
- break;
- default:
- detectionMode = DetectionMode.Registry;
- break;
- }
- sensorToCreate = new WebcamActiveSensor(this._publisher, (int)model.UpdateInterval, model.Name, detectionMode);
+ sensorToCreate = new WebcamActiveSensor(this._publisher, (int)model.UpdateInterval, model.Name);
break;
case AvailableSensors.MicrophoneActiveSensor:
sensorToCreate = new MicrophoneActiveSensor(this._publisher, (int)model.UpdateInterval, model.Name);
diff --git a/hass-workstation-service/Communication/InterProcesCommunication/ServiceContractModels.cs b/hass-workstation-service/Communication/InterProcesCommunication/ServiceContractModels.cs
index ebc0bfe..5997f61 100644
--- a/hass-workstation-service/Communication/InterProcesCommunication/ServiceContractModels.cs
+++ b/hass-workstation-service/Communication/InterProcesCommunication/ServiceContractModels.cs
@@ -1,4 +1,4 @@
-using hass_workstation_service.Domain.Sensors;
+using hass_workstation_service.Domain.Sensors;
using System;
using System.Collections.Generic;
using System.Text;
@@ -42,10 +42,4 @@ namespace hass_workstation_service.Communication.InterProcesCommunication.Models
NamedWindowSensor,
IdleTimeSensor
}
-
- public enum WebcamDetectionMode
- {
- Registry,
- OpenCV
- }
}
diff --git a/hass-workstation-service/Data/ConfigurationService.cs b/hass-workstation-service/Data/ConfigurationService.cs
index ae0fea3..ac411ab 100644
--- a/hass-workstation-service/Data/ConfigurationService.cs
+++ b/hass-workstation-service/Data/ConfigurationService.cs
@@ -100,7 +100,7 @@ namespace hass_workstation_service.Data
sensor = new IdleTimeSensor(publisher, configuredSensor.UpdateInterval, configuredSensor.Name, configuredSensor.Id);
break;
case "WebcamActiveSensor":
- sensor = new WebcamActiveSensor(publisher, configuredSensor.UpdateInterval, configuredSensor.Name, configuredSensor.DetectionMode, configuredSensor.Id);
+ sensor = new WebcamActiveSensor(publisher, configuredSensor.UpdateInterval, configuredSensor.Name, configuredSensor.Id);
break;
case "MicrophoneActiveSensor":
sensor = new MicrophoneActiveSensor(publisher, configuredSensor.UpdateInterval, configuredSensor.Name, configuredSensor.Id);
diff --git a/hass-workstation-service/Data/ConfiguredSensor.cs b/hass-workstation-service/Data/ConfiguredSensor.cs
index 133870a..dcb29eb 100644
--- a/hass-workstation-service/Data/ConfiguredSensor.cs
+++ b/hass-workstation-service/Data/ConfiguredSensor.cs
@@ -11,6 +11,5 @@ namespace hass_workstation_service.Data
public string Query { get; set; }
public int? UpdateInterval { get; set; }
public string WindowName { get; set; }
- public DetectionMode DetectionMode { get; set; }
}
}
\ No newline at end of file
diff --git a/hass-workstation-service/Domain/Sensors/WebcamActiveSensor.cs b/hass-workstation-service/Domain/Sensors/WebcamActiveSensor.cs
index e3ea432..bb1c28c 100644
--- a/hass-workstation-service/Domain/Sensors/WebcamActiveSensor.cs
+++ b/hass-workstation-service/Domain/Sensors/WebcamActiveSensor.cs
@@ -1,6 +1,5 @@
using hass_workstation_service.Communication;
using Microsoft.Win32;
-using OpenCvSharp;
using System;
using System.Linq;
using System.Runtime.InteropServices;
@@ -8,35 +7,20 @@ using System.Runtime.Versioning;
namespace hass_workstation_service.Domain.Sensors
{
- public enum DetectionMode
- {
- Registry,
- OpenCV
- }
public class WebcamActiveSensor : AbstractSensor
{
- public DetectionMode DetectionMode { get; private set; }
- public WebcamActiveSensor(MqttPublisher publisher, int? updateInterval = null, string name = "WebcamActive", DetectionMode detectionMode = DetectionMode.Registry, Guid id = default(Guid)) : base(publisher, name, updateInterval ?? 10, id)
+ public WebcamActiveSensor(MqttPublisher publisher, int? updateInterval = null, string name = "WebcamActive", Guid id = default) : base(publisher, name, updateInterval ?? 10, id)
{
- this.DetectionMode = detectionMode;
}
public override string GetState()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
- switch (this.DetectionMode)
- {
- case DetectionMode.Registry:
- return IsWebCamInUseRegistry() ? "True" : "False";
- case DetectionMode.OpenCV:
- return IsWebCamInUseOpenCV() ? "True" : "False";
- default:
- return "Error";
- }
+ return IsWebCamInUseRegistry() ? "True" : "False";
}
else
{
- return "unsopported";
+ return "unsupported";
}
}
public override AutoDiscoveryConfigModel GetAutoDiscoveryConfig()
@@ -51,35 +35,6 @@ namespace hass_workstation_service.Domain.Sensors
});
}
- private bool IsWebCamInUseOpenCV()
- {
- try
- {
- VideoCapture capture = new VideoCapture(0);
- OutputArray image = OutputArray.Create(new Mat());
-
- // capture.Read() return false if it doesn't succeed in capturing
- if (capture.Read(image))
- {
- capture.Release();
- capture.Dispose();
- return false;
- }
- else
- {
- capture.Release();
- capture.Dispose();
- return true;
- }
-
- }
- catch (Exception)
- {
-
- return false;
- }
- }
-
[SupportedOSPlatform("windows")]
private bool IsWebCamInUseRegistry()
{
diff --git a/hass-workstation-service/hass-workstation-service.csproj b/hass-workstation-service/hass-workstation-service.csproj
index 06efa19..d0a83ae 100644
--- a/hass-workstation-service/hass-workstation-service.csproj
+++ b/hass-workstation-service/hass-workstation-service.csproj
@@ -1,4 +1,4 @@
-
+
net5.0
@@ -39,7 +39,6 @@
-