Created
August 27, 2018 19:10
-
-
Save hawkeye64/0d50330deb2a6fedb46968fbe871fe81 to your computer and use it in GitHub Desktop.
Extract Results Example
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); | |
const confidence = outputBlob.at(i, 2); | |
// output blobs are in a percentage | |
const bottomLeft = new cv.Point( | |
outputBlob.at(i, 3) * img.cols, | |
outputBlob.at(i, 6) * img.rows | |
); | |
const topRight = new cv.Point( | |
outputBlob.at(i, 5) * img.cols, | |
outputBlob.at(i, 4) * img.rows | |
); | |
// create a rect | |
const rect = new cv.Rect( | |
bottomLeft.x, | |
topRight.y, | |
topRight.x - bottomLeft.x, | |
bottomLeft.y - topRight.y | |
); | |
return ({ | |
classIndex, | |
confidence, | |
rect | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment