2023年11月9日 星期四

[RPi] 在 Bullseye 和 Buster 使用 ReSpeaker

多年前 seeed 自己維護,但目前只有更新到 2021(Buster) 

https://github.com/respeaker/seeed-voicecard 

後來有人看不下去,修改了核心驅動,並且持續維護,然後就被 fork 了 

https://github.com/seeed-studio-projects/seeed-voicecard 

因此之前我在 Buster 可以修改預設的音效卡,在 Bullseye 不行了 

PulseAudio Sound Server
$ pactl set-default-sink 1 # 1是3.5mm Audio Jack 

$ pactl set-default-sink 2 # 2是ReSpeaker

最後使用 HinTak 的,一切解決!
https://github.com/HinTak/seeed-voicecard

2023年11月5日 星期日

[Ubuntu] 安裝 libcamera + picamera2 失敗!

使用 Ubuntu 22.04 LTS (64-bit) 在 Pi4 實驗,核心版本

```

Linux ubuntu-desktop 5.15.0-1042-raspi #45-Ubuntu SMP PREEMPT Thu Oct 12 09:20:16 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux

```


libcamera 參考 Raspberry Pi 官方教學安裝

```

sudo apt-get install -y libcamera-dev libjpeg-dev libtiff5-dev
sudo apt-get install -y qtbase5-dev libqt5core5a libqt5gui5 libqt5widgets5
sudo apt-get install -y libavcodec-dev libavdevice-dev libavformat-dev libswresample-dev
sudo apt-get install -y python3-pip git python3-jinja2
sudo apt-get install -y libboost-dev
sudo apt-get install -y libgnutls28-dev openssl libtiff5-dev pybind11-dev
sudo apt-get install -y meson cmake
sudo apt-get install -y python3-yaml python3-ply
sudo apt-get install -y libglib2.0-dev libgstreamer-plugins-base1.0-dev

cd ~
git clone https://github.com/raspberrypi/libcamera.git
cd libcamera

meson setup build --buildtype=release -Dpipelines=rpi/vc4,rpi/pisp -Dipas=rpi/vc4,rpi/pisp -Dv4l2=true -Dgstreamer=enabled -Dtest=false -Dlc-compliance=disabled -Dcam=disabled -Dqcam=disabled -Ddocumentation=disabled -Dpycamera=enabled

ninja -C build -j4
sudo ninja -C build install

```

安裝完 libcamera 以後,再安裝 libcamera-apps

```

sudo apt-get install -y libpng-dev
sudo apt-get install -y cmake libboost-program-options-dev libdrm-dev libexif-dev pkg-config
sudo pip3 install ninja meson
sudo pip3 install --upgrade meson
 

cd ~
git clone https://github.com/raspberrypi/libcamera-apps.git
cd libcamera-apps

meson setup build -Denable_libav=true -Denable_drm=true -Denable_egl=true -Denable_qt=true -Denable_opencv=false -Denable_tflite=false
sudo meson install -C build -j4
sudo ninja -C build install
sudo ldconfig

```

安裝完畢後,使用 `libcamera-jpeg -o /tmp/test.jpg` 拍照 OK,但使用 `libcamera-hello -t 0` 預覽就只會出現訊息,但無法預覽

```

[0:02:27.474325545] [1730]  INFO Camera camera_manager.cpp:284 libcamera v0.1.0+99-4a23664b
[0:02:27.552392891] [1731]  WARN RPiSdn sdn.cpp:39 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise
[0:02:27.555707769] [1731]  WARN RPI vc4.cpp:390 Mismatch between Unicam and CamHelper for embedded data usage!
[0:02:27.557198504] [1731]  INFO RPI vc4.cpp:444 Registered camera /base/soc/i2c0mux/i2c@1/imx219@10 to Unicam device /dev/media1 and ISP device /dev/media0
[0:02:27.557285837] [1731]  INFO RPI pipeline_base.cpp:1142 Using configuration file '/usr/local/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'
Preview window unavailable
Mode selection for 1640:1232:12:P
    SRGGB10_CSI2P,640x480/0 - Score: 4504.81
    SRGGB10_CSI2P,1640x1232/0 - Score: 1000
    SRGGB10_CSI2P,1920x1080/0 - Score: 1541.48
    SRGGB10_CSI2P,3280x2464/0 - Score: 1718
    SRGGB8,640x480/0 - Score: 5504.81
    SRGGB8,1640x1232/0 - Score: 2000
    SRGGB8,1920x1080/0 - Score: 2541.48
    SRGGB8,3280x2464/0 - Score: 2718
Stream configuration adjusted
[0:02:27.562332876] [1730]  INFO Camera camera.cpp:1181 configuring streams: (0) 1640x1232-YUV420 (1) 1640x1232-SBGGR10_CSI2P
[0:02:27.563005299] [1731]  INFO RPI vc4.cpp:608 Sensor: /base/soc/i2c0mux/i2c@1/imx219@10 - Selected sensor format: 1640x1232-SBGGR10_1X10 - Selected unicam format: 1640x1232-pBAA
#0 (0.00 fps) exp 31455.00 ag 4.00 dg 1.00
#1 (30.00 fps) exp 29999.00 ag 3.94 dg 1.01
#2 (30.00 fps) exp 29999.00 ag 3.94 dg 1.01
#3 (30.01 fps) exp 29999.00 ag 3.94 dg 1.01
#4 (30.01 fps) exp 29999.00 ag 3.94 dg 1.01
#5 (30.00 fps) exp 29999.00 ag 3.94 dg 1.01
#6 (30.01 fps) exp 29999.00 ag 3.94 dg 1.01

```


之後想再安裝 picamera2,

```

sudo apt-get install -y libcap-dev
sudo apt-get install -y python3-prctl
sudo apt-get install -y python3-opencv
pip3 install picamera2

```


一直出現錯誤訊息。

```

ImportError: cannot import name 'ControlType' from 'libcamera' (unknown location)

```

 看了官方討論,目前還是沒有解決方法。