Add detection settings panel (#23)
Closes #14 and #20 Signed-off-by: Justin Georgi <justin.georgi@gmail.com> Reviewed-on: Georgi_Lab/ALVINN_f7#23
This commit is contained in:
@@ -29,7 +29,7 @@
|
|||||||
<f7-button style="height: auto; width: auto;" href="/detect/limbs/" popover-close="#region-popover">
|
<f7-button style="height: auto; width: auto;" href="/detect/limbs/" popover-close="#region-popover">
|
||||||
<img src="../assets/regions/limb.svg" />
|
<img src="../assets/regions/limb.svg" />
|
||||||
</f7-button>
|
</f7-button>
|
||||||
<f7-button disabled="true" style="height: auto; width: auto;" href="/detect/head/" popover-close="#region-popover">
|
<f7-button class="disabled" style="height: auto; width: auto;" href="/detect/head/" popover-close="#region-popover">
|
||||||
<img src="../assets/regions/headneck.svg" />
|
<img src="../assets/regions/headneck.svg" />
|
||||||
</f7-button>
|
</f7-button>
|
||||||
</f7-segmented>
|
</f7-segmented>
|
||||||
|
|||||||
@@ -3,10 +3,13 @@
|
|||||||
<!-- Top Navbar -->
|
<!-- Top Navbar -->
|
||||||
<f7-navbar :sliding="false" back-link="Back">
|
<f7-navbar :sliding="false" back-link="Back">
|
||||||
<f7-nav-title sliding>{{ regions[activeRegion] }}</f7-nav-title>
|
<f7-nav-title sliding>{{ regions[activeRegion] }}</f7-nav-title>
|
||||||
|
<f7-nav-right>
|
||||||
|
<f7-link icon-ios="f7:menu" icon-md="material:settings" panel-open="right"></f7-link>
|
||||||
|
</f7-nav-right>
|
||||||
</f7-navbar>
|
</f7-navbar>
|
||||||
<f7-block class="detect-grid">
|
<f7-block class="detect-grid">
|
||||||
<div class="image-container">
|
<div class="image-container">
|
||||||
<img :src="imageView" id="im-display" ref="image_src" style="flex: 1 1 0%; object-fit: scale-down; max-width: 100%; max-height: 100%; min-width: 0; min-height: 0;" />
|
<img :src="imageView" id="im-display" ref="image_src" style="flex: 1 1 0%; object-fit: contain; max-width: 100%; max-height: 100%; min-width: 0; min-height: 0;" />
|
||||||
<div ref="structure_box" style="border: solid 3px yellow; position: absolute; display: none;" />
|
<div ref="structure_box" style="border: solid 3px yellow; position: absolute; display: none;" />
|
||||||
</div>
|
</div>
|
||||||
<div v-if="resultData && resultData.detections" class="chip-results" style="grid-area: result-view; flex: 0 0 auto; align-self: center;">
|
<div v-if="resultData && resultData.detections" class="chip-results" style="grid-area: result-view; flex: 0 0 auto; align-self: center;">
|
||||||
@@ -16,30 +19,40 @@
|
|||||||
<f7-button popover-open="#region-popover">
|
<f7-button popover-open="#region-popover">
|
||||||
<img :src="imageRegion" />
|
<img :src="imageRegion" />
|
||||||
</f7-button>
|
</f7-button>
|
||||||
<f7-button @click="setData" :class="(imageLoaded) ? '' : 'disabled'">
|
|
||||||
<img src="../assets/icons/visibility.svg" />
|
|
||||||
</f7-button>
|
|
||||||
<f7-button @click="selectImage">
|
<f7-button @click="selectImage">
|
||||||
<img src="../assets/icons/image.svg" />
|
<img src="../assets/icons/image.svg" />
|
||||||
</f7-button>
|
</f7-button>
|
||||||
|
<f7-button @click="setData" :class="(imageLoaded) ? '' : 'disabled'">
|
||||||
|
<img src="../assets/icons/visibility.svg" />
|
||||||
|
</f7-button>
|
||||||
<f7-button @click="setData">
|
<f7-button @click="setData">
|
||||||
<img src="../assets/icons/videocam.svg" />
|
<img src="../assets/icons/videocam.svg" />
|
||||||
</f7-button>
|
</f7-button>
|
||||||
</f7-segmented>
|
</f7-segmented>
|
||||||
<input type="file" ref="image_chooser" @change="getImage()" accept="image/*" style="display: none;"/>
|
<input type="file" ref="image_chooser" @change="getImage()" accept="image/*" style="display: none;"/>
|
||||||
</f7-block>
|
</f7-block>
|
||||||
|
|
||||||
|
<f7-panel right cover>
|
||||||
|
<f7-page>
|
||||||
|
<f7-navbar title="Detection Settings"></f7-navbar>
|
||||||
|
<f7-list>
|
||||||
|
<f7-list-input v-model:value="detectSettings.level" :label="`Confidence % threshold: ${detectSettings.level}`" type="range" />
|
||||||
|
<f7-list-item accordion-item title="Structures">
|
||||||
|
<f7-accordion-content>
|
||||||
|
<f7-list>
|
||||||
|
<f7-list-item checkbox checked checkbox-icon="end" title="All/none" @change="selectAll"></f7-list-item>
|
||||||
|
<f7-list-item v-for="structure in detectSettings.filter" checkbox checkbox-icon="end" v-model:checked="structure.detect" :title="structure.name"></f7-list-item>
|
||||||
|
</f7-list>
|
||||||
|
</f7-accordion-content>
|
||||||
|
</f7-list-item>
|
||||||
|
</f7-list>
|
||||||
|
</f7-page>
|
||||||
|
</f7-panel>
|
||||||
</f7-page>
|
</f7-page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.detect-grid {
|
.detect-grid {
|
||||||
/*display: flex;
|
|
||||||
justify-content: flex-start;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: stretch;
|
|
||||||
height: calc(100% - var(--f7-navbar-height) - var(--f7-safe-area-top) - var(--f7-safe-area-bottom));
|
|
||||||
box-sizing: border-box;
|
|
||||||
width: 100vw;*/
|
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
grid-template-rows: 1fr auto min-content;
|
grid-template-rows: 1fr auto min-content;
|
||||||
@@ -60,6 +73,7 @@
|
|||||||
min-height: 0;
|
min-height: 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
align-self: stretch;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chip-results {
|
.chip-results {
|
||||||
@@ -166,7 +180,12 @@
|
|||||||
imageLoaded: false,
|
imageLoaded: false,
|
||||||
imageView: '../assets/icons/image.svg',
|
imageView: '../assets/icons/image.svg',
|
||||||
reader: new FileReader(),
|
reader: new FileReader(),
|
||||||
detectorName: ''
|
detectorName: '',
|
||||||
|
detectSettings: {
|
||||||
|
level: 50,
|
||||||
|
filter: []
|
||||||
|
},
|
||||||
|
serverSettings: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
@@ -191,6 +210,29 @@
|
|||||||
this.imageRegion = '../assets/regions/headneck.svg'
|
this.imageRegion = '../assets/regions/headneck.svg'
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
var loadServerSettings = localStorage.getItem('serverSettings')
|
||||||
|
if (loadServerSettings) this.serverSettings = JSON.parse(loadServerSettings)
|
||||||
|
var self = this
|
||||||
|
if (this.serverSettings && this.serverSettings.use) {
|
||||||
|
var modelURL = `http://${this.serverSettings.address}:${this.serverSettings.port}/detectors`
|
||||||
|
var xhr = new XMLHttpRequest()
|
||||||
|
xhr.open("GET", modelURL)
|
||||||
|
xhr.setRequestHeader('Content-Type', 'application/json')
|
||||||
|
xhr.onload = function () {
|
||||||
|
if (this.status !== 200) {
|
||||||
|
//this.response.text().then(function(message){alert(message)})
|
||||||
|
console.log(this.response)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var detectors = JSON.parse(this.response).detectors
|
||||||
|
self.detectSettings.filter = detectors
|
||||||
|
.find( d => { return d.name == self.detectorName } ).labels
|
||||||
|
.filter( l => { return l != "" } ).sort()
|
||||||
|
.map( l => { return {'name': l, 'detect': true} } )
|
||||||
|
}
|
||||||
|
|
||||||
|
xhr.send()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
chipColor (confVal) {
|
chipColor (confVal) {
|
||||||
@@ -200,10 +242,8 @@
|
|||||||
},
|
},
|
||||||
setData () {
|
setData () {
|
||||||
var self = this
|
var self = this
|
||||||
var loadServerSettings = localStorage.getItem('serverSettings')
|
if (this.serverSettings && this.serverSettings.use) {
|
||||||
if (loadServerSettings) var serverSettings = JSON.parse(loadServerSettings)
|
var modelURL = `http://${this.serverSettings.address}:${this.serverSettings.port}/detect`
|
||||||
if (serverSettings && serverSettings.use) {
|
|
||||||
var modelURL = `http://${serverSettings.address}:${serverSettings.port}/detect`
|
|
||||||
var xhr = new XMLHttpRequest()
|
var xhr = new XMLHttpRequest()
|
||||||
xhr.open("POST", modelURL)
|
xhr.open("POST", modelURL)
|
||||||
xhr.setRequestHeader('Content-Type', 'application/json')
|
xhr.setRequestHeader('Content-Type', 'application/json')
|
||||||
@@ -216,19 +256,33 @@
|
|||||||
self.resultData = JSON.parse(this.response)
|
self.resultData = JSON.parse(this.response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var detectStructures = {}
|
||||||
|
if (this.detectSettings.filter.every( s => { return s.detect } )) {
|
||||||
|
detectStructures['*'] = this.detectSettings.level
|
||||||
|
} else {
|
||||||
|
this.detectSettings.filter.forEach( s => {
|
||||||
|
if (s.detect) detectStructures[s.name] = this.detectSettings.level
|
||||||
|
})
|
||||||
|
}
|
||||||
var doodsData = {
|
var doodsData = {
|
||||||
"detector_name": this.detectorName,
|
"detector_name": this.detectorName,
|
||||||
"detect": {
|
"detect": detectStructures,
|
||||||
"*":50
|
"data": this.reader.result.split(',')[1]
|
||||||
}
|
}
|
||||||
}
|
|
||||||
doodsData.data = this.reader.result.split(',')[1]
|
|
||||||
|
|
||||||
xhr.send(JSON.stringify(doodsData))
|
xhr.send(JSON.stringify(doodsData))
|
||||||
} else {
|
} else {
|
||||||
|
//TODO
|
||||||
f7.dialog.alert('Using built-in model')
|
f7.dialog.alert('Using built-in model')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
selectAll (ev) {
|
||||||
|
if (ev.target.checked) {
|
||||||
|
this.detectSettings.filter.forEach( s => s.detect = true )
|
||||||
|
} else {
|
||||||
|
this.detectSettings.filter.forEach( s => s.detect = false )
|
||||||
|
}
|
||||||
|
},
|
||||||
selectImage () {
|
selectImage () {
|
||||||
var loadResult = this.$refs.image_chooser.click()
|
var loadResult = this.$refs.image_chooser.click()
|
||||||
},
|
},
|
||||||
@@ -248,7 +302,7 @@
|
|||||||
imgWidth = img.offsetHeight * imgAspect
|
imgWidth = img.offsetHeight * imgAspect
|
||||||
imgHeight = img.offsetHeight
|
imgHeight = img.offsetHeight
|
||||||
}
|
}
|
||||||
box.style.display = "block"
|
box.style.display = 'block'
|
||||||
box.style.left = `${(img.offsetWidth - imgWidth) / 2 + this.resultData.detections[iChip].left * imgWidth}px`
|
box.style.left = `${(img.offsetWidth - imgWidth) / 2 + this.resultData.detections[iChip].left * imgWidth}px`
|
||||||
box.style.top = `${(img.offsetHeight - imgHeight) / 2 + this.resultData.detections[iChip].top * imgHeight}px`
|
box.style.top = `${(img.offsetHeight - imgHeight) / 2 + this.resultData.detections[iChip].top * imgHeight}px`
|
||||||
box.style.width = `${(this.resultData.detections[iChip].right - this.resultData.detections[iChip].left) * imgWidth}px`
|
box.style.width = `${(this.resultData.detections[iChip].right - this.resultData.detections[iChip].left) * imgWidth}px`
|
||||||
@@ -260,10 +314,15 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
getImage () {
|
getImage () {
|
||||||
const example = this.$refs.image_chooser.files[0];
|
const searchImage = this.$refs.image_chooser.files[0]
|
||||||
this.imageView = URL.createObjectURL(example);
|
//Promise goes here?
|
||||||
this.reader.readAsDataURL(example)
|
this.imageView = URL.createObjectURL(searchImage)
|
||||||
this.imageLoaded = true;
|
this.reader.readAsDataURL(searchImage)
|
||||||
|
this.imageLoaded = true
|
||||||
|
this.resultData = {}
|
||||||
|
this.selectedChip = -1
|
||||||
|
const box = this.$refs.structure_box
|
||||||
|
box.style.display = 'none'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
<f7-page name="home">
|
<f7-page name="home">
|
||||||
<!-- Top Navbar -->
|
<!-- Top Navbar -->
|
||||||
<f7-navbar>
|
<f7-navbar>
|
||||||
|
|
||||||
<f7-nav-left>
|
<f7-nav-left>
|
||||||
<f7-link icon-ios="f7:menu" icon-md="material:menu" panel-open="left"></f7-link>
|
<f7-link icon-ios="f7:menu" icon-md="material:menu" panel-open="left"></f7-link>
|
||||||
</f7-nav-left>
|
</f7-nav-left>
|
||||||
@@ -23,7 +22,7 @@
|
|||||||
<f7-button class="region-button limbs" href="/detect/limbs/">
|
<f7-button class="region-button limbs" href="/detect/limbs/">
|
||||||
<img class="region-image" src="../assets/regions/limb.svg" />
|
<img class="region-image" src="../assets/regions/limb.svg" />
|
||||||
</f7-button>
|
</f7-button>
|
||||||
<f7-button class="region-button headneck" disabled="true" href="/detect/head/">
|
<f7-button class="region-button headneck disabled" href="/detect/head/">
|
||||||
<img class="region-image" src="../assets/regions/headneck.svg" />
|
<img class="region-image" src="../assets/regions/headneck.svg" />
|
||||||
</f7-button>
|
</f7-button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user