当前位置:网站首页>opencv的四个函数
opencv的四个函数
2022-07-07 10:33:00 【什么时候上岸?】
正式开始opencv的学习了!
1.imshow
2.imread
3.cvtcolor
4.imwrite
imshow("显示窗口的名字",图像名字);//显示图片
img=imread("图片路径");//读入图片
cvtcolor(待转换的图片名字,转换后储存的图片名字,转换效果);//变换图片,如变灰度图
imwrite("路径",图片名字);//储存图片示例代码:
源文件1
#include<tupian.h>
void demo::color_demo(Mat &image)
{
Mat hsv, gray;
cvtColor(image, hsv, COLOR_BGR2HSV);
cvtColor(image, gray, COLOR_BGR2GRAY);
imshow("灰度", gray);
imshow("HSV", hsv);
imwrite("D:/hsv.png", hsv);
imwrite("D:/gray.png", gray);
}源文件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");//图片路径
if (img.empty())
{
cout << "请确认图像文件名称是否正确" << endl;
return -1;
}
//Mat img1;
namedWindow("test", WINDOW_FREERATIO);
imshow("test", img);
demo me;
me.color_demo(img);
waitKey(0);
return 0;
}
头文件
#pragma once
#include<opencv2/opencv.hpp>using namespace cv;
class demo
{
public:
void color_demo(Mat &image);
};
注意:

1.把要导入的图片放在C文件同一目录。
2.把文件路径加入到包含目录,即在解决方案资源管理器找到本次的文件,右击,找到属性,VC++目录,找到包含目录,把上图的文件路径添加进去。
结果如下:

over!!!
边栏推荐
- Tutorial on principles and applications of database system (010) -- exercises of conceptual model and data model
- Upgrade from a tool to a solution, and the new site with praise points to new value
- 数据库系统原理与应用教程(008)—— 数据库相关概念练习题
- Dialogue with Wang Wenyu, co-founder of ppio: integrate edge computing resources and explore more audio and video service scenarios
- 2022A特种设备相关管理(锅炉压力容器压力管道)模拟考试题库模拟考试平台操作
- Experiment with a web server that configures its own content
- BGP third experiment report
- 【统计学习方法】学习笔记——支持向量机(上)
- Apache installation problem: configure: error: APR not found Please read the documentation
- 数据库系统原理与应用教程(010)—— 概念模型与数据模型练习题
猜你喜欢

EPP+DIS学习之路(1)——Hello world!

2022聚合工艺考试题模拟考试题库及在线模拟考试

Hi3516 full system type burning tutorial

Preorder, inorder and postorder traversal of binary tree

leetcode刷题:二叉树24(二叉树的最近公共祖先)

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

消息队列消息丢失和消息重复发送的处理策略

数据库系统原理与应用教程(010)—— 概念模型与数据模型练习题

About web content security policy directive some test cases specified through meta elements

【深度学习】图像多标签分类任务,百度PaddleClas
随机推荐
On valuation model (II): PE index II - PE band
SQL Lab (46~53) (continuous update later) order by injection
RHSA first day operation
【统计学习方法】学习笔记——提升方法
Tutorial on principles and applications of database system (007) -- related concepts of database
SQL injection -- Audit of PHP source code (take SQL lab 1~15 as an example) (super detailed)
Epp+dis learning path (1) -- Hello world!
"Series after reading" my God! It's so simple to understand throttling and anti shake~
Inverted index of ES underlying principle
通讯协议设计与实现
Zhimei creative website exercise
Financial data acquisition (III) when a crawler encounters a web page that needs to scroll with the mouse wheel to refresh the data (nanny level tutorial)
Object. Simple implementation of assign()
[pytorch practice] use pytorch to realize image style migration based on neural network
Cryptography series: detailed explanation of online certificate status protocol OCSP
Hi3516 full system type burning tutorial
H3C HCl MPLS layer 2 dedicated line experiment
leetcode刷题:二叉树26(二叉搜索树中的插入操作)
Routing strategy of multi-point republication [Huawei]
SQL head injection -- injection principle and essence