Skip to content

Commit 45774ec

Browse files
authored
Merge pull request #221 from JingyuanZhang/master
fix(core): fix webgl_feed_process
2 parents 9988181 + f547b9f commit 45774ec

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

packages/paddlejs-core/src/mediaProcessor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ export default class MediaProcessor {
6868
}] as InputFeed[];
6969
}
7070

71-
this.pixelWidth = pixels.width;
72-
this.pixelHeight = pixels.height;
71+
this.pixelWidth = (pixels as HTMLImageElement).naturalWidth || pixels.width;
72+
this.pixelHeight = (pixels as HTMLImageElement).naturalHeight || pixels.height;
7373

7474

7575
this.fitToTargetSize(pixels, imageDataInfo, env.get('webgl_feed_process'));

packages/paddlejs-core/src/runner.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,17 @@ export default class Runner {
209209
return tensorData.find(tensor => tensor.tensorId.endsWith('_image'));
210210
}) as OpExecutor;
211211

212-
let imageInputTensor: Tensor = imageOp.opData.inputTensors[0];
213-
const imageInputTensorParams = imageInputTensor.opts;
214-
imageInputTensorParams.shape = feed[0].shape;
215-
imageInputTensorParams.data = feed[0].data;
216-
imageInputTensor = new Tensor(imageInputTensorParams);
217-
imageOp.opData.inputTensors = [imageInputTensor];
212+
const imageInputTensor = imageOp.opData.inputTensors.find(
213+
tensor => tensor.tensorId.endsWith('_image')
214+
);
215+
imageInputTensor.data = feed[0].data;
216+
217+
if (env.get('webgl_feed_process')) {
218+
const imageInputTensorParams = imageInputTensor.opts;
219+
imageInputTensorParams.shape = feed[0].shape;
220+
imageInputTensorParams.data = feed[0].data;
221+
imageOp.opData.inputTensors = [new Tensor(imageInputTensorParams)];
222+
}
218223
}
219224

220225
async execute() {

0 commit comments

Comments
 (0)