Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
champierre committed Jul 17, 2024
1 parent ef56193 commit 0166614
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 37 deletions.
Binary file modified sample_projects/handpose.sb3
Binary file not shown.
75 changes: 38 additions & 37 deletions scratch-vm/src/extensions/scratch3_handpose2scratch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ const BlockType = require('../../extension-support/block-type');
const Cast = require('../../util/cast');
const formatMessage = require('format-message');

// eslint-disable-next-line max-len
const blockIconURI = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAhGVYSWZNTQAqAAAACAAFARIAAwAAAAEAAQAAARoABQAAAAEAAABKARsABQAAAAEAAABSASgAAwAAAAEAAgAAh2kABAAAAAEAAABaAAAAAAAAAEgAAAABAAAASAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAASKADAAQAAAABAAAASAAAAABjCyvsAAAACXBIWXMAAAsTAAALEwEAmpwYAAACMmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyIKICAgICAgICAgICAgeG1sbnM6ZXhpZj0iaHR0cDovL25zLmFkb2JlLmNvbS9leGlmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlv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VxLHZRnDnmKo7wpd3iXQ1ZrYsVs6x3V/hgNRDB1Vw/r+BLB2zZ0dW2bswJZUYl+hxTejZnfniX8tOEUtjSXI4E7ClHUI10cbEFgCA7RWr4s3UJueTBpATak347C+ExzUMG2pZBDSFputqlXKd+JrJbqyzXRCZH3myuodHjilr/NSTjbuI/XAJ4JHNJKG+XmNyM6vdrVlaJN3fULasYBZJNzOjjhWplZ/ueVW6Nn4w5mEa9InjesmFVbdQ22lAVrhXycy3AsJ/HK2r0FGVwYbvRMa1aumQLHTNIzmLJzdcZtuIoxnbZYAriK14XFYHPe7SaYDPNKRyglKosnzvBXT4wA6bDvYZ4sURAbxRxQKxdG2VG98YcCZ4JzbMd2ghk8dQqGD8VMyCdy2mc7a3A/06nLuOspcMQt0nfq2+aTbRv+XgWAtb4fNZXzxmW2daTN/AVHYwmciXVTQyJxgSY9mwC9tWgD5oZFYw+9niezrsNaEzc5KQ2V02Rmsm+BLmpkTLejpZL6J4ThhRPAmhd+fgWw4ekAPGG3zQwWOxku6IyhaCa5dXTH1gLvqj2BFft/gzxuQuq/RCmKnw6db0+n05JXXYM4cddBcn1EWofJLJBXEz79VH9WvN6vpz/FBzoP1Murvw6iHcAXApDRRRI3y5z8/UWBYyaiftiHxOuXjQSI3vs527edqZ/X6QI8YbcCxXwmLDX9l+IgUUlTFcqY8FtM/aOd05mY3Ey04YzuAn7T0hh6l/+XTMGtDppa0KY7rC9USU93cFOpbxP9NUynpNM5TKZo0fOaStUplfl/wEEOrxTXMXyh35XAk7WyXDMF0VcaIBkBWS8l+186y/8jxtiri8I1XefQm7W+2gB5NM1Rhha/5n+hyhFAM2S9LEhfWYAkWNb3UaJNgXG4NipnTD07EP0f9vkI6bCxOM4AAAAASUVORK5CYII=';

const Message = {
getX: {
'ja': '[HAND_NUMBER] つ目の [LANDMARK] のx座標',
'ja-Hira': '[HAND_NUMBER] つめの [LANDMARK] のxざひょう',
'en': 'x of [LANDMARK] of hand no. [HAND_NUMBER]'
'ja': '[HAND] つ目の [KEYPOINT] のx座標',
'ja-Hira': '[HAND] つめの [KEYPOINT] のxざひょう',
'en': 'x of [KEYPOINT] of hand no. [HAND]'
},
getY: {
'ja': '[HAND_NUMBER] つ目の [LANDMARK] のy座標',
'ja-Hira': 'みぎ [LANDMARK] のyざひょう',
'en': 'y of [LANDMARK] of hand no. [HAND NUMBER]'
'ja': '[HAND] つ目の [KEYPOINT] のy座標',
'ja-Hira': 'みぎ [KEYPOINT] のyざひょう',
'en': 'y of [KEYPOINT] of hand no. [HAND NUMBER]'
},
videoToggle: {
'ja': 'ビデオを [VIDEO_STATE] にする',
Expand Down Expand Up @@ -51,7 +52,7 @@ const Message = {
'ja-Hira': 'じゅんびにじかんがかかります。すこしのあいだ、そうさができなくなりますがおまちください。',
'en': 'Setup takes a while. The browser will get stuck, but please wait.'
},
landmarks: [
keypoints: [
{
'ja': '手首',
'ja-Hira': 'てくび',
Expand Down Expand Up @@ -162,7 +163,7 @@ const Message = {
const AvailableLocales = ['en', 'ja', 'ja-Hira'];

class Scratch3Handpose2ScratchBlocks {
get HAND_NUMBERS_MENU() {
get HANDS_MENU() {
return [
{
text: '1',
Expand Down Expand Up @@ -207,12 +208,12 @@ class Scratch3Handpose2ScratchBlocks {
]
}

get LANDMARK_MENU() {
const landmark_menu = [];
get KEYPOINTS_MENU() {
const keypoints = [];
for (let i = 1; i <= 21; i++) {
landmark_menu.push({ text: `${Message.landmarks[i - 1][this._locale]} (${i})`, value: String(i) })
keypoints.push({ text: `${Message.keypoints[i - 1][this._locale]} (${i})`, value: String(i) })
}
return landmark_menu;
return keypoints;
}

get VIDEO_MENU() {
Expand Down Expand Up @@ -281,7 +282,7 @@ class Scratch3Handpose2ScratchBlocks {
constructor(runtime) {
this.runtime = runtime;

this.landmarks = [];
this.keypoints = [];
this.ratio = 0.75;

const loadScriptSynchronously = (url) => {
Expand All @@ -301,7 +302,7 @@ class Scratch3Handpose2ScratchBlocks {
console.log("Model loaded!")
handpose.detectStart(this.video, (results) => {
this.hands = results;
});
});
});

this.runtime.ioDevices.video.enableVideo().then(() => {
Expand All @@ -324,14 +325,14 @@ class Scratch3Handpose2ScratchBlocks {
blockType: BlockType.REPORTER,
text: Message.getX[this._locale],
arguments: {
HAND_NUMBER: {
HAND: {
type: ArgumentType.STRING,
menu: 'handNumbers',
menu: 'handsMenu',
defaultValue: '1'
},
LANDMARK: {
KEYPOINT: {
type: ArgumentType.STRING,
menu: 'landmark',
menu: 'keypointsMenu',
defaultValue: '1'
}
}
Expand All @@ -341,14 +342,14 @@ class Scratch3Handpose2ScratchBlocks {
blockType: BlockType.REPORTER,
text: Message.getY[this._locale],
arguments: {
HAND_NUMBER: {
HAND: {
type: ArgumentType.STRING,
menu: 'handNumbers',
menu: 'handsMenu',
defaultValue: '1'
},
LANDMARK: {
KEYPOINT: {
type: ArgumentType.STRING,
menu: 'landmark',
menu: 'keypointsMenu',
defaultValue: '1'
}
}
Expand Down Expand Up @@ -393,9 +394,9 @@ class Scratch3Handpose2ScratchBlocks {
}
],
menus: {
landmark: {
keypointsMenu: {
acceptReporters: true,
items: this.LANDMARK_MENU
items: this.KEYPOINTS_MENU
},
videoMenu: {
acceptReporters: true,
Expand All @@ -409,35 +410,35 @@ class Scratch3Handpose2ScratchBlocks {
acceptReporters: true,
items: this.INTERVAL_MENU
},
handNumbers: {
handsMenu: {
acceptReporters: true,
items: this.HAND_NUMBERS_MENU
items: this.HANDS_MENU
},
}
};
}

getX(args) {
let landmark = parseInt(args.LANDMARK, 10) - 1;
let hand = parseInt(args.HAND_NUMBER, 10) - 1;
if (this.hands?.[hand]?.keypoints?.[landmark]) {
let keypoint = parseInt(args.KEYPOINT, 10) - 1;
let hand = parseInt(args.HAND, 10) - 1;
if (this.hands?.[hand]?.keypoints?.[keypoint]) {
if (this.runtime.ioDevices.video.mirror === false) {
return -1 * (240 - this.hands[hand].keypoints[landmark].x * this.ratio);
return -1 * (240 - this.hands[hand].keypoints[keypoint].x * this.ratio);
} else {
return 240 - this.hands[hand].keypoints[landmark].x * this.ratio;
return 240 - this.hands[hand].keypoints[keypoint].x * this.ratio;
}
} else {
return null;
return '';
}
}

getY(args) {
let landmark = parseInt(args.LANDMARK, 10) - 1;
let hand = parseInt(args.HAND_NUMBER, 10) - 1;
if (this.hands?.[hand]?.keypoints?.[landmark]) {
return 180 - this.hands[hand].keypoints[landmark].y * this.ratio;
let keypoint = parseInt(args.KEYPOINT, 10) - 1;
let hand = parseInt(args.HAND, 10) - 1;
if (this.hands?.[hand]?.keypoints?.[keypoint]) {
return 180 - this.hands[hand].keypoints[keypoint].y * this.ratio;
} else {
return null;
return '';
}
}

Expand Down

0 comments on commit 0166614

Please sign in to comment.