import cv from "."; async function test() { await cv.downloadAddon(); const fs = await import("fs"); // const buffer = fs.readFileSync("data/im1.jpeg") const res = await cv.imread("test_data/im1.jpeg"); // const res = await cv.imdecode(buffer); const cropIm = cv.crop(res, { x: 10, y: 10, width: 300, height: 200 }); console.log(cropIm.data) console.log(cv.imwrite("test_data/cropIm.jpg", cropIm)); fs.writeFileSync("test_data/base.jpg", cv.imencode(".jpg", res)!); const rotated = cv.warpAffine(res, cv.getRotationMatrix2D(100, 100, 50, 1), res.cols, res.rows); cv.imwrite("test_data/rotated.jpg", rotated); cv.imwrite("test_data/blur.jpg", cv.blur(res, 20, 20)); cv.imwrite("test_data/copyMakeBorder.jpg", cv.copyMakeBorder(res, 100, 30, 50, 40, cv.BORDER_CONSTANT)); cv.imwrite("test_data/flip.jpg", cv.flip(res, "both")); cv.rectangle(res, [10, 10, 200, 200], [0, 0, 255], 3); cv.circle(res, [200, 200], 200, [255, 0, 0], 4); cv.line(res, [100, 100], [300, 500], [0, 0, 255], 3); cv.ellipse(res, [300, 500], [200, 100], 45, 0, 360, [0, 255, 0], 3); cv.polylines(res, [[50, 50], [150, 150], [50, 150]], true, [255, 0, 255], 3); cv.fillConvexPoly(res, [[50, 50], [150, 150], [150, 50]], [255, 0, 255]); cv.drawMarker(res, [300, 200], [255, 255, 0]); cv.imwrite("test_data/draw.jpg", res); } test();