2023/9/26
![]() |
https://www.switch-science.com/products/8940によると
|
libcamera-helloカメラで撮影している画像が5秒間表示される。
libcamera-hello -t 0でずっと表示できる。フォーカスの調整などには便利な機能だ。
$ make g++ -Wall capture.cpp -I /usr/include/opencv4 -lopencv_core /usr/bin/ld: /tmp/ccBuOzXu.o: in function `main': capture.cpp:(.text+0x30): undefined reference to `cv::VideoCapture::VideoCapture(int, int)' /usr/bin/ld: capture.cpp:(.text+0x3c): undefined reference to `cv::VideoCapture::isOpened() const' /usr/bin/ld: capture.cpp:(.text+0xc8): undefined reference to `cv::VideoCapture::read(cv::_OutputArray const&)' /usr/bin/ld: capture.cpp:(.text+0x144): undefined reference to `cv::imshow(std::__cxx11::basic_stringOepnCVのサイト(https://docs.opencv.org/4.5.1/index.html) を見るとライブラリ・APIについての説明があるので、cv::VideoCapture他を探す。, std::allocator > const&, cv::_InputArray const&)' /usr/bin/ld: capture.cpp:(.text+0x170): undefined reference to `cv::waitKey(int)' /usr/bin/ld: capture.cpp:(.text+0x1a0): undefined reference to `cv::VideoCapture::~VideoCapture()' /usr/bin/ld: capture.cpp:(.text+0x1fc): undefined reference to `cv::VideoCapture::~VideoCapture()' collect2: error: ld returned 1 exit status make: *** [Makefile:9: a.out] エラー 1 $
$ ./a.out [ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (1824) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src0 reported: Failed to allocate required memory. [ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (914) open OpenCV | GStreamer warning: unable to start pipeline [ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (501) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created Start grabbing Press any key to terminate ERROR! Blank frame grabbed管理者権限でlsmodを実行する。カメラそのものはimx219として認識している。
# lsmod |grep imx219 imx219 20480 1 v4l2_fwnode 24576 2 imx219,bcm2835_unicam v4l2_async 24576 3 v4l2_fwnode,imx219,bcm2835_unicam videodev 274432 9 v4l2_async,bcm2835_codec,imx219,videobuf2_v4l2,bcm2835_unicam,bcm2835_v4l2,videobuf2_common,v4l2_mem2mem,bcm2835_isp mc 61440 9 v4l2_async,videodev,bcm2835_codec,imx219,videobuf2_v4l2,bcm2835_unicam,videobuf2_common,v4l2_mem2mem,bcm2835_isp管理者権限でvcgencmdを実行する。カメラは見つからないらしい。
# vcgencmd get_camera supported=0 detected=0, libcamera interfaces=0 ---カメラが見つからない📷カメラモジュールを使ってOpenCVでキャプチャする - ⭐( https://zenn.dev/kotaproj/books/raspberrypi-tips/viewer/400_kiso_camera)によるとcamaraをLegacy Camera supportを有効にすればよいらしい。
raspi-confインターフェースオプションからカメラの設定を選ぶ。
# lsmod |grep imx219 --- imx219は見つからない bcm2835はある。 # vcgencmd get_camera supported=1 detected=1, libcamera interfaces=0 ---supported=1 detected=1でみつけたようだlibcamera-helloは実行に失敗する。 これはダメな設定かもしれない。
$ libcamera-hello libEGL warning: DRI2: failed to authenticate Made X/EGL preview window [0:05:33.338142193] [1574] INFO Camera camera_manager.cpp:297 libcamera v0.0.5+83-bde9b04f ERROR: *** no cameras available ***
$ ./a.out [ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (1824) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src0 reported: Failed to allocate required memory. [ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (914) open OpenCV | GStreamer warning: unable to start pipeline [ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (501) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created Start grabbing Press any key to terminate