-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
771 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
lazy val commonSettings = Seq( | ||
version := "0.1.0", | ||
scalaVersion := "2.11.7" | ||
) | ||
|
||
lazy val root = (project in file(".")). | ||
settings(commonSettings: _*). | ||
settings( | ||
name := "pencil_style_scala" | ||
) | ||
|
||
|
||
libraryDependencies ++= Seq( | ||
"org.scalanlp" %% "breeze" % "0.12", | ||
"org.scalanlp" %% "breeze-natives" % "0.12", | ||
"org.scalanlp" %% "breeze-viz" % "0.12" | ||
) | ||
|
||
resolvers ++= Seq( | ||
"Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/", | ||
"Sonatype Releases" at "https://oss.sonatype.org/content/repositories/releases/" | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
sbt.version=0.13.11 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from scipy.sparse import lil_matrix | ||
from scipy.sparse.linalg import spsolve | ||
import os | ||
|
||
|
||
A = lil_matrix((10, 10)) | ||
b = lil_matrix((10, 10)) | ||
|
||
for line in open( os.getcwd() + '/python/' + 'AA.txt','r').readlines(): | ||
lists = line.split() | ||
if len(lists) == 2: | ||
A = lil_matrix( ( int(lists[0]), int(lists[1]) ) ) | ||
else: | ||
A[int(lists[0]), int(lists[1])] = float(lists[2]) | ||
|
||
for line in open( os.getcwd() + '/python/' + 'bb.txt','r').readlines(): | ||
lists = line.split() | ||
if len(lists) == 2: | ||
b = lil_matrix( ( int(lists[0]), int(lists[1]) ) ) | ||
else: | ||
b[int(lists[0]), int(lists[1])] = float(lists[2]) | ||
|
||
A = A.tocsr() | ||
x = spsolve(A, b) | ||
|
||
fo = open( os.getcwd() + '/python/' + 'xx.txt', 'wb') | ||
for xx in x: | ||
fo.write( str(xx) + '\n' ); | ||
|
||
fo.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
ROOT=$(cd "$(dirname $0)"; pwd) | ||
|
||
# better to copy your opencv-300.jar to replace this one | ||
OPENCV_JAR_FILE=$ROOT/lib/opencv-300.jar | ||
|
||
# needs to set to your opencv-3.0 build lib path | ||
LIBRARY_PATH=$HOME/opencv3.0/opencv-3.0.0/build/lib/ | ||
|
||
CLASS_PATH=$OPENCV_JAR_FILE:$ROOT/target/scala-2.11/classes/:$HOME/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.11.7.jar:\ | ||
$HOME/.ivy2/cache/org.scalanlp/breeze_2.11/jars/breeze_2.11-0.12.jar:\ | ||
$HOME/.ivy2/cache/org.scalanlp/breeze-macros_2.11/jars/breeze-macros_2.11-0.12.jar:\ | ||
$HOME/.ivy2/cache/com.github.fommil.netlib/core/jars/core-1.1.2.jar:\ | ||
$HOME/.ivy2/cache/net.sourceforge.f2j/arpack_combined_all/jars/arpack_combined_all-0.1.jar:\ | ||
$HOME/.ivy2/cache/net.sf.opencsv/opencsv/jars/opencsv-2.3.jar:\ | ||
$HOME/.ivy2/cache/com.github.rwl/jtransforms/jars/jtransforms-2.4.0.jar:\ | ||
$HOME/.ivy2/cache/junit/junit/jars/junit-4.8.2.jar:\ | ||
$HOME/.ivy2/cache/org.apache.commons/commons-math3/jars/commons-math3-3.2.jar:\ | ||
$HOME/.ivy2/cache/org.spire-math/spire_2.11/jars/spire_2.11-0.7.4.jar:\ | ||
$HOME/.ivy2/cache/org.spire-math/spire-macros_2.11/jars/spire-macros_2.11-0.7.4.jar:\ | ||
$HOME/.ivy2/cache/org.slf4j/slf4j-api/jars/slf4j-api-1.7.5.jar:\ | ||
$HOME/.ivy2/cache/com.chuusai/shapeless_2.11/bundles/shapeless_2.11-2.0.0.jar:\ | ||
$HOME/.ivy2/cache/org.scalanlp/breeze-natives_2.11/jars/breeze-natives_2.11-0.12.jar:\ | ||
$HOME/.ivy2/cache/com.github.fommil.netlib/netlib-native_ref-osx-x86_64/jars/netlib-native_ref-osx-x86_64-1.1-natives.jar:\ | ||
$HOME/.ivy2/cache/com.github.fommil.netlib/native_ref-java/jars/native_ref-java-1.1.jar:\ | ||
$HOME/.ivy2/cache/com.github.fommil/jniloader/jars/jniloader-1.1.jar:\ | ||
$HOME/.ivy2/cache/com.github.fommil.netlib/netlib-native_ref-linux-x86_64/jars/netlib-native_ref-linux-x86_64-1.1-natives.jar:\ | ||
$HOME/.ivy2/cache/com.github.fommil.netlib/netlib-native_ref-linux-i686/jars/netlib-native_ref-linux-i686-1.1-natives.jar:\ | ||
$HOME/.ivy2/cache/com.github.fommil.netlib/netlib-native_ref-win-x86_64/jars/netlib-native_ref-win-x86_64-1.1-natives.jar:\ | ||
$HOME/.ivy2/cache/com.github.fommil.netlib/netlib-native_ref-win-i686/jars/netlib-native_ref-win-i686-1.1-natives.jar:\ | ||
$HOME/.ivy2/cache/com.github.fommil.netlib/netlib-native_ref-linux-armhf/jars/netlib-native_ref-linux-armhf-1.1-natives.jar:\ | ||
$HOME/.ivy2/cache/com.github.fommil.netlib/netlib-native_system-osx-x86_64/jars/netlib-native_system-osx-x86_64-1.1-natives.jar:\ | ||
$HOME/.ivy2/cache/com.github.fommil.netlib/native_system-java/jars/native_system-java-1.1.jar:\ | ||
$HOME/.ivy2/cache/com.github.fommil.netlib/netlib-native_system-linux-x86_64/jars/netlib-native_system-linux-x86_64-1.1-natives.jar:\ | ||
$HOME/.ivy2/cache/com.github.fommil.netlib/netlib-native_system-linux-i686/jars/netlib-native_system-linux-i686-1.1-natives.jar:\ | ||
$HOME/.ivy2/cache/com.github.fommil.netlib/netlib-native_system-linux-armhf/jars/netlib-native_system-linux-armhf-1.1-natives.jar:\ | ||
$HOME/.ivy2/cache/com.github.fommil.netlib/netlib-native_system-win-x86_64/jars/netlib-native_system-win-x86_64-1.1-natives.jar:\ | ||
$HOME/.ivy2/cache/com.github.fommil.netlib/netlib-native_system-win-i686/jars/netlib-native_system-win-i686-1.1-natives.jar:\ | ||
$HOME/.ivy2/cache/org.scalanlp/breeze-viz_2.11/jars/breeze-viz_2.11-0.12.jar:\ | ||
$HOME/.ivy2/cache/jfree/jcommon/jars/jcommon-1.0.16.jar:\ | ||
$HOME/.ivy2/cache/jfree/jfreechart/jars/jfreechart-1.0.13.jar:\ | ||
$HOME/.ivy2/cache/org.apache.xmlgraphics/xmlgraphics-commons/jars/xmlgraphics-commons-1.3.1.jar:\ | ||
$HOME/.ivy2/cache/commons-io/commons-io/jars/commons-io-1.3.1.jar:\ | ||
$HOME/.ivy2/cache/commons-logging/commons-logging/jars/commons-logging-1.0.4.jar:\ | ||
$HOME/.ivy2/cache/com.lowagie/itext/jars/itext-2.1.5.jar:\ | ||
$HOME/.ivy2/cache/bouncycastle/bcmail-jdk14/jars/bcmail-jdk14-138.jar:\ | ||
$HOME/.ivy2/cache/bouncycastle/bcprov-jdk14/jars/bcprov-jdk14-138.jar | ||
|
||
PYTHON_DIR_PATH=$ROOT/python | ||
|
||
IMG_PATH=$ROOT/images/img/flower.png | ||
OUT_PATH=$ROOT/images/pencil_result.jpg | ||
TEXTURE_IMG_PATH=$ROOT/images/textures/texture.jpg | ||
|
||
# set to 0 generates the pencil drawing, | ||
# set to 1 generates the colourful pencil drawing | ||
IS_DRAW_COLOR=1 | ||
|
||
# set to 1 will output the middle results | ||
# set to 0 just output the final result | ||
IS_SHOW_STEP=1 | ||
|
||
|
||
|
||
java -Xmx4G -cp $CLASS_PATH \ | ||
-Djava.library.path=$LIBRARY_PATH \ | ||
PencilStyle $IMG_PATH $OUT_PATH $TEXTURE_IMG_PATH $IS_DRAW_COLOR $PYTHON_DIR_PATH $IS_SHOW_STEP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import org.opencv.core.Core | ||
import Utils._ | ||
import java.io.InputStreamReader | ||
import java.io.BufferedReader | ||
|
||
object PencilStyle { | ||
|
||
def main(args: Array[String]): Unit = { | ||
System.loadLibrary(Core.NATIVE_LIBRARY_NAME) | ||
if(args.length < 6) { | ||
println("usage: PencilStyle imagePath resultPath textureImgPath isDrawColor pythonDirPath isShowSteps") | ||
} | ||
val img = imgRead(args(0)) | ||
|
||
val (showStep, outputPath) = if (args(5).toInt == 1) (true, args(1).substring(0, args(1).lastIndexOf("/"))) else (false, "") | ||
|
||
val cons = Configs( | ||
30, // larger for a shorter line fragment | ||
8, // smaller for thiner outline sketches | ||
2f, //larger for smoother tonal mappings | ||
0.2f, | ||
args(2), | ||
args(4), | ||
showStep, | ||
outputPath | ||
) | ||
val result = { | ||
if (args(3).toInt == 0) pencilDraw(img, cons) | ||
else colourPencilDraw(img, cons) | ||
} | ||
imgWrite(result, args(1)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import org.opencv.core.Core | ||
|
||
object test { | ||
|
||
def run() = { | ||
|
||
} | ||
|
||
def main(args: Array[String]): Unit = { | ||
System.loadLibrary(Core.NATIVE_LIBRARY_NAME) | ||
println("Hello, OpenCV") | ||
// Load the native library. | ||
} | ||
|
||
} |
Oops, something went wrong.