antes do hardware chegar
00Ambiente e ferramentas
simulaçãoestudo
▶PC do jogo
Instalar ferramentas de firmware
- ✓VS Code + extensão STM32CubeIDE (STMicroelectronics)
- ✓Arduino IDE + pacote SparkFun (Pro Micro)
- ✓Drivers ST-Link via STM32CubeProgrammer
PC do jogo — OBS
Configurar OBS NVENC + SRT
Configura o OBS para usar encoder NVENC (GPU) e transmitir via SRT para o PC antigo.
Configurações → Stream Serviço: Custom Servidor: srt://192.168.1.X:5000 Configurações → Saída → Streaming Encoder: NVENC H.264 Bitrate: 3000 kbps Preset: Low-Latency HP Keyframe: 1s Configurações → Vídeo Resolução: 640x360 FPS: 30
⚠ Se a GPU não suportar NVENC, usa x264 ultrafast como fallback.
PC antigo — C++
Instalar stack C++
- g++ C++17 (sudo apt install build-essential)
- OpenCV 4.x (sudo apt install libopencv-dev)
- ONNX Runtime (onnxruntime.ai)
- libsrt (sudo apt install libsrt-dev)
- serialib header-only (github.com/imabot2/serialib)
- ffmpeg (sudo apt install ffmpeg)
g++ -O2 -std=c++17 main.cpp \ $(pkg-config --cflags --libs opencv4) \ -lpthread -o mouse_ai
PC antigo — Python
Instalar stack Python para treino
pip install torch ultralytics opencv-python pyserial numpy
- PyTorch + Ultralytics instalados
ℹ Python só é usado para treinar modelos. A inferência roda em C++.
validação — SRT
Testar pipeline SRT antes do hardware
#include <opencv2/opencv.hpp>
int main() {
cv::VideoCapture cap("srt://0.0.0.0:5000?mode=listener",
cv::CAP_FFMPEG);
cap.set(cv::CAP_PROP_BUFFERSIZE, 1);
cv::Mat frame;
while (true) {
cap.read(frame);
if (!frame.empty()) {
cv::imshow("SRT OK", frame);
if (cv::waitKey(1) == 'q') break;
}
}
}✓ Validação: imagem da tela do PC do jogo aparece no PC antigo.
fase 1 — pro micro hid
01Pro Micro emulando mouse USB HID
simulaçãohardware
▶fase 2 — uart stm32 ↔ pro micro
02UART com level shifter TXS0108E
simulaçãohardware
▶fase 3 — stm32 usb host
03STM32 como USB Host lendo o mouse físico
hardware real
▶fase 4 — pipeline c++ + srt
04PC antigo — C++ recebe SRT e processa IA
hardwarec++
▶fase 5 — fusão + brake assist
05Fusão movimento real + IA e brake assist
hardware realcalibração
▶fase 6 — humanização (opcional)
06Humanização — Bézier + YOLO + LSTM
c++ / pythonhardware
▶referências rápidas
★Latências, bibliotecas e links
referência
▶