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

createImageBitmap, bitmap.close() safari can't use. #58

Closed
Jimmysh opened this issue Jan 12, 2021 · 1 comment
Closed

createImageBitmap, bitmap.close() safari can't use. #58

Jimmysh opened this issue Jan 12, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Jimmysh
Copy link

Jimmysh commented Jan 12, 2021

Issue Description

createImageBitmap, bitmap.close() safari can't use.

human/src/human.js

Lines 463 to 485 in 77408fc

async warmup(userConfig) {
const b64toBlob = (base64, type = 'application/octet-stream') => fetch(`data:${type};base64,${base64}`).then((res) => res.blob());
if (userConfig) this.config = mergeDeep(this.config, userConfig);
const video = this.config.videoOptimized;
this.config.videoOptimized = false;
let blob;
switch (this.config.warmup) {
case 'face': blob = await b64toBlob(sample.face); break;
case 'full': blob = await b64toBlob(sample.body); break;
default: blob = null;
}
if (!blob) return null;
const bitmap = await createImageBitmap(blob);
const t0 = now();
const warmup = await this.detect(bitmap, config);
const t1 = now();
bitmap.close();
log('Warmup', this.config.warmup, (t1 - t0), warmup);
this.config.videoOptimized = video;
return warmup;
}
}

createImageBitmap
ImageBitmap

Please back to

human/src/human.js

Lines 425 to 465 in 977f92f

async warmup(userConfig) {
if (userConfig) this.config = mergeDeep(this.config, userConfig);
return new Promise((resolve) => {
const video = this.config.videoOptimized;
this.config.videoOptimized = false;
let src;
let size;
switch (this.config.warmup) {
case 'face':
size = 256;
src = sample.face;
break;
case 'full':
size = 1200;
src = sample.body;
break;
default:
size = 0;
src = null;
}
const img = new Image(size, size);
img.onload = () => {
const canvas = (typeof OffscreenCanvas !== 'undefined') ? new OffscreenCanvas(size, size) : document.createElement('canvas');
canvas.width = size;
canvas.height = size;
const ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0);
const data = ctx.getImageData(0, 0, size, size);
const t0 = now();
this.detect(data, config).then((warmup) => {
const t1 = now();
log('Warmup', this.config.warmup, (t1 - t0), warmup);
this.config.videoOptimized = video;
resolve(warmup);
});
};
if (src) img.src = src;
else resolve(null);
});
}
}

@vladmandic vladmandic added the bug Something isn't working label Jan 12, 2021
@vladmandic
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants