0

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?

1 Answers1

0

Thanks to @The Laggy Tablet, I did some research and found 100+ youtube video tutorials about Tkinter by John Alder. I am not sure if I can post links, so I won't, but it is very easy to find.

It is actually pretty easy to use and when you finish it and make it into an actual GUI, other people can use it without needing to install any dependencies, or even Python.

Hope this helps someone in the future. Cheers!