Files
HawkeyeVision/Plugins/LindtLeerformPlugin/Plugin.cs
2026-04-07 14:52:20 +02:00

40 lines
1.5 KiB
C#

using LindtLeerformPlugin.Services;
using Ninject;
using VisionBuilder.UI.Common;
using VisionBuilder.UI.Common.Plugins;
using VisionBuilder.UI.Common.Processing;
using VisionBuilder.UI.Common.ViewModel.Interfaces.UI;
namespace LindtLeerformPlugin;
public class Plugin : IPlugin
{
public void RegisterGlobalModules(IKernel kernel)
{
kernel.Rebind<IRecipeCreationTool>().To<LeerformRecipeCreationTool>().InSingletonScope();
}
public void RegisterCameraModules(IKernel kernel, string cameraName)
{
kernel.Bind<LeerformSettings, ISettings>().ToConstant(new LeerformSettings(cameraName));
// Remove existing recognition settings ISettings binding before rebinding
var existingRecognitionControlSettings = kernel.GetBindings(typeof(BaseRecognitionControlSettings)).First();
var toRemove = kernel.GetBindings(typeof(ISettings))
.First(x => x.ProviderCallback.Target == existingRecognitionControlSettings.ProviderCallback.Target);
kernel.RemoveBinding(toRemove);
kernel.Bind<LeerformRecognitionControlSettings, BaseRecognitionControlSettings, ISettings>()
.ToConstant(new LeerformRecognitionControlSettings(cameraName));
kernel.Bind<LeerformPatternRecognitionService>().ToSelf().InSingletonScope();
kernel.Bind<LeerformRecipeStore>().ToSelf().InSingletonScope();
kernel.Rebind<IRecognitionControl>()
.To<LeerformRecognitionControl>()
.InSingletonScope();
kernel.RegisterModule<LeerformModule>();
}
}