mirror of
https://github.com/ColonelParrot/jscanify.git
synced 2025-12-30 22:31:52 +00:00
Add base folder check, optimizations
This commit is contained in:
parent
2adb81c60f
commit
90cf5246c8
@ -1,8 +1,12 @@
|
||||
/*
|
||||
run tests with: npm test
|
||||
*/
|
||||
|
||||
console.log("RUNNING JSCANIFY TESTS");
|
||||
console.log("Warning: This may take a bit");
|
||||
|
||||
const { Canvas, createCanvas, Image, ImageData, loadImage } = require("canvas");
|
||||
const { writeFileSync, unlinkSync, existsSync } = require("fs");
|
||||
const { loadImage } = require("canvas");
|
||||
const { mkdirSync, writeFileSync, unlinkSync, existsSync } = require("fs");
|
||||
const assert = require("assert");
|
||||
|
||||
const jscanify = require("../src/jscanify-node");
|
||||
@ -13,6 +17,8 @@ const outputPaths = {
|
||||
extracted: __dirname + "/output/extracted.jpg",
|
||||
};
|
||||
|
||||
const baseFolder = __dirname.replaceAll("\\", "/") + "/output/";
|
||||
|
||||
const TEST_IMAGE_PATH = path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
@ -30,6 +36,10 @@ function setup() {
|
||||
unlinkSync(path);
|
||||
}
|
||||
});
|
||||
|
||||
if (!existsSync(baseFolder)) {
|
||||
mkdirSync(baseFolder);
|
||||
}
|
||||
}
|
||||
|
||||
function test() {
|
||||
@ -39,6 +49,7 @@ function test() {
|
||||
console.log("loading OpenCV.js...");
|
||||
scanner.loadOpenCV(function (cv) {
|
||||
console.log("Finished loading OpenCV.js");
|
||||
console.log("Writing test images to: " + baseFolder);
|
||||
describe("feature tests", function (done) {
|
||||
it("should highlight paper", function (done) {
|
||||
const highlighted = scanner.highlightPaper(testImage);
|
||||
@ -48,7 +59,7 @@ function test() {
|
||||
);
|
||||
|
||||
assert.ok(existsSync(outputPaths.highlight));
|
||||
done()
|
||||
done();
|
||||
});
|
||||
|
||||
it("should extract paper", function (done) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user