├── .gitattributes ├── .github ├── FUNDING.yml └── workflows │ ├── release-central.yml │ └── release.yml ├── .gitignore ├── .run └── Run PaperVision.run.xml ├── EOCVSimPlugin ├── build.gradle └── src │ └── main │ ├── java │ └── io │ │ └── github │ │ └── deltacv │ │ └── papervision │ │ └── plugin │ │ └── project │ │ ├── PaperVisionProject.java │ │ └── recovery │ │ ├── RecoveredProject.java │ │ ├── RecoveryDaemonClientMain.java │ │ └── RecoveryData.java │ ├── kotlin │ └── io │ │ └── github │ │ └── deltacv │ │ └── papervision │ │ └── plugin │ │ ├── EOCVSimIpcPaperVisionMain.kt │ │ ├── PaperVisionEOCVSimPlugin.kt │ │ ├── PaperVisionProcessRunner.kt │ │ ├── eocvsim │ │ ├── PaperVisionDefaultPipeline.kt │ │ └── SinglePipelineCompiler.kt │ │ ├── gui │ │ ├── eocvsim │ │ │ ├── EditSelectionPanel.kt │ │ │ ├── NewProjectPanel.kt │ │ │ ├── PaperVisionTabButtonsPanel.kt │ │ │ ├── PaperVisionTabPanel.kt │ │ │ ├── ProjectTreeCellRenderer.kt │ │ │ └── dialog │ │ │ │ ├── CreateNewProjectPanel.kt │ │ │ │ ├── PaperVisionDialogFactory.kt │ │ │ │ └── ProjectRecoveryPanel.kt │ │ └── imgui │ │ │ ├── CloseConfirmWindow.kt │ │ │ ├── EasyVisionIntroWindow.kt │ │ │ └── InputSourceWindow.kt │ │ ├── ipc │ │ ├── EOCVSimIpcEngine.kt │ │ ├── EOCVSimIpcEngineBridge.kt │ │ ├── eocvsim │ │ │ ├── EOCVSimEngineImageStreamer.kt │ │ │ ├── EOCVSimPrevizSession.kt │ │ │ ├── NoOpEngineImageStreamer.kt │ │ │ └── StreamableNoReflectOpenCvPipelineInstantiator.kt │ │ ├── message │ │ │ ├── EOCVSimMessages.kt │ │ │ ├── ListenerMessages.kt │ │ │ ├── ProjectMessages.kt │ │ │ └── response │ │ │ │ └── EOCVSimResponses.kt │ │ ├── serialization │ │ │ ├── IpcGson.kt │ │ │ └── PolymorphicAdapter.kt │ │ └── stream │ │ │ └── ThreadedMjpegByteReceiver.kt │ │ └── project │ │ ├── PaperVisionProjectManager.kt │ │ ├── PaperVisionProjectTree.kt │ │ └── recovery │ │ └── RecoveryDaemonProcessManager.kt │ └── plugin.toml ├── LICENSE ├── LwjglPlatform ├── Standalone │ ├── build.gradle │ └── src │ │ └── main │ │ └── kotlin │ │ └── io │ │ └── github │ │ └── deltacv │ │ └── papervision │ │ └── platform │ │ └── lwjgl │ │ └── AppMain.kt ├── build.gradle └── src │ └── main │ ├── kotlin │ └── io │ │ └── github │ │ └── deltacv │ │ └── papervision │ │ └── platform │ │ └── lwjgl │ │ ├── PaperVisionApp.kt │ │ ├── glfw │ │ ├── GlfwKeys.kt │ │ └── GlfwWindow.kt │ │ ├── texture │ │ ├── OpenGLTexture.kt │ │ └── OpenGLTextureFactory.kt │ │ └── util │ │ ├── IOUtil.kt │ │ └── Image.kt │ └── resources │ └── logback.xml ├── PaperVision ├── NodeAnnotationProcessor │ ├── build.gradle │ └── src │ │ └── main │ │ ├── kotlin │ │ └── io │ │ │ └── github │ │ │ └── deltacv │ │ │ └── papervision │ │ │ └── annotation │ │ │ ├── PaperNodeAnnotationProcessor.kt │ │ │ └── PaperNodeAnnotationProcessorProvider.kt │ │ └── resources │ │ └── META-INF │ │ └── services │ │ └── com.google.devtools.ksp.processing.SymbolProcessorProvider ├── build.gradle └── src │ └── main │ ├── kotlin │ └── io │ │ └── github │ │ └── deltacv │ │ └── papervision │ │ ├── PaperVision.kt │ │ ├── action │ │ ├── Action.kt │ │ └── editor │ │ │ ├── AttributeActions.kt │ │ │ └── NodeActions.kt │ │ ├── attribute │ │ ├── Attribute.kt │ │ ├── TypedAttribute.kt │ │ ├── math │ │ │ ├── BooleanAttribute.kt │ │ │ ├── DoubleAttribute.kt │ │ │ ├── IntAttribute.kt │ │ │ └── RangeAttribute.kt │ │ ├── misc │ │ │ ├── EnumAttribute.kt │ │ │ ├── ListAttribute.kt │ │ │ └── StringAttribute.kt │ │ └── vision │ │ │ ├── MatAttribute.kt │ │ │ └── structs │ │ │ ├── LineParametersAttribute.kt │ │ │ ├── PointsAttribute.kt │ │ │ ├── RectAttribute.kt │ │ │ ├── RotatedRectAttribute.kt │ │ │ ├── ScalarAttribute.kt │ │ │ ├── ScalarRangeAttribute.kt │ │ │ └── Vector2Attribute.kt │ │ ├── codegen │ │ ├── CodeGen.kt │ │ ├── CodeGenManager.kt │ │ ├── Csv.kt │ │ ├── GenNode.kt │ │ ├── GenValue.kt │ │ ├── Generator.kt │ │ ├── GeneratorsGenNode.kt │ │ ├── build │ │ │ ├── Scope.kt │ │ │ ├── Type.kt │ │ │ ├── Value.kt │ │ │ ├── ValueBuilder.kt │ │ │ └── type │ │ │ │ ├── CPythonOpenCvTypes.kt │ │ │ │ ├── CPythonType.kt │ │ │ │ ├── JavaTypes.kt │ │ │ │ ├── JvmOpenCvTypes.kt │ │ │ │ ├── KotlinTypes.kt │ │ │ │ └── StandardTypes.kt │ │ ├── dsl │ │ │ ├── CodeGenContext.kt │ │ │ ├── GeneratorContext.kt │ │ │ ├── GeneratorsContext.kt │ │ │ ├── LanguageContext.kt │ │ │ ├── ScopeContext.kt │ │ │ └── TargetsContext.kt │ │ ├── language │ │ │ ├── BaseLanguage.kt │ │ │ ├── Language.kt │ │ │ ├── interpreted │ │ │ │ ├── CPythonLanguage.kt │ │ │ │ ├── JavascriptLanguage.kt │ │ │ │ ├── JythonLanguage.kt │ │ │ │ └── LuaLanguage.kt │ │ │ └── jvm │ │ │ │ ├── JavaLanguage.kt │ │ │ │ └── KotlinLanguage.kt │ │ └── vision │ │ │ └── Targets.kt │ │ ├── engine │ │ ├── LocalPaperVisionEngine.kt │ │ ├── bridge │ │ │ ├── LocalPaperVisionEngineBridge.kt │ │ │ ├── NoOpPaperVisionEngineBridge.kt │ │ │ └── PaperVisionEngineBridge.kt │ │ ├── client │ │ │ ├── ByteMessageReceiver.kt │ │ │ └── PaperVisionEngineClient.kt │ │ └── previz │ │ │ ├── ClientPrevizManager.kt │ │ │ └── PipelineStream.kt │ │ ├── exception │ │ └── GenException.kt │ │ ├── gui │ │ ├── AboutModalWindow.kt │ │ ├── CodeDisplayWindow.kt │ │ ├── FontAwesomeIcons.kt │ │ ├── FontManager.kt │ │ ├── GuidedTourWindow.kt │ │ ├── IntroModalWindow.kt │ │ ├── NodeEditor.kt │ │ ├── NodeList.kt │ │ ├── ToastWindow.kt │ │ ├── eocvsim │ │ │ ├── ImageDisplay.kt │ │ │ ├── ImageDisplayNode.kt │ │ │ └── ImageDisplayWindow.kt │ │ ├── style │ │ │ ├── ImNodesStyle.kt │ │ │ └── imnodes │ │ │ │ └── ImNodesDarkStyle.kt │ │ └── util │ │ │ ├── ExtraWidgets.kt │ │ │ ├── Popup.kt │ │ │ ├── SysUtil.kt │ │ │ ├── Table.kt │ │ │ └── Window.kt │ │ ├── id │ │ ├── IdElement.kt │ │ ├── IdElementContainer.kt │ │ └── IdElementContainerStack.kt │ │ ├── io │ │ ├── KeyManager.kt │ │ ├── TextureProcessorQueue.kt │ │ ├── Util.kt │ │ └── turbojpeg │ │ │ └── TJLoader.kt │ │ ├── node │ │ ├── DrawNode.kt │ │ ├── FlagsNode.kt │ │ ├── InvisibleNode.kt │ │ ├── Link.kt │ │ ├── Node.kt │ │ ├── NodeRegistry.kt │ │ ├── code │ │ │ └── CodeSnippetNode.kt │ │ ├── math │ │ │ ├── SumIntegerNode.kt │ │ │ └── Vector2Node.kt │ │ └── vision │ │ │ ├── ColorSpace.kt │ │ │ ├── MatNodes.kt │ │ │ ├── classification │ │ │ ├── CrosshairNode.kt │ │ │ ├── FilterContoursByAreaNode.kt │ │ │ ├── FilterContoursByRatioNode.kt │ │ │ ├── FilterContoursByShapeNode.kt │ │ │ ├── FilterRectsByRatioNode.kt │ │ │ └── targets │ │ │ │ ├── ExportTargetNode.kt │ │ │ │ └── ExportTargetsNode.kt │ │ │ ├── featuredet │ │ │ ├── BoundingRectsNode.kt │ │ │ ├── BoundingRotatedRectsNode.kt │ │ │ ├── FindCountoursNode.kt │ │ │ └── filter │ │ │ │ ├── FilterBiggestContourNode.kt │ │ │ │ ├── FilterBiggestRectangleNode.kt │ │ │ │ └── FilterBiggestRotatedRectangleNode.kt │ │ │ ├── imageproc │ │ │ ├── BlurNode.kt │ │ │ ├── CannyEdgeNode.kt │ │ │ ├── CvtColorNode.kt │ │ │ ├── ErodeDilateNode.kt │ │ │ ├── MaskNode.kt │ │ │ ├── ThresholdNode.kt │ │ │ └── bitwise │ │ │ │ ├── BitwiseANDNode.kt │ │ │ │ ├── BitwiseNOTNode.kt │ │ │ │ ├── BitwiseORNode.kt │ │ │ │ └── BitwiseXORNode.kt │ │ │ └── overlay │ │ │ ├── DrawContoursNode.kt │ │ │ ├── DrawRectanglesNode.kt │ │ │ ├── DrawRotatedRectanglesNode.kt │ │ │ └── LineParametersNode.kt │ │ ├── platform │ │ ├── PlatformConfig.kt │ │ ├── PlatformKeys.kt │ │ ├── PlatformSetup.kt │ │ ├── PlatformTexture.kt │ │ ├── PlatformWindow.kt │ │ └── animation │ │ │ ├── PlatformTextureAnimation.kt │ │ │ └── TimedTextureAnimation.kt │ │ ├── serialization │ │ ├── PaperVisionData.kt │ │ ├── PaperVisionSerializer.kt │ │ └── data │ │ │ ├── DataSerializable.kt │ │ │ ├── DataSerializer.kt │ │ │ └── adapter │ │ │ ├── DataDeserialization.kt │ │ │ ├── DataSerializableAdapter.kt │ │ │ ├── DataSerialization.kt │ │ │ ├── Gson.kt │ │ │ └── SerializeIgnoreExclusionStrategy.kt │ │ └── util │ │ ├── ElapsedTime.kt │ │ ├── LogExt.kt │ │ ├── Range.kt │ │ ├── ReflectExt.kt │ │ ├── StrUtil.kt │ │ ├── UtilExt.kt │ │ └── event │ │ ├── EventListener.kt │ │ └── PaperVisionEventHandler.kt │ └── resources │ ├── README.md │ ├── fonts │ ├── Calcutta-Bold.otf │ ├── Calcutta-Regular.otf │ ├── Calcutta-SemiBold.otf │ ├── JetBrainsMono-Regular.ttf │ └── icons │ │ ├── FontAwesome6-Brands-Regular-400.otf │ │ └── FontAwesome6-Free-Solid-900.otf │ ├── ico │ ├── ico_ezv.png │ ├── ico_ezv.txt │ └── ico_ezv_logo.txt │ ├── img │ ├── PleaseHangOn.png │ └── TechnicalDifficulties.png │ ├── lang.csv │ └── testproj.json ├── README.md ├── Shared ├── build.gradle └── src │ └── main │ └── kotlin │ └── io │ └── github │ └── deltacv │ └── papervision │ ├── engine │ ├── MessageHandlerPaperVisionEngine.kt │ ├── PaperVisionEngine.kt │ ├── client │ │ ├── message │ │ │ ├── PrevizMessages.kt │ │ │ └── ProjectMessages.kt │ │ └── response │ │ │ ├── DefaultResponses.kt │ │ │ └── TypeResponses.kt │ └── message │ │ ├── ByteMessages.kt │ │ ├── PaperVisionEngineMessage.kt │ │ ├── PaperVisionEngineMessageBase.kt │ │ └── PaperVisionEngineMessageResponse.kt │ ├── gui │ └── style │ │ ├── ImNodesStyleTemplate.kt │ │ ├── Style.kt │ │ └── Util.kt │ └── node │ ├── Category.kt │ └── PaperNode.kt ├── build.common.gradle ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── jitpack.yml ├── settings.gradle └── tools ├── Common.jar ├── sign_output.bat └── sign_output.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | # Make sure line endings are always checked in as LF, and auto-converted to CLRF when checked out on Windows machines. See https://stackoverflow.com/a/40821931 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: deltacv -------------------------------------------------------------------------------- /.github/workflows/release-central.yml: -------------------------------------------------------------------------------- 1 | name: Publish package to the Maven Central Repository 2 | on: 3 | push: 4 | # Pattern matched against refs/tags 5 | tags: 6 | - 'v*' 7 | jobs: 8 | publish: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v3 12 | - name: Set up Java 13 | uses: actions/setup-java@v3 14 | with: 15 | java-version: '17' 16 | distribution: 'adopt' 17 | - name: Run chmod to make gradlew executable 18 | run: chmod +x ./gradlew 19 | - name: Publish package to maven central 20 | env: 21 | ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.JRELEASER_MAVENCENTRAL_USERNAME }} 22 | ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.JRELEASER_MAVENCENTRAL_PASSWORD }} 23 | ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} 24 | ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} 25 | PLUGINSIGNING_PRIVATE: ${{ secrets.DELTACV_PLUGINSIGNING_PRIVATE }} 26 | run: | 27 | ./gradlew -Penv=release :Shared:publishToMavenCentral :PaperVision:publishToMavenCentral :LwjglPlatform:publishToMavenCentral :EOCVSimPlugin:publishToMavenCentral --no-configuration-cache -x test -x :EOCVSimPlugin:shadowJar -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Create GitHub release(s) 2 | 3 | on: 4 | push: 5 | branches: [ master, dev ] 6 | tags: 'v*' 7 | 8 | jobs: 9 | build-and-release: 10 | if: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref != 'ref/heads/master' }} 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v4 14 | - name: Set up JDK 15 | uses: actions/setup-java@v4 16 | with: 17 | distribution: 'temurin' 18 | java-version: '17' 19 | 20 | - name: Grant execute permission for gradlew 21 | run: chmod +x gradlew 22 | 23 | - name: Build release shadow jar with Gradle 24 | env: 25 | PLUGINSIGNING_PRIVATE: ${{ secrets.DELTACV_PLUGINSIGNING_PRIVATE }} 26 | run: ./gradlew -Penv=release shadowJar -x test 27 | if: ${{ startsWith(github.ref, 'refs/tags/v') }} 28 | 29 | - name: Build dev shadow jar with Gradle 30 | env: 31 | PLUGINSIGNING_PRIVATE: ${{ secrets.DELTACV_PLUGINSIGNING_PRIVATE }} 32 | run: | 33 | SHA_SHORT="$(git rev-parse --short HEAD)" 34 | ./gradlew -Phash=$SHA_SHORT shadowJar -x test 35 | if: ${{ !startsWith(github.ref, 'refs/tags/v') }} 36 | 37 | - uses: pyTooling/Actions/releaser@r0 38 | with: 39 | token: ${{ secrets.GITHUB_TOKEN }} 40 | tag: 'Dev' 41 | rm: true 42 | files: | 43 | EOCVSimPlugin/build/libs/*.jar 44 | if: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/v')}} 45 | 46 | - uses: softprops/action-gh-release@v2 47 | if: ${{ startsWith(github.ref, 'refs/tags/v') }} 48 | with: 49 | token: ${{ secrets.GITHUB_TOKEN }} 50 | files: 'EOCVSimPlugin/build/libs/*.jar' -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.toptal.com/developers/gitignore/api/intellij 2 | # Edit at https://www.toptal.com/developers/gitignore?templates=intellij 3 | 4 | ### Intellij ### 5 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 6 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 7 | 8 | .idea/ 9 | .gradle/ 10 | .kotlin/ 11 | 12 | # Sensitive or high-churn files 13 | .idea/**/dataSources/ 14 | .idea/**/dataSources.ids 15 | .idea/**/dataSources.local.xml 16 | .idea/**/sqlDataSources.xml 17 | .idea/**/dynamic.xml 18 | .idea/**/uiDesigner.xml 19 | .idea/**/dbnavigator.xml 20 | 21 | # Gradle 22 | .idea/**/gradle.xml 23 | 24 | # Gradle and Maven with auto-import 25 | # When using Gradle or Maven with auto-import, you should exclude module files, 26 | # since they will be recreated, and may cause churn. Uncomment if using 27 | # auto-import. 28 | .idea/artifacts 29 | .idea/compiler.xml 30 | .idea/jarRepositories.xml 31 | .idea/modules.xml 32 | .idea/*.iml 33 | .idea/modules 34 | *.iml 35 | *.ipr 36 | 37 | # CMake 38 | cmake-build-*/ 39 | 40 | # Mongo Explorer plugin 41 | .idea/**/mongoSettings.xml 42 | 43 | # File-based project format 44 | *.iws 45 | 46 | # IntelliJ 47 | out/ 48 | 49 | # mpeltonen/sbt-idea plugin 50 | .idea_modules/ 51 | 52 | # JIRA plugin 53 | atlassian-ide-plugin.xml 54 | 55 | # Cursive Clojure plugin 56 | .idea/replstate.xml 57 | 58 | # Crashlytics plugin (for Android Studio and IntelliJ) 59 | com_crashlytics_export_strings.xml 60 | crashlytics.properties 61 | crashlytics-build.properties 62 | fabric.properties 63 | 64 | # Editor-based Rest Client 65 | .idea/httpRequests 66 | 67 | # Android studio 3.1+ serialized cache file 68 | .idea/caches/build_file_checksums.ser 69 | 70 | ### Intellij Patch ### 71 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 72 | 73 | # *.iml 74 | # modules.xml 75 | # .idea/misc.xml 76 | # *.ipr 77 | 78 | # Sonarlint plugin 79 | # https://plugins.jetbrains.com/plugin/7973-sonarlint 80 | .idea/**/sonarlint/ 81 | 82 | # SonarQube Plugin 83 | # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin 84 | .idea/**/sonarIssues.xml 85 | 86 | # Markdown Navigator plugin 87 | # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced 88 | .idea/**/markdown-navigator.xml 89 | .idea/**/markdown-navigator-enh.xml 90 | .idea/**/markdown-navigator/ 91 | 92 | # Cache file creation bug 93 | # See https://youtrack.jetbrains.com/issue/JBR-2257 94 | .idea/$CACHE_FILE$ 95 | 96 | # CodeStream plugin 97 | # https://plugins.jetbrains.com/plugin/12206-codestream 98 | .idea/codestream.xml 99 | 100 | # End of https://www.toptal.com/developers/gitignore/api/intellij 101 | 102 | *.log 103 | 104 | **/build/* 105 | **/Build.kt 106 | !PaperVision/src/main/kotlin/io/github/deltacv/papervision/codegen/build/* 107 | 108 | 109 | *.DS_Store 110 | 111 | imgui.ini -------------------------------------------------------------------------------- /.run/Run PaperVision.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 16 | 18 | true 19 | true 20 | false 21 | false 22 | 23 | 24 | -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/java/io/github/deltacv/papervision/plugin/project/PaperVisionProject.java: -------------------------------------------------------------------------------- 1 | package io.github.deltacv.papervision.plugin.project; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.JsonElement; 5 | 6 | public class PaperVisionProject { 7 | 8 | public long timestamp; 9 | public String path; 10 | public String name; 11 | public JsonElement json; 12 | 13 | private static final Gson gson = new Gson(); 14 | 15 | public PaperVisionProject(long timestamp, String path, String name, JsonElement json) { 16 | this.timestamp = timestamp; 17 | this.path = path; 18 | this.name = name; 19 | this.json = json; 20 | } 21 | 22 | public static PaperVisionProject fromJson(String jsonString) { 23 | return gson.fromJson(jsonString, PaperVisionProject.class); 24 | } 25 | 26 | public String toJson() { 27 | return gson.toJson(this); 28 | } 29 | } -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/java/io/github/deltacv/papervision/plugin/project/recovery/RecoveredProject.java: -------------------------------------------------------------------------------- 1 | package io.github.deltacv.papervision.plugin.project.recovery; 2 | 3 | import com.google.gson.Gson; 4 | import io.github.deltacv.papervision.plugin.project.PaperVisionProject; 5 | 6 | public class RecoveredProject { 7 | public String originalProjectPath; 8 | public long date; 9 | public String hash; 10 | public PaperVisionProject project; 11 | 12 | private static final Gson gson = new Gson(); 13 | 14 | public RecoveredProject(String originalProjectPath, long date, String hash, PaperVisionProject project) { 15 | this.originalProjectPath = originalProjectPath; 16 | this.date = date; 17 | this.hash = hash; 18 | this.project = project; 19 | } 20 | 21 | public String toJson() { 22 | return gson.toJson(this); 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return "RecoveredProject{" + 28 | "path='" + originalProjectPath + '\'' + 29 | ", date=" + date + 30 | ", hash='" + hash + '\'' + 31 | '}'; 32 | } 33 | 34 | public static RecoveredProject fromJson(String json) { 35 | return gson.fromJson(json, RecoveredProject.class); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/java/io/github/deltacv/papervision/plugin/project/recovery/RecoveryDaemonClientMain.java: -------------------------------------------------------------------------------- 1 | package io.github.deltacv.papervision.plugin.project.recovery; 2 | 3 | import org.java_websocket.client.WebSocketClient; 4 | import org.java_websocket.handshake.ServerHandshake; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import java.net.URI; 9 | import java.net.URISyntaxException; 10 | import java.nio.file.Files; 11 | import java.nio.file.Path; 12 | import java.nio.file.Paths; 13 | 14 | public class RecoveryDaemonClientMain extends WebSocketClient { 15 | 16 | public static final int MAX_CONNECTION_ATTEMPTS_BEFORE_EXITING = 3; 17 | 18 | public static final Logger logger = LoggerFactory.getLogger(RecoveryDaemonClientMain.class); 19 | 20 | public RecoveryDaemonClientMain(int port) throws URISyntaxException { 21 | super(new URI("ws://127.0.0.1:" + port)); 22 | } 23 | 24 | @Override 25 | public void onOpen(ServerHandshake handshakedata) { 26 | logger.info("Connected to recovery daemon server at port {}", uri.getPort()); 27 | } 28 | 29 | @Override 30 | public void onMessage(String message) { 31 | try { 32 | RecoveryData recoveryData = RecoveryData.deserialize(message); 33 | Path recoveryPath = Paths.get(recoveryData.recoveryFolderPath); 34 | 35 | if (!Files.exists(recoveryPath)) { 36 | Files.createDirectories(recoveryPath); 37 | } 38 | 39 | Path recoveryFilePath = recoveryPath.resolve(recoveryData.recoveryFileName); 40 | Files.write(recoveryFilePath, recoveryData.projectData.toJson().getBytes()); 41 | } catch (Exception e) { 42 | logger.error("Failed to save recovery data", e); 43 | } 44 | } 45 | 46 | @Override 47 | public void onClose(int code, String reason, boolean remote) { 48 | } 49 | 50 | @Override 51 | public void onError(Exception ex) { 52 | } 53 | 54 | public static void main(String[] args) { 55 | int port = args.length > 0 ? Integer.parseInt(args[0]) : 17112; 56 | 57 | RecoveryDaemonClientMain client = null; 58 | int connectionAttempts = 0; 59 | 60 | try { 61 | while(!Thread.interrupted()) { 62 | if(connectionAttempts >= MAX_CONNECTION_ATTEMPTS_BEFORE_EXITING) { 63 | logger.warn("Failed to connect to recovery daemon after " + MAX_CONNECTION_ATTEMPTS_BEFORE_EXITING + " attempts. Exiting..."); 64 | System.exit(0); 65 | } 66 | 67 | if(client == null || client.isClosed()) { 68 | client = new RecoveryDaemonClientMain(port); 69 | client.connect(); 70 | connectionAttempts += 1; 71 | } 72 | 73 | Thread.sleep(100); 74 | } 75 | } catch (URISyntaxException e) { 76 | throw new RuntimeException(e); 77 | } catch(InterruptedException ignored) { } 78 | } 79 | } -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/java/io/github/deltacv/papervision/plugin/project/recovery/RecoveryData.java: -------------------------------------------------------------------------------- 1 | package io.github.deltacv.papervision.plugin.project.recovery; 2 | 3 | import com.google.gson.Gson; 4 | 5 | public class RecoveryData { 6 | 7 | public String recoveryFolderPath; 8 | public String recoveryFileName; 9 | public RecoveredProject projectData; 10 | 11 | private static final Gson gson = new Gson(); 12 | 13 | public RecoveryData(String recoveryFolderPath, String recoveryFileName, RecoveredProject projectData) { 14 | this.recoveryFolderPath = recoveryFolderPath; 15 | this.recoveryFileName = recoveryFileName; 16 | this.projectData = projectData; 17 | } 18 | 19 | public static String serialize(RecoveryData data) { 20 | return gson.toJson(data); 21 | } 22 | 23 | public static RecoveryData deserialize(String json) { 24 | return gson.fromJson(json, RecoveryData.class); 25 | } 26 | } -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/kotlin/io/github/deltacv/papervision/plugin/eocvsim/PaperVisionDefaultPipeline.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.plugin.eocvsim 20 | 21 | import com.github.serivesmejia.eocvsim.util.loggerForThis 22 | import com.qualcomm.robotcore.eventloop.opmode.Disabled 23 | import io.github.deltacv.eocvsim.pipeline.StreamableOpenCvPipeline 24 | import org.firstinspires.ftc.robotcore.external.Telemetry 25 | import org.opencv.core.Mat 26 | import org.opencv.core.MatOfByte 27 | import org.opencv.core.Scalar 28 | import org.opencv.core.Size 29 | import org.opencv.imgcodecs.Imgcodecs 30 | import org.opencv.imgproc.Imgproc 31 | import org.openftc.easyopencv.OpenCvPipeline 32 | 33 | @Disabled 34 | class PaperVisionDefaultPipeline( 35 | val telemetry: Telemetry 36 | ) : StreamableOpenCvPipeline() { 37 | 38 | val logger by loggerForThis() 39 | 40 | lateinit var drawMat: Mat 41 | 42 | override fun init(mat: Mat) { 43 | drawMat = Mat(mat.size(), mat.type()) 44 | drawMat.setTo(Scalar(0.0, 0.0, 0.0, 0.0)) 45 | 46 | try { 47 | val bytes = PaperVisionDefaultPipeline::class.java.getResourceAsStream("/ico/ico_ezv.png")!!.use { 48 | it.readBytes() 49 | } 50 | 51 | val logoBytes = MatOfByte(*bytes) 52 | val logoMat = Imgcodecs.imdecode(logoBytes, Imgcodecs.IMREAD_UNCHANGED) 53 | logoBytes.release() 54 | 55 | Imgproc.cvtColor(logoMat, logoMat, Imgproc.COLOR_BGR2RGBA) 56 | 57 | Imgproc.resize(logoMat, logoMat, Size(logoMat.size().width / 2, logoMat.size().width / 2)) 58 | 59 | // Draw the logo centered 60 | val x = (drawMat.width() - logoMat.width()) / 2 61 | val y = (drawMat.height() - logoMat.height()) / 2 62 | 63 | val roi = drawMat.submat(y, y + logoMat.height(), x, x + logoMat.width()) 64 | logoMat.copyTo(roi) 65 | 66 | logoMat.release() 67 | } catch(e: Exception) { 68 | logger.warn("Failed to load logo", e) 69 | } 70 | } 71 | 72 | override fun processFrame(input: Mat): Mat { 73 | telemetry.addLine("Making computer vision accessible to everyone") 74 | telemetry.update() 75 | 76 | streamFrame(0, input, null) 77 | 78 | return drawMat 79 | } 80 | 81 | } -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/kotlin/io/github/deltacv/papervision/plugin/eocvsim/SinglePipelineCompiler.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.plugin.eocvsim 20 | 21 | import com.github.serivesmejia.eocvsim.util.ReflectUtil 22 | import org.codehaus.janino.JavaSourceClassLoader 23 | import org.codehaus.janino.SimpleCompiler 24 | import org.openftc.easyopencv.OpenCvPipeline 25 | import java.util.* 26 | import javax.tools.* 27 | 28 | 29 | object SinglePipelineCompiler { 30 | 31 | /** 32 | * Takes source code and returns a compiled pipeline class 33 | */ 34 | @Suppress("UNCHECKED_CAST") 35 | fun compilePipeline(pipelineName: String, pipelineSource: String): Class { 36 | // Create a SimpleCompiler instance 37 | val compiler = SimpleCompiler() 38 | 39 | // Set the source code 40 | compiler.cook(pipelineSource) 41 | 42 | val clazz = compiler.classLoader.loadClass(pipelineName) 43 | 44 | require(ReflectUtil.hasSuperclass(clazz, OpenCvPipeline::class.java)) { 45 | "Pipeline class must extend OpenCvPipeline" 46 | } 47 | 48 | return clazz as Class 49 | } 50 | } -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/kotlin/io/github/deltacv/papervision/plugin/gui/eocvsim/NewProjectPanel.kt: -------------------------------------------------------------------------------- 1 | package io.github.deltacv.papervision.plugin.gui.eocvsim 2 | 3 | import com.github.serivesmejia.eocvsim.util.extension.removeFromEnd 4 | import com.github.serivesmejia.eocvsim.util.loggerForThis 5 | import io.github.deltacv.papervision.plugin.gui.eocvsim.dialog.PaperVisionDialogFactory 6 | import io.github.deltacv.papervision.plugin.project.PaperVisionProjectManager 7 | import java.awt.Dimension 8 | import java.awt.GridBagConstraints 9 | import java.awt.GridBagLayout 10 | import java.awt.Insets 11 | import java.awt.Window 12 | import javax.swing.Box 13 | import javax.swing.BoxLayout 14 | import javax.swing.JButton 15 | import javax.swing.JFileChooser 16 | import javax.swing.JFrame 17 | import javax.swing.JOptionPane 18 | import javax.swing.JPanel 19 | import javax.swing.SwingUtilities 20 | import javax.swing.filechooser.FileNameExtensionFilter 21 | 22 | class NewProjectPanel( 23 | val projectManager: PaperVisionProjectManager, 24 | val ancestor: Window 25 | ) : JPanel() { 26 | 27 | val logger by loggerForThis() 28 | 29 | val newProjectBtt = JButton("New Project") 30 | 31 | val importProjectBtt = JButton("Import Project") 32 | 33 | init { 34 | layout = GridBagLayout() 35 | 36 | newProjectBtt.addActionListener { 37 | projectManager.newProjectAsk(ancestor) 38 | } 39 | 40 | add(newProjectBtt, GridBagConstraints().apply { 41 | gridx = 0 42 | gridy = 0 43 | }) 44 | 45 | importProjectBtt.addActionListener { 46 | projectManager.importProjectAsk(ancestor) 47 | } 48 | 49 | add(importProjectBtt, GridBagConstraints().apply { 50 | gridx = 1 51 | gridy = 0 52 | }) 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/kotlin/io/github/deltacv/papervision/plugin/gui/eocvsim/ProjectTreeCellRenderer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.plugin.gui.eocvsim 20 | 21 | import io.github.deltacv.papervision.plugin.project.PaperVisionProjectTree 22 | import java.awt.Component 23 | import javax.swing.JTree 24 | import javax.swing.UIManager 25 | import javax.swing.tree.DefaultMutableTreeNode 26 | import javax.swing.tree.DefaultTreeCellRenderer 27 | 28 | class ProjectTreeCellRenderer: DefaultTreeCellRenderer() { 29 | 30 | override fun getTreeCellRendererComponent(tree: JTree, value: Any, selected: Boolean, expanded: Boolean, leaf: Boolean, row: Int, hasFocus: Boolean): Component { 31 | val component = super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus) 32 | 33 | if(value is DefaultMutableTreeNode) { 34 | val node = value.userObject 35 | 36 | if(node is PaperVisionProjectTree.ProjectTreeNode.Project) { 37 | icon = UIManager.getIcon("FileView.fileIcon") 38 | } else if(node is PaperVisionProjectTree.ProjectTreeNode.Folder) { 39 | icon = UIManager.getIcon("FileView.directoryIcon") 40 | } 41 | } 42 | 43 | return component 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/kotlin/io/github/deltacv/papervision/plugin/gui/eocvsim/dialog/PaperVisionDialogFactory.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.plugin.gui.eocvsim.dialog 20 | 21 | import io.github.deltacv.papervision.plugin.project.recovery.RecoveredProject 22 | import java.awt.Dialog 23 | import java.awt.Window 24 | import javax.swing.JDialog 25 | import javax.swing.JFrame 26 | import javax.swing.JPanel 27 | import javax.swing.SwingUtilities 28 | 29 | object PaperVisionDialogFactory { 30 | 31 | fun displayNewProjectDialog(parent: Window, projects: List, groups: List, name: String? = null, callback: (String?, String) -> Unit) { 32 | val panel = CreateNewProjectPanel(projects, groups, name, callback) 33 | displayDialog("${if(name == null) "New" else "Import"} Project", panel, parent) 34 | } 35 | 36 | fun displayProjectRecoveryDialog(parent: Window, recoveredProjects: List, callback: (List) -> Unit) { 37 | val panel = ProjectRecoveryPanel(recoveredProjects, callback) 38 | displayDialog("Recover PaperVision Projects", panel, parent) 39 | } 40 | 41 | private fun displayDialog(title: String, panel: JPanel, parent: Window) { 42 | SwingUtilities.invokeLater { 43 | val dialog = JDialog(parent, title, Dialog.ModalityType.APPLICATION_MODAL) 44 | 45 | dialog.add(panel) 46 | dialog.pack() 47 | dialog.setLocationRelativeTo(null) 48 | 49 | dialog.isVisible = true 50 | } 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/kotlin/io/github/deltacv/papervision/plugin/gui/imgui/CloseConfirmWindow.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.plugin.gui.imgui 20 | 21 | import imgui.ImGui 22 | import imgui.flag.ImGuiWindowFlags 23 | import io.github.deltacv.mai18n.tr 24 | import io.github.deltacv.papervision.gui.util.Window 25 | import io.github.deltacv.papervision.util.flags 26 | 27 | class CloseConfirmWindow( 28 | val callback: (Action) -> Unit 29 | ) : Window() { 30 | enum class Action { 31 | YES, 32 | NO, 33 | CANCEL 34 | } 35 | 36 | override var title = "win_confirm" 37 | override val windowFlags = flags( 38 | ImGuiWindowFlags.NoResize, 39 | ImGuiWindowFlags.NoMove, 40 | ImGuiWindowFlags.NoCollapse 41 | ) 42 | 43 | override val isModal = true 44 | 45 | override fun onEnable() { 46 | focus = true 47 | } 48 | 49 | override fun drawContents() { 50 | ImGui.text(tr("mis_savebefore_exit")) 51 | ImGui.separator() 52 | 53 | if(ImGui.button(tr("mis_save"))) { 54 | callback(Action.YES) 55 | ImGui.closeCurrentPopup() 56 | } 57 | ImGui.sameLine() 58 | if(ImGui.button(tr("mis_discard"))) { 59 | callback(Action.NO) 60 | ImGui.closeCurrentPopup() 61 | } 62 | ImGui.sameLine() 63 | if(ImGui.button(tr("mis_cancel"))) { 64 | callback(Action.CANCEL) 65 | ImGui.closeCurrentPopup() 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/kotlin/io/github/deltacv/papervision/plugin/gui/imgui/EasyVisionIntroWindow.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.plugin.gui.imgui 20 | 21 | import imgui.ImGui 22 | import imgui.flag.ImGuiWindowFlags 23 | import io.github.deltacv.papervision.gui.util.Window 24 | import io.github.deltacv.papervision.util.flags 25 | 26 | class EasyVisionIntroWindow : Window() { 27 | override var title = "Welcome!" 28 | 29 | override val windowFlags = flags( 30 | ImGuiWindowFlags.NoResize, 31 | ImGuiWindowFlags.NoMove, 32 | ImGuiWindowFlags.NoCollapse 33 | ) 34 | 35 | private var isFirstDraw = true 36 | 37 | override fun onEnable() { 38 | centerWindow() 39 | focus = true 40 | isFirstDraw = true 41 | } 42 | 43 | override fun drawContents() { 44 | // Recenter the window on the second draw 45 | if (!isFirstDraw) { 46 | centerWindow() 47 | } else { 48 | isFirstDraw = false 49 | } 50 | 51 | ImGui.text("Welcome to EasyVision!") 52 | ImGui.separator() 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/kotlin/io/github/deltacv/papervision/plugin/ipc/eocvsim/NoOpEngineImageStreamer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.plugin.ipc.eocvsim 20 | 21 | import io.github.deltacv.eocvsim.stream.ImageStreamer 22 | import org.opencv.core.Mat 23 | 24 | object NoOpEngineImageStreamer : ImageStreamer { 25 | override fun sendFrame(id: Int, image: Mat, cvtCode: Int?) { 26 | // no-op 27 | } 28 | } -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/kotlin/io/github/deltacv/papervision/plugin/ipc/eocvsim/StreamableNoReflectOpenCvPipelineInstantiator.kt: -------------------------------------------------------------------------------- 1 | package io.github.deltacv.papervision.plugin.ipc.eocvsim 2 | 3 | import io.github.deltacv.eocvsim.pipeline.StreamableOpenCvPipeline 4 | import com.github.serivesmejia.eocvsim.pipeline.instantiator.DefaultPipelineInstantiator 5 | import com.github.serivesmejia.eocvsim.pipeline.instantiator.PipelineInstantiator 6 | import io.github.deltacv.eocvsim.stream.ImageStreamer 7 | import io.github.deltacv.eocvsim.virtualreflect.jvm.JvmVirtualReflection 8 | import org.firstinspires.ftc.robotcore.external.Telemetry 9 | import org.openftc.easyopencv.OpenCvPipeline 10 | 11 | class StreamableNoReflectOpenCvPipelineInstantiator( 12 | val imageStreamer: ImageStreamer 13 | ) : PipelineInstantiator { 14 | 15 | override fun instantiate(clazz: Class<*>, telemetry: Telemetry) = 16 | DefaultPipelineInstantiator.instantiate(clazz, telemetry).apply { 17 | if(this is StreamableOpenCvPipeline) { 18 | this.streamer = imageStreamer 19 | } 20 | } 21 | 22 | override fun virtualReflectOf(pipeline: OpenCvPipeline) = JvmVirtualReflection 23 | 24 | override fun variableTunerTarget(pipeline: OpenCvPipeline) = Any() 25 | 26 | } -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/kotlin/io/github/deltacv/papervision/plugin/ipc/message/EOCVSimMessages.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.plugin.ipc.message 20 | 21 | import io.github.deltacv.papervision.engine.message.PaperVisionEngineMessageBase 22 | 23 | data class InputSourceData( 24 | var name: String, 25 | var type: InputSourceType, 26 | var timestamp: Long 27 | ) 28 | enum class InputSourceType { 29 | IMAGE, CAMERA, VIDEO 30 | } 31 | 32 | class GetInputSourcesMessage : PaperVisionEngineMessageBase() 33 | 34 | class GetCurrentInputSourceMessage : PaperVisionEngineMessageBase() 35 | 36 | class SetInputSourceMessage( 37 | var inputSource: String 38 | ) : PaperVisionEngineMessageBase() 39 | 40 | class OpenCreateInputSourceMessage( 41 | var sourceType: InputSourceType 42 | ) : PaperVisionEngineMessageBase() -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/kotlin/io/github/deltacv/papervision/plugin/ipc/message/ListenerMessages.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.plugin.ipc.message 20 | 21 | import com.google.gson.JsonElement 22 | import io.github.deltacv.papervision.engine.message.PaperVisionEngineMessageBase 23 | 24 | // LISTENERS FOR EOCV-SIM 25 | 26 | class EditorChangeMessage( 27 | val json: JsonElement 28 | ) : PaperVisionEngineMessageBase() 29 | 30 | // LISTENERS FOR PAPERVISION 31 | 32 | class InputSourceListChangeListenerMessage : PaperVisionEngineMessageBase(persistent = true) -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/kotlin/io/github/deltacv/papervision/plugin/ipc/message/ProjectMessages.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.plugin.ipc.message 20 | 21 | import com.google.gson.JsonElement 22 | import io.github.deltacv.papervision.engine.message.PaperVisionEngineMessage 23 | import io.github.deltacv.papervision.engine.message.PaperVisionEngineMessageBase 24 | 25 | class GetCurrentProjectMessage : PaperVisionEngineMessageBase() 26 | 27 | class DiscardCurrentRecoveryMessage : PaperVisionEngineMessageBase() 28 | 29 | class SaveCurrentProjectMessage( 30 | var json: JsonElement 31 | ) : PaperVisionEngineMessageBase() -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/kotlin/io/github/deltacv/papervision/plugin/ipc/message/response/EOCVSimResponses.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.plugin.ipc.message.response 20 | 21 | import io.github.deltacv.papervision.engine.client.response.OkResponse 22 | import io.github.deltacv.papervision.plugin.ipc.message.InputSourceData 23 | 24 | class InputSourcesListResponse( 25 | var sources: Array 26 | ) : OkResponse() -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/kotlin/io/github/deltacv/papervision/plugin/ipc/serialization/IpcGson.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.plugin.ipc.serialization 20 | 21 | import com.google.gson.GsonBuilder 22 | import io.github.deltacv.papervision.engine.message.PaperVisionEngineMessage 23 | import io.github.deltacv.papervision.engine.message.PaperVisionEngineMessageResponse 24 | 25 | object IpcGson { 26 | object IpcMessageAdapter : PolymorphicAdapter("message", IpcGson::class.java.classLoader) 27 | object IpcMessageResponseAdapter : PolymorphicAdapter("messageResponse", IpcGson::class.java.classLoader) 28 | 29 | val gson = GsonBuilder() 30 | .registerTypeHierarchyAdapter(PaperVisionEngineMessage::class.java, IpcMessageAdapter) 31 | .registerTypeHierarchyAdapter(PaperVisionEngineMessageResponse::class.java, IpcMessageResponseAdapter) 32 | .create() 33 | } 34 | 35 | val ipcGson = IpcGson.gson -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/kotlin/io/github/deltacv/papervision/plugin/ipc/serialization/PolymorphicAdapter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.plugin.ipc.serialization 20 | 21 | import com.google.gson.Gson 22 | import com.google.gson.JsonDeserializationContext 23 | import com.google.gson.JsonDeserializer 24 | import com.google.gson.JsonElement 25 | import com.google.gson.JsonObject 26 | import com.google.gson.JsonSerializationContext 27 | import com.google.gson.JsonSerializer 28 | import java.lang.reflect.Type 29 | import kotlin.jvm.java 30 | 31 | private val gson = Gson() 32 | 33 | open class PolymorphicAdapter( 34 | val name: String, 35 | val classloader: ClassLoader = PolymorphicAdapter::class.java.classLoader 36 | ) : JsonSerializer, JsonDeserializer { 37 | 38 | override fun serialize(src: T, typeOfSrc: Type, context: JsonSerializationContext): JsonElement { 39 | val obj = JsonObject() 40 | 41 | obj.addProperty("${name}Class", src!!::class.java.name) 42 | obj.add(name, gson.toJsonTree(src)) 43 | 44 | return obj 45 | } 46 | 47 | @Suppress("UNCHECKED_CAST") 48 | override fun deserialize(json: JsonElement, typeOfT: Type, context: JsonDeserializationContext): T { 49 | val className = json.asJsonObject.get("${name}Class").asString 50 | 51 | val clazz = classloader.loadClass(className) 52 | 53 | return gson.fromJson(json.asJsonObject.get(name), clazz) as T 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /EOCVSimPlugin/src/main/plugin.toml: -------------------------------------------------------------------------------- 1 | name = "PaperVision" 2 | author = "deltacv" 3 | author-email = "dev@deltacv.org" 4 | # This will be replaced by Gradle using the artifact version 5 | version = "{{version}}" 6 | description = "Create your custom OpenCV algorithms using a user-friendly node editor interface, inspired by Blender and Unreal Engine blueprints! Quickly prototype your vision using live previews as you edit. " 7 | 8 | min-api-version = "4.0.0" 9 | 10 | super-access = true 11 | super-access-reason = "PaperVision requires your permision to fully support all features related to rendering user interaction and filesystem access." 12 | 13 | main = "io.github.deltacv.papervision.plugin.PaperVisionEOCVSimPlugin" -------------------------------------------------------------------------------- /LwjglPlatform/Standalone/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.jetbrains.kotlin.jvm' 3 | } 4 | 5 | apply from: '../../build.common.gradle' 6 | 7 | dependencies { 8 | implementation project(":LwjglPlatform") 9 | 10 | implementation "org.jetbrains.kotlin:kotlin-stdlib" 11 | 12 | implementation "ch.qos.logback:logback-classic:$logback_classic_version" 13 | } 14 | 15 | task(runEv, dependsOn: 'classes', type: JavaExec) { 16 | main = 'io.github.deltacv.papervision.platform.lwjgl.AppMain' 17 | classpath = sourceSets.main.runtimeClasspath 18 | 19 | if (org.gradle.internal.os.OperatingSystem.current().isMacOsX()) { 20 | jvmArgs += ['-XstartOnFirstThread', '-Djava.awt.headless=true'] 21 | } 22 | } 23 | 24 | tasks.withType(Jar) { 25 | manifest { 26 | attributes['Main-Class'] = 'io.github.deltacv.papervision.platform.lwjgl.AppMain' 27 | } 28 | } -------------------------------------------------------------------------------- /LwjglPlatform/Standalone/src/main/kotlin/io/github/deltacv/papervision/platform/lwjgl/AppMain.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | @file:JvmName("AppMain") 20 | package io.github.deltacv.papervision.platform.lwjgl 21 | 22 | import imgui.app.Application 23 | 24 | fun main() { 25 | Application.launch(PaperVisionApp(showWelcomeWindow = true)) 26 | } -------------------------------------------------------------------------------- /LwjglPlatform/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.jetbrains.kotlin.jvm' 3 | id 'signing' 4 | id "com.vanniktech.maven.publish" 5 | } 6 | 7 | apply from: '../build.common.gradle' 8 | 9 | dependencies { 10 | api project(":PaperVision") 11 | 12 | compileOnly "org.jetbrains.kotlin:kotlin-stdlib" 13 | 14 | api "io.github.spair:imgui-java-app:$imgui_version" 15 | 16 | implementation platform('org.lwjgl:lwjgl-bom:3.3.4') 17 | implementation "org.lwjgl:lwjgl-stb" 18 | implementation "org.lwjgl:lwjgl-nfd" 19 | 20 | ['natives-linux', 'natives-windows', 'natives-macos', 'natives-macos-arm64'].each { 21 | implementation "org.lwjgl:lwjgl-stb::$it" 22 | implementation "org.lwjgl:lwjgl-nfd::$it" 23 | } 24 | 25 | implementation "org.slf4j:slf4j-api:$slf4j_version" 26 | } 27 | -------------------------------------------------------------------------------- /LwjglPlatform/src/main/kotlin/io/github/deltacv/papervision/platform/lwjgl/glfw/GlfwKeys.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.platform.lwjgl.glfw 20 | 21 | import io.github.deltacv.papervision.platform.PlatformKeys 22 | import org.lwjgl.glfw.GLFW.* 23 | 24 | object GlfwKeys : PlatformKeys { 25 | 26 | val isMac = System.getProperty("os.name").contains("Mac") 27 | 28 | override val ArrowUp = glfwGetKeyScancode(GLFW_KEY_UP) //111 29 | override val ArrowDown = glfwGetKeyScancode(GLFW_KEY_DOWN)// 116 30 | override val ArrowLeft = glfwGetKeyScancode(GLFW_KEY_LEFT) // 113 31 | override val ArrowRight = glfwGetKeyScancode(GLFW_KEY_RIGHT) //114 32 | 33 | override val Escape = glfwGetKeyScancode(GLFW_KEY_ESCAPE) //9 34 | override val Spacebar = glfwGetKeyScancode(GLFW_KEY_SPACE) //65 35 | override val Delete = glfwGetKeyScancode(GLFW_KEY_DELETE) //119 36 | 37 | override val LeftShift = glfwGetKeyScancode(GLFW_KEY_LEFT_SHIFT) //50 38 | override val RightShift = glfwGetKeyScancode(GLFW_KEY_RIGHT_SHIFT) //62 39 | 40 | override val LeftControl = glfwGetKeyScancode(GLFW_KEY_LEFT_CONTROL) //37 41 | override val RightControl = glfwGetKeyScancode(GLFW_KEY_RIGHT_SHIFT) //105 42 | 43 | override val LeftSuper = glfwGetKeyScancode(GLFW_KEY_LEFT_SUPER) //133 44 | override val RightSuper = glfwGetKeyScancode(GLFW_KEY_RIGHT_SUPER) //134 45 | 46 | override val NativeLeftSuper by lazy { 47 | if(isMac) glfwGetKeyScancode(GLFW_KEY_LEFT_SUPER) else glfwGetKeyScancode(GLFW_KEY_LEFT_CONTROL) 48 | } 49 | override val NativeRightSuper by lazy { 50 | if(isMac) glfwGetKeyScancode(GLFW_KEY_RIGHT_SUPER) else glfwGetKeyScancode(GLFW_KEY_RIGHT_CONTROL) 51 | } 52 | 53 | override val Z = glfwGetKeyScancode(GLFW_KEY_Z) //44 54 | override val Y = glfwGetKeyScancode(GLFW_KEY_Y) //52 55 | override val X = glfwGetKeyScancode(GLFW_KEY_X) //45 56 | override val C = glfwGetKeyScancode(GLFW_KEY_C) //46 57 | override val V = glfwGetKeyScancode(GLFW_KEY_V) //47 58 | } -------------------------------------------------------------------------------- /LwjglPlatform/src/main/kotlin/io/github/deltacv/papervision/platform/lwjgl/util/IOUtil.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.platform.lwjgl.util 20 | 21 | import org.lwjgl.BufferUtils 22 | import org.lwjgl.system.MemoryUtil 23 | import java.io.IOException 24 | import java.nio.Buffer 25 | import java.nio.ByteBuffer 26 | import java.nio.channels.Channels 27 | import java.nio.file.Files 28 | import java.nio.file.Paths 29 | 30 | object IOUtil { 31 | 32 | private fun resizeBuffer(buffer: ByteBuffer, newCapacity: Int): ByteBuffer { 33 | val newBuffer = BufferUtils.createByteBuffer(newCapacity) 34 | buffer.flip() 35 | newBuffer.put(buffer) 36 | return newBuffer 37 | } 38 | 39 | /** 40 | * Reads the specified resource and returns the raw data as a ByteBuffer. 41 | * 42 | * @param resource the resource to read 43 | * @param bufferSize the initial buffer size 44 | * 45 | * @return the resource data 46 | * 47 | * @throws IOException if an IO error occurs 48 | */ 49 | @Throws(IOException::class) 50 | fun ioResourceToByteBuffer(resource: String, bufferSize: Int): ByteBuffer { 51 | var buffer: ByteBuffer 52 | val path = Paths.get(resource) 53 | if (Files.isReadable(path)) { 54 | Files.newByteChannel(path).use { fc -> 55 | buffer = BufferUtils.createByteBuffer(fc.size().toInt() + 1) 56 | while (fc.read(buffer) != -1) { 57 | } 58 | } 59 | } else { 60 | IOUtil::class.java.getResourceAsStream(resource)!!.use { source -> 61 | Channels.newChannel(source).use { rbc -> 62 | buffer = BufferUtils.createByteBuffer(bufferSize) 63 | while (true) { 64 | val bytes = rbc.read(buffer) 65 | if (bytes == -1) { 66 | break 67 | } 68 | if (buffer.remaining() == 0) { 69 | buffer = resizeBuffer(buffer, buffer.capacity() * 3 / 2) // 50% 70 | } 71 | } 72 | } 73 | } 74 | } 75 | (buffer as Buffer).flip() 76 | return MemoryUtil.memSlice(buffer) 77 | } 78 | } 79 | 80 | -------------------------------------------------------------------------------- /LwjglPlatform/src/main/kotlin/io/github/deltacv/papervision/platform/lwjgl/util/Image.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.platform.lwjgl.util 20 | 21 | import org.lwjgl.stb.STBImage.* 22 | import org.lwjgl.system.MemoryStack 23 | import java.awt.image.BufferedImage 24 | import java.awt.image.DataBufferInt 25 | import java.nio.ByteBuffer 26 | 27 | fun loadImageFromResource(resourcePath: String): ImageData { 28 | val imgBuffer = try { 29 | IOUtil.ioResourceToByteBuffer(resourcePath, 8 * 1024) 30 | } catch(e: Exception) { 31 | throw RuntimeException("Exception while loading image $resourcePath", e) 32 | } 33 | 34 | var image: ImageData? = null 35 | 36 | MemoryStack.stackPush().use { 37 | val comp = it.mallocInt(1) 38 | val w = it.mallocInt(1) 39 | val h = it.mallocInt(1) 40 | 41 | val img = stbi_load_from_memory(imgBuffer, w, h, comp, 4) 42 | ?: throw RuntimeException("Failed to load image $resourcePath due to ${stbi_failure_reason()}") 43 | 44 | image = ImageData(img, w.get(), h.get()) 45 | } 46 | 47 | return image!! 48 | } 49 | 50 | data class ImageData(val buffer: ByteBuffer, val width: Int, val height: Int) 51 | 52 | fun ImageData.toBufferedImage(): BufferedImage { 53 | val image = BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB) 54 | val pixels = (image.raster.dataBuffer as DataBufferInt).data 55 | 56 | buffer.rewind() 57 | 58 | for(i in 0 until width * height) { 59 | val r = buffer.get().toInt() and 0xFF 60 | val g = buffer.get().toInt() and 0xFF 61 | val b = buffer.get().toInt() and 0xFF 62 | val a = buffer.get().toInt() and 0xFF 63 | 64 | pixels[i] = (a shl 24) or (r shl 16) or (g shl 8) or b 65 | } 66 | 67 | return image 68 | } -------------------------------------------------------------------------------- /LwjglPlatform/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | [%d{HH:mm:ss}] [%thread/%level]: [%class{0}] %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /PaperVision/NodeAnnotationProcessor/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.jetbrains.kotlin.jvm' 3 | } 4 | 5 | apply from: '../../build.common.gradle' 6 | 7 | dependencies { 8 | implementation 'com.google.devtools.ksp:symbol-processing-api:2.0.20-1.0.24' 9 | implementation "com.squareup:kotlinpoet:1.18.1" 10 | 11 | implementation project(":Shared") 12 | } -------------------------------------------------------------------------------- /PaperVision/NodeAnnotationProcessor/src/main/kotlin/io/github/deltacv/papervision/annotation/PaperNodeAnnotationProcessorProvider.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.annotation 20 | 21 | import com.google.devtools.ksp.processing.SymbolProcessor 22 | import com.google.devtools.ksp.processing.SymbolProcessorEnvironment 23 | import com.google.devtools.ksp.processing.SymbolProcessorProvider 24 | 25 | class PaperNodeAnnotationProcessorProvider : SymbolProcessorProvider { 26 | override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor { 27 | return PaperNodeAnnotationProcessor(environment) 28 | } 29 | } -------------------------------------------------------------------------------- /PaperVision/NodeAnnotationProcessor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider: -------------------------------------------------------------------------------- 1 | io.github.deltacv.papervision.annotation.PaperNodeAnnotationProcessorProvider -------------------------------------------------------------------------------- /PaperVision/build.gradle: -------------------------------------------------------------------------------- 1 | import java.nio.file.Paths 2 | import java.time.LocalDateTime 3 | import java.time.format.DateTimeFormatter 4 | 5 | plugins { 6 | id 'com.google.devtools.ksp' version '2.0.20-1.0.24' 7 | id 'org.jetbrains.kotlin.jvm' 8 | id 'signing' 9 | id "com.vanniktech.maven.publish" 10 | } 11 | 12 | apply from: '../build.common.gradle' 13 | 14 | dependencies { 15 | compileOnly "org.jetbrains.kotlin:kotlin-stdlib" 16 | implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" 17 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinx_coroutines_version" 18 | 19 | compileOnly "io.github.spair:imgui-java-binding:$imgui_version" // platforms should add the "implementation" they need 20 | 21 | api "org.slf4j:slf4j-api:$slf4j_version" 22 | 23 | api 'org.deltacv:mai18n:1.1.5' 24 | 25 | implementation "org.java-websocket:Java-WebSocket:1.5.2" 26 | 27 | implementation "com.google.code.gson:gson:$gson_version" 28 | implementation "io.github.classgraph:classgraph:$classgraph_version" 29 | 30 | implementation 'ome:turbojpeg:8.0.0' 31 | 32 | api project(":Shared") 33 | ksp project(":PaperVision:NodeAnnotationProcessor") 34 | } 35 | 36 | ksp { 37 | arg("paperNodeClassesMetadataPackage", "io.github.deltacv.papervision.node") 38 | arg("paperNodeClassesMetadataClassName", "PaperNodeClassesMetadata") 39 | } 40 | 41 | tasks.register('writeBuildClassJava') { 42 | String date = DateTimeFormatter.ofPattern("yyyy-M-d hh:mm:ss").format(LocalDateTime.now()) 43 | 44 | File versionFile = Paths.get( 45 | projectDir.absolutePath, 'src', 'main', 'kotlin', 46 | 'io', 'github', 'deltacv', 'papervision', 'Build.kt' 47 | ).toFile() 48 | 49 | versionFile.delete() 50 | 51 | versionFile << "package io.github.deltacv.papervision\n" + 52 | "\n" + 53 | "/*\n" + 54 | " * Autogenerated file! Do not manually edit this file, as\n" + 55 | " * it is regenerated any time the build task is run.\n" + 56 | " *\n" + 57 | " * Based from PhotonVision PhotonVersion generator task\n" + 58 | " */\n" + 59 | "@Suppress(\"UNUSED\")\n" + 60 | "object Build {\n" + 61 | " const val VERSION_STRING = \"$version\";\n" + 62 | " const val STANDARD_VERSION_STRING = \"$standardVersion\";\n" + 63 | " const val BUILD_DATE = \"$date\";\n" + 64 | " const val IS_DEV = ${version.contains("dev")};\n" + 65 | "}" 66 | } 67 | 68 | build.dependsOn writeBuildClassJava 69 | -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/action/Action.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.action 20 | 21 | import io.github.deltacv.papervision.id.DrawableIdElementBase 22 | import io.github.deltacv.papervision.id.IdElementContainerStack 23 | import io.github.deltacv.papervision.util.loggerForThis 24 | 25 | abstract class Action( 26 | val executeOnEnable: Boolean = true 27 | ) : DrawableIdElementBase() { 28 | override val idElementContainer = IdElementContainerStack.threadStack.peekNonNull() 29 | 30 | val logger by loggerForThis() 31 | 32 | override fun enable() { 33 | if(!idElementContainer.stackPointerFollowing) { 34 | logger.info("Forking after pointer") 35 | idElementContainer.fork() 36 | } 37 | super.enable() 38 | } 39 | 40 | override fun onEnable() { 41 | if(executeOnEnable) { 42 | execute() 43 | } 44 | } 45 | 46 | override fun draw() {} 47 | 48 | abstract fun undo() 49 | abstract fun execute() 50 | } 51 | 52 | class RootAction : Action( 53 | executeOnEnable = false 54 | ) { 55 | override fun undo() {} 56 | 57 | override fun execute() { 58 | logger.info("Root action executed") 59 | idElementContainer.pushforwardIfNonNull() 60 | } 61 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/action/editor/AttributeActions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.action.editor 20 | 21 | import io.github.deltacv.papervision.action.Action 22 | import io.github.deltacv.papervision.node.Link 23 | 24 | class CreateLinkAction( 25 | val link: Link 26 | ) : Action() { 27 | override fun undo() { 28 | link.delete() 29 | } 30 | 31 | override fun execute() { 32 | link.associatedAction = this 33 | if(link.isEnabled) return 34 | 35 | if(link.hasEnabled) { 36 | link.restore() 37 | } else { 38 | link.enable() 39 | } 40 | } 41 | } 42 | 43 | class DeleteLinksAction( 44 | val links: List 45 | ) : Action() { 46 | override fun undo() { 47 | links.forEach { 48 | if(it.isEnabled) return 49 | it.enable() 50 | } 51 | } 52 | 53 | override fun execute() { 54 | links.forEach { 55 | it.delete() 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/action/editor/NodeActions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.action.editor 20 | 21 | import io.github.deltacv.papervision.action.Action 22 | import io.github.deltacv.papervision.node.Node 23 | 24 | class CreateNodesAction( 25 | val nodes: List> 26 | ) : Action() { 27 | 28 | constructor(node: Node<*>) : this(listOf(node)) 29 | 30 | override fun undo() { 31 | for(node in nodes) { 32 | if(node.isEnabled) { 33 | node.delete() 34 | } 35 | } 36 | } 37 | 38 | override fun execute() { 39 | for(node in nodes) { 40 | if(node.isEnabled) continue 41 | 42 | if(node.hasEnabled) { 43 | node.restore() 44 | } else { 45 | node.enable() 46 | } 47 | } 48 | } 49 | } 50 | 51 | class DeleteNodesAction( 52 | val nodes: List> 53 | ) : Action() { 54 | override fun undo() { 55 | nodes.forEach { 56 | if(it.isEnabled) return 57 | 58 | if(it.hasEnabled) { 59 | it.restore() 60 | } else { 61 | it.enable() 62 | } 63 | } 64 | } 65 | 66 | override fun execute() { 67 | nodes.forEach { 68 | it.delete() 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/attribute/math/DoubleAttribute.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.attribute.math 20 | 21 | import imgui.ImGui 22 | import imgui.type.ImDouble 23 | import imgui.type.ImFloat 24 | import io.github.deltacv.papervision.PaperVision 25 | import io.github.deltacv.papervision.attribute.AttributeMode 26 | import io.github.deltacv.papervision.attribute.AttributeType 27 | import io.github.deltacv.papervision.attribute.TypedAttribute 28 | import io.github.deltacv.papervision.codegen.CodeGen 29 | import io.github.deltacv.papervision.codegen.GenValue 30 | import io.github.deltacv.papervision.gui.FontAwesomeIcons 31 | import io.github.deltacv.papervision.util.Range2d 32 | 33 | class DoubleAttribute( 34 | override val mode: AttributeMode, 35 | override var variableName: String? = null 36 | ) : TypedAttribute(Companion) { 37 | 38 | companion object: AttributeType { 39 | override val icon = FontAwesomeIcons.SquareRootAlt 40 | 41 | override fun new(mode: AttributeMode, variableName: String) = DoubleAttribute(mode, variableName) 42 | } 43 | 44 | val value = ImDouble() 45 | private val sliderValue = ImFloat() 46 | 47 | private val sliderId by PaperVision.miscIds.nextId() 48 | 49 | private var range: Range2d? = null 50 | 51 | override fun drawAttribute() { 52 | super.drawAttribute() 53 | checkChange() 54 | 55 | if(!hasLink && mode == AttributeMode.INPUT) { 56 | sameLineIfNeeded() 57 | 58 | ImGui.pushItemWidth(110.0f) 59 | 60 | if(range == null) { 61 | ImGui.inputDouble("", value) 62 | } else { 63 | ImGui.sliderFloat("###$sliderId", sliderValue.data, range!!.min.toFloat(), range!!.max.toFloat()) 64 | value.set(sliderValue.get().toDouble()) 65 | } 66 | 67 | ImGui.popItemWidth() 68 | } 69 | } 70 | 71 | fun sliderMode(range: Range2d) { 72 | this.range = range 73 | } 74 | 75 | fun normalMode() { 76 | this.range = null 77 | } 78 | 79 | override fun thisGet() = value.get() 80 | 81 | override fun value(current: CodeGen.Current) = value( 82 | current, "a Double", GenValue.Double(value.get()) 83 | ) { it is GenValue.Double } 84 | 85 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/attribute/vision/structs/PointsAttribute.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.attribute.vision.structs 20 | 21 | import io.github.deltacv.papervision.attribute.AttributeMode 22 | import io.github.deltacv.papervision.attribute.AttributeType 23 | import io.github.deltacv.papervision.attribute.TypedAttribute 24 | import io.github.deltacv.papervision.codegen.CodeGen 25 | import io.github.deltacv.papervision.codegen.GenValue 26 | import io.github.deltacv.papervision.gui.FontAwesomeIcons 27 | import io.github.deltacv.papervision.gui.style.hexColor 28 | import io.github.deltacv.papervision.gui.style.rgbaColor 29 | 30 | class PointsAttribute ( 31 | override val mode: AttributeMode, 32 | override var variableName: String? = null 33 | ) : TypedAttribute(PointsAttribute) { 34 | 35 | companion object : AttributeType { 36 | override val icon = FontAwesomeIcons.BezierCurve 37 | 38 | override val styleColor = rgbaColor(253, 216, 53, 180) 39 | override val styleHoveredColor = rgbaColor(253, 216, 53, 255) 40 | 41 | override val listStyleColor = rgbaColor(253, 216, 53, 140) 42 | override val listStyleHoveredColor = rgbaColor(253, 216, 53, 255) 43 | 44 | override fun new(mode: AttributeMode, variableName: String) = PointsAttribute(mode, variableName) 45 | } 46 | 47 | override fun value(current: CodeGen.Current) = value( 48 | current, "a Points" 49 | ) { it is GenValue.GPoints.RuntimePoints } 50 | 51 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/attribute/vision/structs/RectAttribute.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.attribute.vision.structs 20 | 21 | import io.github.deltacv.papervision.attribute.AttributeMode 22 | import io.github.deltacv.papervision.attribute.AttributeType 23 | import io.github.deltacv.papervision.attribute.TypedAttribute 24 | import io.github.deltacv.papervision.codegen.CodeGen 25 | import io.github.deltacv.papervision.codegen.GenValue 26 | import io.github.deltacv.papervision.gui.FontAwesomeIcons 27 | import io.github.deltacv.papervision.gui.style.rgbaColor 28 | 29 | class RectAttribute ( 30 | override val mode: AttributeMode, 31 | override var variableName: String? = null 32 | ) : TypedAttribute(Companion) { 33 | 34 | companion object : AttributeType { 35 | override val icon = FontAwesomeIcons.Square 36 | 37 | override val styleColor = rgbaColor(253, 216, 53, 180) 38 | override val styleHoveredColor = rgbaColor(253, 216, 53, 255) 39 | 40 | override val listStyleColor = rgbaColor(253, 216, 53, 140) 41 | override val listStyleHoveredColor = rgbaColor(253, 216, 53, 255) 42 | 43 | override fun new(mode: AttributeMode, variableName: String) = RectAttribute(mode, variableName) 44 | } 45 | 46 | override fun value(current: CodeGen.Current) = value( 47 | current, "a Rect" 48 | ) { it is GenValue.GRect.RuntimeRect } 49 | 50 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/attribute/vision/structs/RotatedRectAttribute.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.attribute.vision.structs 20 | 21 | import io.github.deltacv.papervision.attribute.AttributeMode 22 | import io.github.deltacv.papervision.attribute.AttributeType 23 | import io.github.deltacv.papervision.attribute.TypedAttribute 24 | import io.github.deltacv.papervision.codegen.CodeGen 25 | import io.github.deltacv.papervision.codegen.GenValue 26 | import io.github.deltacv.papervision.gui.FontAwesomeIcons 27 | import io.github.deltacv.papervision.gui.style.rgbaColor 28 | 29 | class RotatedRectAttribute ( 30 | override val mode: AttributeMode, 31 | override var variableName: String? = null 32 | ) : TypedAttribute(Companion) { 33 | 34 | companion object : AttributeType { 35 | override val icon = FontAwesomeIcons.VectorSquare 36 | 37 | override val styleColor = rgbaColor(253, 216, 53, 180) 38 | override val styleHoveredColor = rgbaColor(253, 216, 53, 255) 39 | 40 | override val listStyleColor = rgbaColor(253, 216, 53, 140) 41 | override val listStyleHoveredColor = rgbaColor(253, 216, 53, 255) 42 | 43 | override fun new(mode: AttributeMode, variableName: String) = RotatedRectAttribute(mode, variableName) 44 | } 45 | 46 | override fun value(current: CodeGen.Current) = value( 47 | current, "a Rotated Rect" 48 | ) { it is GenValue.GRect.Rotated.RuntimeRotatedRect } 49 | 50 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/codegen/Csv.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.codegen 20 | 21 | import io.github.deltacv.papervision.codegen.build.Type 22 | import io.github.deltacv.papervision.codegen.build.Value 23 | 24 | fun Array.csv(): String { 25 | val builder = StringBuilder() 26 | 27 | for((i, parameter) in this.withIndex()) { 28 | builder.append(parameter) 29 | 30 | if(i < this.size - 1) { 31 | builder.append(", ") 32 | } 33 | } 34 | 35 | return builder.toString() 36 | } 37 | 38 | fun Array.csv(): String { 39 | val stringArray = this.map { it.value!! }.toTypedArray() 40 | return stringArray.csv() 41 | } 42 | 43 | fun Array.csv(): String { 44 | val stringArray = this.map { it.shortNameWithGenerics }.toTypedArray() 45 | return stringArray.csv() 46 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/codegen/GenNode.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.codegen 20 | 21 | import io.github.deltacv.papervision.attribute.Attribute 22 | import io.github.deltacv.papervision.util.loggerForThis 23 | import java.util.logging.Logger 24 | 25 | interface GenNode : Generator { 26 | 27 | val genOptions: CodeGenOptions 28 | var lastGenSession: S? 29 | 30 | fun propagate(current: CodeGen.Current) 31 | 32 | fun receivePropagation(current: CodeGen.Current) { 33 | genCodeIfNecessary(current) 34 | } 35 | 36 | /** 37 | * Generates code if there's not a session in the current CodeGen 38 | * Automatically propagates to all the nodes attached to the output 39 | * attributes after genCode finishes. Called by default on onPropagateReceive() 40 | */ 41 | @Suppress("UNCHECKED_CAST") 42 | fun genCodeIfNecessary(current: CodeGen.Current) { 43 | val logger = loggerForThis().value 44 | 45 | val codeGen = current.codeGen 46 | 47 | if(genOptions.genAtTheEnd && codeGen.stage != CodeGen.Stage.END_GEN) { 48 | if(!codeGen.endingNodes.contains(this)) { 49 | logger.info("Marked node $this as an ending node") 50 | codeGen.endingNodes.add(this) 51 | } 52 | 53 | return 54 | } 55 | 56 | val session = codeGen.sessions[this] 57 | 58 | if(session == null) { 59 | // prevents duplicate code in weird edge cases 60 | // (it's so hard to consider and test every possibility with nodes...) 61 | if(!codeGen.busyNodes.contains(this)) { 62 | codeGen.busyNodes.add(this) 63 | 64 | logger.info("Generating code for node $this") 65 | 66 | lastGenSession = genCode(current) 67 | codeGen.sessions[this] = lastGenSession!! 68 | 69 | codeGen.busyNodes.remove(this) 70 | 71 | logger.info("DONE generating code for node $this") 72 | 73 | propagate(current) 74 | } 75 | } else { 76 | lastGenSession = session as S 77 | } 78 | } 79 | 80 | fun getOutputValueOf(current: CodeGen.Current, attrib: Attribute): GenValue 81 | 82 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/codegen/Generator.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.codegen 20 | 21 | interface Generator { 22 | fun genCode(current: CodeGen.Current): S 23 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/codegen/GeneratorsGenNode.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.codegen 20 | 21 | import io.github.deltacv.papervision.codegen.language.Language 22 | 23 | interface GeneratorsGenNode : GenNode { 24 | val generators: Map> 25 | 26 | fun map(language: Language, generator: Generator) = Pair(language, generator) 27 | 28 | override fun genCode(current: CodeGen.Current): S { 29 | val generator = generators[current.language] ?: throw NoSuchElementException("No generator found for language ${current.language.javaClass.simpleName} at node ${this::class.simpleName}") 30 | lastGenSession = generator.genCode(current) 31 | 32 | return lastGenSession!! 33 | } 34 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/codegen/build/Type.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.codegen.build 20 | 21 | import io.github.deltacv.papervision.codegen.csv 22 | 23 | open class Type( 24 | val className: String, 25 | open val packagePath: String = "", 26 | val generics: Array? = null, 27 | 28 | open val actualImport: Type? = null, 29 | val isArray: Boolean = false 30 | ) { 31 | 32 | companion object { 33 | val NONE = Type("", "") 34 | } 35 | 36 | val hasGenerics get() = !generics.isNullOrEmpty() 37 | 38 | open val shouldImport get() = className != packagePath 39 | 40 | val shortNameWithGenerics get() = 41 | if(generics != null) 42 | "$className<${generics.csv()}>" 43 | else className 44 | 45 | override fun toString() = "Type(className=$className, packagePath=$packagePath, actualImport=$actualImport, isArray=$isArray)" 46 | 47 | } 48 | 49 | private val typeCache = mutableMapOf, Type>() 50 | 51 | val Any.genType: Type get() = this::class.java.genType 52 | 53 | val Class<*>.genType: Type get() { 54 | if(!typeCache.containsKey(this)) { 55 | typeCache[this] = Type(simpleName, getPackage()?.name ?: "") 56 | } 57 | 58 | return typeCache[this]!! 59 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/codegen/build/Value.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.codegen.build 20 | 21 | val String.v get() = ConValue(genType, this) 22 | val Number.v get() = toString().v 23 | 24 | abstract class Value { 25 | 26 | abstract val type: Type 27 | abstract val value: String? 28 | 29 | private val internalImports = mutableListOf() 30 | val imports get() = internalImports as List 31 | 32 | protected fun processImports() { 33 | // avoid adding imports for primitive types 34 | if(type.shouldImport) { 35 | additionalImports(type) 36 | } 37 | 38 | if(type.generics != null) { 39 | for(genericType in type.generics!!) { 40 | if(genericType.shouldImport) { 41 | additionalImports(genericType) 42 | } 43 | } 44 | } 45 | } 46 | 47 | fun additionalImports(vararg imports: Type) { 48 | internalImports.addAll(imports) 49 | } 50 | 51 | fun additionalImports(vararg imports: Value) { 52 | for(import in imports) { 53 | internalImports.addAll(import.imports) 54 | } 55 | } 56 | } 57 | 58 | open class ConValue(override val type: Type, override val value: String?): Value() { 59 | init { 60 | processImports() 61 | } 62 | } 63 | 64 | class Condition(booleanType: Type, condition: String) : ConValue(booleanType, condition) 65 | class Operation(numberType: Type, operation: String) : ConValue(numberType, operation) 66 | 67 | open class Variable(val name: String, val variableValue: Value) : ConValue(variableValue.type, name) { 68 | 69 | constructor(type: Type, name: String) : this(name, ConValue(type, name)) 70 | 71 | init { 72 | additionalImports(*variableValue.imports.toTypedArray()) 73 | } 74 | 75 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/codegen/build/type/CPythonOpenCvTypes.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.codegen.build.type 20 | 21 | import io.github.deltacv.papervision.codegen.build.ConValue 22 | 23 | object CPythonOpenCvTypes { 24 | object cv2 : CPythonType("cv2") { 25 | val RETR_LIST = ConValue(this, "cv2.RETR_LIST").apply { 26 | additionalImports(this) 27 | } 28 | 29 | val RETR_EXTERNAL = ConValue(this, "cv2.RETR_EXTERNAL").apply { 30 | additionalImports(this) 31 | } 32 | 33 | val CHAIN_APPROX_SIMPLE = ConValue(this, "cv2.CHAIN_APPROX_SIMPLE").apply { 34 | additionalImports(this) 35 | } 36 | 37 | val MORPH_RECT = ConValue(this, "cv2.MORPH_RECT").apply { 38 | additionalImports(this) 39 | } 40 | 41 | val contourArea = ConValue(this, "cv2.contourArea").apply { 42 | additionalImports(this) 43 | } 44 | } 45 | 46 | val np = CPythonType("numpy", null, "np") 47 | 48 | val npArray = object: CPythonType("np.ndarray") { 49 | override var actualImport = np 50 | } 51 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/codegen/build/type/CPythonType.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.codegen.build.type 20 | 21 | import io.github.deltacv.papervision.codegen.build.Type 22 | 23 | open class CPythonType( 24 | val module: String, 25 | val name: String? = null, 26 | val alias: String? = null 27 | ) : Type(alias ?: name ?: module, module) { 28 | override val shouldImport = true 29 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/codegen/build/type/JavaTypes.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.codegen.build.type 20 | 21 | import io.github.deltacv.papervision.codegen.build.Type 22 | 23 | object JavaTypes { 24 | 25 | val String = Type("String", "java.lang") 26 | 27 | val Math = object: Type("Math", "java.lang") { 28 | override val shouldImport = false 29 | } 30 | 31 | fun Set(elementType: Type) = Type( 32 | "Set", "java.util", 33 | arrayOf(elementType) 34 | ) 35 | 36 | fun ArrayList(elementType: Type) = Type( 37 | "ArrayList", "java.util", 38 | arrayOf(elementType) 39 | ) 40 | 41 | fun HashMap(key: Type, value: Type) = Type( 42 | "HashMap", "java.util", 43 | arrayOf(key, value) 44 | ) 45 | 46 | class Map(key: Type, value: Type) : Type( 47 | "Map", "java.util", 48 | arrayOf(key, value) 49 | ) { 50 | class Entry(key: Type, value: Type) : Type( 51 | "Map.Entry", "java.util", 52 | arrayOf(key, value) 53 | ) 54 | } 55 | 56 | fun List(elementType: Type) = Type( 57 | "List", "java.util", 58 | arrayOf(elementType) 59 | ) 60 | 61 | val Collections = Type("Collections", "java.util") 62 | 63 | val LabelAnnotation = Type("Label", "io.github.deltacv.eocvsim.virtualreflect.jvm") 64 | 65 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/codegen/build/type/JvmOpenCvTypes.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.codegen.build.type 20 | 21 | import io.github.deltacv.papervision.codegen.build.ConValue 22 | import io.github.deltacv.papervision.codegen.build.Type 23 | 24 | object JvmOpenCvTypes { 25 | 26 | val OpenCvPipeline = Type("OpenCvPipeline", "org.openftc.easyopencv") 27 | val StreamableOpenCvPipeline = Type("StreamableOpenCvPipeline", "io.github.deltacv.eocvsim.pipeline") 28 | 29 | object Imgproc : Type("Imgproc", "org.opencv.imgproc") { 30 | val RETR_LIST = ConValue(StandardTypes.cint, "Imgproc.RETR_LIST").apply { 31 | additionalImports(this) 32 | } 33 | 34 | val RETR_EXTERNAL = ConValue(StandardTypes.cint, "Imgproc.RETR_EXTERNAL").apply { 35 | additionalImports(this) 36 | } 37 | 38 | val CHAIN_APPROX_SIMPLE = ConValue(StandardTypes.cint, "Imgproc.CHAIN_APPROX_SIMPLE").apply { 39 | additionalImports(this) 40 | } 41 | 42 | val MORPH_RECT = ConValue(StandardTypes.cint, "Imgproc.MORPH_RECT").apply { 43 | additionalImports(this) 44 | } 45 | } 46 | 47 | object CvType : Type("CvType", "org.opencv.core") 48 | 49 | val Core = Type("Core", "org.opencv.core") 50 | 51 | val Mat = Type("Mat", "org.opencv.core") 52 | val MatOfInt = Type("MatOfInt", "org.opencv.core") 53 | val MatOfPoint = Type("MatOfPoint", "org.opencv.core") 54 | val MatOfPoint2f = Type("MatOfPoint2f", "org.opencv.core") 55 | 56 | val Size = Type("Size", "org.opencv.core") 57 | val Scalar = Type("Scalar", "org.opencv.core") 58 | 59 | val Rect = Type("Rect", "org.opencv.core") 60 | val RotatedRect = Type("RotatedRect", "org.opencv.core") 61 | 62 | val Point = Type("Point", "org.opencv.core") 63 | 64 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/codegen/build/type/KotlinTypes.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.codegen.build.type 20 | 21 | import io.github.deltacv.papervision.codegen.build.Type 22 | 23 | object KotlinTypes { 24 | 25 | val Boolean = Type("Boolean", "Boolean") 26 | 27 | val Int = Type("Int", "Int") 28 | val Long = Type("Long", "Long") 29 | val Float = Type("Float", "Float") 30 | val Double = Type("Double", "Double") 31 | 32 | val Unit = Type("Unit", "kotlin") 33 | 34 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/codegen/build/type/StandardTypes.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.codegen.build.type 20 | 21 | import io.github.deltacv.papervision.codegen.build.Type 22 | 23 | object StandardTypes { 24 | 25 | val cboolean = Type("boolean", "boolean") 26 | 27 | val cint = Type("int", "int") 28 | val clong = Type("long", "long") 29 | val cfloat = Type("float", "float") 30 | val cdouble = Type("double", "double") 31 | 32 | val cvoid = Type("void", "void") 33 | 34 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/codegen/dsl/CodeGenContext.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.codegen.dsl 20 | 21 | import io.github.deltacv.papervision.codegen.* 22 | import io.github.deltacv.papervision.codegen.build.* 23 | 24 | class CodeGenContext(val codeGen: CodeGen) : LanguageContext(codeGen.language) { 25 | 26 | val isForPreviz get() = codeGen.isForPreviz 27 | 28 | fun enum(name: String, vararg values: String) { 29 | codeGen.classStartScope.enumClass(name, *values) 30 | } 31 | 32 | fun init(block: ScopeContext.() -> Unit) { 33 | codeGen.initScope(block) 34 | } 35 | 36 | fun processFrame(block: ScopeContext.() -> Unit) { 37 | codeGen.processFrameScope(block) 38 | } 39 | 40 | fun onViewportTapped(block: ScopeContext.() -> Unit) { 41 | codeGen.viewportTappedScope(block) 42 | } 43 | 44 | fun public(variable: Variable, label: String? = null) = 45 | codeGen.classStartScope.instanceVariable(Visibility.PUBLIC, variable, label) 46 | 47 | fun private(variable: Variable) = 48 | codeGen.classStartScope.instanceVariable(Visibility.PRIVATE, variable, null) 49 | 50 | fun protected(variable: Variable) = 51 | codeGen.classStartScope.instanceVariable(Visibility.PROTECTED, variable, null) 52 | 53 | private var isFirstGroup = true 54 | 55 | fun group(scope: Scope = codeGen.classStartScope, block: () -> Unit) { 56 | if(!isFirstGroup) { 57 | scope.newLineIfNotBlank() 58 | } 59 | isFirstGroup = false 60 | 61 | block() 62 | } 63 | 64 | fun uniqueVariable(name: String, value: Value) = variable(tryName(name), value) 65 | 66 | fun tryName(name: String) = codeGen.classStartScope.tryName(name) 67 | 68 | operator fun String.invoke( 69 | vis: Visibility, returnType: Type, 70 | vararg parameters: Parameter, 71 | isStatic: Boolean = false, isFinal: Boolean = false, isOverride: Boolean = true, 72 | scopeBlock: ScopeContext.() -> Unit 73 | ) { 74 | val s = Scope(2, codeGen.language) 75 | scopeBlock(s.context) 76 | 77 | codeGen.classEndScope.method( 78 | vis, returnType, this, s, *parameters, 79 | isStatic = isStatic, isFinal = isFinal, isOverride = isOverride 80 | ) 81 | } 82 | 83 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/codegen/dsl/GeneratorContext.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.codegen.dsl 20 | 21 | import io.github.deltacv.papervision.codegen.CodeGen 22 | import io.github.deltacv.papervision.codegen.CodeGenSession 23 | import io.github.deltacv.papervision.codegen.Generator 24 | import io.github.deltacv.papervision.codegen.language.Language 25 | 26 | class GeneratorContext(val current: CodeGen.Current) 27 | 28 | fun generator(init: GeneratorContext.() -> S) = 29 | object: Generator { 30 | override fun genCode(current: CodeGen.Current) = init(GeneratorContext(current)) 31 | } 32 | 33 | fun generatorFor(language: Language, init: GeneratorContext.() -> S) = 34 | language to generator(init) 35 | 36 | fun generatorFor(vararg languages: Language, init: GeneratorContext.() -> S) = 37 | languages.map { it to generator(init) }.toMap() -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/codegen/dsl/GeneratorsContext.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.codegen.dsl 20 | 21 | import io.github.deltacv.papervision.codegen.CodeGenSession 22 | import io.github.deltacv.papervision.codegen.Generator 23 | import io.github.deltacv.papervision.codegen.language.Language 24 | 25 | class GeneratorsContext { 26 | val generators = mutableMapOf>() 27 | 28 | fun generatorFor(language: Language, init: GeneratorContext.() -> S) = generatorFor(language, init).apply { generators[first] = second } 29 | fun generatorFor(vararg languages: Language, init: GeneratorContext.() -> S) = generatorFor(*languages, init = init).apply { forEach { generators[it.key] = it.value } } 30 | 31 | fun generatorFor(language: Language, generator: Generator) = generators.put(language, generator) 32 | fun generatorFor(vararg languages: Language, generator: Generator) = languages.forEach { generators[it] = generator } 33 | } 34 | 35 | fun generatorsBuilder(init: GeneratorsContext.() -> Unit) = GeneratorsContext().run { 36 | init() 37 | generators 38 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/codegen/dsl/TargetsContext.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.codegen.dsl 20 | 21 | import io.github.deltacv.papervision.codegen.CodeGen 22 | import io.github.deltacv.papervision.codegen.build.Type 23 | import io.github.deltacv.papervision.codegen.build.Value 24 | import io.github.deltacv.papervision.codegen.build.Variable 25 | import io.github.deltacv.papervision.codegen.build.type.JavaTypes 26 | import io.github.deltacv.papervision.codegen.build.type.JvmOpenCvTypes 27 | import io.github.deltacv.papervision.codegen.vision.enableTargets 28 | 29 | class TargetsContext(context: LanguageContext) { 30 | val rectTargets = context.run { 31 | Variable("rectTargets", JavaTypes.HashMap(JavaTypes.String, JvmOpenCvTypes.Rect).new()) 32 | } 33 | val rotRectTargets = context.run { 34 | Variable("rotRectTarget", JavaTypes.HashMap(JavaTypes.String, JvmOpenCvTypes.RotatedRect).new()) 35 | } 36 | 37 | fun ScopeContext.addRectTarget(label: Value, rect: Value) { 38 | "addRectTarget"(label, rect) 39 | } 40 | 41 | fun ScopeContext.addRotRectTarget(label: Value, rect: Value) { 42 | "addRotRectTarget"(label, rect) 43 | } 44 | 45 | fun ScopeContext.clearTargets() { 46 | "clearTargets"() 47 | } 48 | } 49 | 50 | fun CodeGen.Current.targets(enableTargetsIfNeeded: Boolean = true, block: TargetsContext.() -> T): T { 51 | if(enableTargetsIfNeeded) { 52 | enableTargets() 53 | } 54 | 55 | return block(TargetsContext(codeGen.context)) 56 | } 57 | -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/codegen/language/jvm/JavaLanguage.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.codegen.language.jvm 20 | 21 | import io.github.deltacv.papervision.codegen.language.LanguageBase 22 | 23 | object JavaLanguage : LanguageBase() -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/engine/bridge/NoOpPaperVisionEngineBridge.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.engine.bridge 20 | 21 | import io.github.deltacv.papervision.engine.client.PaperVisionEngineClient 22 | import io.github.deltacv.papervision.engine.message.PaperVisionEngineMessage 23 | import io.github.deltacv.papervision.engine.message.PaperVisionEngineMessageResponse 24 | import io.github.deltacv.papervision.util.event.PaperVisionEventHandler 25 | import java.util.concurrent.ArrayBlockingQueue 26 | 27 | object NoOpPaperVisionEngineBridge : PaperVisionEngineBridge { 28 | override val isConnected: Boolean 29 | get() = false 30 | 31 | override val onClientProcess = PaperVisionEventHandler("LocalPaperVisionEngineBridge-OnClientProcess") 32 | override val processedBinaryMessagesHashes = ArrayBlockingQueue(1) 33 | 34 | override fun connectClient(client: PaperVisionEngineClient) { 35 | // No-op 36 | } 37 | 38 | override fun terminate(client: PaperVisionEngineClient) { 39 | // No-op 40 | } 41 | 42 | override fun broadcastBytes(bytes: ByteArray) { 43 | // No-op 44 | } 45 | 46 | override fun sendMessage(client: PaperVisionEngineClient, message: PaperVisionEngineMessage) { 47 | // No-op 48 | } 49 | 50 | override fun acceptResponse(response: PaperVisionEngineMessageResponse) { 51 | // No-op 52 | } 53 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/engine/bridge/PaperVisionEngineBridge.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.engine.bridge 20 | 21 | import io.github.deltacv.papervision.engine.client.PaperVisionEngineClient 22 | import io.github.deltacv.papervision.engine.message.PaperVisionEngineMessage 23 | import io.github.deltacv.papervision.engine.message.PaperVisionEngineMessageResponse 24 | import io.github.deltacv.papervision.util.event.PaperVisionEventHandler 25 | import java.util.concurrent.ArrayBlockingQueue 26 | 27 | interface PaperVisionEngineBridge { 28 | val isConnected: Boolean 29 | 30 | val onClientProcess: PaperVisionEventHandler 31 | val processedBinaryMessagesHashes: ArrayBlockingQueue 32 | 33 | fun connectClient(client: PaperVisionEngineClient) 34 | fun terminate(client: PaperVisionEngineClient) 35 | 36 | fun broadcastBytes(bytes: ByteArray) 37 | 38 | fun sendMessage(client: PaperVisionEngineClient, message: PaperVisionEngineMessage) 39 | fun acceptResponse(response: PaperVisionEngineMessageResponse) 40 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/engine/client/ByteMessageReceiver.kt: -------------------------------------------------------------------------------- 1 | package io.github.deltacv.papervision.engine.client 2 | 3 | typealias Handler = (Int, String, ByteArray) -> Unit 4 | 5 | abstract class ByteMessageReceiver { 6 | 7 | private val handlers = mutableListOf() 8 | 9 | fun callHandlers(id: Int, tag: String, bytes: ByteArray) { 10 | handlers.forEach { handler -> 11 | handler(id, tag, bytes) 12 | } 13 | } 14 | 15 | open fun addHandler(tag: String, handler: Handler) { 16 | handlers.add(handler) 17 | } 18 | 19 | open fun removeHandler(handlerInstance: Handler) { 20 | handlers.remove(handlerInstance) 21 | } 22 | 23 | open fun stop() { } 24 | 25 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/exception/GenException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.exception 20 | 21 | import io.github.deltacv.papervision.attribute.Attribute 22 | import io.github.deltacv.papervision.node.Node 23 | 24 | class NodeGenException(val node: Node<*>, override val message: String) : RuntimeException(message) 25 | 26 | class AttributeGenException(val attribute: Attribute, override val message: String) : RuntimeException(message) -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/gui/ToastWindow.kt: -------------------------------------------------------------------------------- 1 | package io.github.deltacv.papervision.gui 2 | 3 | import imgui.ImGui 4 | import imgui.ImVec2 5 | import imgui.flag.ImGuiWindowFlags 6 | import io.github.deltacv.mai18n.tr 7 | import io.github.deltacv.papervision.gui.util.Window 8 | import io.github.deltacv.papervision.util.ElapsedTime 9 | import io.github.deltacv.papervision.util.flags 10 | 11 | class ToastWindow( 12 | val message: String, 13 | val durationSeconds: Double = 5.0, 14 | val font: Font? = null 15 | ) : Window() { 16 | override var title = "toast" 17 | 18 | override val windowFlags = flags( 19 | ImGuiWindowFlags.NoTitleBar, 20 | ImGuiWindowFlags.NoResize, 21 | ImGuiWindowFlags.NoMove, 22 | ImGuiWindowFlags.NoScrollbar, 23 | ) 24 | 25 | val timer = ElapsedTime() 26 | 27 | override fun onEnable() { 28 | super.onEnable() 29 | timer.reset() 30 | 31 | for(window in idElementContainer.inmutable) { 32 | if(window is ToastWindow && window != this) { 33 | window.delete() 34 | } 35 | } 36 | 37 | firstDraw = true 38 | } 39 | 40 | private var firstDraw = true 41 | 42 | override fun drawContents() { 43 | if(font != null) { 44 | ImGui.pushFont(font.imfont) 45 | } 46 | 47 | val currentSize = if(firstDraw) { 48 | ImVec2( 49 | ImGui.calcTextSize(tr(message)).x + 10, 50 | ImGui.calcTextSize(tr(message)).y + 10 51 | ) 52 | } else size 53 | 54 | position = ImVec2( 55 | ImGui.getMainViewport().centerX - currentSize.x / 2, 56 | ImGui.getMainViewport().sizeY - currentSize.y - 20 57 | ) 58 | 59 | ImGui.text(tr(message)) 60 | 61 | if(font != null) { 62 | ImGui.popFont() 63 | } 64 | 65 | if(timer.seconds > durationSeconds) { 66 | delete() 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/gui/eocvsim/ImageDisplay.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.gui.eocvsim 20 | 21 | import imgui.ImGui 22 | import io.github.deltacv.papervision.id.IdElement 23 | import io.github.deltacv.papervision.id.IdElementContainerStack 24 | import io.github.deltacv.papervision.engine.previz.PipelineStream 25 | 26 | class ImageDisplay( 27 | var pipelineStream: PipelineStream 28 | ) : IdElement { 29 | override val id by IdElementContainerStack.threadStack.peekNonNull().nextId(this) 30 | 31 | fun drawStream() { 32 | pipelineStream.textureOf(id)?.draw() 33 | 34 | if (ImGui.isItemHovered() && ImGui.isMouseDoubleClicked(0)) { 35 | if(pipelineStream.status == PipelineStream.Status.MINIMIZED) { 36 | pipelineStream.maximize() 37 | } else { 38 | pipelineStream.minimize() 39 | } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/gui/eocvsim/ImageDisplayNode.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.gui.eocvsim 20 | 21 | import imgui.ImGui 22 | import imgui.extension.imnodes.ImNodes 23 | import imgui.extension.imnodes.flag.ImNodesCol 24 | import io.github.deltacv.papervision.attribute.Attribute 25 | import io.github.deltacv.papervision.attribute.EmptyInputAttribute 26 | import io.github.deltacv.papervision.attribute.vision.MatAttribute 27 | import io.github.deltacv.papervision.codegen.CodeGen 28 | import io.github.deltacv.papervision.codegen.NoSession 29 | import io.github.deltacv.papervision.id.IdElementContainerStack 30 | import io.github.deltacv.papervision.node.Category 31 | import io.github.deltacv.papervision.node.DrawNode 32 | import io.github.deltacv.papervision.node.PaperNode 33 | import io.github.deltacv.papervision.serialization.data.SerializeIgnore 34 | 35 | @PaperNode( 36 | name = "nod_previewdisplay", 37 | category = Category.HIGH_LEVEL_CV, 38 | showInList = false 39 | ) 40 | @SerializeIgnore 41 | class ImageDisplayNode( 42 | val imageDisplay: ImageDisplay 43 | ) : DrawNode(joinActionStack = false) { 44 | 45 | val input = EmptyInputAttribute(this) 46 | 47 | override fun drawNode() { 48 | ImNodes.pushColorStyle(ImNodesCol.Pin, MatAttribute.styleColor) 49 | ImNodes.pushColorStyle(ImNodesCol.PinHovered, MatAttribute.styleHoveredColor) 50 | 51 | ImNodes.beginInputAttribute(input.id) 52 | ImNodes.endInputAttribute() 53 | 54 | ImNodes.popColorStyle() 55 | ImNodes.popColorStyle() 56 | 57 | ImGui.sameLine() 58 | 59 | imageDisplay.drawStream() 60 | } 61 | 62 | override fun delete() { 63 | super.delete() 64 | input.delete() 65 | } 66 | 67 | override fun genCode(current: CodeGen.Current) = NoSession 68 | 69 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/gui/eocvsim/ImageDisplayWindow.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.gui.eocvsim 20 | 21 | import imgui.ImGui 22 | import imgui.flag.ImGuiWindowFlags 23 | import io.github.deltacv.mai18n.tr 24 | import io.github.deltacv.papervision.engine.previz.PipelineStream 25 | import io.github.deltacv.papervision.gui.util.Window 26 | import io.github.deltacv.papervision.util.flags 27 | 28 | class ImageDisplayWindow( 29 | val imageDisplay: ImageDisplay 30 | ) : Window() { 31 | override var title = "Preview" 32 | 33 | override val windowFlags = flags( 34 | ImGuiWindowFlags.AlwaysAutoResize, 35 | ImGuiWindowFlags.NoMove, 36 | ImGuiWindowFlags.NoCollapse 37 | ) 38 | 39 | override fun drawContents() { 40 | imageDisplay.drawStream() 41 | 42 | val pipelineStream = imageDisplay.pipelineStream 43 | 44 | val buttonText = if(pipelineStream.status == PipelineStream.Status.MINIMIZED) { 45 | "Maximize" 46 | } else { 47 | "Minimize" 48 | } 49 | 50 | if (ImGui.button(buttonText)) { 51 | if(pipelineStream.status == PipelineStream.Status.MINIMIZED) { 52 | pipelineStream.maximize() 53 | } else { 54 | pipelineStream.minimize() 55 | } 56 | } 57 | 58 | ImGui.sameLine() 59 | 60 | val statusText = if(pipelineStream.isAtOfflineTexture(imageDisplay.id)) 61 | "mis_loading" 62 | else "mis_runningok" 63 | 64 | ImGui.text(tr(statusText)) 65 | } 66 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/gui/style/ImNodesStyle.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.gui.style 20 | 21 | import imgui.extension.imnodes.ImNodes 22 | import imgui.extension.imnodes.flag.ImNodesCol 23 | 24 | interface ImNodesStyle : ImNodesStyleTemplate { 25 | override fun apply() { 26 | ImNodes.pushColorStyle(ImNodesCol.NodeBackground, nodeBackground) 27 | ImNodes.pushColorStyle(ImNodesCol.NodeBackgroundHovered, nodeBackgroundHovered) 28 | ImNodes.pushColorStyle(ImNodesCol.NodeBackgroundSelected, nodeBackgroundSelected) 29 | ImNodes.pushColorStyle(ImNodesCol.NodeOutline, nodeOutline) 30 | 31 | ImNodes.pushColorStyle(ImNodesCol.TitleBar, titleBar) 32 | ImNodes.pushColorStyle(ImNodesCol.TitleBarHovered, titleBarHovered) 33 | ImNodes.pushColorStyle(ImNodesCol.TitleBarSelected, titleBarSelected) 34 | 35 | ImNodes.pushColorStyle(ImNodesCol.Link, link) 36 | ImNodes.pushColorStyle(ImNodesCol.LinkHovered, linkHovered) 37 | ImNodes.pushColorStyle(ImNodesCol.LinkSelected, linkSelected) 38 | 39 | ImNodes.pushColorStyle(ImNodesCol.Pin, pin) 40 | ImNodes.pushColorStyle(ImNodesCol.PinHovered, pinHovered) 41 | 42 | ImNodes.pushColorStyle(ImNodesCol.BoxSelector, boxSelector) 43 | ImNodes.pushColorStyle(ImNodesCol.BoxSelectorOutline, boxSelectorOutline) 44 | } 45 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/gui/style/imnodes/ImNodesDarkStyle.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.gui.style.imnodes 20 | 21 | import io.github.deltacv.papervision.gui.style.ImNodesStyle 22 | import io.github.deltacv.papervision.gui.style.rgbaColor 23 | 24 | object ImNodesDarkStyle : ImNodesStyle { 25 | override val nodeBackground = rgbaColor(50, 50, 50, 255) 26 | override val nodeBackgroundHovered = rgbaColor(75, 75, 75, 255) 27 | override val nodeBackgroundSelected = rgbaColor(75, 75, 75, 255) 28 | override val nodeOutline = rgbaColor(100, 100, 100, 255) 29 | 30 | override val titleBar = rgbaColor(41, 74, 122, 255) 31 | override val titleBarHovered = rgbaColor(66, 150, 250, 255) 32 | override val titleBarSelected = rgbaColor(66, 150, 250, 255) 33 | 34 | override val link = rgbaColor(61, 133, 224, 200) 35 | override val linkHovered = rgbaColor(66, 150, 250, 255) 36 | override val linkSelected = rgbaColor(66, 150, 250, 255) 37 | 38 | override val pin = rgbaColor(53, 150, 250, 180) 39 | override val pinHovered = rgbaColor(53, 150, 250, 255) 40 | 41 | override val boxSelector = rgbaColor(61, 133, 224, 30) 42 | override val boxSelectorOutline = rgbaColor(61, 133, 224, 150) 43 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/gui/util/ExtraWidgets.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.gui.util 20 | 21 | import imgui.ImGui 22 | import imgui.flag.ImGuiMouseButton 23 | import imgui.type.ImInt 24 | 25 | object ExtraWidgets { 26 | 27 | fun rangeSliders(min: Int, max: Int, 28 | minValue: ImInt, maxValue: ImInt, 29 | minId: Int, maxId: Int, 30 | width: Float = 110f) { 31 | ImGui.pushItemWidth(width) 32 | ImGui.sliderInt("###$minId", minValue.data, min, max) 33 | 34 | ImGui.sameLine() 35 | 36 | ImGui.sliderInt("###$maxId", maxValue.data, min, max) 37 | ImGui.popItemWidth() 38 | 39 | val mn = minValue.get() 40 | val mx = maxValue.get() 41 | 42 | if(mn > mx) { 43 | minValue.set(mx) 44 | } 45 | if(mx < mn) { 46 | maxValue.set(mn) 47 | } 48 | } 49 | 50 | private val valuesStringCache = mutableMapOf, Array>() 51 | 52 | fun > enumCombo(values: Array, currentItem: ImInt): T { 53 | val clazz = values[0]::class.java 54 | 55 | val valuesStrings = if (valuesStringCache.containsKey(clazz)) { 56 | valuesStringCache[clazz]!! 57 | } else { 58 | val v = values.map { 59 | it.name 60 | }.toTypedArray() 61 | valuesStringCache[clazz] = v 62 | 63 | v 64 | } 65 | 66 | ImGui.combo("", currentItem, valuesStrings) 67 | 68 | return values[currentItem.get()] 69 | } 70 | 71 | fun toggleButton(label: String, currentState: Boolean): Boolean { 72 | ImGui.button(label) 73 | 74 | return if(ImGui.isItemClicked(ImGuiMouseButton.Left)) { 75 | !currentState 76 | } else currentState 77 | } 78 | 79 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/gui/util/SysUtil.kt: -------------------------------------------------------------------------------- 1 | package io.github.deltacv.papervision.gui.util 2 | 3 | import java.lang.management.ManagementFactory 4 | 5 | enum class OperatingSystem { 6 | WINDOWS, 7 | LINUX, 8 | MACOS, 9 | UNKNOWN 10 | } 11 | 12 | val OS: OperatingSystem get() { 13 | val osName = System.getProperty("os.name").lowercase() 14 | 15 | return when { 16 | osName.contains("win") -> OperatingSystem.WINDOWS 17 | osName.contains("nux") -> OperatingSystem.LINUX 18 | osName.contains("mac") || osName.contains("darwin") -> OperatingSystem.MACOS 19 | else -> OperatingSystem.UNKNOWN 20 | } 21 | } 22 | 23 | enum class SystemArchitecture { 24 | X86, 25 | X86_64, 26 | ARMv7, 27 | ARMv8, 28 | UNKNOWN 29 | } 30 | 31 | val ARCH: SystemArchitecture get() { 32 | val arch = System.getProperty("os.arch") 33 | 34 | return when { 35 | arch.contains("amd64") || arch.contains("x86_64") -> SystemArchitecture.X86_64 36 | arch.contains("x86") || arch.contains("i38") -> SystemArchitecture.X86 37 | arch.contains("arm64") || arch.contains("aarch") -> SystemArchitecture.ARMv8 38 | arch.contains("arm") -> SystemArchitecture.ARMv7 39 | else -> SystemArchitecture.UNKNOWN 40 | } 41 | } 42 | 43 | fun getMemoryUsageMB(): Long { 44 | val mb = 1024 * 1024 45 | return (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / mb 46 | } 47 | 48 | fun getProcessCPULoad(): Double { 49 | val osBean = ManagementFactory.getOperatingSystemMXBean() as com.sun.management.OperatingSystemMXBean 50 | return osBean.processCpuLoad 51 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/id/IdElement.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.id 20 | 21 | object NoneIdElement : IdElement { 22 | override val id = 0xDAFC 23 | } 24 | 25 | interface IdElement { 26 | val id: Int 27 | } 28 | 29 | interface DrawableIdElement : IdElement { 30 | 31 | fun draw() 32 | 33 | fun delete() 34 | 35 | fun restore() 36 | 37 | fun onEnable() { } 38 | 39 | fun enable() 40 | 41 | fun pollChange(): Boolean 42 | 43 | } 44 | 45 | @Suppress("UNCHECKED_CAST") 46 | abstract class DrawableIdElementBase> : DrawableIdElement { 47 | 48 | abstract val idElementContainer: IdElementContainer 49 | 50 | var hasEnabled = false 51 | private set 52 | 53 | val isEnabled get() = idElementContainer.has(id, this as T) 54 | 55 | open val requestedId: Int? = null 56 | 57 | private var internalId: Int? = null 58 | 59 | override val id: Int get() { 60 | if(internalId == null) { 61 | enable() 62 | } 63 | 64 | return internalId!! 65 | } 66 | 67 | override fun enable() { 68 | if(internalId == null || !idElementContainer.has(id, this as T)) { 69 | internalId = provideId() 70 | onEnable() 71 | hasEnabled = true 72 | } 73 | } 74 | 75 | protected open fun provideId() = 76 | if(requestedId == null) { 77 | idElementContainer.nextId(this as T).value 78 | } else idElementContainer.requestId(this as T, requestedId!!).value 79 | 80 | override fun delete() { 81 | idElementContainer.removeId(id) 82 | } 83 | 84 | override fun restore() { 85 | idElementContainer[id] = this as T 86 | } 87 | 88 | override fun pollChange() = false 89 | 90 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/io/Util.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.io 20 | 21 | import java.io.File 22 | import java.io.InputStream 23 | import java.nio.file.Files 24 | import java.nio.file.StandardCopyOption 25 | 26 | import java.awt.image.BufferedImage 27 | 28 | import java.awt.Image 29 | import java.awt.image.DataBufferByte 30 | import javax.imageio.ImageIO 31 | 32 | fun copyToFile(inp: InputStream, file: File, replaceIfExisting: Boolean = true) { 33 | if(file.exists() && !replaceIfExisting) return 34 | 35 | Files.copy(inp, file.toPath(), StandardCopyOption.REPLACE_EXISTING) 36 | } 37 | 38 | fun copyToTempFile(inp: InputStream, name: String, replaceIfExisting: Boolean = true): File { 39 | val tmpDir = System.getProperty("java.io.tmpdir") 40 | val tempFile = File(tmpDir + File.separator + name) 41 | 42 | copyToFile(inp, tempFile, replaceIfExisting) 43 | 44 | return tempFile 45 | } 46 | 47 | val String.fileExtension: String? get() { 48 | return if(contains(".")) { 49 | substring(lastIndexOf(".") + 1) 50 | } else { 51 | null 52 | } 53 | } 54 | 55 | fun resourceToString(resourcePath: String): String { 56 | val stream = KeyManager::class.java.getResourceAsStream(resourcePath)!! 57 | return stream.bufferedReader().use { it.readText() } 58 | } 59 | 60 | fun bufferedImageFromResource(resourcePath: String): BufferedImage = ImageIO.read( 61 | KeyManager::class.java.getResourceAsStream(resourcePath)!! 62 | ) 63 | 64 | fun BufferedImage.bytes(): ByteArray = (raster.dataBuffer as DataBufferByte).data 65 | 66 | fun BufferedImage.scaleToFit(newWidth: Int, newHeight: Int): BufferedImage { 67 | val scalex = newWidth.toDouble() / width 68 | val scaley = newHeight.toDouble() / height 69 | val scale = scalex.coerceAtMost(scaley) 70 | 71 | val w = (width * scale).toInt() 72 | val h = (height * scale).toInt() 73 | 74 | val tmp = getScaledInstance(w, h, Image.SCALE_SMOOTH) 75 | 76 | val resized = BufferedImage(w, h, type) 77 | val g2d = resized.createGraphics() 78 | 79 | g2d.drawImage(tmp, 0, 0, null) 80 | g2d.dispose() 81 | 82 | tmp.flush() 83 | 84 | return resized 85 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/io/turbojpeg/TJLoader.kt: -------------------------------------------------------------------------------- 1 | package io.github.deltacv.papervision.io.turbojpeg 2 | 3 | import java.io.File 4 | import java.io.IOException 5 | import java.nio.file.Files 6 | import java.nio.file.StandardCopyOption 7 | import java.util.* 8 | 9 | object TJLoader { 10 | fun load() { 11 | // get os and arch 12 | val os = System.getProperty("os.name").lowercase(Locale.getDefault()) 13 | val arch = System.getProperty("os.arch").lowercase(Locale.getDefault()) 14 | 15 | var libPath: String? = null 16 | 17 | if (os.contains("win")) { 18 | if (arch.contains("64")) { 19 | libPath = "/META-INF/lib/windows_64/turbojpeg.dll" 20 | } else { 21 | libPath = "/META-INF/lib/windows_32/turbojpeg.dll" 22 | } 23 | } else if (os.contains("linux")) { 24 | if (arch.contains("64")) { 25 | libPath = "/META-INF/lib/linux_64/libturbojpeg.so" 26 | } else { 27 | libPath = "/META-INF/lib/linux_32/libturbojpeg.so" 28 | } 29 | } else if (os.contains("mac") || os.contains("darwin")) { 30 | if (arch.contains("64")) { 31 | libPath = "/META-INF/lib/osx_64/libturbojpeg.dylib" 32 | } else if (arch.contains("ppc")) { 33 | libPath = "/META-INF/lib/osx_ppc/libturbojpeg.dylib" 34 | } else { 35 | libPath = "/META-INF/lib/osx_32/libturbojpeg.dylib" 36 | } 37 | } 38 | 39 | if (libPath == null) { 40 | throw RuntimeException("Unsupported OS/Arch: " + os + " " + arch) 41 | } 42 | 43 | loadFromResource(libPath) 44 | } 45 | 46 | private fun loadFromResource(resource: String) { 47 | try { 48 | TJLoader::class.java.getResourceAsStream(resource).use { res -> 49 | if (res == null) { 50 | throw RuntimeException("Native lib not found: " + resource) 51 | } 52 | // Crear archivo temporal 53 | val tempFile = File.createTempFile("libturbojpeg", getFileExtension(resource)) 54 | tempFile.deleteOnExit() // Eliminar después de ejecución 55 | 56 | // Copiar contenido 57 | Files.copy(res, tempFile.toPath(), StandardCopyOption.REPLACE_EXISTING) 58 | 59 | // Cargar la biblioteca 60 | System.load(tempFile.getAbsolutePath()) 61 | } 62 | } catch (e: IOException) { 63 | throw RuntimeException(e) 64 | } 65 | } 66 | 67 | 68 | private fun getFileExtension(path: String): String { 69 | if (path.endsWith(".dll")) return ".dll" 70 | if (path.endsWith(".so")) return ".so" 71 | if (path.endsWith(".dylib")) return ".dylib" 72 | return "" 73 | } 74 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/node/FlagsNode.kt: -------------------------------------------------------------------------------- 1 | package io.github.deltacv.papervision.node 2 | 3 | import io.github.deltacv.papervision.serialization.data.SerializeData 4 | 5 | @PaperNode( 6 | name = "Flags", 7 | description = "A node that holds flags", 8 | category = Category.MISC, 9 | showInList = false 10 | ) 11 | class FlagsNode : InvisibleNode() { 12 | 13 | override val requestedId = 171 14 | 15 | @SerializeData 16 | val flags = mutableMapOf() 17 | 18 | @SerializeData 19 | val numFlags = mutableMapOf() 20 | 21 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/node/InvisibleNode.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.node 20 | 21 | import imgui.extension.imnodes.ImNodes 22 | import imgui.extension.imnodes.flag.ImNodesCol 23 | import io.github.deltacv.papervision.codegen.CodeGen 24 | import io.github.deltacv.papervision.codegen.NoSession 25 | import io.github.deltacv.papervision.gui.style.rgbaColor 26 | import io.github.deltacv.papervision.serialization.data.SerializeIgnore 27 | 28 | @SerializeIgnore 29 | open class InvisibleNode : Node(allowDelete = false) { 30 | 31 | private val invisibleColor = rgbaColor(0, 0, 0, 0) 32 | 33 | override fun draw() { 34 | ImNodes.pushColorStyle(ImNodesCol.NodeOutline, invisibleColor) 35 | ImNodes.pushColorStyle(ImNodesCol.TitleBar, invisibleColor) 36 | ImNodes.pushColorStyle(ImNodesCol.TitleBarHovered, invisibleColor) 37 | ImNodes.pushColorStyle(ImNodesCol.TitleBarSelected, invisibleColor) 38 | ImNodes.pushColorStyle(ImNodesCol.NodeBackground, invisibleColor) 39 | ImNodes.pushColorStyle(ImNodesCol.NodeBackgroundHovered, invisibleColor) 40 | ImNodes.pushColorStyle(ImNodesCol.NodeBackgroundSelected, invisibleColor) 41 | 42 | ImNodes.beginNode(id) 43 | ImNodes.endNode() 44 | 45 | repeat(7) { 46 | ImNodes.popColorStyle() 47 | } 48 | } 49 | 50 | override fun genCode(current: CodeGen.Current) = NoSession 51 | 52 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/node/NodeRegistry.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.node 20 | 21 | import io.github.deltacv.papervision.gui.CategorizedNodes 22 | import io.github.deltacv.papervision.util.hasSuperclass 23 | 24 | @Suppress("UNCHECKED_CAST") 25 | object NodeRegistry { 26 | 27 | val nodes: CategorizedNodes = mutableMapOf() 28 | 29 | init { 30 | // Register nodes from metadata generated by KSP - NodeAnnotationProcessor 31 | fromMetadataClasslist(PaperNodeClassesMetadata.classList) 32 | } 33 | 34 | fun fromMetadataClasslist(classList: List) { 35 | for (className in classList) { 36 | val clazz = NodeRegistry::class.java.classLoader.loadClass(className) 37 | val regAnnotation = clazz.getDeclaredAnnotation(PaperNode::class.java) 38 | 39 | if (clazz.hasSuperclass(Node::class.java)) { 40 | val nodeClazz = clazz as Class> 41 | registerNode(nodeClazz, regAnnotation.category) 42 | } 43 | } 44 | } 45 | 46 | fun registerNode(nodeClass: Class>, category: Category) { 47 | val list = nodes[category] 48 | 49 | val mutableNodes = nodes as MutableMap 50 | 51 | if (list == null) { 52 | mutableNodes[category] = mutableListOf(nodeClass) 53 | } else { 54 | list.add(nodeClass) 55 | } 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/node/code/CodeSnippetNode.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.node.code 20 | 21 | import io.github.deltacv.papervision.codegen.CodeGen 22 | import io.github.deltacv.papervision.codegen.CodeGenSession 23 | import io.github.deltacv.papervision.node.Category 24 | import io.github.deltacv.papervision.node.DrawNode 25 | import io.github.deltacv.papervision.node.PaperNode 26 | 27 | /* @PaperNode( 28 | name = "nod_codesnippet", 29 | category = Category.CODE, 30 | description = "A user-written snippet of Java code that will be inlined in the final pipeline, with configurable parameters and outputs." 31 | ) */ 32 | class CodeSnippetNode : DrawNode() { 33 | 34 | override fun drawNode() { 35 | 36 | } 37 | 38 | override fun genCode(current: CodeGen.Current): Session { 39 | TODO("Not yet implemented") 40 | } 41 | 42 | class Session : CodeGenSession { 43 | 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/node/math/SumIntegerNode.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.node.math 20 | 21 | import io.github.deltacv.papervision.attribute.Attribute 22 | import io.github.deltacv.papervision.node.DrawNode 23 | import io.github.deltacv.papervision.attribute.math.IntAttribute 24 | import io.github.deltacv.papervision.attribute.misc.ListAttribute 25 | import io.github.deltacv.papervision.codegen.CodeGen 26 | import io.github.deltacv.papervision.codegen.CodeGenSession 27 | import io.github.deltacv.papervision.codegen.GenValue 28 | import io.github.deltacv.papervision.node.PaperNode 29 | import io.github.deltacv.papervision.node.Category 30 | 31 | /* 32 | @PaperNode( 33 | name = "nod_sumintegers", 34 | category = Category.MATH, 35 | description = "Sums a list of integers and outputs the result" 36 | )*/ 37 | class SumIntegerNode : DrawNode() { 38 | 39 | val numbers = ListAttribute(INPUT, IntAttribute, "$[att_numbers]") 40 | val result = IntAttribute(OUTPUT, "$[att_result]") 41 | 42 | override fun onEnable() { 43 | + numbers 44 | + result 45 | } 46 | 47 | override fun genCode(current: CodeGen.Current) = current { 48 | val session = Session() 49 | 50 | session 51 | } 52 | 53 | override fun getOutputValueOf(current: CodeGen.Current, attrib: Attribute): GenValue { 54 | genCodeIfNecessary(current) 55 | 56 | if(attrib == result) { 57 | return lastGenSession!!.result 58 | } 59 | 60 | noValue(attrib) 61 | } 62 | 63 | class Session : CodeGenSession { 64 | lateinit var result: GenValue.Int 65 | } 66 | 67 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/node/vision/ColorSpace.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.node.vision 20 | 21 | enum class ColorSpace(val channels: Int, val channelNames: Array) { 22 | RGBA(4, arrayOf("R", "G", "B", "A")), 23 | RGB(3, arrayOf("R", "G", "B")), 24 | BGR(3, arrayOf("B", "G", "R")), 25 | HSV(3, arrayOf("H", "S", "V")), 26 | YCrCb(3, arrayOf("Y", "Cr", "Cb")), 27 | LAB(3, arrayOf("L", "a", "b")), 28 | GRAY(1, arrayOf("Gray")) 29 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/platform/PlatformConfig.kt: -------------------------------------------------------------------------------- 1 | package io.github.deltacv.papervision.platform 2 | 3 | import com.google.gson.GsonBuilder 4 | import io.github.deltacv.papervision.util.loggerForThis 5 | import java.io.File 6 | 7 | class PaperVisionConfig { 8 | @JvmField 9 | var lang = "en" 10 | 11 | @JvmField 12 | var shouldAskForLang = true 13 | } 14 | 15 | abstract class PlatformConfig { 16 | var fields = PaperVisionConfig() 17 | 18 | abstract fun load() 19 | abstract fun save() 20 | } 21 | 22 | val defaultConfigPath = System.getProperty("user.home") + File.separator + ".papervision" + File.separator + "config.json" 23 | 24 | class DefaultFilePlatformConfig : FilePlatformConfig(defaultConfigPath) { 25 | init { 26 | File(defaultConfigPath).parentFile.mkdirs() 27 | } 28 | } 29 | 30 | open class FilePlatformConfig( 31 | val path: String 32 | ) : PlatformConfig() { 33 | 34 | val gson = GsonBuilder().setPrettyPrinting().create() 35 | val file = File(path) 36 | 37 | val logger by loggerForThis() 38 | 39 | init { 40 | Runtime.getRuntime().addShutdownHook(Thread { 41 | save() 42 | }) 43 | } 44 | 45 | override fun load() { 46 | if(!file.exists()) { 47 | save() 48 | return 49 | } 50 | 51 | logger.info("Loading config from $path") 52 | fields = gson.fromJson(file.readText(), PaperVisionConfig::class.java) 53 | } 54 | 55 | override fun save() { 56 | logger.info("Saving config to $path") 57 | file.writeText(gson.toJson(fields)) 58 | } 59 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/platform/PlatformKeys.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.platform 20 | 21 | interface PlatformKeys { 22 | val ArrowUp: Int 23 | val ArrowDown: Int 24 | val ArrowLeft: Int 25 | val ArrowRight: Int 26 | 27 | val Escape: Int 28 | val Spacebar: Int 29 | val Delete: Int 30 | 31 | val LeftShift: Int 32 | val RightShift: Int 33 | 34 | val LeftControl: Int 35 | val RightControl: Int 36 | 37 | val LeftSuper: Int 38 | val RightSuper: Int 39 | 40 | val NativeLeftSuper: Int 41 | val NativeRightSuper: Int 42 | 43 | val Z: Int 44 | val Y: Int 45 | val X: Int 46 | val C: Int 47 | val V: Int 48 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/platform/PlatformSetup.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.platform 20 | 21 | import io.github.deltacv.papervision.engine.bridge.PaperVisionEngineBridge 22 | import io.github.deltacv.papervision.engine.client.ByteMessageReceiver 23 | 24 | class PlatformSetup(val name: String) { 25 | var window: PlatformWindow? = null 26 | var textureFactory: PlatformTextureFactory? = null 27 | 28 | var keys: PlatformKeys? = null 29 | 30 | var showWelcomeWindow = false 31 | 32 | var engineBridge: PaperVisionEngineBridge? = null 33 | var previzByteMessageReceiverProvider: (() -> ByteMessageReceiver)? = null 34 | 35 | var config: PlatformConfig = DefaultFilePlatformConfig() 36 | } 37 | 38 | data class PlatformSetupCallback(val name: String, val block: PlatformSetup.() -> Unit) { 39 | fun setup(): PlatformSetup { 40 | val setup = PlatformSetup(name) 41 | setup.block() 42 | return setup 43 | } 44 | } 45 | 46 | fun platformSetup(name: String, block: PlatformSetup.() -> Unit) = PlatformSetupCallback(name, block) -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/platform/PlatformTexture.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.platform 20 | 21 | import imgui.ImGui 22 | import io.github.deltacv.papervision.id.DrawableIdElementBase 23 | import io.github.deltacv.papervision.id.IdElementContainer 24 | import io.github.deltacv.papervision.id.IdElementContainerStack 25 | import io.github.deltacv.papervision.io.TextureProcessorQueue 26 | import java.nio.ByteBuffer 27 | import java.util.concurrent.Executor 28 | import java.util.concurrent.Executors 29 | 30 | abstract class PlatformTexture : DrawableIdElementBase() { 31 | 32 | override val idElementContainer = IdElementContainerStack.threadStack.peekNonNull() 33 | 34 | val textureProcessorQueue = IdElementContainerStack.threadStack.peekSingleNonNull() 35 | 36 | abstract val width: Int 37 | abstract val height: Int 38 | 39 | abstract val textureId: Long 40 | 41 | abstract fun set(bytes: ByteArray, colorSpace: ColorSpace = ColorSpace.RGB) 42 | abstract fun set(bytes: ByteBuffer, colorSpace: ColorSpace = ColorSpace.RGB) 43 | 44 | abstract fun setJpeg(bytes: ByteArray) 45 | abstract fun setJpeg(bytes: ByteBuffer) 46 | 47 | override fun draw() { 48 | ImGui.image(textureId, width.toFloat(), height.toFloat()) 49 | } 50 | 51 | override fun restore() { 52 | throw UnsupportedOperationException("Cannot restore texture after it has been deleted") 53 | } 54 | 55 | } 56 | 57 | interface PlatformTextureFactory { 58 | fun create(width: Int, height: Int, bytes: ByteArray, colorSpace: ColorSpace = ColorSpace.RGB): PlatformTexture 59 | 60 | fun create(width: Int, height: Int, bytes: ByteBuffer, colorSpace: ColorSpace = ColorSpace.RGB): PlatformTexture 61 | 62 | fun create(resource: String): PlatformTexture 63 | 64 | fun createFromJpegBytes(bytes: ByteBuffer): PlatformTexture 65 | } 66 | 67 | enum class ColorSpace(val channels: Int) { 68 | RGB(3), RGBA(4), BGR(3), BGRA(4) 69 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/platform/PlatformWindow.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.platform 20 | 21 | import imgui.ImVec2 22 | 23 | data class PlatformFileFilter( 24 | val name: String, 25 | val extensions: List 26 | ) 27 | 28 | enum class PlatformFileChooserResult { 29 | CANCELLED, 30 | OK 31 | } 32 | 33 | interface PlatformWindow { 34 | 35 | var title: String 36 | var icon: String 37 | 38 | val size: ImVec2 39 | 40 | var visible: Boolean 41 | 42 | var maximized: Boolean 43 | 44 | var focus: Boolean 45 | 46 | fun requestFocus() 47 | 48 | fun saveFileDialog(content: ByteArray, defaultName: String = "", vararg platformFileFilter: PlatformFileFilter): PlatformFileChooserResult 49 | 50 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/platform/animation/PlatformTextureAnimation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.platform.animation 20 | 21 | import io.github.deltacv.papervision.id.IdElementContainer 22 | import io.github.deltacv.papervision.platform.ColorSpace 23 | import io.github.deltacv.papervision.platform.PlatformTexture 24 | import java.lang.UnsupportedOperationException 25 | import java.nio.ByteBuffer 26 | 27 | abstract class PlatformTextureAnimation : PlatformTexture() { 28 | 29 | abstract var frame: Int 30 | 31 | abstract var isActive: Boolean 32 | 33 | override val id by animations.nextId() 34 | 35 | var isPaused: Boolean 36 | get() = !isActive 37 | set(value) { 38 | isActive = !value 39 | } 40 | 41 | abstract fun next() 42 | 43 | abstract fun update() 44 | 45 | override fun draw() { 46 | update() 47 | super.draw() 48 | } 49 | 50 | override fun set(bytes: ByteArray, colorSpace: ColorSpace) = 51 | throw UnsupportedOperationException("set() is not supported on animations") 52 | 53 | override fun set(bytes: ByteBuffer, colorSpace: ColorSpace) = 54 | throw UnsupportedOperationException("set() is not supported on animations") 55 | 56 | override fun setJpeg(bytes: ByteArray) = 57 | throw UnsupportedOperationException("setJpeg() is not supported on animations") 58 | 59 | override fun setJpeg(bytes: ByteBuffer) = 60 | throw UnsupportedOperationException("setJpeg() is not supported on animations") 61 | 62 | companion object { 63 | val animations = IdElementContainer() 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/platform/animation/TimedTextureAnimation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.platform.animation 20 | 21 | import io.github.deltacv.papervision.platform.PlatformTexture 22 | import io.github.deltacv.papervision.util.ElapsedTime 23 | import java.nio.ByteBuffer 24 | 25 | class TimedTextureAnimation( 26 | val fps: Double, 27 | val textures: Array 28 | ): PlatformTextureAnimation() { 29 | 30 | override var frame = 0 31 | private var halfFrames = 0.0 32 | 33 | override var isActive = true 34 | 35 | private val deltaTimer = ElapsedTime() 36 | 37 | override fun next() { 38 | frame += 1 39 | 40 | if(frame >= textures.size) { 41 | frame = 0 42 | } 43 | } 44 | 45 | override fun update() { 46 | if(isActive) { 47 | halfFrames += fps * deltaTimer.seconds 48 | 49 | frame = halfFrames.toInt() 50 | 51 | if(frame >= textures.size) { 52 | halfFrames -= frame 53 | frame = 0 54 | } 55 | } 56 | 57 | deltaTimer.reset() 58 | } 59 | 60 | override val width: Int get() = textures[frame].width 61 | override val height: Int get() = textures[frame].height 62 | 63 | override val textureId: Long get() = textures[frame].textureId 64 | 65 | override fun delete() { 66 | for(texture in textures) { 67 | texture.delete() 68 | } 69 | isActive = false 70 | } 71 | 72 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/serialization/PaperVisionData.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.serialization 20 | 21 | import imgui.ImVec2 22 | 23 | abstract class AttributeSerializationData { 24 | open var id: Int = 0 25 | } 26 | 27 | class BasicAttribData(id: Int) : AttributeSerializationData() { 28 | init { 29 | this.id = id 30 | } 31 | 32 | constructor(): this(0) 33 | } 34 | 35 | abstract class NodeSerializationData { 36 | open var id: Int = 0 37 | open var nodePos: ImVec2 = ImVec2(0f, 0f) 38 | } 39 | 40 | class BasicNodeData( 41 | id: Int, 42 | nodePos: ImVec2 43 | ) : NodeSerializationData() { 44 | 45 | init { 46 | this.id = id 47 | this.nodePos = nodePos 48 | } 49 | 50 | constructor() : this(0, ImVec2(0f, 0f)) 51 | 52 | } 53 | 54 | data class LinkSerializationData( 55 | var from: Int, 56 | var to: Int 57 | ) { 58 | constructor() : this(0, 0) 59 | } 60 | -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/serialization/data/DataSerializable.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.serialization.data 20 | 21 | interface DataSerializable { 22 | val shouldSerialize: Boolean 23 | get() = true 24 | 25 | fun serialize(): D 26 | fun deserialize(data: D) 27 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/serialization/data/DataSerializer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.serialization.data 20 | 21 | import com.google.gson.* 22 | import com.google.gson.reflect.TypeToken 23 | import io.github.deltacv.papervision.serialization.data.adapter.DataSerializableAdapter 24 | import io.github.deltacv.papervision.serialization.data.adapter.SerializeIgnoreExclusionStrategy 25 | 26 | object DataSerializer { 27 | 28 | val gson = GsonBuilder() 29 | .registerTypeHierarchyAdapter(DataSerializable::class.java, DataSerializableAdapter) 30 | .addSerializationExclusionStrategy(SerializeIgnoreExclusionStrategy) 31 | .create() 32 | 33 | val type = object : TypeToken>>>() {}.type 34 | 35 | fun serialize(serializables: Map>>): String { 36 | return gson.toJson(serializables) 37 | } 38 | 39 | fun serializeToTree(serializables: Map>>): JsonElement { 40 | return gson.toJsonTree(serializables) 41 | } 42 | 43 | fun deserialize(data: String): Map>> { 44 | return gson.fromJson(data, type) 45 | } 46 | 47 | fun deserialize(obj: JsonElement): Map>> { 48 | return gson.fromJson(obj, type) 49 | } 50 | 51 | } 52 | 53 | @Target(AnnotationTarget.FIELD) 54 | annotation class SerializeData 55 | 56 | @Target(AnnotationTarget.CLASS, AnnotationTarget.PROPERTY) 57 | annotation class SerializeIgnore 58 | -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/serialization/data/adapter/DataSerializableAdapter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.serialization.data.adapter 20 | 21 | import com.google.gson.* 22 | import io.github.deltacv.papervision.serialization.data.DataSerializable 23 | import java.lang.reflect.Type 24 | 25 | object DataSerializableAdapter : JsonSerializer>, JsonDeserializer> { 26 | 27 | override fun serialize(src: DataSerializable<*>, typeOfSrc: Type, context: JsonSerializationContext): JsonElement { 28 | return dataSerializableToJsonObject(src, context) 29 | } 30 | 31 | override fun deserialize( 32 | json: JsonElement, 33 | typeOfT: Type, 34 | context: JsonDeserializationContext 35 | ): DataSerializable<*> { 36 | return jsonObjectToDataSerializable(json, context) 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/serialization/data/adapter/Gson.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.serialization.data.adapter 20 | 21 | import com.google.gson.GsonBuilder 22 | import io.github.deltacv.papervision.serialization.data.DataSerializable 23 | 24 | val gson = GsonBuilder() 25 | .registerTypeHierarchyAdapter(DataSerializable::class.java, DataSerializableAdapter) 26 | .addSerializationExclusionStrategy(SerializeIgnoreExclusionStrategy) 27 | .create() -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/serialization/data/adapter/SerializeIgnoreExclusionStrategy.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.serialization.data.adapter 20 | 21 | import com.google.gson.ExclusionStrategy 22 | import com.google.gson.FieldAttributes 23 | import io.github.deltacv.papervision.serialization.data.SerializeIgnore 24 | 25 | object SerializeIgnoreExclusionStrategy : ExclusionStrategy { 26 | override fun shouldSkipField(f: FieldAttributes): Boolean { 27 | // Check if the field or its class has the SerializeIgnore annotation 28 | return f.declaredClass.isAnnotationPresent(SerializeIgnore::class.java) || 29 | f.annotations.any { it.annotationClass.java.isAnnotationPresent(SerializeIgnore::class.java) } 30 | } 31 | 32 | override fun shouldSkipClass(clazz: Class<*>): Boolean { 33 | // Check if the class has the SerializeIgnore annotation 34 | return clazz.isAnnotationPresent(SerializeIgnore::class.java) 35 | } 36 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/util/ElapsedTime.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.util 20 | 21 | class ElapsedTime { 22 | 23 | var startTime = System.currentTimeMillis() 24 | private set 25 | 26 | val millis get() = System.currentTimeMillis() - startTime 27 | val seconds get() = millis.toDouble() / 1000.0 28 | 29 | fun reset() { 30 | startTime = System.currentTimeMillis() 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/util/LogExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.util 20 | 21 | import org.slf4j.LoggerFactory 22 | import kotlin.reflect.KClass 23 | 24 | internal fun Any.loggerFor(clazz: KClass<*>) = lazy { LoggerFactory.getLogger(clazz.java) } 25 | internal fun Any.loggerForThis() = lazy { LoggerFactory.getLogger(this::class.java) } 26 | 27 | internal fun Any.loggerOf(name: String) = lazy { LoggerFactory.getLogger(name) } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/util/Range.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.util 20 | 21 | data class Range2i(val min: Int, val max: Int) { 22 | fun clip(x: Int) = if(x < min) min else if(x > max) max else x 23 | } 24 | data class Range2d(val min: Double, val max: Double) { 25 | fun clip(x: Double) = if(x < min) min else if(x > max) max else x 26 | } 27 | 28 | fun clip(x: Int, min: Int, max: Int): Int = if(x < min) min else if(x > max) max else x -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/util/ReflectExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.util 20 | 21 | import java.lang.reflect.Field 22 | 23 | fun Class<*>.hasSuperclass(superclass: Class<*>): Boolean { 24 | return superclass.isAssignableFrom(this) 25 | } 26 | 27 | /** 28 | * Get a field from a class, including superclasses. 29 | */ 30 | fun Class<*>.getFieldDeep(name: String): Field? { 31 | var field: Field? = null 32 | var clazz: Class<*>? = this 33 | 34 | while (clazz != null && field == null) { 35 | try { 36 | field = clazz.getDeclaredField(name) 37 | } catch (_: Exception) { } 38 | clazz = clazz.superclass 39 | } 40 | 41 | return field 42 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/util/StrUtil.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.util 20 | 21 | fun String.replaceLast(oldValue: String, newValue: String): String { 22 | val lastIndex = lastIndexOf(oldValue) 23 | if (lastIndex == -1) { 24 | return this 25 | } 26 | val prefix = substring(0, lastIndex) 27 | val suffix = substring(lastIndex + oldValue.length) 28 | return "$prefix$newValue$suffix" 29 | } 30 | 31 | fun String.toValidIdentifier( 32 | invalidCharReplacement: String = "_" 33 | ): String { 34 | if(invalidCharReplacement.isNotBlank()) { 35 | for(c in invalidCharReplacement) { 36 | if(!Character.isJavaIdentifierPart(c) || !Character.isJavaIdentifierStart(c)) { 37 | throw IllegalArgumentException("Invalid replacement character '$c'") 38 | } 39 | } 40 | } 41 | 42 | val sb = StringBuilder() 43 | if(!Character.isJavaIdentifierStart(this[0])) { 44 | sb.append(invalidCharReplacement); 45 | } 46 | 47 | for (c in toCharArray()) { 48 | if(!Character.isJavaIdentifierPart(c)) { 49 | sb.append(invalidCharReplacement); 50 | } else { 51 | sb.append(c); 52 | } 53 | } 54 | 55 | return sb.toString() 56 | } -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/util/UtilExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.util 20 | 21 | val Any.hexString get() = Integer.toHexString(hashCode())!! 22 | 23 | fun flags(vararg flags: Int) = if(flags.isNotEmpty()) { 24 | var composedFlags = flags[0] 25 | 26 | for(i in 1 until flags.size) { 27 | composedFlags = composedFlags or flags[i] 28 | } 29 | 30 | composedFlags 31 | } else 0 -------------------------------------------------------------------------------- /PaperVision/src/main/kotlin/io/github/deltacv/papervision/util/event/EventListener.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package io.github.deltacv.papervision.util.event 19 | 20 | fun interface EventListener { 21 | fun run(remover: EventListenerRemover) 22 | } 23 | 24 | class EventListenerRemover( 25 | val handler: PaperVisionEventHandler, 26 | val listener: EventListener, 27 | val isOnceListener: Boolean 28 | ) { 29 | fun removeThis() { 30 | if(isOnceListener) 31 | handler.removeOnceListener(listener) 32 | else 33 | handler.removePersistentListener(listener) 34 | } 35 | 36 | fun removeOn(handler: PaperVisionEventHandler) = handler.doOnce { 37 | removeThis() 38 | } 39 | } -------------------------------------------------------------------------------- /PaperVision/src/main/resources/README.md: -------------------------------------------------------------------------------- 1 | Macro used for inserting a row below the current selection (very convenient when bound to a key, e.g Alt + Insert) 2 | ```basic 3 | Sub CopyRangeInsertAfter() 4 | REM Blablabla 5 | Dim oSheet, oSelection, oSource, oTarget 6 | oSheet = ThisComponent.CurrentController.ActiveSheet 7 | oSelection = ThisComponent.getCurrentSelection() 8 | oSource = oSelection.getRangeAddress() 9 | oSheet.Rows.insertByIndex(oSource.EndRow + 1, 1 + oSource.EndRow - oSource.StartRow) 10 | oTarget = oSheet.getCellByPosition(oSource.StartColumn, oSource.EndRow + 1).CellAddress 11 | oSheet.copyRange(oTarget, oSource) 12 | End Sub 13 | ``` -------------------------------------------------------------------------------- /PaperVision/src/main/resources/fonts/Calcutta-Bold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deltacv/PaperVision/318828d221c24d3bef9c6af962bf77532716b68c/PaperVision/src/main/resources/fonts/Calcutta-Bold.otf -------------------------------------------------------------------------------- /PaperVision/src/main/resources/fonts/Calcutta-Regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deltacv/PaperVision/318828d221c24d3bef9c6af962bf77532716b68c/PaperVision/src/main/resources/fonts/Calcutta-Regular.otf -------------------------------------------------------------------------------- /PaperVision/src/main/resources/fonts/Calcutta-SemiBold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deltacv/PaperVision/318828d221c24d3bef9c6af962bf77532716b68c/PaperVision/src/main/resources/fonts/Calcutta-SemiBold.otf -------------------------------------------------------------------------------- /PaperVision/src/main/resources/fonts/JetBrainsMono-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deltacv/PaperVision/318828d221c24d3bef9c6af962bf77532716b68c/PaperVision/src/main/resources/fonts/JetBrainsMono-Regular.ttf -------------------------------------------------------------------------------- /PaperVision/src/main/resources/fonts/icons/FontAwesome6-Brands-Regular-400.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deltacv/PaperVision/318828d221c24d3bef9c6af962bf77532716b68c/PaperVision/src/main/resources/fonts/icons/FontAwesome6-Brands-Regular-400.otf -------------------------------------------------------------------------------- /PaperVision/src/main/resources/fonts/icons/FontAwesome6-Free-Solid-900.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deltacv/PaperVision/318828d221c24d3bef9c6af962bf77532716b68c/PaperVision/src/main/resources/fonts/icons/FontAwesome6-Free-Solid-900.otf -------------------------------------------------------------------------------- /PaperVision/src/main/resources/ico/ico_ezv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deltacv/PaperVision/318828d221c24d3bef9c6af962bf77532716b68c/PaperVision/src/main/resources/ico/ico_ezv.png -------------------------------------------------------------------------------- /PaperVision/src/main/resources/ico/ico_ezv.txt: -------------------------------------------------------------------------------- 1 | 000000000000000 2 | 00000000000000000000000 3 | 000000000 000000000 4 | 0000000 0000000 5 | 000000 00000 000000 6 | 000000 00000 00000 7 | 00000 0000 00000 00000 00 00 00 00 8 | 00000 0000 0000 00000 000000000 00 000 000 000 9 | 00000 0000 000000 0000 000 00 000000 0000000 000000 0000000000 000 00 000000 00 000000 0000000 10 | 0000 00 000 0000 00000 000 000 0 00 000 000 000 000 0000000 000 000 00 00 00 000 000 000 000 000 11 | 0000 0000 0000 00000 00000000 0000000 00 00 0000000000 000 00 000 00 0000 000 000 000 00 00 12 | 0000 0000 0000 00000 000 000 000 00 00 000 000 000 00 00 000000 000 000 000 00 00 13 | 0000 0000 0000 00000 000 000 0000 00 000 000 0 000 00000 00 0 000 000 000 000 00 00 14 | 00000 00000000000000000 0000 000 00000000 0000000 0000000 000 000 00 0000000 00 000000 00 00 15 | 00000 00000000000000000 00000 00 16 | 00000 00000 00 17 | 000000 00000 18 | 000000 000000 19 | 0000000 0000000 20 | 000000000 000000000 21 | 00000000000000000000000 22 | 000000000000000 -------------------------------------------------------------------------------- /PaperVision/src/main/resources/ico/ico_ezv_logo.txt: -------------------------------------------------------------------------------- 1 | ++++++++ 2 | +++ +++ 3 | ++ + ++ 4 | ++ + ++ ++ 5 | ++ + + ++ 6 | ++ + + ++ 7 | ++ ++++++++ ++ 8 | ++ ++ 9 | +++ +++ 10 | ++++++++ made with <3 by deltacv -------------------------------------------------------------------------------- /PaperVision/src/main/resources/img/PleaseHangOn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deltacv/PaperVision/318828d221c24d3bef9c6af962bf77532716b68c/PaperVision/src/main/resources/img/PleaseHangOn.png -------------------------------------------------------------------------------- /PaperVision/src/main/resources/img/TechnicalDifficulties.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deltacv/PaperVision/318828d221c24d3bef9c6af962bf77532716b68c/PaperVision/src/main/resources/img/TechnicalDifficulties.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PaperVision 2 | 3 | Create your custom OpenCV algorithms using a user-friendly node editor interface inspired by Blender and Unreal Engine blueprints. 4 | 5 | 6 | 7 | # Running 8 | 9 | ## Run with EOCV-Sim (recommended) 10 | 11 | PaperVision comes bundled with EOCV-Sim, starting from v4.0.0. [You can download the latest version of EOCV-Sim from the docs](https://docs.deltacv.org/eocv-sim/downloading-eocv-sim).

12 | Make sure to refer to the "PaperVision" tab in the simulator to create a new project and open it right away ! The integration with EOCV-Sim will allow you to live preview your pipeline as you build it in the node editor. 13 | 14 | ## Run with Gradle 15 | 16 | Use the following commands to run the project with gradle, this will allow you to test the latest features and changes, building from source. 17 |
18 | 19 | ```shell 20 | git clone https://github.com/deltacv/PaperVision.git 21 | cd PaperVision 22 | ./gradlew runEv 23 | ``` 24 | 25 |
This option won't allow for live previewing, since the backend runs in NO-OP mode, but it will let you to test the node editor. 26 | 27 | # Community 28 | 29 | Please [join the discord server](https://discord.gg/A3RMYzf6DA) to keep an active beta testing community, where you'll be able to report issues and suggest new features. Please note that off-topic discourse is not allowed on the server, and in the case of underage FIRST participants, YPP policies will be actively enforced. 30 | -------------------------------------------------------------------------------- /Shared/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.jetbrains.kotlin.jvm' 3 | id 'signing' 4 | id "com.vanniktech.maven.publish" 5 | } 6 | 7 | apply from: '../build.common.gradle' 8 | 9 | dependencies { 10 | compileOnly "io.github.spair:imgui-java-binding:$imgui_version" // platforms should add the "implementation" they need 11 | implementation "com.google.code.gson:gson:$gson_version" 12 | } -------------------------------------------------------------------------------- /Shared/src/main/kotlin/io/github/deltacv/papervision/engine/MessageHandlerPaperVisionEngine.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.engine 20 | 21 | import io.github.deltacv.papervision.engine.client.response.ErrorResponse 22 | import io.github.deltacv.papervision.engine.message.PaperVisionEngineMessage 23 | import io.github.deltacv.papervision.engine.message.PaperVisionEngineMessageResponse 24 | import kotlin.reflect.KClass 25 | 26 | abstract class MessageHandlerPaperVisionEngine : PaperVisionEngine { 27 | 28 | private val messageHandlers = mutableMapOf, MessageHandlerCtx<*>.() -> Unit>() 29 | 30 | override fun acceptMessage(message: PaperVisionEngineMessage) { 31 | try { 32 | // find the handler with the topmost class 33 | val handler = 34 | messageHandlers.entries.find { (type, _) -> type.isAssignableFrom(message.javaClass) }?.value 35 | handler?.invoke(MessageHandlerCtx(this, message)) 36 | } catch(e: Exception) { 37 | sendResponse(ErrorResponse(e.message ?: "An error occurred", e).apply { 38 | id = message.id 39 | }) 40 | } 41 | } 42 | 43 | @Suppress("UNCHECKED_CAST") 44 | fun setMessageHandlerOf(type: KClass, handler: MessageHandlerCtx.() -> Unit) { 45 | messageHandlers[type.java] = handler as MessageHandlerCtx<*>.() -> Unit 46 | } 47 | 48 | inline fun setMessageHandlerOf(noinline handler: MessageHandlerCtx.() -> Unit) { 49 | setMessageHandlerOf(T::class, handler) 50 | } 51 | 52 | } 53 | 54 | 55 | class MessageHandlerCtx( 56 | val engine: MessageHandlerPaperVisionEngine, 57 | val message: T 58 | ) { 59 | fun respond(response: PaperVisionEngineMessageResponse) { 60 | response.id = message.id 61 | engine.sendResponse(response) 62 | } 63 | } -------------------------------------------------------------------------------- /Shared/src/main/kotlin/io/github/deltacv/papervision/engine/PaperVisionEngine.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.engine 20 | 21 | import io.github.deltacv.papervision.engine.message.ByteMessageTag 22 | import io.github.deltacv.papervision.engine.message.ByteMessages 23 | import io.github.deltacv.papervision.engine.message.PaperVisionEngineMessage 24 | import io.github.deltacv.papervision.engine.message.PaperVisionEngineMessageResponse 25 | import java.nio.ByteBuffer 26 | 27 | interface PaperVisionEngine { 28 | fun sendBytes(bytes: ByteArray) 29 | fun sendBytes(tag: ByteArray, id: Int, bytes: ByteArray) = sendBytes(ByteMessages.toBytes(tag, id, bytes)) 30 | fun sendBytes(tag: ByteMessageTag, id: Int, bytes: ByteArray) = sendBytes(tag.tag, id, bytes) 31 | 32 | fun acceptMessage(message: PaperVisionEngineMessage) 33 | fun sendResponse(response: PaperVisionEngineMessageResponse) 34 | } -------------------------------------------------------------------------------- /Shared/src/main/kotlin/io/github/deltacv/papervision/engine/client/message/PrevizMessages.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.engine.client.message 20 | 21 | import io.github.deltacv.papervision.engine.message.PaperVisionEngineMessageBase 22 | 23 | class PrevizPingMessage( 24 | var previzName: String 25 | ) : PaperVisionEngineMessageBase() 26 | 27 | class PrevizStartMessage( 28 | var previzName: String, 29 | var sourceCode: String, 30 | var streamWidth: Int, 31 | var streamHeight: Int 32 | ) : PaperVisionEngineMessageBase() 33 | 34 | class PrevizSourceCodeMessage( 35 | var previzName: String, 36 | var sourceCode: String 37 | ) : PaperVisionEngineMessageBase() 38 | 39 | class PrevizStopMessage( 40 | var previzName: String 41 | ) : PaperVisionEngineMessageBase() 42 | 43 | class PrevizAskNameMessage : PaperVisionEngineMessageBase() 44 | 45 | class TunerChangeValueMessage( 46 | var label: String, 47 | var value: Any 48 | ) : PaperVisionEngineMessageBase() 49 | 50 | class TunerChangeValuesMessage( 51 | var label: String, 52 | var values: Array<*> 53 | ) : PaperVisionEngineMessageBase() -------------------------------------------------------------------------------- /Shared/src/main/kotlin/io/github/deltacv/papervision/engine/client/message/ProjectMessages.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.engine.client.message 20 | 21 | import io.github.deltacv.papervision.engine.message.PaperVisionEngineMessageBase 22 | 23 | class AskProjectGenClassNameMessage : PaperVisionEngineMessageBase() -------------------------------------------------------------------------------- /Shared/src/main/kotlin/io/github/deltacv/papervision/engine/client/response/DefaultResponses.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.engine.client.response 20 | 21 | import io.github.deltacv.papervision.engine.message.PaperVisionEngineMessageResponse 22 | 23 | open class OkResponse(val info: String = "") : PaperVisionEngineMessageResponse() { 24 | override val status = true 25 | 26 | override fun toString(): String { 27 | return "OkResponse(type=\"${this::class.java.typeName}\", info=\"$info\")" 28 | } 29 | } 30 | 31 | open class ErrorResponse(val reason: String, val stackTrace: Array? = null) : PaperVisionEngineMessageResponse() { 32 | override val status = false 33 | 34 | constructor(reason: String, throwable: Throwable) : this(reason, throwable.stackTrace.map { it.toString() }.toTypedArray()) 35 | 36 | override fun toString(): String { 37 | return "ErrorResponse(type=\"${this::class.java.typeName}\", reason=\"$reason\", exception=\"${stackTrace?.getOrNull(0)}\")" 38 | } 39 | } -------------------------------------------------------------------------------- /Shared/src/main/kotlin/io/github/deltacv/papervision/engine/client/response/TypeResponses.kt: -------------------------------------------------------------------------------- 1 | 2 | 3 | package io.github.deltacv.papervision.engine.client.response 4 | 5 | import com.google.gson.JsonElement 6 | 7 | class BooleanResponse( 8 | var value: Boolean 9 | ) : OkResponse() 10 | 11 | class StringResponse( 12 | var value: String 13 | ) : OkResponse() 14 | 15 | class JsonElementResponse( 16 | var value: JsonElement 17 | ) : OkResponse() -------------------------------------------------------------------------------- /Shared/src/main/kotlin/io/github/deltacv/papervision/engine/message/PaperVisionEngineMessage.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.engine.message 20 | 21 | fun interface OnResponseCallback { 22 | fun onResponse(response: PaperVisionEngineMessageResponse) 23 | } 24 | 25 | interface PaperVisionEngineMessage { 26 | var id: Int 27 | var persistent: Boolean 28 | 29 | fun acceptResponse(response: PaperVisionEngineMessageResponse) 30 | 31 | fun onResponse(callback: OnResponseCallback): PaperVisionEngineMessage 32 | } -------------------------------------------------------------------------------- /Shared/src/main/kotlin/io/github/deltacv/papervision/engine/message/PaperVisionEngineMessageBase.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.engine.message 20 | 21 | abstract class PaperVisionEngineMessageBase( 22 | override var persistent: Boolean = false 23 | ) : PaperVisionEngineMessage { 24 | 25 | companion object { 26 | private var idCount = -1 27 | 28 | @Synchronized fun nextId(): Int { 29 | idCount++ 30 | return idCount 31 | } 32 | } 33 | 34 | @Transient 35 | private val onResponseCallbacks = mutableListOf() 36 | 37 | override var id = nextId() 38 | 39 | override fun acceptResponse(response: PaperVisionEngineMessageResponse) { 40 | for(callback in onResponseCallbacks) { 41 | callback.onResponse(response) 42 | } 43 | } 44 | 45 | override fun onResponse(callback: OnResponseCallback): PaperVisionEngineMessageBase { 46 | onResponseCallbacks.add(callback) 47 | return this 48 | } 49 | 50 | inline fun onResponseWith(crossinline callback: (T) -> Unit) = 51 | onResponse { 52 | if(it is T) { 53 | callback(it) 54 | } 55 | }.run { this } 56 | 57 | override fun toString() = "MessageBase(type=\"${this::class.java.typeName}\", id=$id)" 58 | 59 | } -------------------------------------------------------------------------------- /Shared/src/main/kotlin/io/github/deltacv/papervision/engine/message/PaperVisionEngineMessageResponse.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.engine.message 20 | 21 | abstract class PaperVisionEngineMessageResponse { 22 | var id = 0 23 | 24 | abstract val status: Boolean 25 | 26 | override fun toString(): String { 27 | return "IpcMessageResponse(type=\"${this::class.java.typeName}\", status=\"${if(status) "OK" else "ERROR"}\")" 28 | } 29 | } -------------------------------------------------------------------------------- /Shared/src/main/kotlin/io/github/deltacv/papervision/gui/style/ImNodesStyleTemplate.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.gui.style 20 | 21 | interface ImNodesStyleTemplate : Style { 22 | val nodeBackground: Int 23 | val nodeBackgroundHovered: Int 24 | val nodeBackgroundSelected: Int 25 | val nodeOutline: Int 26 | 27 | val titleBar: Int 28 | val titleBarHovered: Int 29 | val titleBarSelected: Int 30 | 31 | val link: Int 32 | val linkHovered: Int 33 | val linkSelected: Int 34 | 35 | val pin: Int 36 | val pinHovered: Int 37 | 38 | val boxSelector: Int 39 | val boxSelectorOutline: Int 40 | } -------------------------------------------------------------------------------- /Shared/src/main/kotlin/io/github/deltacv/papervision/gui/style/Style.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.gui.style 20 | 21 | object CurrentStyles { 22 | lateinit var imnodesStyle: ImNodesStyleTemplate 23 | } 24 | 25 | interface Style { 26 | fun apply() 27 | } -------------------------------------------------------------------------------- /Shared/src/main/kotlin/io/github/deltacv/papervision/gui/style/Util.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.gui.style 20 | 21 | import imgui.ImColor 22 | import imgui.ImVec4 23 | import kotlin.math.roundToInt 24 | 25 | fun rgbaColor(r: Int, g: Int, b: Int, a: Int) = ImColor.rgba( 26 | r.toFloat() / 255f, 27 | g.toFloat() / 255f, 28 | b.toFloat() / 255f, 29 | a.toFloat() / 255f 30 | ) 31 | 32 | fun hexColor(hex: String) = ImColor.rgb(hex) 33 | 34 | fun Int.opacity(opacity: Float): Int { 35 | // Ensure the opacity is within 0 and 1 36 | val clampedOpacity = opacity.coerceIn(0f, 1f) 37 | 38 | // Extract the color components assuming the format is RGBA 39 | val r = (this shr 24) and 0xFF 40 | val g = (this shr 16) and 0xFF 41 | val b = (this shr 8) and 0xFF 42 | val a = this and 0xFF 43 | 44 | // Apply the opacity to the alpha component 45 | val opaqueA = (a * clampedOpacity).roundToInt().coerceIn(0, 255) 46 | 47 | // Recombine the components back into a color integer 48 | return rgbaColor(r, g, b, opaqueA) 49 | } 50 | 51 | fun Int.darken(factor: Float): Int { 52 | // Ensure the factor is within 0 and 1 53 | val clampedFactor = factor.coerceIn(0f, 1f) 54 | 55 | // Extract the color components assuming the format is RGBA 56 | val r = (this shr 24) and 0xFF 57 | val g = (this shr 16) and 0xFF 58 | val b = (this shr 8) and 0xFF 59 | val a = this and 0xFF 60 | 61 | // Apply the darkening factor to each RGB component 62 | val darkenedR = (r * clampedFactor).roundToInt().coerceIn(0, 255) 63 | val darkenedG = (g * clampedFactor).roundToInt().coerceIn(0, 255) 64 | val darkenedB = (b * clampedFactor).roundToInt().coerceIn(0, 255) 65 | 66 | // Recombine the components back into a color integer 67 | return rgbaColor(darkenedR, darkenedG, darkenedB, a) 68 | } -------------------------------------------------------------------------------- /Shared/src/main/kotlin/io/github/deltacv/papervision/node/Category.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.node 20 | 21 | import io.github.deltacv.papervision.gui.style.CurrentStyles.imnodesStyle 22 | import io.github.deltacv.papervision.gui.style.hexColor 23 | 24 | enum class Category(val properName: String, 25 | val color: Int = imnodesStyle.titleBar, 26 | val colorSelected: Int = imnodesStyle.titleBarHovered) { 27 | 28 | FLOW("cat_pipeline_flow", 29 | hexColor("#00838f"), // material cyan 30 | hexColor("#00acc1")), 31 | 32 | CODE("cat_coding"), 33 | HIGH_LEVEL_CV("cat_high_level_cv"), 34 | 35 | IMAGE_PROC("cat_image_proc", 36 | hexColor("#ff6f00"), // material amber 37 | hexColor("#ffa000")), 38 | 39 | FEATURE_DET("cat_feature_det", 40 | hexColor("#3949ab"), // material indigo 41 | hexColor("#5c6bc0")), 42 | 43 | CLASSIFICATION("cat_class", 44 | hexColor("#F9A825"), // material yellow 800 45 | hexColor("#FDD835")), 46 | 47 | OVERLAY("cat_overlay", 48 | hexColor("#00897b"), // material teal 49 | hexColor("#26a69a")), 50 | 51 | MATH("cat_math"), 52 | MISC("cat_misc") 53 | 54 | } -------------------------------------------------------------------------------- /Shared/src/main/kotlin/io/github/deltacv/papervision/node/PaperNode.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PaperVision 3 | * Copyright (C) 2024 Sebastian Erives, deltacv 4 | 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package io.github.deltacv.papervision.node 20 | 21 | @Target(AnnotationTarget.CLASS) 22 | annotation class PaperNode( 23 | val name: String, 24 | val category: Category, 25 | val description: String = "", 26 | val showInList: Boolean = true 27 | ) -------------------------------------------------------------------------------- /build.common.gradle: -------------------------------------------------------------------------------- 1 | java { 2 | toolchain { 3 | languageVersion = JavaLanguageVersion.of(11) 4 | } 5 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | import java.nio.file.Paths 2 | import java.time.LocalDateTime 3 | import java.time.format.DateTimeFormatter 4 | 5 | buildscript { 6 | ext { 7 | kotlin_version = "2.0.20" 8 | kotlinx_coroutines_version = "1.8.1" 9 | classgraph_version = "4.8.108" 10 | imgui_version = "1.87.6" 11 | gson_version = "2.8.9" 12 | lwjgl_version = "3.3.2" 13 | 14 | slf4j_version = "2.0.16" 15 | log4j_version = "2.24.0" 16 | logback_classic_version = "1.5.8" 17 | 18 | Penv = findProperty('env') 19 | if(Penv != null && (Penv != 'dev' && Penv != 'release')) { 20 | throw new GradleException("Invalid env property, must be 'dev' or 'release'") 21 | } 22 | 23 | env = Penv == 'release' ? 'release' : 'dev' 24 | 25 | println("Current build is: $env") 26 | } 27 | 28 | repositories { 29 | mavenCentral() 30 | google() 31 | } 32 | 33 | dependencies { 34 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 35 | classpath 'com.vanniktech:gradle-maven-publish-plugin:0.30.0' 36 | } 37 | } 38 | 39 | allprojects { 40 | group 'org.deltacv.PaperVision' 41 | version '1.0.6' 42 | 43 | ext { 44 | standardVersion = version 45 | } 46 | 47 | repositories { 48 | mavenCentral() 49 | google() 50 | maven { url "https://maven.pkg.jetbrains.space/public/p/compose/dev" } 51 | maven { url 'https://maven.scijava.org/content/repositories/public/' } 52 | } 53 | 54 | if(env == 'dev') { 55 | String date = DateTimeFormatter.ofPattern( 56 | "yyMMdd-HHmm" 57 | ).format(LocalDateTime.now()) 58 | 59 | String hash = findProperty('hash') 60 | 61 | version += "-dev-${hash ?: date}" 62 | println("Final version of ${project} is $version") 63 | 64 | File libsFolder = Paths.get( 65 | projectDir.absolutePath, 'build', 'libs' 66 | ).toFile() 67 | 68 | for(file in libsFolder.listFiles()) { 69 | if(file.name.contains("dev") && file.name.endsWith(".jar")) 70 | file.delete() 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official 2 | 3 | // or when publishing to https://central.sonatype.com/ 4 | SONATYPE_HOST=CENTRAL_PORTAL 5 | RELEASE_SIGNING_ENABLED=true 6 | 7 | POM_DESCRIPTION=Create your custom OpenCV algorithms using a user-friendly node editor interface 8 | POM_INCEPTION_YEAR=2024 9 | POM_URL=https://github.com/deltacv/PaperVision/ 10 | 11 | POM_LICENSE_NAME=GNU General Public License v3.0 12 | POM_LICENSE_URL=https://www.gnu.org/licenses/gpl-3.0.en.html 13 | POM_LICENSE_DIST=repo 14 | 15 | POM_SCM_URL=https://github.com/deltacv/PaperVision/ 16 | POM_SCM_CONNECTION=scm:git:git://github.com/deltacv/PaperVision.git 17 | POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/deltacv/PaperVision.git 18 | 19 | POM_DEVELOPER_ID=serivesmejia 20 | POM_DEVELOPER_NAME=Sebastian Erives 21 | POM_DEVELOPER_URL=https://github.com/serivesmejia/ -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deltacv/PaperVision/318828d221c24d3bef9c6af962bf77532716b68c/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Nov 19 04:25:27 CST 2024 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /jitpack.yml: -------------------------------------------------------------------------------- 1 | jdk: 2 | - openjdk11 3 | before_install: 4 | - chmod +x gradlew 5 | install: 6 | - ./gradlew :Shared:publishToMavenLocal :PaperVision:publishToMavenLocal :LwjglPlatform:publishToMavenLocal :EOCVSimPlugin:publishToMavenLocal 7 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'PaperVision' 2 | 3 | include 'PaperVision' 4 | include 'PaperVision:NodeAnnotationProcessor' 5 | include 'Shared' 6 | 7 | include 'EOCVSimPlugin' 8 | 9 | include 'LwjglPlatform' 10 | include 'LwjglPlatform:Standalone' -------------------------------------------------------------------------------- /tools/Common.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deltacv/PaperVision/318828d221c24d3bef9c6af962bf77532716b68c/tools/Common.jar -------------------------------------------------------------------------------- /tools/sign_output.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal enabledelayedexpansion 3 | 4 | if "%1"=="" ( 5 | echo Error: The path to the root project is required as the first argument. 6 | exit /b 1 7 | ) 8 | 9 | if "%2"=="" ( 10 | echo Error: The signing key is required as the second argument. 11 | exit /b 1 12 | ) 13 | 14 | for %%i in (EOCVSimPlugin\build\libs\*.jar) do ( 15 | java -classpath "%~1\tools\Common.jar" io.github.deltacv.eocvsim.plugin.security.PluginSigningTool --plugin=%%i --authority=deltacv --key=%2 16 | ) -------------------------------------------------------------------------------- /tools/sign_output.sh: -------------------------------------------------------------------------------- 1 | for i in EOCVSimPlugin/build/libs/*.jar; do 2 | java -classpath "$1/tools/Common.jar" io.github.deltacv.eocvsim.plugin.security.PluginSigningTool --plugin=$i --authority=deltacv --key=$2 3 | done --------------------------------------------------------------------------------