Optimizing a loop using multiple detectCheckerboard functions.
3 views (last 30 days)
Show older comments
Hi all,
For my third year university project I have been tasked to use matlab to track and record the moves in a chess game.
For one of my initial steps I have chosen to create a loop that looks into the folder taken, take an image, detect a checkerboard, then rotate it an adjust the image to a standardized size so that when the image is checked for squares with or without peices on them it is alot easier as each square will always be in the same location on the image.
I have got the loop to work and furthermore have been able to avoid processing unneeded using the fact that if the board isnt an 8x8, or if no checkerboard can be detected, the image is to be ignored. (Used for if a hand blocks the board, or if something is accidently dropped on said board)
Although this would work fine if I was to take all the pictures of the game first then scan through them for the moves, I want to push myself to beable to update the moves almost as soon as they happen, so that the movelist can be updated live, and perhaps even be intergrated with chess programs later on to add more advanced features (For example telling the player the best move to make next).
To do this my code has to be very fast. This script has to run faster than the gap between the images being taken, or else it wont be able to keep up with the game being played. As of right now on a resonably fast computer, my loop can process 5 images in 13 seconds. Only three of these images are actual chessboards, one is a chessboard with a line through the middle to represent when something blocks the board, and another is of a cat, to see what happens when no chessboard is detected.
What im asking is anyone can recommend any edits to my current code to make it run faster (or perhaps even a way to assign more of my computers processing power to the script?)
Bellow you can find my script, and the images i am processing, the output images gained from said processing and a screenshot of the profiller results. (folders not normally in the zip format, had to upload them to the forum in this format)
Any help would be great, thanks for reading;
-Greg
0 Comments
Answers (0)
See Also
Categories
Find more on Desktop in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!