Skip to content

Instantly share code, notes, and snippets.

@duanebester
Last active May 31, 2018 21:16
Show Gist options
  • Save duanebester/5f7fdcc4225060bd27762e32c004dec8 to your computer and use it in GitHub Desktop.
Save duanebester/5f7fdcc4225060bd27762e32c004dec8 to your computer and use it in GitHub Desktop.
object Main extends App with OCR {
implicit val system: ActorSystem = ActorSystem("ocr")
implicit val executor: ExecutionContextExecutor = system.dispatcher
implicit val materializer: ActorMaterializer = ActorMaterializer()
implicit val jsonStreamingSupport = EntityStreamingSupport.json()
import MyJsonProtocol._
def imageDeSkew:Flow[BufferedImage] = ???
def imageToBinaryImage:Flow[BufferedImage] = ???
def bufferedImageToMat:Flow[BufferedImage] = ???
def matToBufferedImage:Flow[Mat] = ???
def enhanceMat:Flow[Mat] = ???
def imageOcr:Flow[BufferedImage] = ???
def imageWriter:Flow[BufferedImage] = ???
val route =
path("image" / "process") {
post {
fileUpload("fileUpload") {
case (fileInfo, fileStream) =>
println(fileInfo)
val inputStream = fileStream.runWith(StreamConverters.asInputStream())
val image: BufferedImage = ImageIO.read(inputStream)
// Process BufferedImage
complete("OK")
}
}
}
Http().bindAndHandle(route, "localhost", 8080)
}
object MyJsonProtocol
extends SprayJsonSupport
with DefaultJsonProtocol {
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment