get closest to center of screen (#115)

* get closest to center of screen

* closest to center, for tensorrt
This commit is contained in:
coolgoagle 2023-11-07 11:13:52 -06:00 committed by GitHub
parent eb88b0e66e
commit ad4bc9cd72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -42,6 +42,9 @@ def main():
# Set to True if you want to get the visuals # Set to True if you want to get the visuals
visuals = False visuals = False
# Set to True if you want to move to the target closest to the center of your screen
centerOfScreen = True
# Selecting the correct game window # Selecting the correct game window
try: try:
videoGameWindows = pygetwindow.getAllWindows() videoGameWindows = pygetwindow.getAllWindows()
@ -169,8 +172,17 @@ def main():
targets = pd.DataFrame( targets = pd.DataFrame(
targets, columns=['current_mid_x', 'current_mid_y', 'width', "height", "confidence"]) targets, columns=['current_mid_x', 'current_mid_y', 'width', "height", "confidence"])
center_screen = [cWidth, cHeight]
# If there are people in the center bounding box # If there are people in the center bounding box
if len(targets) > 0: if len(targets) > 0:
if (centerOfScreen):
# Compute the distance from the center
targets["dist_from_center"] = np.sqrt((targets.current_mid_x - center_screen[0])**2 + (targets.current_mid_y - center_screen[1])**2)
# Sort the data frame by distance from center
targets = targets.sort_values("dist_from_center")
# Get the last persons mid coordinate if it exists # Get the last persons mid coordinate if it exists
if last_mid_coord: if last_mid_coord:
targets['last_mid_x'] = last_mid_coord[0] targets['last_mid_x'] = last_mid_coord[0]

View File

@ -40,6 +40,9 @@ def main():
# Set to True if you want to get the visuals # Set to True if you want to get the visuals
visuals = False visuals = False
# Set to True if you want to move to the target closest to the center of your screen
centerOfScreen = True
# Selecting the correct game window # Selecting the correct game window
try: try:
videoGameWindows = pygetwindow.getAllWindows() videoGameWindows = pygetwindow.getAllWindows()
@ -169,8 +172,17 @@ def main():
targets = pd.DataFrame( targets = pd.DataFrame(
targets, columns=['current_mid_x', 'current_mid_y', 'width', "height", "confidence"]) targets, columns=['current_mid_x', 'current_mid_y', 'width', "height", "confidence"])
center_screen = [cWidth, cHeight]
# If there are people in the center bounding box # If there are people in the center bounding box
if len(targets) > 0: if len(targets) > 0:
if (centerOfScreen):
# Compute the distance from the center
targets["dist_from_center"] = np.sqrt((targets.current_mid_x - center_screen[0])**2 + (targets.current_mid_y - center_screen[1])**2)
# Sort the data frame by distance from center
targets = targets.sort_values("dist_from_center")
# Get the last persons mid coordinate if it exists # Get the last persons mid coordinate if it exists
if last_mid_coord: if last_mid_coord:
targets['last_mid_x'] = last_mid_coord[0] targets['last_mid_x'] = last_mid_coord[0]