[在香蕉派上使用摄像头:安装 & C++/Python示例程序]/Using OpenCV on BananaPi : Install & example programs in C++ / Python

in #opencv8 years ago

You may know raspberry Pi, BananaPi is the similar open source hardware single-board computers.
你可能知道树莓派,BananaPi 是一款类似的 开源硬件单板计算机。

You can do a lot of interesting things on it.
你可以用它做很多有趣的事。

This article introduce you how to install OpenCV on it, and also provide two example program wrote in C++ and Python.
这篇文章向你介绍如何在BananaPi 安装OpenCV, 并且提供两个用C++和Python编写的示例程序。

Install / 安装

To install OpenCV on BananaPi, just run following command on terminal.
在BananaPi上安装OpenCV,只需执行如下指令:
sudo apt-get install libcv-dev

And to use it with Python, you also need to run following command.
为了让Python能够使用OpenCV,你需要执行如下指令:
sudo apt-get install python-opencv

Capture camera images and display /捕获摄像头图像并显示 (C++)

    #include <opencv2/highgui/highgui.hpp>
    #include <opencv2/core/core.hpp>
    using namespace cv;

    int main()
    {
        VideoCapture cap(0);
        if(!cap.isOpened())
        {
            return -1;
        }
        Mat frame;
        Mat edges;

        bool stop = false;
        while(!stop)
        {
            cap>>frame;
            imshow("http://www.godpub.com", frame);
            if(waitKey(20) >=0)
                stop = true;
        }
        return 0;
    }

Build /编译:
g++ -o cap cap.cpp -lopencv_core -lopencv_highgui

The result/ 执行效果

Capture camera images and display /捕获摄像头图像并显示 (Python)

    import cv2
    cap=cv2.VideoCapture(0)
    while True:
        ret, frame = cap.read()
        cv2.imshow('http://www.godpub.com',frame)
        if cv2.waitKey(10) == 27:
             break
    cv2.destroyAllWindows()

The result/ 执行效果

Enjoy it.

注:我以前写的香蕉派相关的文章,简单处理一下发这里,看看会受欢迎不?:)

Sort:  

看不大懂 ... 不过我支持,呵呵!

可以做很多好玩的东西,比如人脸识别,车牌识别之类的
然后最近玩steemit,把这些之前玩的都荒废了

看来这个题材也不受欢迎

加上food的tag可能會好點?:P

额,会挨打的

Great post, Banana Pi can do it.

好帖,这东西很有前途

谢谢:)

Coin Marketplace

STEEM 0.22
TRX 0.25
JST 0.039
BTC 95945.56
ETH 3335.53
USDT 1.00
SBD 3.19