当前位置: 首页 > news >正文

【树莓派 picamera】

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

文章目录

  • 前言
    • https://www.cnblogs.com/uestc-mm/p/7606855.html
  • 一、picamera是什么?
  • 二、使用步骤
    • 1.引入库
    • 2.先要安装opencv
  • 总结


前言

想用树莓派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 textimage = frame.array# show the framecv2.imshow("Frame", image)key = cv2.waitKey(1) & 0xFF# clear the stream in preparation for the next framerawCapture.truncate(0)# if the `q` key was pressed, break from the loopif key == ord("q"):break

在这里插入图片描述

2.先要安装opencv

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

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

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

import cv2

如果没有出现错误,那么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

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

在这里插入图片描述

在这里插入图片描述

总结

让它继续装

http://www.lryc.cn/news/192405.html

相关文章:

  • HarmonyOS应用开发者基础认证【满分答案】
  • CSS 常用样式——定位属性类型及特点
  • 华纳云:Linux文件不存在无法删除如何解决
  • mysql增加字段语句转为Oracle语句
  • VMware搭载linux出现的bugs
  • websocket逆向-protobuf序列化与反序列化
  • 车载电子电器架构 —— 国产基础软件生态简介
  • CNN-generated images are surprisingly easy to spot... for now
  • 蓝桥杯(七段码,C++)
  • Master PDF Editor v5.9.70便携版
  • 【剑指Offer】20.表示数值的字符串
  • 2023年9月Web3行业月度发展报告区块链篇 | 陀螺科技会员专享
  • Unity 快捷键的一些记录
  • GIT指令 - git stash
  • LiveMedia视频中间件视频隐私打码直播解决方案
  • 关于神经网络的思考
  • CodeForces每日好题10.14
  • Python Django 之连接 Mysql 数据库详解
  • Java设计模式:Callback
  • 年底旺季,Shopee、Lazada如何通过测评补单技术打造产品权重收割流量
  • CentOS 7 安装 MySQL8.0
  • C# 往多线程传递安全参数的方法
  • Java之SPI
  • 【数据结构】算法的空间复杂度
  • 恢复Windows 11经典右键菜单:一条命令解决显示更多选项问题
  • Android:事件分发机制(二)
  • vue2时间处理插件——dayjs
  • 软考 系统架构设计师系列知识点之软件质量属性(6)
  • Python6-wxPython库
  • 使用OpenSSL的反弹shell