You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

树莓派无法检测Freenove摄像头问题求助

树莓派无法检测Freenove 8MP摄像头的解决方案

问题概况

  • 设备:树莓派 + Freenove Camera Module for RPi (8MP)
  • 执行检测命令:
    vcgencmd get_camera
    
    输出:
    supported=0 detected=0, libcamera interfaces=0
    
  • 接线确认无误,但误插display排线接口时摄像头电源灯亮起,插入正确camera接口时灯不亮
  • 通过sudo raspi-config仅能看到「Legacy Camera」选项,启用后仍无法检测摄像头
  • 已完成系统更新(sudo apt update && sudo apt upgrade)并安装picamera包,问题未解决

测试代码

import picamera

class CameraTest:
    def __init__(self):
        self.camera = picamera.PiCamera()

    def capture_image(self, filename):
        self.camera.capture(filename)

    def close(self):
        self.camera.close()

if __name__ == "__main__":
    try:
        camera_test = CameraTest()
        camera_test.capture_image("test_image.jpg")
        print("Image captured successfully.")
    except Exception as e:
        print("An error occurred:", e)
    finally:
        camera_test.close()

运行报错

mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
An error occurred: Camera is not enabled. Try running 'sudo raspi- 
config' and ensure that the camera has been enabled.
Traceback (most recent call last):
File "/home/ben6brewer/Desktop/Greenhouse/CamTest.py", line 21, in
camera_test.close()
NameError: name 'camera_test' is not defined

解决步骤

1. 硬件与接口排查

  • 确认树莓派型号:RPi 4/400及更新型号的Camera接口为3.3V供电,而display接口是5V,摄像头电源灯可能只响应5V,所以灯不亮不代表Camera接口没供电。
  • 重新插拔排线:确保排线金属触点朝下(紧贴树莓派PCB),两端卡扣完全扣紧,排线无弯折、破损。
  • 交叉测试:把摄像头接到另一台正常树莓派上,排除摄像头本身故障。

2. 系统配置调整

  • 检查系统版本:执行cat /etc/os-release,如果是Bookworm及以上版本,默认使用libcamera框架,Legacy Camera仅兼容老系统,需切换配置:
    1. 运行sudo raspi-config
    2. 进入「Interface Options」→「Camera」(若未找到该选项,先禁用Legacy Camera)
    3. 启用Camera后重启树莓派
  • 禁用Legacy Camera:若之前开启了Legacy模式,先关闭(sudo raspi-config→「Interface Options」→「Legacy Camera」→Disable),避免与libcamera冲突,重启后再启用Camera选项。

3. 适配新系统的摄像头库

  • Bookworm及以上版本不再支持picamera,需安装picamera2:
    sudo apt install python3-picamera2
    
  • 替换测试代码(同时修复原代码中camera_test未初始化就调用close的bug):
    from picamera2 import Picamera2
    
    class CameraTest:
        def __init__(self):
            self.camera = Picamera2()
            # 配置静态拍照参数
            config = self.camera.create_still_configuration()
            self.camera.configure(config)
    
        def capture_image(self, filename):
            self.camera.start()
            self.camera.capture_file(filename)
            self.camera.stop()
    
        def close(self):
            self.camera.close()
    
    if __name__ == "__main__":
        camera_test = None
        try:
            camera_test = CameraTest()
            camera_test.capture_image("test_image.jpg")
            print("图片捕获成功。")
        except Exception as e:
            print("发生错误:", e)
        finally:
            if camera_test:
                camera_test.close()
    

4. 验证摄像头状态

  • 重启后执行libcamera-hello,若弹出预览窗口,说明摄像头正常工作。
  • 再次执行vcgencmd get_camera,正常输出应为supported=1 detected=1。

内容的提问来源于stack exchange,提问作者xampL

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 12:41:39