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.
- Facial recognition system
- Segmentation and recognition
- Object detection
- Motion tracking
- Gesture recognition
- others
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.
#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:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· 写一个简单的SQL生成工具