当前位置:网站首页>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!!!
边栏推荐
- Attack and defense world - PWN learning notes
- Tutorial on principles and applications of database system (009) -- conceptual model and data model
- (to be deleted later) yyds, paid academic resources, please keep a low profile!
- 【二叉树】删点成林
- Day-15 common APIs and exception mechanisms
- [Q&A]AttributeError: module ‘signal‘ has no attribute ‘SIGALRM‘
- [Q&A]AttributeError: module ‘signal‘ has no attribute ‘SIGALRM‘
- Several methods of checking JS to judge empty objects
- [play RT thread] RT thread Studio - key control motor forward and reverse rotation, buzzer
- HZOJ #235. 递归实现指数型枚举
猜你喜欢
浅谈估值模型 (二): PE指标II——PE Band
In the small skin panel, use CMD to enter the MySQL command, including the MySQL error unknown variable 'secure_ file_ Priv 'solution (super detailed)
RHSA first day operation
数据库安全的重要性
解决 Server returns invalid timezone. Go to ‘Advanced’ tab and set ‘serverTimezone’ property manually
Vxlan static centralized gateway
Vxlan 静态集中网关
ps链接图层的使用方法和快捷键,ps图层链接怎么做的
Tutorial on the principle and application of database system (011) -- relational database
Inverted index of ES underlying principle
随机推荐
Several methods of checking JS to judge empty objects
Session
Day-19 IO stream
IPv6 experiment
Polymorphism, final, etc
SQL lab 11~20 summary (subsequent continuous update) contains the solution that Firefox can't catch local packages after 18 levels
普乐蛙小型5d电影设备|5d电影动感电影体验馆|VR景区影院设备
ps链接图层的使用方法和快捷键,ps图层链接怎么做的
Tutorial on principles and applications of database system (007) -- related concepts of database
Cryptography series: detailed explanation of online certificate status protocol OCSP
聊聊Redis缓存4种集群方案、及优缺点对比
Attack and defense world ----- summary of web knowledge points
Day-20 file operation, recursive copy, serialization
Static vxlan configuration
【从 0 开始学微服务】【00】课程概述
解决 Server returns invalid timezone. Go to ‘Advanced’ tab and set ‘serverTimezone’ property manually
xshell评估期已过怎么办
SQL head injection -- injection principle and essence
GCC compilation error
Sorting, dichotomy