- Google Goggles API
- Sudoku Wizard - a Google Goggles Experiment
So you ask, "what did you exactly build?" I remember back in January when Goggles 1.3 was announced, Google demoed a nifty new feature in Goggles, which recognizes a Sudoku puzzle when provided a picture of one and solves it for you. I was really intrigued with the service since, and that's what drove me to reverse engineer the protocol. So back to the question, I wrote a Sudoku solver Windows Phone 7 application that does just that. You might also ask, "why Windows Phone 7?" Well, it's simple really. Google Goggles is available on iOS and Android platforms - it wouldn't make much sense to build another app targeting those platforms.
If you happen to have a WP7 in your possession, check out the "Sudoku Wizard" app here. Did I mention it's free (yes, Ad-free too).
Sudoku Wizard was written using the information from my previous post. In my previous post, I said that there are two headers that need to be added to all HTTP communication with Goggles. There is another header required for this to work. I needed to modify the user-agent as well. Apparently, Goggles requires an iOS/Android device (or perhaps a WebKit browser) in order to solve your Sudoku puzzle - and that's easily taken care of by modifying the user-agent of each HTTP request. I omitted it from my instructions in my previous post because I had thought it was insignificant. So the only thing different that I needed to do was to change the user-agent in all of the HTTP POST requests. The headers now look like:
Content-Type: application/x-protobuffer
Pragma: no-cache
User-Agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_3 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7E18 Safari/528.16 GoogleMobileApp/0.7.3.5675 GoogleGoggles-iPhone/1.0; gzip
User-Agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_3 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7E18 Safari/528.16 GoogleMobileApp/0.7.3.5675 GoogleGoggles-iPhone/1.0; gzip
In C#:
httpWebRequest.UserAgent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_3 like " + "Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7E18 " + "Safari/528.16 GoogleMobileApp/0.7.3.5675 GoogleGoggles-iPhone/1.0; gzip"
When posting an image of a Sudoku, Goggles will respond with a protobuffer blob with some URLs in it. Goggles solves the Sudoku and returns the solution in a URL, which needs to be displayed in a browser. An example of a response is shown below. The highlighted URL is the one that contains the solution and needs to be shown to the user (keep in mind that the URLs will be expired by the time you have viewed them):
2f6
..
..
.. 004070030600008107013000005038 71000000000000000005932050000
210107800006090060700| 854971632629538147713246895238
714569965382471471659328586497 213147823956392165784.
similar image...;..
....... .....1./http://www.google.com/ goggles/images/sudoku.png:
Sudoku PuzzleB.J
Sudoku PuzzleR.ZOhttp://www.google. com/goggles/result?cssid=
30F2B33236EF604A&rh= 061F6991C6883113...;Q.Ohttp://
Sudoku Puzzle.
Sudoku Puzzle...;..+.8.n._.2. 965f0e6e1638152b"..
+TR=T=47zjUtTuOC0:X=N2eE6:S=_ Wfmn5yVnPqmIncl
+TR=T=VRi6Lyke0hg:X=N2eE6:S= v6Pd5Kfnqtmr6F1u
+TR=T=1Ez8_2tSjsc:X=N2eE6:S= ZH8A8bLT2fSEU0L0
+TR=T=itRprQ9o70M:X=N2eE6:S= H8Oyx0Srj8HaeyQL
+TR=T=A4_uRb4_Axg:X=N2eE6:S=_ afui5_H60kiNDEg....
0
Sudoku Wizard.