Coder Social home page Coder Social logo

dengqizhou30 / aiassist Goto Github PK

View Code? Open in Web Editor NEW
248.0 4.0 61.0 34.74 MB

GameAssist是一个AI游戏助手,结合OpenCv、OpenCvSharp4、ssd_mobilenet_v3等技术,对游戏对象进行识别,支持自动瞄准/自动开枪等功能,提升玩家的游戏体验

License: Apache License 2.0

C# 97.08% Python 1.37% PowerShell 1.55%
opencv tensorflow mobilenetv3 pubg

aiassist's Introduction

通告:本项目不再更新,新项目地址 https://github.com/dengqizhou30/AIAssistOpenCV
新项目做了重构简化,已发布可运行程序,有兴趣的兄弟可以下载试用 https://github.com/dengqizhou30/AIAssistOpenCV/releases

GameAssist是一个AI游戏助手,结合OpenCv、OpenCvSharp4、ssd_mobilenet_v3等技术,对游戏对象进行识别,支持自动瞄准/自动开枪等功能,提升玩家的游戏体验;

OpenCvSharp作者不再支持CUDA加速,编译CUDA一堆问题,正在考虑是否继续使用OpenCvSharp,或者切换到c++项目。c++的UI前端选型比较麻烦,mfc等技术太老,winui3又太新,试用中发现各种不便,纠结中......
找个节假日,切换到c++项目算了,有兴趣的兄弟多交流


工具和普通游戏外挂不同:
普通游戏外挂:通过需改游戏执行代码/修改游戏内存数据/拦截游戏网络通讯等手段,破坏游戏进程,达到提升目的,这些手段是违法的。
GameAssist:使用AI技术进行屏幕检测,原理是用人工智能技术来玩游戏,不使用任何破坏游戏进程的手段。


一、技术栈说明:

1、图像处理框架:
使用OpenCv进行图像封装及AI对象识别;
使用OpenCvSharp4封装库,将OpenCv引入C#开发运行环境;
使用windwos gdi32的Bitmap的Graphics类的CopyFromScreen,获取屏幕像素作为输入图像;

2、AI模型选择:
使用OpenCv的DNN网络模块,加载AI模型进行图像检测;
使用tensoflow的对象检测模型ssd_mobilenet_v3,作为人像检测模型;

注意:OpenCV DNN 模块调用 TensorFlow 训练的目标检测模型时,需要一个额外的配置文件,其主要是基于与 protocol buffers(protobuf) 格式序列化图(graph) 相同的文本格式版本.
OpenCV提供对应的python脚本,根据模型文件来生成模型配置文件:
生成OpenCV生成模型配置文件命令参考:
docker run -it -v /root/123:/root/123 tensorflow/tensorflow:latest-py3 /bin/bash
python tf_text_graph_ssd.py --input frozen_inference_graph.pb --config pipeline.config --output ssd_mobilenet_v2.pbtxt
python tf_text_graph_ssd.py --input frozen_inference_graph.pb --config pipeline.config --output ssd_mobilenet_v3.pbtxt

3、键盘鼠标操作设置:
很多游戏禁止鼠标键盘hook,外部进程无法通过传统事件机制向游戏进程发送鼠标键盘事件。
要实现游戏不会拦截的键盘鼠标操作,需要使用可编程的鼠标键盘硬件设备,这些硬件设备提供程序可以调用的SDK,控制硬件设备来发送鼠标键盘事件。
这种鼠标键盘设备,淘宝上有,USB接口的,具体信息这里不方便列出来,各位兄弟自己去找。


二、测试效果:

1、运行环境:
windows10,16核CPU,16G内存,8G rtx3070显卡

2、测试游戏:
目前只测试了PUBG的绝地求生、腾讯的逆战两款游戏。
逆战图像里面的图像识别准确率比绝地求生高,效果也更好,借助工具辅助,个人由一个菜鸟升级为中高级玩家。

游戏效果截图:
![blockchain](https://github.com/dengqizhou30/AIAssist/blob/master/GameAssist/test/AIAssist.png)
![blockchain](https://github.com/dengqizhou30/AIAssist/blob/master/GameAssist/test/juediqiusheng1.png)
![blockchain](https://github.com/dengqizhou30/AIAssist/blob/master/GameAssist/test/nizhan1.png)
![blockchain](https://i.postimg.cc/yJ6s4z9G/nizhan1.jpg)


三、后续优化方向:

1、模型调优1:目前直接使用了预训练模型,图像识别效果一般。后续需要针对具体的游戏,整理训练样本,进行调优训练,提升识别准确率;(这个需要手工截图、标注,太繁琐,目前实在懒得做)
2、模型调优2:目前只使用对象识别模型,后续尝试对象识别模型和对象追踪算法进行组合,提升模型识别效率;
3、鼠标追踪算法调优:3D游戏鼠标移动瞄准算法,需要不断尝试调优;
4、技术栈升级:opencv、AI模型等,全栈技术紧追业界发展,最快升级到新版本;
5、图像检测使用gpu/CUDA加速,降低cpu消耗同时提升图像检测速度;


四、使用gpu加速:

OpenCvSharp4缺省不支持CUDA,需要使用者自己定制编译。 1、定制编译支持CUDA的OpenCv:
https://github.com/shimat/opencv_files

官方文档中没有说明如何cuda,在运行build_windows.ps1前,需要修改这个文件,添加CUDA配置:
-D WITH_CUDA=ON `
-D CUDA_ARCH_BIN=8.6 `
-D CUDA_ARCH_PTX=8.6 `
文件内容参考 .\GameAssist\tool\cuda\build_windows.ps1
注意CUDA_ARCH_*的值,和你显卡实际的计算能力对应,具体值参考显卡官网:
https://developer.nvidia.com/zh-cn/cuda-gpus
2、定制编译支持CUDA的OpenCvSharp4;
https://github.com/shimat/opencvsharp
在OpenCvSharp.csproj文件中,增加ENABLED_CUDA。
在OpenCvSharpExtern项目上右键,属性,找到c/c++,预编译,增加ENABLED_CUDA。
详细步骤可以参考下面的链接: shimat/opencvsharp#1299
https://blog.csdn.net/bashendixie5/article/details/106162481

OpenCvSharp作者不再支持CUDA加速,这块编译一堆问题,正在考虑是否继续使用OpenCvSharp,或者切换到c++项目......


3、代码中指定使用CUDA进行后台加速:
this.detectionNet.SetPreferableBackend(Backend.CUDA);
this.detectionNet.SetPreferableTarget(Target.CUDA);


五、引用的框架及项目:

1、intel贡献的大神级图像处理框架OpenCv:
https://opencv.org/

OpenCV DNN 模块目前支持多种AI对象检测模型推理运行:
https://github.com/opencv/opencv/tree/master/samples/dnn
https://github.com/opencv/opencv/wiki/TensorFlow-Object-Detection-API
https://github.com/openvinotoolkit/open_model_zoo

2、OpenCvSharp4封装库,将OpenCv引入C#开发运行环境;
https://github.com/shimat/opencvsharp
在Visual Studio中,可以通过NuGet安装OpenCvSharp程序包;

3、谷歌tensoflow的对象检测模型ssd_mobilenet_v3;
https://github.com/tensorflow
https://github.com/tensorflow/models
https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet/README.md
https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2_detection_zoo.md
https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf1_detection_zoo.md


六、联系方式:

日常工作繁忙,不能及时回复,各位可以在 issues 区留言交流。

aiassist's People

Contributors

dengqizhou30 avatar eternaltitan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

aiassist's Issues

可用聊聊吗?

老哥,对于此我想当感兴趣,目前我使用DMA作弊,对你的AI辅助相当感兴趣!

关于鼠标移动得问题

请问您是怎么做到可以 将识别到人物坐标 让鼠标得准星准确得移动到人物得坐标位置得呢?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.