Lnton羚通关于如何使用nanoPC-T4 安装OpenCV?

nanoPC-T4 安装 OpenCV
Note: OpenCV has been pre-installed in FriendlyCore/FriendlyDesktop (Version after 201905) and does not require manual installation.

Please download the latest FriendlyCore/FriendlyDesktop Image file from the following URL: http://download.friendlyarm.com

安装OpenCV

按照上述配置刷机系统已经预装了 OpenCV;

建立 Python3 的 OpenCV 开发环境

注意:这里仅仅拷贝激活脚本,不做其他任何操作

git clone https://github.com/friendlyarm/install-opencv-on-friendlycore
cd install-opencv-on-friendlycore
cp examples/py/cv-env.sh /usr/bin/

测试

pi@NanoPC-T4:/media/nvme/install-opencv-on-friendlycore$ cd examples/py/
pi@NanoPC-T4:/media/nvme/install-opencv-on-friendlycore/examples/py$ . cv-env.sh 
(cv) pi@NanoPC-T4:/media/nvme/install-opencv-on-friendlycore/examples/py$ python ver.py 
4.2.0

虚拟环境激活 . cv-env.sh
虚拟环境退出 deactivate

建立 C++ 的 OpenCV 开发环境

OpenCV 在 nanoPC-T4 里已经预装了。

命令查看下版本号,/usr/local/bin/opencv_version

.
├── CMakeLists.txt
├── README.md
├── sample.png
└── showimage.cpp
# cmake needs this line 
cmake_minimum_required(VERSION 2.8) 

# Enable C++11 
set(CMAKE_CXX_STANDARD 11) 
set(CMAKE_CXX_STANDARD_REQUIRED TRUE) 

# Define project name 
project(showimage) 

# Find OpenCV, you may need to set OpenCV_DIR variable 
# to the absolute path to the directory containing OpenCVConfig.cmake file 
# via the command line or GUI 
find_package(OpenCV REQUIRED COMPONENTS core highgui calib3d) 
include_directories( ${OpenCV_INCLUDE_DIRS} ) 

# Declare the executable target built from your sources 
add_executable(showimage showimage.cpp) 

# Link your application with OpenCV libraries 
target_link_libraries(showimage ${OpenCV_LIBS})
#include 
#include 
#include 
#include 
#include 
#include  

using namespace std;
using namespace cv;

int main(int argc,char* argv[]) 
{
	Mat image = imread("sample.png");
	if (image.empty())
	{
		cout<<"no image"<
mkdir build 
cp sample.png build/
cd build
cmake .. 
make -j4
./showimage

别急,执行完这里会黑屏的,那还是因为环境没有配好,和代码没有关系。

继续执行以下命令:

su pi

输入密码: pi

export DISPLAY=:0.0
. setqt5env

再执行 ./showimage 效果正常。

lnton羚通专注于音视频算法、算力、云平台的高科技人工智能企业。 公司基于视频分析技术、视频智能传输技术、远程监测技术以及智能语音融合技术等, 拥有多款可支持ONVIF、RTSP、GB/T28181等多协议、多路数的音视频智能分析服务器/云平台。

Lnton羚通关于如何使用nanoPC-T4 安装OpenCV?_第1张图片

 

你可能感兴趣的:(算法,opencv,人工智能,计算机视觉)