Skip to content

Commit 4d8d677

Browse files
authored
Fix lint when syncing to g3. (#737)
PROCESS
1 parent 7cfdb63 commit 4d8d677

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

pose-detection/src/movenet/detector.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ class MoveNetDetector implements PoseDetector {
4444
private readonly enableSmoothing: boolean;
4545

4646
// Global states.
47-
private keypointsFilter = new KeypointsOneEuroFilter(KEYPOINT_FILTER_CONFIG);
47+
private readonly keypointsFilter =
48+
new KeypointsOneEuroFilter(KEYPOINT_FILTER_CONFIG);
49+
private readonly cropRegionFilterYMin = new LowPassFilter(CROP_FILTER_ALPHA);
50+
private readonly cropRegionFilterXMin = new LowPassFilter(CROP_FILTER_ALPHA);
51+
private readonly cropRegionFilterYMax = new LowPassFilter(CROP_FILTER_ALPHA);
52+
private readonly cropRegionFilterXMax = new LowPassFilter(CROP_FILTER_ALPHA);
4853
private cropRegion: BoundingBox;
49-
private cropRegionFilterYMin = new LowPassFilter(CROP_FILTER_ALPHA);
50-
private cropRegionFilterXMin = new LowPassFilter(CROP_FILTER_ALPHA);
51-
private cropRegionFilterYMax = new LowPassFilter(CROP_FILTER_ALPHA);
52-
private cropRegionFilterXMax = new LowPassFilter(CROP_FILTER_ALPHA);
5354

5455
constructor(
5556
private readonly moveNetModel: tfc.GraphModel,
@@ -426,7 +427,7 @@ class MoveNetDetector implements PoseDetector {
426427
* image.
427428
*/
428429
private initCropRegion(imageHeight: number, imageWidth: number) {
429-
let boxHeight, boxWidth, yMin, xMin;
430+
let boxHeight: number, boxWidth: number, yMin: number, xMin: number;
430431
if (!this.cropRegion) {
431432
// If it is the first frame, perform a best guess by making the square
432433
// crop at the image center to better utilize the image pixels and

pose-detection/src/test_util.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ export async function loadVideo(
4242
videoPath: string, videoFPS: number,
4343
callback: (video: poseDetection.PoseDetectorInput, timestamp: number) =>
4444
Promise<poseDetection.Pose[]>,
45-
expected: number[][][], model: poseDetection.SupportedModels) {
45+
expected: number[][][],
46+
model: poseDetection.SupportedModels): Promise<HTMLVideoElement> {
4647
// We override video's timestamp with a fake timestamp.
4748
let simulatedTimestamp: number;
4849
// We keep a pointer for the expected array.
@@ -67,7 +68,7 @@ export async function loadVideo(
6768
document.body.appendChild(canvas);
6869
const ctx = canvas.getContext('2d');
6970

70-
const promise = new Promise((resolve, reject) => {
71+
const promise = new Promise<HTMLVideoElement>((resolve, reject) => {
7172
video.onseeked = async () => {
7273
const poses = await callback(video, simulatedTimestamp);
7374
ctx.drawImage(video, 0, 0);
@@ -91,7 +92,7 @@ export async function loadVideo(
9192
simulatedTimestamp += SIMULATED_INTERVAL;
9293
idx++;
9394
} else {
94-
resolve();
95+
resolve(video);
9596
}
9697
};
9798
});
@@ -135,15 +136,17 @@ function drawSkeleton(
135136
ctx.strokeStyle = color;
136137
ctx.lineWidth = 2;
137138

138-
poseDetection.util.getAdjacentPairs(model).forEach(([i, j]) => {
139+
const pairs = poseDetection.util.getAdjacentPairs(model);
140+
for (const pair of pairs) {
141+
const [i, j] = pair;
139142
const kp1 = keypoints[i];
140143
const kp2 = keypoints[j];
141144

142145
ctx.beginPath();
143146
ctx.moveTo(kp1.x, kp1.y);
144147
ctx.lineTo(kp2.x, kp2.y);
145148
ctx.stroke();
146-
});
149+
}
147150
}
148151

149152
function draw(

posenet/src/multi_pose/max_heap.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ function half(k: number) {
2323
}
2424

2525
export class MaxHeap<T> {
26-
private priorityQueue: T[];
26+
private readonly priorityQueue: T[];
27+
private readonly getElementValue: (element: T) => number;
2728
private numberOfElements: number;
28-
private getElementValue: (element: T) => number;
2929

3030
constructor(maxSize: number, getElementValue: (element: T) => number) {
3131
this.priorityQueue = new Array(maxSize);

0 commit comments

Comments
 (0)