Giter VIP home page Giter VIP logo

imneonizer / practical-opencv-project-finding-coordinates-of-detected-objects-and-knn-digit-recognition Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 1.2 MB

In this project i will show you how you can find circles in a image plus recognize digits using knn and finally arrange the recognized digits in ascending order and click on those circles in sequencially

Python 99.56% Batchfile 0.44%
knn digit-recognitoin find-circles knn-recognition finding-coordinates character-recognition game python pyautogui funnearn

practical-opencv-project-finding-coordinates-of-detected-objects-and-knn-digit-recognition's Introduction

Practical-opencv-project-finding-coordinates-of-detected-objects-and-knn-digit-recognition

In this project i will show you how you can find circles, their coordinates in an image plus recognize digits on those circles using knn and finally arrange the recognized digits in ascending order of their value and click on those circles sequencially with the help of coordinates associated with the numbers.

Actually the whole project is about creating a program to play a game automatically the aim of the program is to find circles on the main screen it can be 4 or 5 every circle has a number between 1 to 10 after finding the circles position on the screen it recognizes the digits inside the circles using KNN algorithm after that it process the information i.e 'numbers and their coordinates' on the screen whic are basically stored inside a python dictionary the numbers are arranged in ascending order along with thier position coordinates after processing the information it clicks on to those circles in the ascending order of their values.

External Modules required

>> pip install opencv-contrib-python
>> pip install pyautogui
>> pip install pillow
>> pip install numpy

lets move to the Practical hands on

Step 1: launch run.py

You will see output something similar to this output

Step 2: Lets try a different image

you can change the image to test the program, i have provides five sample images Change image change screenshot = 'images/1.png' to screenshot = 'images/2.png' or screenshot = 'images/3.png' upto five sample images that i have provided.

BTW you can play this game by downloading the application from this website

Actual image, images/1.png

Original image

So far you have got the idea and working pipeline of the project

Now lets discuss whats going behind KNN character recognition, so the program acturally reads the image from images/1.png after that it preprocess the image i.e blurring, dilation etc.. and finally runs canny edge detection algorithm to find the suitable size contours and after that it records the position coordinates in a dictionary and rename them as per their loop index numbers i.e, the circle which is at the bottom most of the images will preferably be saved as '1.png ' out of those detected circles and crops the circle and save it to an external directory for character recognition. cropped circles

once the cropped images along are saved the recogniton directory contains another find_number.py which crops the digit parts from those circles and after recognizing the numbers it renames the files as their recognized values i.e if a circle has number written as '5' inside it then it will be save as concatinated value of its index value and its recognized value idx_val.png ==1_5.png

recognized numbers

The Knn recognition file was trained with the fonts appearing inside the circle

Training image

i have written idx value first becase when we match our data with the dictionary in whih we have stored the idx values and the coordinates of the recognized it will be easier to link the recoggnized the number images with their original coordinate position after they are arranged in ascending order more over we dont know how many circles were there in the images so the index numbers idx will help to fetch the information i.e if we will call idx = 0 it will always printout the smallest recognized value and its coordinate postion from the detected circles.

Final words

The project is developed for the computer to play the game automatically and score as high as possible it is able to do so because before taking any steps it takes the screen shot analyse it and then perform any action how ever i skipped that screenshort part here and explained everything after that so you can check the program still runs when i give the screenshotted image as input.

practical-opencv-project-finding-coordinates-of-detected-objects-and-knn-digit-recognition's People

Contributors

imneonizer avatar

Watchers

 avatar  avatar  avatar

practical-opencv-project-finding-coordinates-of-detected-objects-and-knn-digit-recognition's Issues

Error

running in loop through while command
run status is: 0
deleting photos from recognition/temp_photos if any
'cleaner.exe' is not recognized as an internal or external command,
operable program or batch file.
finding contour and writing photos
running find_number.py, to recognize the numbers
error, unable to open classifications_for_questions.txt, exiting program

Press any key to continue . . .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.