当前位置:网站首页>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!!!
边栏推荐
- 对话PPIO联合创始人王闻宇:整合边缘算力资源,开拓更多音视频服务场景
- (to be deleted later) yyds, paid academic resources, please keep a low profile!
- Error in compiling libssl
- Sign up now | oar hacker marathon phase III midsummer debut, waiting for you to challenge
- leetcode刷题:二叉树21(验证二叉搜索树)
- ES底层原理之倒排索引
- "Series after reading" my God! It's so simple to understand throttling and anti shake~
- About sqli lab less-15 using or instead of and parsing
- Experiment with a web server that configures its own content
- 2022A特种设备相关管理(锅炉压力容器压力管道)模拟考试题库模拟考试平台操作
猜你喜欢
Sort out the garbage collection of JVM, and don't involve high-quality things such as performance tuning for the time being
普乐蛙小型5d电影设备|5d电影动感电影体验馆|VR景区影院设备
VSCode的学习使用
File upload vulnerability - upload labs (1~2)
《看完就懂系列》天哪!搞懂节流与防抖竟简单如斯~
Tutorial on principles and applications of database system (010) -- exercises of conceptual model and data model
Routing strategy of multi-point republication [Huawei]
What is an esp/msr partition and how to create an esp/msr partition
SQL Lab (32~35) contains the principle understanding and precautions of wide byte injection (continuously updated later)
SQL Lab (36~40) includes stack injection, MySQL_ real_ escape_ The difference between string and addslashes (continuous update after)
随机推荐
Hi3516 full system type burning tutorial
【统计学习方法】学习笔记——支持向量机(下)
leetcode刷题:二叉树21(验证二叉搜索树)
爱可可AI前沿推介(7.7)
Tutorial on the principle and application of database system (008) -- exercises on database related concepts
Airserver automatically receives multi screen projection or cross device projection
IPv6 experiment
EPP+DIS学习之路(2)——Blink!闪烁!
[Q&A]AttributeError: module ‘signal‘ has no attribute ‘SIGALRM‘
广州市召开安全生产工作会议
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)
SQL Lab (36~40) includes stack injection, MySQL_ real_ escape_ The difference between string and addslashes (continuous update after)
Configure an encrypted web server
Solve server returns invalid timezone Go to ‘Advanced’ tab and set ‘serverTimezone’ property manually
编译 libssl 报错
数据库系统原理与应用教程(008)—— 数据库相关概念练习题
Multi row and multi column flex layout
Upgrade from a tool to a solution, and the new site with praise points to new value
[pytorch practice] write poetry with RNN
SQL lab 1~10 summary (subsequent continuous update)