Skip to content

Commit b25e000

Browse files
authored
Merge pull request #2383 from entrylabs/issue/5333-2
이슈 5333 추가 이슈 처리
2 parents 17679f8 + cd02d55 commit b25e000

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/graphicEngine/GEHelper.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,13 @@ class _GEHelper extends GEHelperBase {
289289
this.videoContainer = null;
290290
}
291291

292+
destroy() {
293+
this.videoContainer = null;
294+
this.faceIndicatorGraphic = null;
295+
this.poseIndicatorGraphic = null;
296+
this.objectIndicatorGraphic = null;
297+
}
298+
292299
hFlipVideoElement(canvasVideo: PIXI.Sprite | createjs.Bitmap): any {
293300
const { x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY } = canvasVideo;
294301
canvasVideo.setTransform(-x, y, -scaleX, scaleY, rotation, skewX, skewY, regX, regY);

src/util/videoUtils.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ class VideoUtils implements MediaUtilsInterface {
221221
}
222222

223223
try {
224+
if (!this.motionWorker) {
225+
this.motionWorker = new VideoMotionWorker();
226+
}
224227
/*
225228
NT11576 #11683
226229
파이어폭스는 기본적으로 4:3비율로만 비디오를 가져오게 되어있어서, 사이즈를 조절해야함.
@@ -251,7 +254,9 @@ class VideoUtils implements MediaUtilsInterface {
251254
});
252255
console.time('test');
253256
if (this.isChrome) {
254-
this.worker = new VideoWorker();
257+
if (!this.worker) {
258+
this.worker = new VideoWorker();
259+
}
255260
this.worker.onmessage = (e: { data: { type: String; message: any } }) => {
256261
const { type, message } = e.data;
257262
if (Entry.engine.state !== 'run' && type !== 'init') {
@@ -368,6 +373,7 @@ class VideoUtils implements MediaUtilsInterface {
368373
this.stream = stream;
369374
this.canvasVideo = GEHelper.getVideoElement(video);
370375
this.video = video;
376+
this.stopVideo();
371377
this.isInitialized = true;
372378
} catch (err) {
373379
console.log(err);
@@ -849,8 +855,9 @@ class VideoUtils implements MediaUtilsInterface {
849855
destroy() {
850856
this.disableAllModels();
851857
this.turnOffWebcam();
858+
this.reset();
852859
this.stopVideo();
853-
GEHelper.destroyWebcam();
860+
GEHelper.destroy();
854861
this.video = null;
855862
this.canvasVideo = null;
856863
this.inMemoryCanvas = null;
@@ -861,6 +868,8 @@ class VideoUtils implements MediaUtilsInterface {
861868
this.objects = [];
862869
this.poses = { predictions: [], adjacents: [] };
863870
this.faces = [];
871+
this.worker = null;
872+
this.motionWorker = null;
864873
this.isInitialized = false;
865874
}
866875

0 commit comments

Comments
 (0)