public Form1() { SetDpiAwareness(); InitializeComponent(); WriteToLog("PippoFPS PUBG Killtrigger Started!"); float value = (generalColorThreshold / 250f) * 100f; tBColorThreshold.Value = Convert.ToInt16(value); tBColorThreshold.Update(); this.Show(); this.Refresh(); //Get OBS Preview Window to capture IntPtr windowhandle = IntPtr.Zero; while (windowhandle == IntPtr.Zero) { //Let User Pick Process using (var form = new ProcessPicker("obs")) { var result = form.ShowDialog(); if (result == DialogResult.OK) { windowhandle = form.WindowHandle; } else { form.Dispose(); } } } gcaptr.SetWindowHandle = windowhandle; //OBS Remote obsRemote = OBSRemote.Instance; WriteToLog(obsRemote.Connect()); GetAllScreenComponents(); string modelpath = @"./learning/KillDetectionModel.mdl"; if (File.Exists(modelpath)) { learninghelper = new LearningHelper(modelpath); } }
private void Worker_LearnThresholds_DoWork(object sender, DoWorkEventArgs e) { LearningHelper learninghelper = new LearningHelper(); int samplescollected = 0; while (!Worker_LearnThresholds.CancellationPending) { while (GetKillNumber() == 0 && !Worker_LearnThresholds.CancellationPending) { ScreenData scrData = GetScreenData(); if (GetKillNumber() == 0) { scrData.Kill = false; learninghelper.AddData(scrData); samplescollected++; } } List <int> thisKill = new List <int>(); while (GetKillNumber() > 0 && !Worker_LearnThresholds.CancellationPending) { ScreenData scrData = GetScreenData(); if (GetKillNumber() > 0) { scrData.Kill = true; learninghelper.AddData(scrData); samplescollected++; } } } Worker_LearnThresholds.ReportProgress(0, String.Format("Collected a total of {0} samples", samplescollected)); Worker_LearnThresholds.ReportProgress(0, "Creating model from samples...."); double accuracy = learninghelper.LearnFromData(5000); Worker_LearnThresholds.ReportProgress(0, String.Format("Model created. Accuracy on 20% of testdata is {0}", accuracy)); learninghelper.SaveModel(@"./learning/KillDetectionModel.mdl"); }