• 【树莓派 picamera】


    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


    前言

    想用树莓派libcamera ,结果一直安装不上,只能暂停。
    退而求次,使用picamera

    https://www.cnblogs.com/uestc-mm/p/7606855.html

    提示:以下是本篇文章正文内容,下面案例可供参考

    一、picamera是什么?

    PiCamera是树莓派官方提供的一个用于访问树莓派相机模块的Python库。它提供了一组简单的API,使得开发者可以通过Python代码控制树莓派的相机,实现拍摄照片、录制视频等功能。使用PiCamera库,可以方便地实现与相机模块的交互,进行图像处理和计算机视觉等方面的开发。

    二、使用步骤

    1.引入库

    代码如下(示例):

    # import the necessary packages
    from picamera.array import PiRGBArray
    from picamera import PiCamera
    import time
    import cv2
    # initialize the camera and grab a reference to the raw camera capture
    camera = PiCamera()
    camera.resolution = (640, 480)
    camera.framerate = 32
    camera.hflip = True
    camera.vflip = True
    rawCapture = PiRGBArray(camera, size=(640, 480))
    # allow the camera to warmup
    time.sleep(0.1)
    # capture frames from the camera
    for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
        # grab the raw NumPy array representing the image, then initialize the timestamp
        # and occupied/unoccupied text
        image = frame.array
        # show the frame
        cv2.imshow("Frame", image)
        key = cv2.waitKey(1) & 0xFF
        # clear the stream in preparation for the next frame
        rawCapture.truncate(0)
        # if the `q` key was pressed, break from the loop
        if key == ord("q"):
            break
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28

    在这里插入图片描述

    2.先要安装opencv

    要在树莓派上安装Python OpenCV,您可以按照以下步骤进行操作:

    1. 更新系统:使用以下命令更新您的树莓派系统:
    sudo apt-get update
    sudo apt-get upgrade
    
    • 1
    • 2
    1. 安装Python和相关依赖:确保您的树莓派上已经安装了Python和相关依赖。您可以使用以下命令来安装它们:
    sudo apt-get install python3 python3-dev python3-pip
    
    • 1
    1. 安装OpenCV的依赖库:使用以下命令安装OpenCV所需的依赖库:
    sudo apt-get install libopencv-dev
    
    • 1
    1. 安装Python OpenCV库:使用pip命令来安装Python OpenCV库。运行以下命令:
    pip3 install opencv-python
    
    • 1

    这将安装OpenCV的Python绑定和相关的库文件。
    5. 验证安装:安装完成后,您可以验证OpenCV是否正确安装。运行以下命令启动Python解释器并尝试导入OpenCV库:

    import cv2
    
    • 1

    如果没有出现错误,那么OpenCV已经成功安装。

    这样,您就完成了在树莓派上安装Python OpenCV的过程。您可以使用OpenCV库来处理和操作图像以及进行计算机视觉任务。

    pi@pi:~ $ pip cache purge
    Files removed: 1
    pi@pi:~ $ pip install pip -U
    pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
    Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
    Requirement already satisfied: pip in /usr/lib/python3/dist-packages (20.3.4)
    Collecting pip
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    在这里插入图片描述
    在这里插入图片描述
    等了好久好久

    在这里插入图片描述

    在这里插入图片描述

    总结

    让它继续装

  • 相关阅读:
    Function接口设计
    server2012 通过防火墙开启局域网内限定IP进行远程桌面连接
    java实现pdf转为word
    Java获取某天、某月或某年的开始结束日期或开始结束时间戳
    Mendeley教程(3)引用各种文献
    新同事把工作流引擎运用的炉火纯青,直接干掉几千行if else!
    基于ElasticSearch存储海量AIS数据:时空立方体索引篇
    linux 卸载php的最终方案
    时间序列预测—双向LSTM(Bi-LSTM)
    mongodb 基本概念
  • 原文地址:https://blog.csdn.net/ganhui13000/article/details/133827071