Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
SnapSudoku
-
This is not my project, but SnapSudoku is a really neat idea... Take a picture of a Sudoku puzzle in a newspaper and then use Python to OCR the numbers in that puzzle and then solve it. This one uses OpenCV but it would be cool to have a Pythonista version.
It would drive Sudoku players crazy if you could walk up with your iPhone, snap a picture of their puzzle, and show them the solution. The project is Python code so check it out.
Peter Norvig, Director of Engineering at Google has a really interesting Sudoku solver in Python that is a wonderful read. The average time to solve a random Sudoku puzzle is 0.01 seconds.
-
@ccc l did you to and complete the evelator challenge? I was just interested in using it. I live on the 9th floor with 2 elevators. Actually one of the elevators also goes to the roof. So one with 9 floors, the other 10 floors. It's frustratingly bad being at the right place when you need it. Just thought it would be fun to fiddle with a completed simulator
-
I remember something similar being in Programming Computer Vision with Python. If I remember correctly, the solution in that book doesn't use OpenCV, but it does use
scipy
(and maybe also a C implementation of SIFT feature point detection?)Anyway, that won't run in Pythonista but it's certainly closer, so I thought I'd share.
-
The use of OpenCV has been one of the most requested features for awhile. Directly integrating a third partly library into Pythonista is a huge amount of work so @omz has had to keep it on the request list in order to concentrate on other priorities such as getting Python3 done.
A lot has been done with the ability to load and then access a library of code (a framework) from within Pythonista using the objc_util module. You can load and access most of the Apple frameworks now except that you are still limited by Pythonista permissions (plist).
@omz has stated that he learned some new things that have allowed him to run both Python2 and Python3 as shared libraries of code within the same App. I am hoping that this means that something like OpenCV could also now be tackled as a shared library now. There are others in the forum that have attempted to do this in the past that may know more and weigh in on this. My sense is that it might now be possible to do it for yourself using the current XCode template with the ability to release it to others who own the Pythonista App as a longer term possibility.
I think your idea for a Sudoku app could make this the "hello world" example of how to do this since it is a game. The UI alone shows how to implement an interactive grid if tiles and has been done many times already in Pythonista. Filling in the grid using OCR would be a killer demo IMHO.
-
I presume you know that Google Goggles does this now. Of course having it in Pythonista running locally would be very nice.
-
I loved Peter Norvig's section on Why?... especially the quote that Sudoku is "a denial of service attack on human intellect"!!
@Webmaster4o Yes. Section 8.4 Optical Character Recognition starting on pg. 228 of the book you mention above seems to be very applicable but as you say, it requires SciPy which Pythonista does not currently support. Would there be a way to OCR a Sudoku puzzle on the current Pythonista i.e. without OpenCV and SciPy.
@wradcliffe I am not an expert on this but I do not believe that Apple will allow Pythonista to access a third party shared library. I would love to be proven wrong but I believe the shared library would need to be signed with the same digital signature as Pythonista.
@ihf I did not know that Google Goggles did this. It is still a cool challenge.
-
@ccc - you may be right but at least we can agree that this is just a decision that Apple can make now as part of the deployment process through the App store. By opening up the discussion again - I was hoping that @omz could share what he has learned recently that may change the picture. I think that @omz has formally sanctioned using PythonistaKit framework outside of the template indicates he is thinking of providing it as its own 3rd party shared library at some point. Maybe soon!
-
You could use PIL and a Nueral Network to read the sudoku ad solve it. The problem would be making a nureal network with out using a libaray that uses c code. And also then there is the actual solving.
-
From what I have read the solving is the easy part.,a lot of Python code out there for this. Seems the problematic thing is converting a pic/photo into a sudoku puzzle grid with the entries. That's the challenge
-
Could this library potentially help?
I know it is in ObjC however converting it to Python doesn't look to difficult.
It would only provide the points, however writing an algorithm to determine where those points are and what they represent shouldn't be too difficult. -
Note that I've written maze-cv, an app that scans and solves mazes.
The code for recognizing box-shaped objects is probably applicable to the soduku application (though maze-cv requires big red markers on the corners)
maze-cv
includes code for perspective transformations using PIL and numpy that works in Pyyhonista. It also has code for thresholding and segmenting the resulting image. So it really implements everything besides the OCR on individual characters, which I think there are objective c libraries for rendering.Anyway, that's probably useful code, especially since it was all written for Pythonista.
-
SnapSudoku now uses the Norvig code to solve the Sudoku puzzle. Now we need a version that works on Pythonista. @Webmaster4o can you work your magic like you did with maze-cv or @omz can we get OpenCV or SciPy in Pythonista?
-
I am working on a simple Nuertal Network for reading numbers to help with this project. If you can break the image into the boxes I can read the number in each one.
-
http://sudokugrab.blogspot.com/2009/07/how-does-it-all-work.html
has a good summary of puzzle detection algorothms, and some refernces on number recognition. -
Looks like some of the stuff in PCV will run with just
matplotlib
andnumpy
, not sure how much though.