Opencv 4 (c + +) solves “can’t find required data file: starry_night.jpg in function ‘findfile'”

Time:2022-1-8

In the official opencv tutorial: https://docs.opencv.org/4.x/db/deb/tutorial_display_image.html

In, when running the sample code, we will encounter the following error reports:

error: (-2:Unspecified error) OpenCV samples: Can’t find required data file: starry_night.jpg in function ‘findFile’

After checking [opencv installation path] / opencv / modules / core / SRC / utils / samples After the CPP code, we know that the reason for the error is that the environment variable is not set:

OPENCV_SAMPLES_DATA_PATH

 

So let’s set the environment variable:

sudo vi ~/.bashrc

add to:

export OPENCV_ SAMPLES_ DATA_ Path = [opencv installation path] / opencv / samples

source ~/.bashrc

 

So we can run the sample code normally.

 

Recommended Today

The whole tutorial of docker installation and use, installation / complete command / dockerfile image production / docker container arrangement and one click installation of nginx + redis + MySQL / visualizer portal (version 2022)

官网: https://docs.docker.com/ 官网: https://www.docker.com/ docker 镜像市场: https://hub.docker.com/ 一、docker 说明 1.1、docker 核心 1、Docker 是一个开源的应用容器引擎,基于 Go 语言 并遵从 Apache2.0 协议开源,Docker 是一个 CS 架构软件。 2、Docker 是一个虚拟化轻量级linux服务器,可以解决我们在开发环境中运行配置问题 3.、Docker的主要目标是‘build ,ship and run any app,anywhere’,一次封装,到处运行 4、容器是完全使用沙箱机制,相互之间不会有任何接口(类似 iPhone 的 app),更重要的是容器性能开销极低。 1.2、docker 版本问题 .Docker 从 17.03 版本之后分为 CE(Community Edition: 社区版) 和 EE(Enterprise Edition: 企业版),我们用社区版就可以了。 1.3、docker 架构( 3大核心) · 1、Images 镜像 (等于软件) · 2、Registry […]