This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
created: function () { | |
this.$root.$on('expand-tree', this.expandTree) | |
}, | |
beforeDestroy: function () { | |
this.$root.$off('expand-tree', this.expandTree) | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<q-tree | |
ref="folders" | |
:nodes="rootDir" | |
label-key="label" | |
node-key="nodeKey" | |
accordion | |
default-expand-all | |
:selected.sync="selected" | |
@lazy-load="lazyLoad" | |
/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expandTree: function (absolutePath) { | |
// get parts for the path | |
let parts = absolutePath.split(path.sep) | |
let path2 = '' | |
let lastNodeKey | |
// iterate through the path parts. | |
// This code will get the node. If the node is not found, | |
// it forces lazy-load by programmatically expanding | |
// the parent node. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const exec = require('child_process').exec | |
const fs = require('fs') | |
const path = require('path') | |
function getWindowsDrives (callback) { | |
if (!callback) { | |
throw new Error('getWindowsDrives called with no callback') | |
} | |
if (process.platform !== 'win32') { | |
throw new Error('getWindowsDrives called but process.plaform !== \'win32\'') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path') | |
const fs = require('fs') | |
/** | |
* Generator function that lists all files in a folder recursively | |
* in a synchronous fashion | |
* | |
* @param {String} folder - folder to start with | |
* @param {Number} recurseLevel - number of times to recurse folders | |
* @returns {IterableIterator<String>} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -type f -name "*Color*.jpg" -exec classify --image "{}" --confidence 30 \; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generate a random color | |
*/ | |
const getRandomColor = () => new cv.Vec(Math.random() * 255, Math.random() * 255, Math.random() * 255); | |
/** | |
* Returns a function that, for each prediction, draws a rect area with rndom color | |
* @param {Arry} predictions Array of predictions | |
*/ | |
const makeDrawClassDetections = (predictions) => (drawImg, getColor, thickness = 2) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Extracts results from a network OutputBob | |
* @param {Object} outputBlob The outputBlob returned from net.forward() | |
* @param {Object} img The image used for classification | |
*/ | |
const extractResultsCoco = (outputBlob, img) => { | |
return Array(outputBlob.rows).fill(0) | |
.map((res, i) => { | |
// get class index | |
const classIndex = outputBlob.at(i, 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Predicts classifications based on passed in image | |
* @param {Object} img The image to use for predictions | |
*/ | |
const predict = (img) => { | |
// white is the better padding color | |
const white = new cv.Vec(255, 255, 255) | |
// resize to model size | |
const theImage = img.resizeToMax(modelData.size, modelData.size).padToSquare(white) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// OpenCV | |
const cv = require('opencv4nodejs') | |
// initialize model from prototxt and modelFile | |
let net | |
if (dataFile === 'coco300' || dataFile === 'coco512') { | |
net = cv.readNetFromCaffe(prototxt, modelFile) | |
} | |
// read the image |