Open CV


Opencv (Open Source Computer Vision Library) is a library of programming functions mainly aimed at real-time computer version.

Get official release from SourceForge or get the latest sources from Github

Programming language

C++ interface. You can find API here.

Applications

All the links below need access to wikipedia, otherwise it is Unreachable.

OS support

  • Windows, Linux, macOS etc.
  • Android, iOS etc.

Installation in Linux

Environment: Fedora 35

# Install OpenCV from Fedora Linux Repository
sudo dnf install opencv opencv-contrib opencv-doc python3-opencv python3-matplotlib python3-numpy
# Test using Python
[limc@fedora Test]$ python
Python 3.10.1 (main, Jan 10 2022, 00:00:00) [GCC 11.2.1 20211203 (Red Hat 11.2.1-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2 as cv
>>> print(cv.__version__)
4.5.3
>>> exit()

print(cv.__version__) tells the OpenCV version. That indicates that the OpenCV and Python OpenCV libraries have been successfully installed.

Test in cpp

First, we write a piece of code, which just read and show an GBR image.
Note, starry_night.jpg should be placed in the source code directory in this test.
starry_night.jpg

#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
using namespace cv;
int main()
{
std::string image_path = samples::findFile("starry_night.jpg");
Mat img = imread(image_path, IMREAD_COLOR);
if(img.empty())
{
std::cout << "Could not read the image: " << image_path << std::endl;
return 1;
}
imshow("Display window", img);
int k = waitKey(0); // Wait for a keystroke in the window
if(k == 's')
{
imwrite("starry_night.png", img);
}
return 0;
}

Then, we compile and run using commands below.

[limc@fedora Test]$ g++ display_image.cpp `pkg-config --cflags --libs opencv`
[limc@fedora Test]$ ./a.out

Result:
image

posted @   Ahmad  阅读(149)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· 写一个简单的SQL生成工具
点击右上角即可分享
微信分享提示