Open1

opencv4nodejsでWebカメラを使おうとするとエラーになる on Raspberry Pi 4B

光岡 高宏光岡 高宏

環境

  • Raspberry Pi 4B 8GB
  • OS: Raspbian GNU/Linux 10
  • Node.js v14.17.4
  • opencv4nodejs: 5.6.0

コード

import cv from 'opencv4nodejs';

try {
    console.log('start');
    
    const camera = new cv.VideoCapture(0);
    console.log('got camera');

    const image = await camera.readAsync();
    console.log('got image');

    cv.imshowWait('result', image); 
    console.log('end');
} catch (e){
    console.log("Couldn't start camera:", e)
}

出力

start

(node:1296): GStreamer-CRITICAL **: 22:54:57.949: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed