-
-
Save khaong/1cef8002dea2e49777a0664f3688b9dd to your computer and use it in GitHub Desktop.
add to image-util-e2e-specs.js
This file contains 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
it('should produce image results', async function () { | |
const fs = require('fs/promises'); | |
const output_images_path = path.resolve(__dirname, '..', '..', 'build', 'output'); | |
try { await fs.mkdir(output_images_path); } catch (error) {} | |
/* this is what works on my local setup, adjust as necessary for opencv4nodejs require */ | |
const packageName = 'opencv4nodejs'; | |
const globalPackageName = path.resolve(process.env.npm_config_prefix, 'lib', 'node_modules', packageName); | |
const cv = require(globalPackageName); | |
const {results, visualization} = await getImageOccurrences(originalImage, numberImage, {visualize: true, threshold: 0.8}); | |
const fullHighlightedImage = await cv.imdecodeAsync(visualization); | |
await cv.imwriteAsync(path.resolve(output_images_path, 'full-highlights.png'), fullHighlightedImage); | |
for (let i = 0; i < results.length; i++) { | |
const highlightedImage = await cv.imdecodeAsync(results[i].visualization); | |
await cv.imwriteAsync(path.resolve(output_images_path, `highlight-${i}.png`), highlightedImage); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment