Add sample image option (#136)
Signed-off-by: Justin Georgi <justin.georgi@gmail.com> Reviewed-on: #136
This commit is contained in:
@@ -94,8 +94,8 @@
|
||||
<f7-button style="height: auto; width: auto;" popover-close="#capture-popover" @click="selectImage('file')">
|
||||
<SvgIcon icon="photo_library" />
|
||||
</f7-button>
|
||||
<f7-button style="height: auto; width: auto;" popover-close="#capture-popover" @click="videoStream">
|
||||
<SvgIcon icon="videocam"/>
|
||||
<f7-button v-if="otherSettings.demo" style="height: auto; width: auto;" popover-close="#capture-popover" @click="selectImage('sample')">
|
||||
<SvgIcon icon="photo-sample"/>
|
||||
</f7-button>
|
||||
</f7-segmented>
|
||||
</f7-popover>
|
||||
@@ -286,6 +286,19 @@
|
||||
this.videoAvailable = await this.openCamera(this.$refs.image_container)
|
||||
if (this.videoAvailable) { return }
|
||||
}
|
||||
if (mode == 'sample') {
|
||||
f7.dialog.create({
|
||||
title: 'Sample images',
|
||||
buttons: [
|
||||
{text: 'Sample 1', close: true, onClick: () => this.getImage('sample1'), cssClass: 'avn-dialog-button'},
|
||||
{text: 'Sample 2', close: true, onClick: () => this.getImage('sample2'), cssClass: 'avn-dialog-button'},
|
||||
{text: 'Sample 3', close: true, onClick: () => this.getImage('sample3'), cssClass: 'avn-dialog-button'},
|
||||
{text: 'Cancel', close: true, color: 'red', cssClass: 'avn-dialog-button'}
|
||||
],
|
||||
verticalButtons: true
|
||||
}).open()
|
||||
return
|
||||
}
|
||||
this.$refs.image_chooser.click()
|
||||
},
|
||||
onFail (message) {
|
||||
@@ -341,15 +354,22 @@
|
||||
} else if (this.isCordova && this.imageLoadMode == "camera") {
|
||||
this.detecting = true
|
||||
resolve('data:image/jpg;base64,' + searchImage)
|
||||
} else {
|
||||
const searchImage = this.$refs.image_chooser.files[0]
|
||||
this.$refs.image_chooser.value=[]
|
||||
var reader = new FileReader()
|
||||
reader.addEventListener("load", () => {
|
||||
this.detecting = true
|
||||
resolve(reader.result)
|
||||
}
|
||||
var reader = new FileReader()
|
||||
reader.addEventListener("load", () => {
|
||||
this.detecting = true
|
||||
resolve(reader.result)
|
||||
})
|
||||
if (this.imageLoadMode == 'sample') {
|
||||
fetch(`../samples/${this.detectorName}-${searchImage}.jpeg`).then( resp => {
|
||||
return resp.blob()
|
||||
}).then(respBlob => {
|
||||
reader.readAsDataURL(respBlob)
|
||||
})
|
||||
reader.readAsDataURL(searchImage)
|
||||
} else {
|
||||
const fileImage = this.$refs.image_chooser.files[0]
|
||||
this.$refs.image_chooser.value=[]
|
||||
reader.readAsDataURL(fileImage)
|
||||
}
|
||||
})
|
||||
loadImage.then((imgData) => {
|
||||
|
||||
Reference in New Issue
Block a user