-<div>
- <ru-page-header class="admin">
- <main-left>
- <h1>Product Manager</h1>
- </main-left>
- <main-right>
- <a href="#/product_pages/new">
- <button class="primary">Create New Product</button>
-
This file contains hidden or 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
import akka.Done | |
import akka.actor.ActorSystem | |
import akka.kafka.ProducerSettings | |
import akka.kafka.scaladsl.Producer | |
import akka.stream.scaladsl.Source | |
import akka.stream.{ActorMaterializer, Materializer} | |
import com.typesafe.config.ConfigFactory | |
import org.apache.kafka.clients.producer.ProducerRecord | |
import org.apache.kafka.common.serialization.StringSerializer |
This file contains hidden or 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
import akka.actor.ActorSystem | |
import akka.kafka.{ConsumerSettings, Subscriptions} | |
import akka.kafka.scaladsl.Consumer | |
import akka.stream.scaladsl.Sink | |
import akka.stream.{ActorMaterializer, Materializer} | |
import com.typesafe.config.ConfigFactory | |
import org.apache.kafka.common.serialization.StringDeserializer | |
import scala.concurrent.ExecutionContextExecutor | |
import scala.util.{Failure, Success} |
This file contains hidden or 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
akka { | |
kafka { | |
producer { | |
parallelism = 10 | |
close-timeout = 60s | |
use-dispatcher = "akka.kafka.default-dispatcher" | |
eos-commit-interval = 100ms | |
kafka-clients { | |
bootstrap.servers = "localhost:9092" | |
} |
This file contains hidden or 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
name := "kafka-test" | |
version := "0.1" | |
scalaVersion := "2.12.7" | |
libraryDependencies += "com.typesafe" % "config" % "1.3.3" | |
libraryDependencies += "com.typesafe.akka" %% "akka-stream-kafka" % "1.0-M1" |
This file contains hidden or 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
// Add class wrapping String for JSON Streaming | |
case class OcrString(ocr:String) | |
def imageOcr = Flow[BufferedImage].map(bi => { | |
val ocr = tesseract.doOCR(bi) | |
OcrString(ocr) | |
}) | |
// Update route | |
path("image" / "ocr") { |
This file contains hidden or 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
import org.bytedeco.javacpp.{opencv_photo => Photo} | |
def enhanceMat = Flow[Mat].map(mat => { | |
val src = mat.clone() | |
Photo.fastNlMeansDenoising(mat, src, 40, 10, 40) | |
val dst = src.clone() | |
Photo.detailEnhance(src,dst) | |
dst | |
}) |
This file contains hidden or 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
def bufferedImageToMat = Flow[BufferedImage].map(bi => { | |
val mat = new Mat(bi.getHeight, bi.getWidth, CV_8UC(3)) | |
val indexer:UByteRawIndexer = mat.createIndexer() | |
for (y <- 0 until bi.getHeight()) { | |
for (x <- 0 until bi.getWidth()) { | |
val rgb = bi.getRGB(x, y) | |
indexer.put(y, x, 0, (rgb >> 0) & 0xFF) | |
indexer.put(y, x, 1, (rgb >> 8) & 0xFF) | |
indexer.put(y, x, 2, (rgb >> 16) & 0xFF) | |
} |
This file contains hidden or 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
val route = | |
path("image" / "process") { | |
post { | |
fileUpload("fileUpload") { | |
case (_, fileStream) => | |
val inputStream = fileStream.runWith(StreamConverters.asInputStream()) | |
val image: BufferedImage = ImageIO.read(inputStream) | |
val preProcessed: Source[ByteString, NotUsed] = Source | |
.single(image) |
This file contains hidden or 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
def imageDeSkew(skewThreshold:Double = 0.05) = Flow[BufferedImage].map(bi => { | |
val deSkew = new ImageDeskew(bi) | |
val imageSkewAngle = deSkew.getSkewAngle | |
if (imageSkewAngle > skewThreshold || imageSkewAngle < -skewThreshold) { | |
ImageUtil.rotate(bi, -imageSkewAngle, bi.getWidth() / 2, bi.getHeight() / 2) | |
} else { | |
bi | |
} | |
}) |