RPi 2B python opencv camera demo example

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RPi 2B python opencv camera demo example相关的知识,希望对你有一定的参考价值。

/**************************************************************************************
 *                     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

二、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 doesnt 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)

 

以上是关于RPi 2B python opencv camera demo example的主要内容,如果未能解决你的问题,请参考以下文章

windows ssh RPi 2B

windows 远程桌面连接 RPi 2B

RPi 2B GPIO 测试

RPi 2B 自动发送获取的IP到固定邮箱

RPi 2B IPC webcam server

RPi 2B Raspbian system install