当前位置:网站首页>Four functions of opencv
Four functions of opencv
2022-07-07 12:46:00 【When will we get ashore?】
The official start of the opencv Of learning !
1.imshow
2.imread
3.cvtcolor
4.imwrite
imshow(" Displays the name of the window ", Image name );// display picture
img=imread(" Picture path ");// Read in the picture
cvtcolor( Name of the image to be converted , The name of the image stored after conversion , Conversion effect );// Transform picture , E.g. grayscale image
imwrite(" route ", Picture name );// Save pictures Sample code :
Source file 1
#include<tupian.h>
void demo::color_demo(Mat &image)
{
Mat hsv, gray;
cvtColor(image, hsv, COLOR_BGR2HSV);
cvtColor(image, gray, COLOR_BGR2GRAY);
imshow(" Grayscale ", gray);
imshow("HSV", hsv);
imwrite("D:/hsv.png", hsv);
imwrite("D:/gray.png", gray);
}Source file 2
#include <iostream>
#include<tupian.h>
#include<opencv2\opencv.hpp>
using namespace std;
using namespace cv;
int main(int argc,char** argv)
{
Mat img;
img = imread("C:/Users/guoyongbin123/Desktop/C++/opencv4/opencv4/Lena.png");// Picture path
if (img.empty())
{
cout << " Please confirm that the image file name is correct " << endl;
return -1;
}
//Mat img1;
namedWindow("test", WINDOW_FREERATIO);
imshow("test", img);
demo me;
me.color_demo(img);
waitKey(0);
return 0;
}
The header file
#pragma once
#include<opencv2/opencv.hpp>using namespace cv;
class demo
{
public:
void color_demo(Mat &image);
};
Be careful :

1. Put the image to be imported in C Files in the same directory .
2. Add the file path to the containing directory , That is, find this file in Solution Explorer , Right click , Find the attribute ,VC++ Catalog , Find the directory containing , Add the file path shown above .
give the result as follows :

over!!!
边栏推荐
- Session
- SQL Lab (46~53) (continuous update later) order by injection
- Day-16 set
- leetcode刷题:二叉树24(二叉树的最近公共祖先)
- [statistical learning methods] learning notes - improvement methods
- Master formula. (used to calculate the time complexity of recursion.)
- 通讯协议设计与实现
- Aike AI frontier promotion (7.7)
- [statistical learning method] learning notes - support vector machine (I)
- 聊聊Redis缓存4种集群方案、及优缺点对比
猜你喜欢

Solve server returns invalid timezone Go to ‘Advanced’ tab and set ‘serverTimezone’ property manually

Decrypt gd32 MCU product family, how to choose the development board?

opencv的四个函数
![[statistical learning method] learning notes - support vector machine (I)](/img/3f/56db88d717d7cd6624b3d0867146e9.png)
[statistical learning method] learning notes - support vector machine (I)
![[statistical learning methods] learning notes - Chapter 5: Decision Tree](/img/0e/c60e04ab4a7ae4728cc76eff1c028a.png)
[statistical learning methods] learning notes - Chapter 5: Decision Tree

idm服务器响应显示您没有权限下载解决教程

leetcode刷题:二叉树21(验证二叉搜索树)

Tutorial on principles and applications of database system (007) -- related concepts of database

金融数据获取(三)当爬虫遇上要鼠标滚轮滚动才会刷新数据的网页(保姆级教程)

In the small skin panel, use CMD to enter the MySQL command, including the MySQL error unknown variable 'secure_ file_ Priv 'solution (super detailed)
随机推荐
leetcode刷题:二叉树23(二叉搜索树中的众数)
利用栈来实现二进制转化为十进制
Tutorial on the principle and application of database system (008) -- exercises on database related concepts
Preorder, inorder and postorder traversal of binary tree
[statistical learning methods] learning notes - Chapter 4: naive Bayesian method
Static comprehensive experiment
ip2long与long2IP 分析
Day-17 connection set
ACL 2022 | small sample ner of sequence annotation: dual tower Bert model integrating tag semantics
Polymorphism, final, etc
NPM instal reports agent or network problems
[疑难杂症]pip运行突然出现ModuleNotFoundError: No module named ‘pip‘
leetcode刷题:二叉树26(二叉搜索树中的插入操作)
SQL blind injection (WEB penetration)
Day-14 common APIs
BGP third experiment report
Object. Simple implementation of assign()
[statistical learning methods] learning notes - improvement methods
Static vxlan configuration
Vxlan static centralized gateway