action_count
Advanced tools
Comparing version 1.0.10 to 1.0.11
{ | ||
"name": "action_count", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "test for npm package", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -12,4 +12,8 @@ var Person = require('./person_model') | ||
} | ||
clear() { | ||
this.person.online_action_number = 0 | ||
} | ||
} | ||
module.exports = ActionCount |
@@ -48,2 +48,4 @@ const math = require('mathjs') | ||
this.window_detect_vectors = [] | ||
// 0: idle, 1: 1st matched, 2: 2nd matched, 3: done | ||
this.windowState = 0 | ||
@@ -61,9 +63,10 @@ axios_inst.get("/template.json").then(response => { | ||
let frameBeg = frame_ids[0] | ||
let frameMid = frame_ids[frame_ids.length/2] | ||
console.log(frameMid) | ||
let frameMid = frame_ids[Math.floor(frame_ids.length/2)] | ||
let frameEnd = frame_ids[frame_ids.length-1] | ||
let pose_vector1 = this.action[frameBeg].compute_metrics() | ||
let pose_vector2 = this.action[frameEnd].compute_metrics() | ||
let pose_vector2 = this.action[frameMid].compute_metrics() | ||
let pose_vector3 = this.action[frameEnd].compute_metrics() | ||
this.window_detect_vectors.push(pose_vector1) | ||
this.window_detect_vectors.push(pose_vector2) | ||
this.window_detect_vectors.push(pose_vector3) | ||
console.log(this.window_detect_vectors) | ||
@@ -80,4 +83,4 @@ | ||
this.online_threshold = 300 | ||
this.window_detect_threshold = 200 | ||
this.online_threshold = 5000 | ||
this.window_detect_threshold = 70 | ||
@@ -104,9 +107,48 @@ this.online_action_valid_num = 1 | ||
let online_frame_vector = online_frame_kp.compute_metrics() | ||
if (this.online_action.length === 0) { | ||
let dist = euclidean(this.window_detect_vectors[0], online_frame_vector) | ||
this.windowState = 0; | ||
} | ||
let begDist = euclidean(this.window_detect_vectors[0], online_frame_vector) | ||
let midDist = euclidean(this.window_detect_vectors[1], online_frame_vector) | ||
let endDist = euclidean(this.window_detect_vectors[2], online_frame_vector) | ||
if (this.windowState === 0) { | ||
if (begDist >= this.window_detect_threshold) return false; | ||
console.log("1st dist: ", begDist) | ||
this.online_action.push(online_frame_kp) | ||
this.online_action_pose_metric.push(online_frame_vector) | ||
this.windowState = 1; | ||
} else if (this.windowState === 1) { | ||
this.online_action.push(online_frame_kp) | ||
this.online_action_pose_metric.push(online_frame_vector) | ||
if (begDist < this.window_detect_threshold && this.online_action.length > 5) { | ||
this.online_action.splice(0, this.online_action.length-5) | ||
this.online_action_pose_metric.splice(0, this.online_action_pose_metric.length-5) | ||
console.log(this.online_action_pose_metric.length) | ||
//console.log("1st dist: ", begDist) | ||
} | ||
if (midDist < this.window_detect_threshold) { | ||
if (this.online_action.length > 5) { | ||
console.log("2nd dist: ", midDist) | ||
this.windowState = 2; | ||
} | ||
} | ||
} else if (this.windowState === 2) { | ||
this.online_action.push(online_frame_kp) | ||
this.online_action_pose_metric.push(online_frame_vector) | ||
if (endDist < this.window_detect_threshold) { | ||
console.log("3rd dist: ", endDist) | ||
this.windowState = 3; | ||
return true; | ||
} | ||
} | ||
return false; | ||
this.online_frame_counter += 1 | ||
if (this.online_action.length === 0) { | ||
this.window_detect_left_dists.push(dist) | ||
if (dist < this.window_detect_threshold) { | ||
//console.log("euclidean distance: ", dist) | ||
this.online_action.push(online_frame_kp) | ||
this.online_action_pose_metric.push(online_frame_vector) | ||
console.log("euclidean distance: ", dist) | ||
this.current_window_index = [this.online_frame_counter] | ||
@@ -131,3 +173,3 @@ } | ||
console.log("win_index: ", this.current_window_index) | ||
//console.log("win_index: ", this.current_window_index) | ||
let online_pose_matrix = this.online_action_pose_metric | ||
@@ -138,4 +180,2 @@ this.online_action = [] | ||
online_pose_matrix = math.transpose(online_pose_matrix) | ||
console.log("length: ", this.template_pose_matrix[0].length, online_pose_matrix[0].length) | ||
let f = this.compute_similarity(this.template_pose_matrix, online_pose_matrix) | ||
@@ -199,4 +239,3 @@ console.log(f.dist, f.dif_max, f.dif_min) | ||
let dif_min = dif_max | ||
let dist = dtw.compute(M1[0], M2[0]) | ||
let dist = dtw.compute(M1[0], M2[0]) | ||
for (let i=1; i<M1.length; i++) { | ||
@@ -206,3 +245,5 @@ let dif = math.std(M1[i])/math.std(M2[i]) | ||
if (dif_min > dif) dif_min = dif; | ||
dist += dtw.compute(M1[i], M2[i]) | ||
let oneDist = dtw.compute(M1[i], M2[i]) | ||
dist += oneDist | ||
console.log("distance: ", oneDist) | ||
} | ||
@@ -209,0 +250,0 @@ dist /= M1.length |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16721
361