-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
173 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import ch.bildspur.vision.*; | ||
import ch.bildspur.vision.result.*; | ||
|
||
DeepVision deepVision = new DeepVision(this); | ||
YOLONetwork yolo; | ||
ResultList<ObjectDetectionResult> detections; | ||
|
||
PImage image; | ||
int textSize = 12; | ||
|
||
public void setup() { | ||
size(640, 480); | ||
|
||
colorMode(HSB, 360, 100, 100); | ||
|
||
image = loadImage("pexels-lina-kivaka-5623971.jpg"); | ||
|
||
println("creating model..."); | ||
yolo = deepVision.createYOLOv5l(); | ||
|
||
println("loading yolo model..."); | ||
yolo.setup(); | ||
|
||
println("inferencing..."); | ||
yolo.setConfidenceThreshold(0.95f); | ||
yolo.setTopK(0); | ||
|
||
detections = yolo.run(image); | ||
} | ||
|
||
public void draw() { | ||
background(55); | ||
|
||
image(image, 0, 0); | ||
|
||
noFill(); | ||
strokeWeight(2f); | ||
|
||
strokeWeight(3f); | ||
textSize(textSize); | ||
|
||
for (ObjectDetectionResult detection : detections) { | ||
int hue = (int)(360.0 / yolo.getLabels().size() * detection.getClassId()); | ||
|
||
noFill(); | ||
stroke(hue, 80, 100); | ||
rect(detection.getX(), detection.getY(), detection.getWidth(), detection.getHeight()); | ||
|
||
fill(hue, 80, 100); | ||
rect(detection.getX(), detection.getY() - (textSize + 3), textWidth(detection.getClassName()) + 4, textSize + 3); | ||
|
||
fill(0); | ||
textAlign(LEFT, TOP); | ||
text(detection.getClassName(), detection.getX() + 2, detection.getY() - textSize - 3); | ||
} | ||
|
||
surface.setTitle("YOLO Test - FPS: " + Math.round(frameRate)); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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