有没有一种简单的方法可以以灰度显示相机馈送?
我找到了一个 QR 码扫描应用程序的示例,可以将相机纹理作为灰度像素值数组处理,但我坚持显示灰度而不是 RGBA。
// Install a module which gets the camera feed as a UInt8Array.
XR.addCameraPipelineModule(
XR.CameraPixelArray.pipelineModule({luminance: true, width: 240, height: 320}))
// Install a module that draws the camera feed to the canvas.
XR.addCameraPipelineModule(XR.GlTextureRenderer.pipelineModule())
// Create our custom application logic for scanning and displaying QR codes.
XR.addCameraPipelineModule({
name = 'qrscan',
onProcessCpu = ({onProcessGpuResult}) => {
// CameraPixelArray.pipelineModule() returned these in onProcessGpu.
const { pixels, rows, cols, rowBytes } = onProcesGpuResult.camerapixelarray
const { wasFound, url, corners } = findQrCode(pixels, rows, cols, rowBytes)
return { wasFound, url, corners }
},
onUpdate = ({onProcessCpuResult}) => {
// These were returned by this module ('qrscan') in onProcessCpu
const {wasFound, url, corners } = onProcessCpuResult.qrscan
if (wasFound) {
showUrlAndCorners(url, corners)
}
},
})