add docthor-core
parent
24fca8c62c
commit
0a97b37244
|
|
@ -1,12 +1,14 @@
|
|||
import korlibs.korge.gradle.korge
|
||||
import korlibs.korge.gradle.targets.jvm.JvmAddOpens
|
||||
import korlibs.korge.gradle.targets.jvm.JvmAddOpens.beforeJava9
|
||||
import korlibs.korge.gradle.targets.jvm.KorgeJavaExec
|
||||
|
||||
plugins {
|
||||
id("com.soywiz.korge") version "5.3.0"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
jvmMainImplementation("ch.qos.logback:logback-classic:1.4.14")
|
||||
jvmMainImplementation(project(":libraries:docthor-core"))
|
||||
}
|
||||
|
||||
korge {
|
||||
targetJvm()
|
||||
serializationJson()
|
||||
|
|
|
|||
|
|
@ -1,31 +1,32 @@
|
|||
import de.itkl.docthor.core.DocumentViewer
|
||||
import de.itkl.textprocessing.Document
|
||||
import korlibs.event.Key
|
||||
import korlibs.image.bitmap.context2d
|
||||
import korlibs.korge.*
|
||||
import korlibs.korge.scene.*
|
||||
import korlibs.korge.view.*
|
||||
import korlibs.image.color.*
|
||||
import korlibs.image.font.readBitmapFont
|
||||
import korlibs.image.format.*
|
||||
import korlibs.io.file.std.*
|
||||
import korlibs.korge.input.*
|
||||
import korlibs.korge.tween.get
|
||||
import korlibs.korge.tween.tween
|
||||
import korlibs.korge.ui.uiButton
|
||||
import korlibs.korge.ui.uiCheckBox
|
||||
import korlibs.math.geom.*
|
||||
import korlibs.math.geom.shape.toShape2D
|
||||
import korlibs.math.geom.shape.toShape2d
|
||||
import korlibs.math.geom.vector.VectorPath
|
||||
import korlibs.math.interpolation.Easing
|
||||
import korlibs.render.platform.DummyOpenglContext.scaleFactor
|
||||
import java.nio.file.Paths
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
suspend fun main() {
|
||||
val document = DocumentViewer().loadTestDocument(Paths.get("assets/xs-reg"), "00001.jpg")
|
||||
Korge(windowSize = Size(512, 512), backgroundColor = Colors["#2b2b2b"]) {
|
||||
val sceneContainer = sceneContainer()
|
||||
|
||||
sceneContainer.changeTo { ViewDocument() }
|
||||
sceneContainer.changeTo { ViewDocument(document) }
|
||||
}
|
||||
}
|
||||
|
||||
class ViewDocument : Scene() {
|
||||
class ViewDocument(private val document: Document) : Scene() {
|
||||
override suspend fun SContainer.sceneMain() {
|
||||
var scaleFactor = 0.5
|
||||
var offset = Point(0.0,0.0)
|
||||
|
|
@ -69,8 +70,18 @@ class ViewDocument : Scene() {
|
|||
}
|
||||
}
|
||||
|
||||
val imageFile = localCurrentDirVfs["assets/xs-reg/00001.jpg"].readBitmap()
|
||||
image(imageFile)
|
||||
}
|
||||
val imageFile = localCurrentDirVfs["assets/xs-reg/00001.jpg"].readBitmap()
|
||||
image(imageFile)
|
||||
document.retrieveOcrPages().first().words.forEach { word ->
|
||||
|
||||
}
|
||||
|
||||
val shape = VectorPath {
|
||||
moveTo(0, 0)
|
||||
lineTo(100, 0)
|
||||
lineTo(100, 100)
|
||||
close()
|
||||
}.toShape2D()
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ repositories {
|
|||
dependencies {
|
||||
val koin_version = "3.5.3"
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
|
||||
implementation("io.insert-koin:koin-core:$koin_version")
|
||||
api("io.insert-koin:koin-core:$koin_version")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.5.0")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.2")
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
dependencies {
|
||||
fun addProjects(vararg names: String) {
|
||||
names.forEach {
|
||||
api(project(":libraries:$it"))
|
||||
}
|
||||
}
|
||||
|
||||
addProjects(
|
||||
"assetmanager",
|
||||
"core-api",
|
||||
"textprocessing",
|
||||
"httpClient",
|
||||
"tui",
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package de.itkl.docthor.core
|
||||
|
||||
import de.itkl.assetmanager.assetManagerModule
|
||||
import de.itkl.core_api.coreApiModule
|
||||
import de.itkl.httpClient.clients.MsOcr
|
||||
import de.itkl.httpClient.httpClientModule
|
||||
import de.itkl.textprocessing.CorpusFactory
|
||||
import de.itkl.textprocessing.Document
|
||||
import de.itkl.textprocessing.textProcessingModule
|
||||
import de.itkl.tui.tuiModule
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
import org.koin.core.context.startKoin
|
||||
import java.nio.file.Path
|
||||
|
||||
class DocumentViewer : KoinComponent {
|
||||
|
||||
init {
|
||||
startKoin {
|
||||
modules(
|
||||
coreApiModule,
|
||||
textProcessingModule,
|
||||
tuiModule,
|
||||
assetManagerModule,
|
||||
httpClientModule
|
||||
)
|
||||
}
|
||||
}
|
||||
suspend fun loadTestDocument(corpusPath: Path, documentName: String): Document {
|
||||
val corpus = CorpusFactory().load(corpusPath.toAbsolutePath().toString())
|
||||
val document = corpus.document(documentName)
|
||||
val ocrExtractor: MsOcr by inject()
|
||||
document.process(ocrExtractor)
|
||||
return document
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue