Created
October 27, 2018 00:59
-
-
Save n1ckfg/57da5435257d9b1f71097e4ca5998d78 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gab.opencv.*; | |
OpenCV opencv; | |
PImage src, canny; | |
int lowThreshold = 20; | |
int highThreshold = 75; | |
void setup() { | |
src = loadImage("test.jpg"); | |
size(1080, 720, P2D); | |
doCanny(); | |
} | |
void doCanny() { | |
opencv = new OpenCV(this, src); | |
opencv.findCannyEdges(lowThreshold, highThreshold); | |
canny = opencv.getSnapshot(); | |
} | |
void draw() { | |
if (keyPressed) { | |
if (key == 'w') { | |
lowThreshold++; | |
} else if (key == 's') { | |
lowThreshold--; | |
} | |
if (key == 'i') { | |
highThreshold++; | |
} else if (key == 'k') { | |
highThreshold--; | |
} | |
if (key == 'w' || key == 's' || key == 'i' || key == 'k') { | |
lowThreshold = constrain(lowThreshold, 0, 255); | |
highThreshold = constrain(highThreshold, 0, 255); | |
doCanny(); | |
println(lowThreshold + " " + highThreshold); | |
} | |
} | |
image(canny, 0, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment