Move result filter to app (#43)

Also changed chip colors to gradient from indexed list.

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>

Reviewed-on: Georgi_Lab/ALVINN_f7#43
This commit is contained in:
2023-12-12 20:32:20 -07:00
parent c805be725d
commit 1d7d8ca0d8

View File

@@ -14,7 +14,16 @@
<div ref="structure_box" style="border: solid 3px var(--avn-structure-box-color); position: absolute; display: none; box-sizing: border-box;" /> <div ref="structure_box" style="border: solid 3px var(--avn-structure-box-color); position: absolute; display: none; box-sizing: border-box;" />
</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;">
<f7-chip v-for="(result, idx) in resultData.detections" :class="(idx == selectedChip) ? 'selected-chip' : ''" :text="result.label" media=" " :tooltip="result.confidence.toFixed(1)" :media-bg-color="chipColor(result.confidence)" deleteable @click="selectChip(idx)" @delete="deleteChip(idx)" /> <f7-chip v-for="result in showResults.filter( r => { return r.aboveThreshold && r.isSearched && !r.isDeleted })"
:class="(result.resultIndex == selectedChip) ? 'selected-chip' : ''"
:text="result.label"
media=" "
:tooltip="result.confidence.toFixed(1)"
deleteable
@click="selectChip(result.resultIndex)"
@delete="deleteChip(result.resultIndex)"
:style="chipGradient(result.confidence)"
/>
</div> </div>
<f7-segmented class="image-menu" raised> <f7-segmented class="image-menu" raised>
<f7-button popover-open="#region-popover"> <f7-button popover-open="#region-popover">
@@ -99,6 +108,10 @@
align-self: stretch; align-self: stretch;
} }
.chip-media {
background-color: var(--chip-media-background) !important;
}
.chip-results { .chip-results {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
@@ -271,13 +284,24 @@
computed: { computed: {
debugDisplay () { debugDisplay () {
return this.debugText.join('<br/>') return this.debugText.join('<br/>')
},
showResults () {
var filteredResults = this.resultData.detections
var allSelect = this.detectorLabels.every( s => { return s.detect } )
var selectedLabels = this.detectorLabels
.filter( l => { return l.detect })
.map( l => { return l.name })
filteredResults.forEach( (d, i) => {
filteredResults[i].resultIndex = i
filteredResults[i].aboveThreshold = d.confidence >= this.detectorLevel
filteredResults[i].isSearched = allSelect || selectedLabels.includes(d.label)
})
return filteredResults
} }
}, },
methods: { methods: {
chipColor (confVal) { chipGradient (confVal) {
if (confVal >= 90) return 'green' return `--chip-media-background: hsl(${confVal / 100 * 120}deg 100% 50%)`
if (confVal >= 70) return 'lime'
return 'yellow'
}, },
setData () { setData () {
var self = this var self = this
@@ -298,6 +322,7 @@
self.resultData = JSON.parse(xhr.response) self.resultData = JSON.parse(xhr.response)
} }
/*
var detectStructures = {} var detectStructures = {}
if (this.detectorLabels.every( s => { return s.detect } )) { if (this.detectorLabels.every( s => { return s.detect } )) {
detectStructures['*'] = this.detectorLevel detectStructures['*'] = this.detectorLevel
@@ -311,6 +336,14 @@
"detect": detectStructures, "detect": detectStructures,
"data": this.reader.result.split(',')[1] "data": this.reader.result.split(',')[1]
} }
*/
var doodsData = {
"detector_name": this.detectorName,
"detect": {
"*": 1
},
"data": this.reader.result.split(',')[1]
}
xhr.send(JSON.stringify(doodsData)) xhr.send(JSON.stringify(doodsData))
} else { } else {
@@ -329,14 +362,14 @@
var loadResult = this.$refs.image_chooser.click() var loadResult = this.$refs.image_chooser.click()
}, },
selectChip ( iChip ) { selectChip ( iChip ) {
var imgWidth
var imgHeight
if (this.selectedChip == iChip) { if (this.selectedChip == iChip) {
this.resetView() this.resetView()
return return
} }
var imgWidth
var imgHeight
this.selectedChip = iChip this.selectedChip = iChip
const box = this.$refs.structure_box const box = this.$refs.structure_box
const img = this.$refs.image_src const img = this.$refs.image_src