当前位置:网站首页>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!!!
边栏推荐
猜你喜欢
2022聚合工艺考试题模拟考试题库及在线模拟考试
【统计学习方法】学习笔记——逻辑斯谛回归和最大熵模型
Day-18 hash table, generic
Vxlan 静态集中网关
On valuation model (II): PE index II - PE band
[statistical learning methods] learning notes - improvement methods
AirServer自动接收多画面投屏或者跨设备投屏
In the small skin panel, use CMD to enter the MySQL command, including the MySQL error unknown variable 'secure_ file_ Priv 'solution (super detailed)
Aike AI frontier promotion (7.7)
leetcode刷题:二叉树27(删除二叉搜索树中的节点)
随机推荐
What if does not match your user account appears when submitting the code?
layer弹出层的关闭问题
Tutorial on the principle and application of database system (008) -- exercises on database related concepts
Day-20 file operation, recursive copy, serialization
Static comprehensive experiment
图像像素读写操作
Realize all, race, allsettled and any of the simple version of promise by yourself
[疑难杂症]pip运行突然出现ModuleNotFoundError: No module named ‘pip‘
解决 Server returns invalid timezone. Go to ‘Advanced’ tab and set ‘serverTimezone’ property manually
Pule frog small 5D movie equipment | 5D movie dynamic movie experience hall | VR scenic area cinema equipment
The hoisting of the upper cylinder of the steel containment of the world's first reactor "linglong-1" reactor building was successful
数据库安全的重要性
Tutorial on principles and applications of database system (007) -- related concepts of database
The left-hand side of an assignment expression may not be an optional property access. ts(2779)
[pytorch practice] image description -- let neural network read pictures and tell stories
浅谈估值模型 (二): PE指标II——PE Band
AirServer自动接收多画面投屏或者跨设备投屏
Several methods of checking JS to judge empty objects
SQL blind injection (WEB penetration)
Idea 2021 Chinese garbled code