masking update

This commit is contained in:
Elijah Harmon 2023-11-26 16:31:45 -08:00
parent 8429fe0441
commit a43e16432c
5 changed files with 26 additions and 23 deletions

View File

@ -3,11 +3,12 @@ screenShotHeight = 320
screenShotWidth = 320 screenShotWidth = 320
# For use in games that are 3rd person and character model interferes with the autoaim # For use in games that are 3rd person and character model interferes with the autoaim
# EXAMPLE: Fortnite and New World useMask = False
aaRightShift = 0 maskWidth = 80
maskHeight = 200
# Autoaim mouse movement amplifier # Autoaim mouse movement amplifier
aaMovementAmp = .4 aaMovementAmp = .1
# Person Class Confidence # Person Class Confidence
confidence = 0.4 confidence = 0.4

View File

@ -5,7 +5,7 @@ import bettercam
# Could be do with # Could be do with
# from config import * # from config import *
# But we are writing it out for clarity for new devs # But we are writing it out for clarity for new devs
from config import aaRightShift, screenShotHeight, screenShotWidth from config import screenShotHeight, screenShotWidth
def gameSelection() -> (bettercam.BetterCam, int, int | None): def gameSelection() -> (bettercam.BetterCam, int, int | None):
# Selecting the correct game window # Selecting the correct game window
@ -55,18 +55,8 @@ def gameSelection() -> (bettercam.BetterCam, int, int | None):
return None return None
print("Successfully activated the game window...") print("Successfully activated the game window...")
# Setting up the screen shots
sctArea: dict[str, int] = {"mon": 1, "top": videoGameWindow.top + (videoGameWindow.height - screenShotHeight) // 2,
"left": aaRightShift + ((videoGameWindow.left + videoGameWindow.right) // 2) - (screenShotWidth // 2),
"width": screenShotWidth,
"height": screenShotHeight}
#! Uncomment if you want to view the entire screen
# sctArea = {"mon": 1, "top": 0, "left": 0, "width": 1920, "height": 1080}
# Starting screenshoting engine # Starting screenshoting engine
left = aaRightShift + \ left = ((videoGameWindow.left + videoGameWindow.right) // 2) - (screenShotWidth // 2)
((videoGameWindow.left + videoGameWindow.right) // 2) - (screenShotWidth // 2)
top = videoGameWindow.top + \ top = videoGameWindow.top + \
(videoGameWindow.height - screenShotHeight) // 2 (videoGameWindow.height - screenShotHeight) // 2
right, bottom = left + screenShotWidth, top + screenShotHeight right, bottom = left + screenShotWidth, top + screenShotHeight
@ -74,8 +64,10 @@ def gameSelection() -> (bettercam.BetterCam, int, int | None):
region: tuple = (left, top, right, bottom) region: tuple = (left, top, right, bottom)
# Calculating the center Autoaim box # Calculating the center Autoaim box
cWidth: int = sctArea["width"] / 2 cWidth: int = screenShotWidth // 2
cHeight: int = sctArea["height"] / 2 cHeight: int = screenShotHeight // 2
print(region)
camera = bettercam.create(region=region, output_color="BGRA", max_buffer_len=512) camera = bettercam.create(region=region, output_color="BGRA", max_buffer_len=512)
if camera is None: if camera is None:

View File

@ -11,7 +11,7 @@ from utils.general import (cv2, non_max_suppression, xyxy2xywh)
# Could be do with # Could be do with
# from config import * # from config import *
# But we are writing it out for clarity for new devs # But we are writing it out for clarity for new devs
from config import aaMovementAmp, aaRightShift, aaQuitKey, screenShotHeight, confidence, headshot_mode, cpsDisplay, visuals, centerOfScreen from config import aaMovementAmp, useMask, maskWidth, maskHeight, aaQuitKey, screenShotHeight, confidence, headshot_mode, cpsDisplay, visuals, centerOfScreen
import gameSelection import gameSelection
def main(): def main():
@ -41,6 +41,9 @@ def main():
# Getting Frame # Getting Frame
npImg = np.array(camera.get_latest_frame()) npImg = np.array(camera.get_latest_frame())
if useMask:
npImg[-maskHeight:, :maskWidth, :] = 0
# Normalizing Data # Normalizing Data
im = torch.from_numpy(npImg) im = torch.from_numpy(npImg)
if im.shape[2] == 4: if im.shape[2] == 4:
@ -99,7 +102,7 @@ def main():
targets.sort_values(by="dist", ascending=False) targets.sort_values(by="dist", ascending=False)
# Take the first person that shows up in the dataframe (Recall that we sort based on Euclidean distance) # Take the first person that shows up in the dataframe (Recall that we sort based on Euclidean distance)
xMid = targets.iloc[0].current_mid_x + aaRightShift xMid = targets.iloc[0].current_mid_x
yMid = targets.iloc[0].current_mid_y yMid = targets.iloc[0].current_mid_y
box_height = targets.iloc[0].height box_height = targets.iloc[0].height

View File

@ -13,7 +13,7 @@ import torch
# Could be do with # Could be do with
# from config import * # from config import *
# But we are writing it out for clarity for new devs # But we are writing it out for clarity for new devs
from config import aaMovementAmp, aaRightShift, aaQuitKey, confidence, headshot_mode, cpsDisplay, visuals, onnxChoice, centerOfScreen from config import aaMovementAmp, useMask, maskHeight, maskWidth, aaQuitKey, confidence, headshot_mode, cpsDisplay, visuals, onnxChoice, centerOfScreen
import gameSelection import gameSelection
def main(): def main():
@ -49,6 +49,9 @@ def main():
# Getting Frame # Getting Frame
npImg = np.array(camera.get_latest_frame()) npImg = np.array(camera.get_latest_frame())
if useMask:
npImg[-maskHeight:, :maskWidth, :] = 0
# If Nvidia, do this # If Nvidia, do this
if onnxChoice == 3: if onnxChoice == 3:
# Normalizing Data # Normalizing Data
@ -122,7 +125,7 @@ def main():
targets.sort_values(by="dist", ascending=False) targets.sort_values(by="dist", ascending=False)
# Take the first person that shows up in the dataframe (Recall that we sort based on Euclidean distance) # Take the first person that shows up in the dataframe (Recall that we sort based on Euclidean distance)
xMid = targets.iloc[0].current_mid_x + aaRightShift xMid = targets.iloc[0].current_mid_x
yMid = targets.iloc[0].current_mid_y yMid = targets.iloc[0].current_mid_y
box_height = targets.iloc[0].height box_height = targets.iloc[0].height

View File

@ -13,7 +13,7 @@ import cupy as cp
# Could be do with # Could be do with
# from config import * # from config import *
# But we are writing it out for clarity for new devs # But we are writing it out for clarity for new devs
from config import aaMovementAmp, aaRightShift, aaQuitKey, confidence, headshot_mode, cpsDisplay, visuals, centerOfScreen from config import aaMovementAmp, useMask, maskHeight, maskWidth, aaQuitKey, confidence, headshot_mode, cpsDisplay, visuals, centerOfScreen
import gameSelection import gameSelection
def main(): def main():
@ -41,6 +41,10 @@ def main():
if npImg.shape[3] == 4: if npImg.shape[3] == 4:
# If the image has an alpha channel, remove it # If the image has an alpha channel, remove it
npImg = npImg[:, :, :, :3] npImg = npImg[:, :, :, :3]
if useMask:
npImg[:, -maskHeight:, :maskWidth, :] = 0
im = npImg / 255 im = npImg / 255
im = im.astype(cp.half) im = im.astype(cp.half)
@ -90,7 +94,7 @@ def main():
targets.sort_values(by="dist", ascending=False) targets.sort_values(by="dist", ascending=False)
# Take the first person that shows up in the dataframe (Recall that we sort based on Euclidean distance) # Take the first person that shows up in the dataframe (Recall that we sort based on Euclidean distance)
xMid = targets.iloc[0].current_mid_x + aaRightShift xMid = targets.iloc[0].current_mid_x
yMid = targets.iloc[0].current_mid_y yMid = targets.iloc[0].current_mid_y
box_height = targets.iloc[0].height box_height = targets.iloc[0].height