This repository has been archived by the owner on Apr 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates bodypix examples to use preload() for p5js examples (#214)
* adds preload example * updates bodypix to use preload()
- Loading branch information
Showing
7 changed files
with
68 additions
and
28 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<html> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title>BodyPix with Webcam</title> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.8.0/p5.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.8.0/addons/p5.dom.min.js"></script> | ||
<script src="http://localhost:8080/ml5.js" type="text/javascript"></script> | ||
|
||
<style></style> | ||
</head> | ||
|
||
<script src="sketch.js"></script> | ||
|
||
<body> | ||
<h1>BodyPix with Image</h1> | ||
<small>images via: https://commons.wikimedia.org</small> | ||
|
||
</body> | ||
|
||
</html> |
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,30 @@ | ||
let bodypix; | ||
let segmentation; | ||
let img; | ||
|
||
function preload() { | ||
img = loadImage('data/ada.jpg'); | ||
bodypix = ml5.bodyPix(); | ||
} | ||
|
||
function setup() { | ||
createCanvas(480, 640); | ||
bodypix.segment(img, gotResults) | ||
} | ||
|
||
function gotResults(err, result) { | ||
if (err) { | ||
console.log(err) | ||
return | ||
} | ||
// console.log(result); | ||
segmentation = result; | ||
|
||
background(0); | ||
|
||
// console.log(segmentation.maskPerson) | ||
// TODO: image seems to be repeating 4x | ||
image(img, 0, 0, width, height) | ||
image(segmentation.maskBackground, 0, 0, width, height) | ||
|
||
} |
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