diff --git a/LineDetection.html b/LineDetection.html index f50045749..07da98577 100644 --- a/LineDetection.html +++ b/LineDetection.html @@ -25,6 +25,8 @@ this.canvas.height = height; this.ctx = this.canvas.getContext('2d'); this.lastDetectedLine = []; + this.frameCount = 0; + this.allCoordinates = []; } async detectLine() { @@ -39,6 +41,14 @@ this.lastDetectedLine = lineCoordinates; } + if (this.frameCount < 7) { + this.allCoordinates.push(lineCoordinates); + this.frameCount++; + if (this.frameCount === 7) { + this.writeCoordinatesToFile(this.allCoordinates); + } + } + this.drawLine(this.lastDetectedLine); return this.canvas.toDataURL(); } catch (error) { @@ -83,6 +93,18 @@ }); this.ctx.stroke(); } + + writeCoordinatesToFile(allCoordinates) { + const content = allCoordinates.map((frame, index) => + `Frame ${index + 1}:\n${frame.map(coord => coord.join(',')).join('\n')}\n` + ).join('\n'); + const blob = new Blob([content], { type: 'text/plain' }); + const a = document.createElement('a'); + a.href = URL.createObjectURL(blob); + a.download = 'coordinates.txt'; + a.click(); + URL.revokeObjectURL(a.href); + } } let detector; @@ -119,4 +141,3 @@

Line Detection

Processed Image - diff --git a/extensions/src/doodlebot/index.ts b/extensions/src/doodlebot/index.ts index 207b3788b..be88c495f 100644 --- a/extensions/src/doodlebot/index.ts +++ b/extensions/src/doodlebot/index.ts @@ -100,6 +100,7 @@ export default class DoodlebotBlocks extends extension(details, "ui", "indicator text: "displayLine" }) async displayLine() { + console.log("displayLine"); if (!this.lineDetector) { const ipAddress = await this.doodlebot?.getIPAddress(); if (!ipAddress) {