Skip to content
Open

Main #411

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
5eefc27
Merge pull request #331 from mitmedialab/dev
pmalacho-mit Feb 4, 2024
620d4de
Merge remote-tracking branch 'origin/dev'
pmalacho-mit May 10, 2024
02fffc7
Merge pull request #359 from mitmedialab/dev
pmalacho-mit May 25, 2024
f83d392
Merge pull request #364 from mitmedialab/dev
pmalacho-mit Jun 20, 2024
659286f
Merge branch 'dev'
pmalacho-mit Jul 25, 2024
154e93c
Merge pull request #391 from mitmedialab/dev
mayarajan3 Feb 9, 2025
a3bcde5
updates
mayarajan3 Mar 13, 2025
0576ac6
Merge pull request #395 from mitmedialab/drive-fix
mayarajan3 Mar 13, 2025
39fbf93
temporarily remove api
mayarajan3 May 14, 2025
7ad0bbf
Merge pull request #400 from mitmedialab/textClassification-fix-api
mayarajan3 May 28, 2025
d0fc9c9
load tfjs
mayarajan3 Aug 14, 2025
a99a737
new changes
mayarajan3 Aug 14, 2025
a965903
Merge pull request #410 from mitmedialab/poseBody-issue
pmalacho-mit Aug 14, 2025
aa0d3d8
cpu instead of webgl
mayarajan3 Aug 14, 2025
91ceb29
Merge pull request #412 from mitmedialab/poseBody-issue
mayarajan3 Aug 14, 2025
f29c946
remove async
mayarajan3 Aug 14, 2025
a29e843
back to webgl
mayarajan3 Aug 14, 2025
f1a46a3
Merge pull request #413 from mitmedialab/poseBody-issue
mayarajan3 Aug 14, 2025
9ec434a
face and body landmarks
mayarajan3 Nov 6, 2025
84f0b3f
hand add
mayarajan3 Nov 6, 2025
f5daafb
small issues
mayarajan3 Nov 6, 2025
aae2437
switch hand to mediapipe
mayarajan3 Nov 6, 2025
d4bf839
Merge branch 'switch-hand-mediapipe' into add-landmarks-detection
mayarajan3 Nov 6, 2025
55b3da7
edit return
mayarajan3 Nov 6, 2025
7451e1d
update
mayarajan3 Nov 6, 2025
876acd1
improve accuracy
mayarajan3 Nov 7, 2025
b375cf4
undo
mayarajan3 Nov 7, 2025
aeb08ad
video attempt
mayarajan3 Nov 7, 2025
dc8d5d9
add landmarks
mayarajan3 Nov 7, 2025
0659144
video updates
mayarajan3 Nov 7, 2025
ee9603d
Merge pull request #424 from mitmedialab/switch-hand-mediapipe-video
mayarajan3 Nov 7, 2025
3add86a
going back to images
mayarajan3 Nov 10, 2025
65f3c93
debug statement
mayarajan3 Nov 11, 2025
ec1b3b4
debug statement
mayarajan3 Nov 11, 2025
eea38e2
trigger build
mayarajan3 Nov 12, 2025
9a669bf
unnecessary print
mayarajan3 Nov 12, 2025
f7d3fa8
remove print statements
mayarajan3 Nov 12, 2025
b4d3d33
improve loop
mayarajan3 Nov 13, 2025
f67c7f0
merge image loop
mayarajan3 Nov 13, 2025
4aa8080
remove dead code
mayarajan3 Nov 13, 2025
8e31f0c
Merge pull request #423 from mitmedialab/add-landmarks-detection
mayarajan3 Nov 13, 2025
b680d2f
table fix
mayarajan3 Nov 26, 2025
6c04e72
Merge pull request #430 from mitmedialab/table-fix
mayarajan3 Nov 26, 2025
8a348a7
column and row names
mayarajan3 Dec 1, 2025
a5ae0f3
Merge pull request #431 from mitmedialab/table-fix
mayarajan3 Dec 2, 2025
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
33 changes: 32 additions & 1 deletion extensions/src/poseBody/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ArgumentType, BlockType, Extension, Block, DefineBlock, Environment, ExtensionMenuDisplayDetails, RuntimeEvent, ValueOf } from "$common";
import "@tensorflow/tfjs-backend-webgl";
import * as posenet from '@tensorflow-models/posenet';

import { legacyFullSupport, info } from "./legacy";
Expand Down Expand Up @@ -36,6 +37,7 @@ type Details = {
* Contains descriptions of the blocks of the Block Sensing extension
*/
type Blocks = {
returnPart(coord: string, bodyPart: string): number;
goToPart(bodyPart: string): void;
// these video blocks are present in a few different extensions, perhaps making a file just for these?
videoToggle(state: string): void;
Expand Down Expand Up @@ -76,12 +78,13 @@ export default class PoseBody extends Extension<Details, Blocks> {
*/
bodyOptions = info.menus.PART.items;


/**
* Acts like class PoseBody's constructor (instead of a child class constructor)
* @param env
*/
init(env: Environment) {

if (this.runtime.ioDevices) {
this._loop();
}
Expand Down Expand Up @@ -154,6 +157,7 @@ export default class PoseBody extends Extension<Details, Blocks> {
* @returns
*/
async ensureBodyModelLoaded() {

this.bodyModel ??= await posenet.load();
return this.bodyModel;
}
Expand Down Expand Up @@ -216,6 +220,32 @@ export default class PoseBody extends Extension<Details, Blocks> {
}
});

const returnPart = legacyDefinition.returnPart({
operation: (coord: string, bodyPart: string) => {

if (this.hasPose()) {
const { x, y } = this.tfCoordsToScratch(this.poseState.keypoints.find(point => point.part === bodyPart).position);
if (coord === 'x') {
return x;
} else {
return y;
}
}
},
argumentMethods: {
0: {
handler(coord: string) {
return ['x', 'y'].includes(coord) ? coord : 'x';
}
},
1: {
handler: (bodyPart: string) => {
return handlerOptions.includes(bodyPart) ? bodyPart : 'nose';
}
}
}
});

const videoToggle = legacyDefinition.videoToggle({
operation: (video_state) => {
this.toggleVideo(video_state);
Expand All @@ -237,6 +267,7 @@ export default class PoseBody extends Extension<Details, Blocks> {

return {
goToPart,
returnPart,
videoToggle,
setVideoTransparency
}
Expand Down
31 changes: 31 additions & 0 deletions extensions/src/poseBody/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ export const info = {
}
}
},
{
"opcode": "returnPart",
"text": "get [COORD] of [PART]",
"blockType": "reporter",
"isTerminal": false,
"arguments": {
"COORD": {
"type": "string",
"defaultValue": "x",
"menu": "COORD"
},
"PART": {
"type": "string",
"defaultValue": "rightShoulder",
"menu": "PART"
}
}
},
{
"opcode": "videoToggle",
"text": "turn video [VIDEO_STATE]",
Expand Down Expand Up @@ -115,6 +133,19 @@ export const info = {
}
]
},
"COORD": {
"acceptReporters": false,
"items": [
{
"text": "x",
"value": "x"
},
{
"text": "y",
"value": "y"
}
]
},
"ATTRIBUTE": {
"acceptReporters": true,
"items": [
Expand Down
4 changes: 3 additions & 1 deletion extensions/src/poseBody/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"author": "",
"license": "ISC",
"dependencies": {
"@tensorflow-models/posenet": "2.2.1"
"@tensorflow-models/posenet": "2.2.2",
"@tensorflow/tfjs-backend-webgl": "3.0.0-rc.1",
"@tensorflow/tfjs-core": "3.0.0-rc.1"
}
}
97 changes: 59 additions & 38 deletions extensions/src/poseBody/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions extensions/src/poseFace/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Details = {
*/
type Blocks = {
affdexGoToPart(facePart: string): void;
affdexReturnPart(coord: string, facePart: string): number;
affdexWhenExpression(expression: string): boolean;
affdexExpressionAmount(expression: string): number;
affdexIsExpression(expression: string): boolean;
Expand Down Expand Up @@ -199,6 +200,18 @@ export default class PoseFace extends Extension<Details, Blocks> {
(util.target as any).setXY(x, y, false);
}

returnPart(coord, part, util) {
if (!this.affdexState || !this.affdexState.featurePoints) return;

const featurePoint = this.affdexState.featurePoints[part];
const { x, y } = this.convertCoordsToScratch(featurePoint);
if (coord === 'x') {
return x;
} else {
return y;
}
}

/**
* If an expression is being expressed
* @param expression
Expand Down Expand Up @@ -302,6 +315,12 @@ export default class PoseFace extends Extension<Details, Blocks> {
}
});

const affdexReturnPart = legacyDefinition.affdexReturnPart({
operation: (coord: string, part: string, util: BlockUtility) => {
return this.returnPart(coord, part, util)
}
});

const affdexWhenExpression = legacyDefinition.affdexWhenExpression({
operation: (expression: string) => {
return this.isExpression(expression);
Expand Down Expand Up @@ -403,6 +422,7 @@ export default class PoseFace extends Extension<Details, Blocks> {

return {
affdexGoToPart,
affdexReturnPart,
affdexWhenExpression,
affdexExpressionAmount,
affdexIsExpression,
Expand Down
31 changes: 31 additions & 0 deletions extensions/src/poseFace/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ export const info = {
}
}
},
{
"opcode": "affdexReturnPart",
"text": "get [COORD] from [AFFDEX_POINT]",
"blockType": "reporter",
"isTerminal": false,
"arguments": {
"COORD": {
"type": "string",
"defaultValue": "x",
"menu": "COORD"
},
"AFFDEX_POINT": {
"type": "string",
"defaultValue": "0",
"menu": "AFFDEX_POINT"
}
}
},
{
"opcode": "affdexWhenExpression",
"text": "when [EXPRESSION] detected",
Expand Down Expand Up @@ -446,6 +464,19 @@ export const info = {
"value": "on-flipped"
}
]
},
"COORD": {
"acceptReporters": false,
"items": [
{
"text": "x",
"value": "x"
},
{
"text": "y",
"value": "y"
},
]
}
}
} as const;
Expand Down
Loading
Loading