Skip to content

Commit

Permalink
version 1.7 for sudoku capturer
Browse files Browse the repository at this point in the history
  • Loading branch information
rladstaetter committed Jan 6, 2016
1 parent e37ddd3 commit 898492a
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 146 deletions.
31 changes: 1 addition & 30 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,36 +69,7 @@
<version>5.2</version>
</dependency>
</dependencies>
<configuration>
<release>true</release>
<run>
<debug>false</debug>
</run>
<proguard>
<skip>false</skip>
<config>proguard.cfg</config>
</proguard>
<sdk>
<platform>21</platform>
</sdk>
<extractDuplicates>true</extractDuplicates>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<executions>
<execution>
<id>zipAlign</id>
<phase>install</phase>
<goals>
<goal>zipalign</goal>
</goals>
<configuration>
<zipalign>
<skip>false</skip>
<verbose>true</verbose>
</zipalign>
</configuration>
</execution>
</executions>

</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
Expand Down
21 changes: 5 additions & 16 deletions sudoku-android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ created. A keystore is necessary for signing the application. There are several

To install the application on your device, type:

mvn clean android:generate-sources package android:deploy

mvn clean install
mvn android:deploy

## For App Store upload

For signing and releasing it for the app store:

mvn clean android:generate-sources install -Pandroid,sign
mvn package -Psign,SETTINGS.android

Make sure you've defined the necessary properties in your settings.xml, namely

android.keystore
Expand All @@ -32,16 +32,5 @@ For upload to app store use

via the web interface of googles play store.

## TODOS

- create a HUD with a frame so the user knows where to place the sudoku
- translate to chinese
- improvement of detection algorithm for the sudoku corners
- parameter dialog / preferences
- change minimal number of cells to start solving algorithm
- change minimal number of hits for a cell
- fix bug that contour lines show in black, not in green (only on samsung2)
- progress bar implementieren: entlang dem bild unten einen bar der von rot auf grün wechselt,
und je nach anzahl der erkannten nummern sich langsam füllt
- mini thumb matrix links oben anzeigen von erkannten zahlen


30 changes: 30 additions & 0 deletions sudoku-android/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,36 @@
<plugin>
<groupId>com.simpligility.maven.plugins</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<release>true</release>
<run>
<debug>false</debug>
</run>
<proguard>
<skip>false</skip>
<config>proguard.cfg</config>
</proguard>
<sdk>
<platform>21</platform>
</sdk>
<extractDuplicates>true</extractDuplicates>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<executions>
<execution>
<id>zipAlign</id>
<phase>package</phase>
<goals>
<goal>zipalign</goal>
</goals>
<configuration>
<zipalign>
<skip>false</skip>
<verbose>true</verbose>
</zipalign>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
4 changes: 2 additions & 2 deletions sudoku-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.ladstatt.sudoku"
android:versionCode="9"
package="net.ladstatt.apps.sudoku.android"
android:versionCode="1700"
android:versionName="1.7"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.android.com/apk/res/android">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.ladstatt.sudoku
package net.ladstatt.apps.sudoku.android

import _root_.android.app.Activity
import _root_.android.os.{Bundle, Handler, Process}
Expand All @@ -8,10 +8,9 @@ import _root_.android.view.{Gravity, View, WindowManager}
import _root_.android.widget.{Button, FrameLayout}
import com.google.ads.{AdRequest, AdSize, AdView}
import net.ladstatt.sudoku._
import net.ladstatt.sudoku.R
import org.opencv.android.{OpenCVLoader, CameraBridgeViewBase}
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2
import org.opencv.android.{CameraBridgeViewBase, OpenCVLoader}
import org.opencv.core._
import org.opencv.core.Mat

import scala.concurrent.Await
import scala.concurrent.duration._
Expand Down Expand Up @@ -121,7 +120,7 @@ class SudokuCapturer extends Activity with CvCameraViewListener2 with CanLog {

override def onBackPressed(): Unit = {
super.onBackPressed()
logInfo("backButton pressed")
//logInfo("backButton pressed")
}

override def onStop(): Unit = {
Expand All @@ -131,21 +130,21 @@ class SudokuCapturer extends Activity with CvCameraViewListener2 with CanLog {

override def onPause(): Unit = {
super.onPause()
logInfo("onPause called")
//logInfo("onPause called")
if (cameraView != null) cameraView.disableView()
}

override def onResume(): Unit = {
super.onResume()
logInfo("onResume called")
// logInfo("onResume called")
AndroidOpenCV.init()
//OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback)
()
}

override def onDestroy(): Unit = {
super.onDestroy()
logInfo("onDestroy called")
//logInfo("onDestroy called")
if (cameraView != null) cameraView.disableView()
}

Expand All @@ -168,11 +167,11 @@ class SudokuCapturer extends Activity with CvCameraViewListener2 with CanLog {
}

def onCameraViewStarted(width: Int, height: Int) {
logInfo(s"onCameraViewStarted (width: $width, height: $height)")
//logInfo(s"onCameraViewStarted (width: $width, height: $height)")
}

def onCameraViewStopped() {
logInfo("onCameraViewStopped called")
// logInfo("onCameraViewStopped called")
}

def onCameraFrame(inputFrame: CameraBridgeViewBase.CvCameraViewFrame): Mat = {
Expand Down Expand Up @@ -204,52 +203,4 @@ class SudokuCapturer extends Activity with CvCameraViewListener2 with CanLog {
}
}

/*
def onCameraFrame2(inputFrame: CameraBridgeViewBase.CvCameraViewFrame): Mat = {
if (solution != null) {
solution
} else {
if (!calculationInProgress) {
calculationInProgress = true
Try {
logInfo("starting to find sudoku ...")
detectSudoku(inputFrame)
} match {
case Success(frameResult) => {
if (isValidSolution(frameResult.solutionString)) {
solution = frameResult.solution
logInfo("found sudoku: " + frameResult.solutionString)
// execOnUIThread(rescanButton.setVisibility(View.VISIBLE))
}
execOnUIThread(updateSLabels2(history.mkValueIntermediateMatrix))
execOnUIThread(nrDetections.setText(history.detectedNumbers.size.toString))
// execOnUIThread(updateSLabels(frameResult.detectedCells))
calculationInProgress = false
frameResult.solution
}
case Failure(e: SudokuException) => {
val mat = Await.result(mkMatWithCurve(inputFrame.rgba, e.curve, new Scalar(0, 255, 0), 1), Duration.Inf)
solution = null
calculationInProgress = false
logInfo("couldn't find sudoku: " + e.getMessage)
mat
}
case Failure(e) => {
solution = null
calculationInProgress = false
// history.reset
// execOnUIThread(resetSLabels())
logInfo("sudoku error: " + e.getMessage)
inputFrame.gray
}
}
} else {
logInfo("calculation in progress ...")
inputFrame.gray
}
}
} */

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class SudokuStateTest extends FunSuite with GeneratorDrivenPropertyChecks
// val frameGen : Gen[Mat] =
val stateGen: Gen[SCandidate] =
for {nr <- Gen.choose(0, 10000)
f <- Gen.const(OpenCVTestContext.frameSudoku_1)
f <- Gen.const(SudokuTestContext.frameSudoku_1)
cap <- Gen.choose(8, 15)
minHits <- Gen.choose(20, 30)} yield SCandidate(nr = nr, frame = f )
// SudokuState(cap = cap, minHits = minHits)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SudokuTest {
@Test def testDetect(): Unit = {
import scala.concurrent.ExecutionContext.Implicits.global
assertEquals(81.toLong, refCellNumbers.size.toLong)
val cells = Await.result(Future.sequence(OpenCVTestContext.sudoku_1.cellDetector.futureSCells), Duration.Inf)
val cells = Await.result(Future.sequence(SudokuTestContext.sudoku_1.cellDetector.futureSCells), Duration.Inf)
var i = 0
for (c <- cells) {
assertEquals(refCellNumbers(i)._1.toLong, c.value.toLong)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package net.ladstatt.sudoku

import org.opencv.core.{CvType, Mat}
import org.opencv.imgcodecs.Imgcodecs

import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scala.io.Source

/**
* Provides Test data for Unit Tests
*
* Created by lad on 06.01.16.
*/
object SudokuTestContext {
Expand All @@ -12,4 +19,24 @@ object SudokuTestContext {
val easySudokus =
Source.fromInputStream(getClass.getResourceAsStream("easysudokus.txt")).getLines().mkString("\n")

lazy val frameSudoku_1: Mat = Imgcodecs.imread("src/test/resources/net/ladstatt/sudoku/sudoku_1.png")
lazy val solutionSudoku_1 =
"""617948532
|524361879
|389725641
|742816953
|156439728
|938257416
|275683194
|461592387
|893174265""".stripMargin.replaceAll("\n", "").toCharArray
lazy val sudoku_1 = SCandidate(nr = 0, frame = frameSudoku_1)

lazy val (sudoku_1Result, _, _) = Await.result(sudoku_1.calc(Map(), Map(), 1, 17, 5000L), Duration.Inf)

lazy val emptyFrame = new Mat(1280, 768, CvType.CV_8UC3)
lazy val emptySudoku = SCandidate(nr = 0, frame = emptyFrame)
lazy val (emptySudokuResult, _, _) = Await.result(emptySudoku.calc(Map(), Map(), 1, 1, 5000L), Duration.Inf)


}

0 comments on commit 898492a

Please sign in to comment.