change camera devices & import path
This commit is contained in:
parent
cdb9ec5b97
commit
3083ea8dcb
4 changed files with 32 additions and 13 deletions
|
|
@ -1,12 +1,12 @@
|
||||||
import { createApp, defineAsyncComponent } from 'vue'
|
import { createApp, defineAsyncComponent } from 'vue'
|
||||||
import App from './App.vue'
|
import App from '@/App.vue'
|
||||||
import './registerServiceWorker'
|
import '@/registerServiceWorker'
|
||||||
import router from './router'
|
import router from '@/router'
|
||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
|
|
||||||
import { Quasar, Dialog, Notify, Loading } from 'quasar'
|
import { Quasar, Dialog, Notify, Loading } from 'quasar'
|
||||||
import '@vuepic/vue-datepicker/dist/main.css'
|
import '@vuepic/vue-datepicker/dist/main.css'
|
||||||
import quasarUserOptions from './quasar-user-options'
|
import quasarUserOptions from '@/quasar-user-options'
|
||||||
|
|
||||||
import 'quasar/src/css/index.sass'
|
import 'quasar/src/css/index.sass'
|
||||||
import th from 'quasar/lang/th'
|
import th from 'quasar/lang/th'
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import axios from "axios"
|
||||||
import config from "process"
|
import config from "process"
|
||||||
// import { dotnetPath } from "../path/axiosPath";
|
// import { dotnetPath } from "../path/axiosPath";
|
||||||
// import { getToken } from "@baloise/vue-keycloak";
|
// import { getToken } from "@baloise/vue-keycloak";
|
||||||
import keycloak from "../plugins/keycloak"
|
import keycloak from "@/plugins/keycloak"
|
||||||
|
|
||||||
const axiosInstance = axios.create({
|
const axiosInstance = axios.create({
|
||||||
withCredentials: false,
|
withCredentials: false,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,9 @@ const initOptions = {
|
||||||
|
|
||||||
const keycloak = new Keycloak(initOptions);
|
const keycloak = new Keycloak(initOptions);
|
||||||
|
|
||||||
keycloak.onAuthSuccess = () => {}; //เพิ่มlogin สำเร็จจะมาทำฟังก์ชันนี้
|
keycloak.onAuthSuccess = () => {
|
||||||
|
//เพิ่มlogin สำเร็จจะมาทำฟังก์ชันนี้
|
||||||
|
};
|
||||||
|
|
||||||
await keycloak.init({ onLoad: "check-sso", checkLoginIframe: false }); //ทำการ connect keycloak
|
await keycloak.init({ onLoad: "check-sso", checkLoginIframe: false }); //ทำการ connect keycloak
|
||||||
export default keycloak;
|
export default keycloak;
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,33 @@
|
||||||
import Camera from 'simple-vue-camera'
|
import Camera from 'simple-vue-camera'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
const camera = ref<InstanceType<typeof Camera>>();
|
const camera = ref<InstanceType<typeof Camera>>()
|
||||||
|
|
||||||
const cameraIsOn = ref<boolean>(false)
|
const cameraIsOn = ref<boolean>(false)
|
||||||
|
const deviceCamera = ref<any>()
|
||||||
|
|
||||||
const cameraOff = () => {
|
const cameraOff = async () => {
|
||||||
cameraIsOn.value ? camera.value?.stop() : camera.value?.start()
|
// change camera device
|
||||||
|
if (cameraIsOn.value) {
|
||||||
|
camera.value?.stop()
|
||||||
|
} else {
|
||||||
|
await camera.value?.start()
|
||||||
|
changeCamera()
|
||||||
|
}
|
||||||
cameraIsOn.value = !cameraIsOn.value
|
cameraIsOn.value = !cameraIsOn.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// change camera device
|
||||||
|
const changeCamera = async () => {
|
||||||
|
const devices: any = await camera.value?.devices(['videoinput'])
|
||||||
|
const device = await devices[0]
|
||||||
|
camera.value?.changeCamera(device.deviceId)
|
||||||
|
deviceCamera.value = devices
|
||||||
|
}
|
||||||
|
|
||||||
// Use camera reference to call functions
|
// Use camera reference to call functions
|
||||||
const takePicture = async () => {
|
const takePicture = async () => {
|
||||||
const imageBlob = await camera.value?.snapshot(
|
const imageBlob = await camera.value?.snapshot(
|
||||||
{ width: 640, height: 480 },
|
{ width: 640, height: 640 },
|
||||||
'image/png',
|
'image/png',
|
||||||
0.5
|
0.5
|
||||||
)
|
)
|
||||||
|
|
@ -25,8 +39,8 @@ const takePicture = async () => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="row col-12">
|
<div class="row col-md-12 col-sm-12">
|
||||||
<div class="col-3">
|
<div class="col-md-3">
|
||||||
<Camera
|
<Camera
|
||||||
:resolution="{ width: 500, height: 500 }"
|
:resolution="{ width: 500, height: 500 }"
|
||||||
ref="camera"
|
ref="camera"
|
||||||
|
|
@ -36,7 +50,10 @@ const takePicture = async () => {
|
||||||
>I'm on top of the video</q-btn
|
>I'm on top of the video</q-btn
|
||||||
>
|
>
|
||||||
<q-btn color="primary" @click="takePicture">Take Picture</q-btn>
|
<q-btn color="primary" @click="takePicture">Take Picture</q-btn>
|
||||||
|
<q-btn color="primary" @click="changeCamera">changeCamera</q-btn>
|
||||||
</Camera>
|
</Camera>
|
||||||
|
|
||||||
|
{{ deviceCamera }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue