Update README.md
This commit is contained in:
@@ -92,73 +92,6 @@ import org.openrndr.extra.jumpfill.directionFieldFromBitmap
|
||||
import org.openrndr.ffmpeg.VideoPlayerFFMPEG
|
||||
import org.openrndr.filter.blur.ApproximateGaussianBlur
|
||||
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
}
|
||||
|
||||
program {
|
||||
val blurFilter = ApproximateGaussianBlur()
|
||||
val blurred = colorBuffer(width, height)
|
||||
|
||||
val thresholdFilter = Threshold()
|
||||
val thresholded = colorBuffer(width, height)
|
||||
|
||||
val directionField = colorBuffer(width, height, type = ColorType.FLOAT32)
|
||||
|
||||
val videoPlayer = VideoPlayerFFMPEG.fromDevice(imageWidth = width, imageHeight = height)
|
||||
videoPlayer.play()
|
||||
|
||||
val videoCopy = renderTarget(width, height) {
|
||||
colorBuffer()
|
||||
}
|
||||
|
||||
extend {
|
||||
// -- copy videoplayer output
|
||||
drawer.isolatedWithTarget(videoCopy) {
|
||||
drawer.ortho(videoCopy)
|
||||
videoPlayer.draw(drawer)
|
||||
}
|
||||
|
||||
// -- blur the input a bit, this produces less noisy bitmap images
|
||||
blurFilter.sigma = 9.0
|
||||
blurFilter.window = 18
|
||||
blurFilter.apply(videoCopy.colorBuffer(0), blurred)
|
||||
|
||||
// -- threshold the blurred image
|
||||
thresholdFilter.threshold = 0.5
|
||||
thresholdFilter.apply(blurred, thresholded)
|
||||
|
||||
directionFieldFromBitmap(drawer, thresholded, result = directionField)
|
||||
|
||||
drawer.isolated {
|
||||
// -- use a shadestyle to visualize the direction field
|
||||
drawer.shadeStyle = shadeStyle {
|
||||
fragmentTransform = """
|
||||
float a = atan(x_fill.r, x_fill.g);
|
||||
if (a < 0) {
|
||||
a += 3.1415926535*2;
|
||||
}
|
||||
if (x_fill.g > 0.5) {
|
||||
x_fill.rgb = 1.0*vec3(cos(a*1.0)*0.5+0.5);
|
||||
} else {
|
||||
x_fill.rgb = 0.25*vec3(cos(a*1.0)*0.5+0.5);
|
||||
}
|
||||
"""
|
||||
}
|
||||
drawer.image(directionField)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
import org.openrndr.application
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.jumpfill.Threshold
|
||||
import org.openrndr.extra.jumpfill.directionFieldFromBitmap
|
||||
import org.openrndr.ffmpeg.VideoPlayerFFMPEG
|
||||
import org.openrndr.filter.blur.ApproximateGaussianBlur
|
||||
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 1280
|
||||
|
||||
Reference in New Issue
Block a user