MCPcopy Create free account
hub / github.com/GoogleChrome/samples / transform

Function transform

mediastreamtrack/script.js:77–93  ·  view source on GitHub ↗
(videoFrame, controller)

Source from the content-addressed store, hash-verified

75
76 const transformer = new TransformStream({
77 async transform(videoFrame, controller) {
78 const bitmap = await createImageBitmap(videoFrame);
79 const detectedBarcodes = await barcodeDetector.detect(bitmap);
80 if (!detectedBarcodes.length) {
81 bitmap.close();
82 controller.enqueue(videoFrame);
83 return;
84 }
85 const timestamp = videoFrame.timestamp;
86 videoFrame.close();
87 const newFrame = await highlightBarcode(
88 bitmap,
89 timestamp,
90 detectedBarcodes
91 );
92 controller.enqueue(newFrame);
93 },
94
95 flush(controller) {
96 controller.terminate();

Callers

nothing calls this directly

Calls 2

highlightBarcodeFunction · 0.85
closeMethod · 0.45

Tested by

no test coverage detected