|
@@ -195,7 +195,7 @@ export default {
|
|
|
timer: null,
|
|
|
detector: null,
|
|
|
hand: 0,
|
|
|
- isC:false,
|
|
|
+ isC: false,
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
@@ -209,16 +209,25 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
start() {
|
|
|
- if(!this.isC){
|
|
|
+ if (!this.isC) {
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ var a = this.$store.state.function
|
|
|
+ .replace(/\ +/g, "")
|
|
|
+ .replace(/[\r\n]/g, "")
|
|
|
+ .replace("screen=1;", "");
|
|
|
+ if (a.indexOf("while") != 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log(a);
|
|
|
this.isZuan = true;
|
|
|
this.isCamera = true;
|
|
|
let video = this.$refs["video"];
|
|
|
setInterval(() => {
|
|
|
- this.handsFind(video);
|
|
|
+ this.handsFind(video);
|
|
|
|
|
|
- // window.requestAnimationFrame(this.start);
|
|
|
+ // window.requestAnimationFrame(this.start);
|
|
|
}, 1000);
|
|
|
},
|
|
|
zhuan(num) {
|
|
@@ -261,27 +270,69 @@ export default {
|
|
|
let _1316y = handsA[13].y / handsA[16].y;
|
|
|
let _1720y = handsA[17].y / handsA[20].y;
|
|
|
|
|
|
+ var a = this.$store.state.function
|
|
|
+ .replace(/\ +/g, "")
|
|
|
+ .replace(/[\r\n]/g, "")
|
|
|
+ .replace("screen=1;");
|
|
|
+ var array = a.split("if");
|
|
|
+ array.splice(0, 1);
|
|
|
+ /*石头剪刀布的转速 */
|
|
|
+ let buNum = 0;
|
|
|
+ let sNum = 0;
|
|
|
+ let jNum = 0;
|
|
|
+ /**1布2石头3剪刀 */
|
|
|
+ for (var i in array) {
|
|
|
+ if (array[i].indexOf("==(1)") != -1) {
|
|
|
+ buNum = parseInt(array[i].split("motor=")[1].split("}")[0]);
|
|
|
+ }
|
|
|
+ if (array[i].indexOf("==(2)") != -1) {
|
|
|
+ sNum = parseInt(array[i].split("motor=")[1].split("}")[0]);
|
|
|
+ }
|
|
|
+ if (array[i].indexOf("==(3)") != -1) {
|
|
|
+ jNum = parseInt(array[i].split("motor=")[1].split("}")[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (_58y > 1 && _912y > 1 && _1316y > 1 && _1720y > 1) {
|
|
|
console.log("布");
|
|
|
if (this.hand == 1) {
|
|
|
return;
|
|
|
}
|
|
|
this.hand = 1;
|
|
|
- this.zhuan(20);
|
|
|
+ if (this.timer) {
|
|
|
+ clearInterval(this.timer);
|
|
|
+ this.timer = null;
|
|
|
+ this.zhuan(buNum);
|
|
|
+ } else {
|
|
|
+ this.zhuan(buNum);
|
|
|
+ }
|
|
|
} else if (_58y < 1 && _912y < 1 && _1316y < 1 && _1720y < 1) {
|
|
|
console.log("石头");
|
|
|
if (this.hand == 2) {
|
|
|
return;
|
|
|
}
|
|
|
this.hand = 2;
|
|
|
- this.zhuan(0);
|
|
|
+ if (this.timer) {
|
|
|
+ clearInterval(this.timer);
|
|
|
+ this.timer = null;
|
|
|
+ this.zhuan(sNum);
|
|
|
+ } else {
|
|
|
+ this.zhuan(sNum);
|
|
|
+ }
|
|
|
} else if (_58y > 1 && _912y > 1 && _1316y < 1 && _1720y < 1) {
|
|
|
console.log("剪刀");
|
|
|
if (this.hand == 3) {
|
|
|
return;
|
|
|
}
|
|
|
this.hand = 3;
|
|
|
- this.zhuan(20);
|
|
|
+
|
|
|
+ if (this.timer) {
|
|
|
+ clearInterval(this.timer);
|
|
|
+ this.timer = null;
|
|
|
+ this.zhuan(jNum);
|
|
|
+ } else {
|
|
|
+ this.zhuan(jNum);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -301,7 +352,7 @@ export default {
|
|
|
})
|
|
|
.catch((error) => {
|
|
|
// console.error("摄像头开启失败,请检查摄像头是否可用!");
|
|
|
- _this.isC = false
|
|
|
+ _this.isC = false;
|
|
|
_this.$message.error("摄像头开启失败,请检查摄像头是否可用!");
|
|
|
});
|
|
|
},
|
|
@@ -348,7 +399,6 @@ export default {
|
|
|
},
|
|
|
|
|
|
async fnInit() {
|
|
|
- // debugger;
|
|
|
const model = handPoseDetection.SupportedModels.MediaPipeHands;
|
|
|
const detectorConfig = {
|
|
|
runtime: "mediapipe", // or 'tfjs'
|
|
@@ -356,15 +406,14 @@ export default {
|
|
|
// solutionPath: `https://cdn.jsdelivr.net/npm/@mediapipe/hands@${mpHands.VERSION}`,
|
|
|
solutionPath: `/static/hands`,
|
|
|
};
|
|
|
- // debugger;
|
|
|
this.detector = await handPoseDetection.createDetector(
|
|
|
model,
|
|
|
detectorConfig
|
|
|
);
|
|
|
- if (this.$store.state.function.indexOf("screen=1;") != -1) {
|
|
|
+ if (this.$store.state.function.indexOf("screen=1;") == 0) {
|
|
|
this.callCamera();
|
|
|
this.isC = true;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
this.isC = false;
|
|
|
}
|
|
|
},
|