RPi 2B python opencv camera demo example

本文介绍如何在RPi2B上使用Python和OpenCV进行摄像头图像捕获。通过安装必要的OpenCV库,并提供了一个简单的Python脚本来演示如何从树莓派摄像头模块捕获图像并将其保存为JPEG文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/**************************************************************************************
 *                     RPi 2B python opencv camera demo example
 * 声明:
 *     本文主要记录RPi 2B 使用python opencv来获取图片的方式。
 *
 *                                                   2016-2-24 深圳 南山平山村 曾剑锋
 ************************************************************************************/

一、参考文档:
    1. OpenCV with Raspberry Pi Camera Face Detection Tutorial - Robotics with Python Raspberry Pi and GoPiGo p.7
        https://pythonprogramming.net/raspberry-pi-camera-opencv-face-detection-tutorial/
    2. Raspberry Pi OpenCV,在树莓派下使用opencv
        http://www.educity.cn/wenda/565761.html
3. 如何安装树莓派摄像头模块
https://linux.cn/article-3650-1.html
二、opencv install:   sudo apt-get update && sudo apt-get install libopencv-dev   sudo apt-get install python-opencv 三、example code #!/usr/bin/python import cv2 as cv import numpy import io import picamera # Create a memory stream so photos doesn't need to be saved in a file stream = io.BytesIO() # Get the picture (low resolution, so it should be quite fast) # Here you can also specify other parameters (e.g.:rotate the image) with picamera.PiCamera() as camera: camera.resolution = (320, 240) camera.capture(stream, format='jpeg') # Convert the picture into a numpy array buff = numpy.fromstring(stream.getvalue(), dtype=numpy.uint8) # Now creates an OpenCV image image = cv.imdecode(buff, 1) # Save the result image cv.imwrite('result.jpg', image)

 

转载于:https://www.cnblogs.com/zengjfgit/p/5223747.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值