Note: you will need to manually create private/
directory.
Requirement:
- an Android phone.
- opencv-python and python 3.7. I have no idea nor do I care why it only works on 3.7.
- adb, we will do screenshots and issue taps using it.
- a compiled binary of tents-demo.
- android_input_agent
Here are few steps to have a working program, if my memory serves.
-
Collect sample for different sizes.
Each different puzzle size needs one. Collect and store them under
private/samples/{h}x{w}/
, whereh
is the screen height of the phone andw
screen width. The naming pattern issample-{size}x{size}.png
where{size}
is the size of the puzzle (a number from5
to22
).To take phone screenshots, use
adb exec-out screencap -p > sample-{size}x{size}.png
. -
Generate
private/preset.json
.This file allows us to quickly find cell positions for all different sizes of the puzzle board.
For this you just need to run
cd py; ./gen_preset.py
. -
Collect digit samples.
We'll need to visit through those samples again in order to collect digit samples for recognition to work. Tagging with
cd py; ./tagging.py
.For the tagging process, it is recommended that you tag at most one sample for each digit at one iteration, this allows us to get a smaller set of samples (untagged samples will be removed if next time it can be recognized (by newly added samples) with a good score.
-
Have a working tents-demo binary.
-
Set
PYTHONPATH
so that it points to a local copy ofandroid_input_agent
's client -
Set environment variable
TENTS_DEMO_BIN
to the location of the binary. -
Set environment variable
AIA_PORT
, which should point to a running server ofandroid_input_agent
. -
cd py/
then./solver.py
when the phone is at a game screen. -
(Optional) Set environment variable
PUZZLE_RECORDS
to a file path to append recognized puzzles to it. -
cd py/; ./analyze_samples.py
can used to gather some analysis, this is mostly just for experimenting with threshold methods.