I am a beginner at coding. I use python and windows 10
I wrote a very simple code that captures and then opens an image, then loops match template in order to determine what is the object in that image using a list containing all the possible answers. Code uses pyautogui and opencv:
import pyautogui
import cv2 as cv
def my_func():
#train image
pyautogui.screenshot("train.png") #I am looking at the picture of an animal and the robot takes a screenshot and stores it.
train_img = cv.imread("train.png", 0)
#Contains all the images to iterate through
template_list = ["apple.png", "person.png", "animal.png"]
for i in template_list:
#template image
template_img = cv.imread(i,0)
#match template
result = cv.matchTemplate(train_img, template_img, cv.TM_CCOEFF_NORMED)
min_val, max_val, min_loc, max_loc = cv.minMaxLoc(result)
if max_val >= .85:
print(i) #prints the name of the matched image
return True
print("could not match the train image to one of the available templates.")
return False
The expected output is just for the console to print:
animal.png
I want to create an application, a window or anything of the sort where you click a button that says "Run" and then the code will run. When done, it will display the console log.
You can do this is VS Code, but while the code is running, I can't see the console log (because I need to go to the image where it will take a screenshot) and I want to be able to see it.
So my questions are:
Is it possible to create a desktop app for windows to do this task?
Will that app work on other computers besides mine?
Do you recommend any other alternatives?