Crossword puzzles are a very popular pastime in most parts of the western world, and provide a quick means of escape for those on the commute or on break from regular work. The solution to the more interesting puzzles require a fairly good vocabulary and the ability to spot patterns and word arrangements. I recently saw an article on using MATLAB to solve a Sudoku puzzle using image acquisition toolbox and a Sudoku solver algorithm. This series of articles will take a slightly different approach, we will still use the image acquisition toolbox; however, instead of an algorithm to solve the puzzle we will use data scraping form a puzzle website to get the most suitable word for a particular place in the crossword.
The website we will be using to get solutions is One Across
MATLAB is built on the java platform and is able to execute java code written at the command line or inserted in .m files. This feature will be exploited in future articles for doing tasks more suitable to the java toolset.
Example Java and MATLAB code in one .m file
%% import java.net.*; import java.io.*; data = URLEncoder.encode('http://www.oneacross.com/cgi-bin/search_banner.cgi?c0=&p0=r%3Foogle&s=+Go%21+'); url = URL('http://www.oneacross.com/'); con = url.openConnection(); con.setDoOutput(true); wr = OutputStreamWriter(con.getOutputStream()); wr.write(data); rd = BufferedReader(InputStreamReader(con.getInputStream())); while rd.readLine() ~= '' %MATLAB CODE line = ans; end
In part two of this series we will look at using image acquisition to capture a live video feed for the puzzle we want to solve and overlaying the possible solution unto the video feed, stay tuned.