Untitled

 avatar
unknown
javascript
a year ago
4.6 kB
5
Indexable
if (this.stopState !== false) {
              this.mediaRecorder.stop();
              let lastFootPointMean;
              let earlierFootPointMean;
              let lastPoints;
              let earlierPoints;
              let indexOfLastFootPointMean;
              for (let i = this.kamilFuncKeypoints.length - 1; i >= 0; i--) {
                lastPoints = this.kamilFuncKeypoints[i];
                const point13 = lastPoints.keypointList[13] !== "notConfident" ? lastPoints.keypointList[13][0] : undefined;
                const point14 = lastPoints.keypointList[14] !== "notConfident" ? lastPoints.keypointList[14][0] : undefined;
                if (point13 !== undefined && point14 !== undefined) {
                  lastFootPointMean = (point14 + point13) / 2;
                  indexOfLastFootPointMean = i;
                  break;
                } else if (point13 !== undefined) {
                  lastFootPointMean = point13;
                  indexOfLastFootPointMean = i;
                  break;
                } else if (point14 !== undefined) {
                  lastFootPointMean = point14;
                  indexOfLastFootPointMean = i;
                  break;
                }
              }
              if (indexOfLastFootPointMean !== undefined) {
                const earlierIndex = Math.max(0, indexOfLastFootPointMean - Math.ceil(this.kamilFuncKeypoints.length * 0.1));
                earlierPoints = this.kamilFuncKeypoints[earlierIndex];
                const earlierPoint13 = earlierPoints.keypointList[13] !== "notConfident" ? earlierPoints.keypointList[13][0] : undefined;
                const earlierPoint14 = earlierPoints.keypointList[14] !== "notConfident" ? earlierPoints.keypointList[14][0] : undefined;
                if (earlierPoint13 !== undefined && earlierPoint14 !== undefined) {
                  earlierFootPointMean = (earlierPoint14 + earlierPoint13) / 2;
                } else if (earlierPoint13 !== undefined) {
                  earlierFootPointMean = earlierPoint13;
                } else if (earlierPoint14 !== undefined) {
                  earlierFootPointMean = earlierPoint14;
                }
              }

              console.log("finish with time out");
              const lastTime = round((lastPoints.timestamp - this.startTime) / 1000, 2);
              const earlierTime = round((earlierPoints.timestamp - this.startTime) / 1000, 2);
              console.log("last time:", lastTime);
              console.log("earlier time:", earlierTime);
              const lastCompleteFrameWidth = Math.abs(firstFootKeypointMean - lastFootPointMean);
              const earlierCompleteFrameWidth = Math.abs(firstFootKeypointMean - earlierFootPointMean);
              console.log("frame width:", frameWidth);
              console.log("last complete frame width:", lastCompleteFrameWidth);
              console.log("earlier complete frame width:", earlierCompleteFrameWidth);
              const lastCompletePercentage = (lastCompleteFrameWidth * 100) / frameWidth;
              const earlierCompletePercentage = (earlierCompleteFrameWidth * 100) / frameWidth;
              console.log("last complete percentage:", lastCompletePercentage);
              console.log("earlier complete percentage:", earlierCompletePercentage);
              const lastRunMeter = (this.props.meter * lastCompletePercentage) / 100;
              const earlierRunMeter = (this.props.meter * earlierCompletePercentage) / 100;
              console.log("last Run Meter:", lastRunMeter);
              console.log("earlier Run Meter:", earlierRunMeter);
              const remainingTime = ((this.props.meter - lastRunMeter) * (lastTime - earlierTime)) / (lastRunMeter - earlierRunMeter);
              console.log("remaining Time:", remainingTime);
              const estimateTotalTime = round(lastTime + remainingTime, 2);
              console.log("estimate Total Time:", estimateTotalTime);
              this.heightMoveNet.push({ time: round(estimateTotalTime, 2), value: round(this.props.meter, 2) });
              this.velocityMoveNet.push({ time: round(estimateTotalTime, 2), value: round((this.props.meter - lastRunMeter) / remainingTime, 2) });
              const Velocity = round(this.props.meter / estimateTotalTime, 2); // m/sec
              const Acceleration = round(Velocity / estimateTotalTime, 2); // m/sec^2
              const power = round((personMass * this.props.meter) / estimateTotalTime, 2);
              this.addJumpState(this.props.meter, estimateTotalTime, power, Velocity, Acceleration, webcamRef.current.getScreenshot());
            }
Editor is loading...
Leave a Comment