Godot Version
Godot 4.2.2
Question
So I’ve been trying to use Godot as a basic image recognition program. However, due to the lack of screen capture stuff on Godot, I’ve been resorting to using Os.execute with .exe files designed to take screenshots about every .3 seconds. Setup looks like this:
var thread0 = Thread.new()
var screenshot_current0 : Image = Image.load_from_file("res://Screenshots/0.png")
func _on_capture_timer_timeout():
if thread0.is_alive():
printerr("Called screen0 but it's still in progress!")
else:
thread0.start(screenshot_load.bind(" \"0.png\" 70 405 180 105", 0), Thread.PRIORITY_HIGH)
func screenshot_load(command, number):
var cmd_output = []
OS.execute("CMD.exe", ["/C", "cd Screenshots && screenshot-cmd.exe" + command], cmd_output)
var image
image = Image.load_from_file("res://Screenshots/" + str(number) + ".png")
call_deferred("screenshot_finished", number)
return image
func screenshot_finished(number):
if number == 0:
screenshot_current0 = thread0.wait_to_finish()
screenshot_captured.emit()
The issues comes from running this setup for an extended period of time. My RAM slowly but surely get filled up until it’s about 85% used with no other programs running. Even when going into the resource manager, there isn’t anything that stands out with excessive usage. I’ve tried both screenshot-cmd.exe and NirCmd.exe and both have this issue.
Also Godot gives me constant warnings that the Loaded resource wont work on export but I’m not planning on exporting it anyways so I don’t think that’s important.
Any fix to this or any other setup I can use to grab a part of a specific Window’s window?