Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Archaeologist] 画像処理のパフォーマンス向上 #14

Open
YusukeHirao opened this issue Apr 12, 2024 · 0 comments
Open

[Archaeologist] 画像処理のパフォーマンス向上 #14

YusukeHirao opened this issue Apr 12, 2024 · 0 comments

Comments

@YusukeHirao
Copy link
Member

同期処理もあり、CLIの出力が固まるレベルでパフォーマンスが悪い。

listener('create', { a: dataA.binary, b: dataB.binary });
const imgA = PNG.sync.read(dataA.binary);
const imgB = PNG.sync.read(dataB.binary);
const width = Math.max(imgA.width, imgB.width);
const height = Math.max(imgA.height, imgB.height);
listener('resize', { a: dataA.binary, b: dataB.binary, width, height });
const resizedA = await resizeImg(dataA.binary, width, height);
const resizedB = await resizeImg(dataB.binary, width, height);
listener('diff', { a: resizedA, b: resizedB });
const imgA_ = PNG.sync.read(resizedA);
const imgB_ = PNG.sync.read(resizedB);
const diffImage = new PNG({ width, height });
const matcheBytes = pixelmatch(imgA_.data, imgB_.data, diffImage.data, width, height);
const matches = 1 - matcheBytes / (width * height);
const imageABuffer = PNG.sync.write(imgA_);
const imageBBuffer = PNG.sync.write(imgB_);
const imageDiffBuffer = PNG.sync.write(diffImage);

非同期にしたり、worker_threadsを使ってサブプロセスに逃がすことを検討する。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant