当前位置:网站首页>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!!!
边栏推荐
- Tutorial on the principle and application of database system (008) -- exercises on database related concepts
- Ctfhub -web SSRF summary (excluding fastcgi and redI) super detailed
- Decrypt gd32 MCU product family, how to choose the development board?
- SQL lab 21~25 summary (subsequent continuous update) (including secondary injection explanation)
- [疑难杂症]pip运行突然出现ModuleNotFoundError: No module named ‘pip‘
- Zhimei creative website exercise
- PHP调用纯真IP数据库返回具体地址
- 金融数据获取(三)当爬虫遇上要鼠标滚轮滚动才会刷新数据的网页(保姆级教程)
- OSPF exercise Report
- [pytorch practice] write poetry with RNN
猜你喜欢
How to apply @transactional transaction annotation to perfection?
RHSA first day operation
Processing strategy of message queue message loss and repeated message sending
About sqli lab less-15 using or instead of and parsing
(to be deleted later) yyds, paid academic resources, please keep a low profile!
leetcode刷题:二叉树21(验证二叉搜索树)
[pytorch practice] use pytorch to realize image style migration based on neural network
What is an esp/msr partition and how to create an esp/msr partition
Several ways to clear floating
【PyTorch实战】用PyTorch实现基于神经网络的图像风格迁移
随机推荐
SQL Lab (32~35) contains the principle understanding and precautions of wide byte injection (continuously updated later)
Solutions to cross domain problems
OSPF exercise Report
visual stdio 2017关于opencv4.1的环境配置
layer弹出层的关闭问题
图像像素读写操作
Dialogue with Wang Wenyu, co-founder of ppio: integrate edge computing resources and explore more audio and video service scenarios
SQL lab 11~20 summary (subsequent continuous update) contains the solution that Firefox can't catch local packages after 18 levels
Several ways to clear floating
ACL 2022 | 序列标注的小样本NER:融合标签语义的双塔BERT模型
Inverted index of ES underlying principle
ip2long与long2IP 分析
sql-lab (54-65)
【统计学习方法】学习笔记——支持向量机(下)
用mysql查询某字段是否有索引
Ctfhub -web SSRF summary (excluding fastcgi and redI) super detailed
如何将 @Transactional 事务注解运用到炉火纯青?
leetcode刷题:二叉树22(二叉搜索树的最小绝对差)
SQL Lab (36~40) includes stack injection, MySQL_ real_ escape_ The difference between string and addslashes (continuous update after)
有什么类方法或是函数可以查看某个项目的Laravel版本的?