Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ packages
/sunone_aimbot_2/models
/sunone_aimbot_2/modules/SimpleIni.h
/sunone_aimbot_2/modules/serial
/sunone_aimbot_2/modules/licenseguard
/sunone_aimbot_2/modules/makcu-cpp-1.3.4
/sunone_aimbot_2/modules/obs-teleport-main
/sunone_aimbot_2/modules/cudnn
/sunone_aimbot_2/config.ini
/sunone_aimbot_2/modules/TensorRT-10.14.1.48
setup_opencv_dml_run.log
Expand Down
4 changes: 2 additions & 2 deletions sunone_aimbot_2/capture/capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,12 +802,12 @@ void captureThread(int CAPTURE_WIDTH, int CAPTURE_HEIGHT)

if (currentCfg.backend == "DML" && dml_detector)
{
dml_detector->processFrame(detectionFrame);
dml_detector->processFrame(detectionFrame, screenshotCpu);
}
#ifdef USE_CUDA
else if (currentCfg.backend == "TRT")
{
trt_detector.processFrame(detectionFrame);
trt_detector.processFrame(detectionFrame, screenshotCpu);
}
#endif
}
Expand Down
46 changes: 46 additions & 0 deletions sunone_aimbot_2/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,18 @@ bool Config::loadConfig(const std::string& filename)
aim_sim_show_history = true;
aim_sim_show_kalman_debug = true;

// Data collection
collect_data_while_playing = false;
collect_only_when_aimbot_running = false;
collect_only_when_targets_present = true;
collect_save_every_n_frames = 15;
collect_jpeg_quality = 95;
collect_output_dir.clear();
auto_label_data = true;
auto_label_min_conf = 0.30f;
auto_label_max_boxes = 20;
auto_label_record_classes.clear();

// Classes
class_player = 0;
class_head = 1;
Expand Down Expand Up @@ -564,6 +576,17 @@ bool Config::loadConfig(const std::string& filename)
aim_sim_show_history = get_bool("aim_sim_show_history", true);
aim_sim_show_kalman_debug = get_bool("aim_sim_show_kalman_debug", true);

collect_data_while_playing = get_bool("collect_data_while_playing", false);
collect_only_when_aimbot_running = get_bool("collect_only_when_aimbot_running", false);
collect_only_when_targets_present = get_bool("collect_only_when_targets_present", true);
collect_save_every_n_frames = get_long("collect_save_every_n_frames", 15);
collect_output_dir = get_string("collect_output_dir", "");
collect_jpeg_quality = get_long("collect_jpeg_quality", 95);
auto_label_data = get_bool("auto_label_data", true);
auto_label_min_conf = (float)get_double("auto_label_min_conf", 0.30);
auto_label_max_boxes = get_long("auto_label_max_boxes", 20);
auto_label_record_classes = get_string("auto_label_record_classes", "");

if (kalman_process_noise_position < 0.0001f) kalman_process_noise_position = 0.0001f;
if (kalman_process_noise_position > 5000.0f) kalman_process_noise_position = 5000.0f;
if (kalman_process_noise_velocity < 0.0001f) kalman_process_noise_velocity = 0.0001f;
Expand Down Expand Up @@ -610,6 +633,15 @@ bool Config::loadConfig(const std::string& filename)
if (aim_sim_target_stop_chance < 0.0f) aim_sim_target_stop_chance = 0.0f;
if (aim_sim_target_stop_chance > 0.95f) aim_sim_target_stop_chance = 0.95f;

if (collect_save_every_n_frames < 1) collect_save_every_n_frames = 1;
if (collect_save_every_n_frames > 600) collect_save_every_n_frames = 600;
if (collect_jpeg_quality < 50) collect_jpeg_quality = 50;
if (collect_jpeg_quality > 100) collect_jpeg_quality = 100;
if (auto_label_min_conf < 0.01f) auto_label_min_conf = 0.01f;
if (auto_label_min_conf > 0.99f) auto_label_min_conf = 0.99f;
if (auto_label_max_boxes < 1) auto_label_max_boxes = 1;
if (auto_label_max_boxes > 200) auto_label_max_boxes = 200;

// Classes
class_player = get_long("class_player", 0);
class_head = get_long("class_head", 1);
Expand Down Expand Up @@ -857,6 +889,20 @@ bool Config::saveConfig(const std::string& filename)
<< "aim_sim_show_history = " << (aim_sim_show_history ? "true" : "false") << "\n"
<< "aim_sim_show_kalman_debug = " << (aim_sim_show_kalman_debug ? "true" : "false") << "\n\n";

file << "# Data Collection\n"
<< "collect_data_while_playing = " << (collect_data_while_playing ? "true" : "false") << "\n"
<< "collect_only_when_aimbot_running = " << (collect_only_when_aimbot_running ? "true" : "false") << "\n"
<< "collect_only_when_targets_present = " << (collect_only_when_targets_present ? "true" : "false") << "\n"
<< "collect_save_every_n_frames = " << collect_save_every_n_frames << "\n"
<< "collect_jpeg_quality = " << collect_jpeg_quality << "\n"
<< "collect_output_dir = " << collect_output_dir << "\n"
<< "auto_label_data = " << (auto_label_data ? "true" : "false") << "\n"
<< std::fixed << std::setprecision(2)
<< "auto_label_min_conf = " << auto_label_min_conf << "\n"
<< std::setprecision(0)
<< "auto_label_max_boxes = " << auto_label_max_boxes << "\n"
<< "auto_label_record_classes = " << auto_label_record_classes << "\n\n";

// Classes
file << "# Custom Classes\n"
<< "class_player = " << class_player << "\n"
Expand Down
12 changes: 12 additions & 0 deletions sunone_aimbot_2/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,18 @@ class Config
bool aim_sim_show_history;
bool aim_sim_show_kalman_debug;

// Data collection
bool collect_data_while_playing;
bool collect_only_when_aimbot_running;
bool collect_only_when_targets_present;
int collect_save_every_n_frames;
int collect_jpeg_quality;
std::string collect_output_dir;
bool auto_label_data;
float auto_label_min_conf;
int auto_label_max_boxes;
std::string auto_label_record_classes;

void clampGameOverlayColor()
{
auto clamp255 = [](int& v) { if (v < 0) v = 0; if (v > 255) v = 255; };
Expand Down
12 changes: 5 additions & 7 deletions sunone_aimbot_2/detector/cuda_preprocess.cu
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#ifdef USE_CUDA
#include <cuda_runtime.h>
#include <opencv2/core/cuda.hpp>
#include <opencv2/core/cuda_types.hpp>

static __global__ void hwc_to_chw_norm_kernel(
const float* __restrict__ srcHwc, int srcStepFloats,
Expand All @@ -23,7 +21,8 @@ static __global__ void hwc_to_chw_norm_kernel(
}

void launch_hwc_to_chw_norm(
const cv::cuda::GpuMat& hwcFloat3,
const float* srcHwc,
size_t srcStepBytes,
float* dstChw,
int width,
int height,
Expand All @@ -32,11 +31,10 @@ void launch_hwc_to_chw_norm(
const dim3 block(16, 16);
const dim3 grid((width + block.x - 1) / block.x, (height + block.y - 1) / block.y);

const int stepFloats = static_cast<int>(hwcFloat3.step) / sizeof(float);
const float* srcPtr = reinterpret_cast<const float*>(hwcFloat3.ptr<float>());
const int stepFloats = static_cast<int>(srcStepBytes / sizeof(float));

hwc_to_chw_norm_kernel << <grid, block, 0, stream >> > (
srcPtr, stepFloats, dstChw, width, height
srcHwc, stepFloats, dstChw, width, height
);
}
#endif
#endif
7 changes: 4 additions & 3 deletions sunone_aimbot_2/detector/cuda_preprocess.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#pragma once
#ifdef USE_CUDA
#include <cstddef>
#include <cuda_runtime.h>
#include <opencv2/core/cuda.hpp>

void launch_hwc_to_chw_norm(
const cv::cuda::GpuMat& hwcFloat3,
const float* srcHwc,
size_t srcStepBytes,
float* dstChw,
int width,
int height,
cudaStream_t stream
);
#endif
#endif
46 changes: 36 additions & 10 deletions sunone_aimbot_2/detector/dml_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "dml_detector.h"
#include "sunone_aimbot_2.h"
#include "scr/data_collector.h"
#include "postProcess.h"
#include "capture.h"
#include "other_tools.h"
Expand Down Expand Up @@ -372,7 +373,7 @@ int DirectMLDetector::getNumberOfClasses()
}
}

void DirectMLDetector::processFrame(const cv::Mat& frame)
void DirectMLDetector::processFrame(const cv::Mat& detection_frame, const cv::Mat& source_frame)
{
if (detectionPaused)
{
Expand All @@ -384,7 +385,8 @@ void DirectMLDetector::processFrame(const cv::Mat& frame)
return;
}
std::unique_lock<std::mutex> lock(inferenceMutex);
currentFrame = frame;
currentFrame = detection_frame;
currentSourceFrame = source_frame.empty() ? detection_frame : source_frame;
frameReady = true;
inferenceCV.notify_one();
}
Expand Down Expand Up @@ -415,6 +417,7 @@ void DirectMLDetector::dmlInferenceThread()
}

cv::Mat frame;
cv::Mat sourceFrame;
bool hasNewFrame = false;
{
std::unique_lock<std::mutex> lock(inferenceMutex);
Expand All @@ -426,6 +429,7 @@ void DirectMLDetector::dmlInferenceThread()
if (frameReady)
{
frame = std::move(currentFrame);
sourceFrame = std::move(currentSourceFrame);
frameReady = false;
hasNewFrame = true;
}
Expand All @@ -443,15 +447,37 @@ void DirectMLDetector::dmlInferenceThread()
std::vector<Detection> filteredDetections = detections;
filterDetectionsByDepthMask(filteredDetections);

std::lock_guard<std::mutex> lock(detectionBuffer.mutex);
detectionBuffer.boxes.clear();
detectionBuffer.classes.clear();
for (const auto& d : filteredDetections) {
detectionBuffer.boxes.push_back(d.box);
detectionBuffer.classes.push_back(d.classId);
std::vector<cv::Rect> boxes;
std::vector<int> classes;
std::vector<float> confidences;
boxes.reserve(filteredDetections.size());
classes.reserve(filteredDetections.size());
confidences.reserve(filteredDetections.size());
for (const auto& d : filteredDetections)
{
boxes.push_back(d.box);
classes.push_back(d.classId);
confidences.push_back(d.confidence);
}
detectionBuffer.version++;
detectionBuffer.cv.notify_all();

{
std::lock_guard<std::mutex> lock(detectionBuffer.mutex);
detectionBuffer.boxes = boxes;
detectionBuffer.classes = classes;
detectionBuffer.version++;
detectionBuffer.cv.notify_all();
}

const cv::Mat& frameForCollection = sourceFrame.empty() ? frame : sourceFrame;
cvm::MaybeCollectDataSample(
"",
config.ai_model.c_str(),
frameForCollection,
boxes,
classes,
confidences,
aiming.load(),
config);
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions sunone_aimbot_2/detector/dml_detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DirectMLDetector
std::vector<std::vector<Detection>> detectBatch(const std::vector<cv::Mat>& frames);

void dmlInferenceThread();
void processFrame(const cv::Mat& frame);
void processFrame(const cv::Mat& detection_frame, const cv::Mat& source_frame = cv::Mat());

int getNumberOfClasses();

Expand All @@ -42,10 +42,11 @@ class DirectMLDetector

std::mutex inferenceMutex;
cv::Mat currentFrame;
cv::Mat currentSourceFrame;
bool frameReady = false;

void initializeModel(const std::string& model_path);
Ort::MemoryInfo memory_info;
};

#endif // DIRECTML_DETECTOR_H
#endif // DIRECTML_DETECTOR_H
Loading