Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoseNet presets and example #124

Merged
merged 2 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions orx-runway/src/demo/kotlin/PoseNet01.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.isolatedWithTarget
import org.openrndr.draw.loadImage
import org.openrndr.draw.renderTarget
import org.openrndr.extra.runway.*

/**
* This demonstrates the body estimation model of PoseNet
* This example requires a `runway/PoseNet` model active in Runway.
*/
fun main() = application {
configure {
width = 512
height = 512
}

program {
val rt = renderTarget(512, 512) {
colorBuffer()
}
val image = loadImage("demo-data/images/peopleCity01.jpg")

drawer.isolatedWithTarget(rt) {
drawer.ortho(rt)
drawer.clear(ColorRGBa.BLACK)
drawer.image(image, (rt.width - image.width) / 2.0, (rt.height - image.height) / 2.0)
}

extend {
val result: PoseNetResponse = runwayQuery("http://localhost:8000/query", PoseNetRequest(rt.colorBuffer(0).toData()))
val poses = result.poses
val scores = result.scores

drawer.image(image, 0.0, 0.0, 512.0, 512.0)

poses.forEach { poses ->
poses.forEach { pose ->
drawer.circle(pose[0]*512.0, pose[1]*512.0, 10.0)
}
}
}
}
}
12 changes: 11 additions & 1 deletion orx-runway/src/main/kotlin/Presets.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,14 @@ class DeOldifyResponse(val image: String)
// -- DenseCap

class DenseCapRequest(val image: String, @SerializedName("max_detections") val maxDetections: Int = 10)
class DenseCapResponse(val bboxes: List<List<Double>>, val classes: List<String>, val scores: List<Double>)
class DenseCapResponse(val bboxes: List<List<Double>>, val classes: List<String>, val scores: List<Double>)

// -- PoseNet
class PoseNetRequest(
val image: String,
@SerializedName("estimationType") val estimationType: String = "Multi Pose",
@SerializedName("maxPoseDetections") val maxPoseDetections: Int = 5,
@SerializedName("scoreThreshold") val scoreThreshold: Double = 0.25
)
class PoseNetResponse(val poses: List<List<List<Double>>>, val scores: List<Double>)