Clean up new video code
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import * as tf from '@tensorflow/tfjs'
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
async openCamera(imContain) {
|
||||
@@ -38,24 +36,6 @@ export default {
|
||||
const tempCtx = tempCVS.getContext('2d')
|
||||
tempCtx.drawImage(vidViewer, 0, 0)
|
||||
this.getImage(tempCVS.toDataURL())
|
||||
},
|
||||
async videoStream () {
|
||||
const vidElement = this.$refs.vid_viewer
|
||||
this.videoAvailable = false
|
||||
const devicesList = await navigator.mediaDevices.enumerateDevices()
|
||||
this.videoDeviceAvailable = devicesList.some( d => d.kind == "videoinput")
|
||||
if (this.videoDeviceAvailable) {
|
||||
var vidConstraint = {
|
||||
//resizeWidth: 640,
|
||||
//resizeHeight: 640,
|
||||
facingMode: 'environment'
|
||||
}
|
||||
tf.data.webcam(vidElement, vidConstraint).then( webData => {
|
||||
this.videoAvailable = true
|
||||
this.cameraStream = vidElement.captureStream()
|
||||
this.videoFrameDetect(webData)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
import * as tf from '@tensorflow/tfjs'
|
||||
import { image } from '@tensorflow/tfjs'
|
||||
import { f7 } from 'framework7-vue'
|
||||
import { nextTick } from 'vue'
|
||||
|
||||
var model = null
|
||||
|
||||
@@ -11,7 +9,10 @@ export default {
|
||||
model = await tf.loadGraphModel(weights)
|
||||
const [modelWidth, modelHeight] = model.inputs[0].shape.slice(1, 3)
|
||||
const dummyT = tf.ones([1,modelWidth,modelHeight,3])
|
||||
model.predict(dummyT) //Run model once to preload weights for better response time
|
||||
/*****************
|
||||
* Run model once to preload weights for better response time
|
||||
*****************/
|
||||
model.predict(dummyT)
|
||||
return model
|
||||
},
|
||||
async localDetect(imageData) {
|
||||
|
||||
Reference in New Issue
Block a user