Skip to content
Snippets Groups Projects
Commit b56b1b99 authored by Edward Alexander Jaya's avatar Edward Alexander Jaya
Browse files

Add zip file to pascal voc

parent 0904b808
Branches
1 merge request!42Dev
Pipeline #27730 canceled with stage
...@@ -17,7 +17,9 @@ ...@@ -17,7 +17,9 @@
"bootstrap-vue": "^2.0.0", "bootstrap-vue": "^2.0.0",
"cookieparser": "^0.1.0", "cookieparser": "^0.1.0",
"debounce": "^1.2.0", "debounce": "^1.2.0",
"file-saver": "^2.0.2",
"js-cookie": "^2.2.1", "js-cookie": "^2.2.1",
"jszip": "^3.4.0",
"nuxt": "^2.0.0", "nuxt": "^2.0.0",
"nuxt-dropzone": "^1.0.4", "nuxt-dropzone": "^1.0.4",
"vue-json-viewer": "^2.2.11", "vue-json-viewer": "^2.2.11",
......
...@@ -52,6 +52,8 @@ import pascalMethods from '~/mixins/outputs/pascalMethods' ...@@ -52,6 +52,8 @@ import pascalMethods from '~/mixins/outputs/pascalMethods'
import Convert from 'xml-js' import Convert from 'xml-js'
import Label from '~/components/label/Label' import Label from '~/components/label/Label'
import Dropdown from '~/components/dropdown/Dropdown' import Dropdown from '~/components/dropdown/Dropdown'
import JSZip from 'jszip'
import { saveAs } from 'file-saver'
export default { export default {
components: { components: {
...@@ -70,17 +72,22 @@ export default { ...@@ -70,17 +72,22 @@ export default {
methods: { methods: {
async getPascalXML () { async getPascalXML () {
this.pascalJSON = {} this.pascalJSON = {}
var newPascalJSON = {"annotation": []}
var allImages = await this.getAllImages() var allImages = await this.getAllImages()
if (allImages) { if (allImages) {
// Generate zip file
var zip = new JSZip()
// Get information about labels
var allLabels = await this.getAllLabel() var allLabels = await this.getAllLabel()
// These methods are available in mixins
await this.setImagesAttr(allImages) await this.setImagesAttr(allImages)
await this.getObjectsAttr(allLabels) await this.getObjectsAttr(allLabels)
console.log('pascal: ', this.pascalJSON)
for (var key in this.pascalJSON) { for (var key in this.pascalJSON) {
newPascalJSON["annotation"].push(this.pascalJSON[key]) var xml = this.convertToXML(this.pascalJSON[key])
zip.file(this.pascalJSON[key].filename + '.xml', xml)
} }
return newPascalJSON zip.generateAsync({type:'blob'}).then((content) => {
saveAs(content, this.dataset)
})
} }
}, },
async setImagesAttr (allImages) { async setImagesAttr (allImages) {
...@@ -99,16 +106,7 @@ export default { ...@@ -99,16 +106,7 @@ export default {
return result return result
}, },
async downloadXML() { async downloadXML() {
var filename = 'XMLFile.xml' await this.getPascalXML()
var element = document.createElement('a')
var newPascalJSON = await this.getPascalXML()
var xml = this.convertToXML(newPascalJSON)
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(xml))
element.setAttribute('download',filename)
element.style.display = 'none'
document.body.appendChild(element)
element.click()
document.body.removeChild(element)
} }
} }
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment