当前位置:网站首页>Opencv learning notes -day1 (image reading display imread, imshow, namedwindow)
Opencv learning notes -day1 (image reading display imread, imshow, namedwindow)
2022-06-30 08:47:00 【Chasing foot dream】
OpenCV Learning notes
day1- Image reading display
use OpenCV Development module , Open a picture in the host Directory ,
And displayed on the desktop
function :
highug Module imread,imshow,namedWindow,imwrite function
Mat imread(const string& filename, int flags=1)
| Parameters | explain |
|---|---|
| filename | Read the address file name of the file |
| flags | Read the color category of the image (flags=1:( Default parameters ) Said to return to 3 Channel image ;CV_LOAD_IMAGE_ANYEPTH: return 16bit or 32bit Images ( When entering the same depth ), Otherwise return to 8bit Images ;CV_LOAD_IMAGE_COLOR: Returns a monochrome image ;CV_LOAD_IMAGE_GRAYSCALE: Return to channel image ;0: Return to single channel image ;<0: Do not channel the image ;>0: Cast to 3 Channel image . |
example 1
// Image reading
Mat scr = imread("D:\\ Study \\OpenCV Study \\pictures\\image\\1.jpg");
- ,imshow() Display an image in the specified window
void imshow(const String& winname, InputArray mat);
| Parameters | explain |
|---|---|
| winname | const string& Type of winname, Refers to the window identification name to be displayed |
| mat | InputArray Type of mat, Refers to the image to be displayed |
notes:imshow() 1, Only support 8 Bits and floating-point numbers display RGB Color space ;
2, RGB Color space :B G R Three channels Three color combination 255255255 And transparent channels
example 2
imshow(" window 1",scr);// In the created window 1 Show
void namedWindow(const String& winname, int flags = WINDOW_AUTOSIZE);
| Parameters | explain |
|---|---|
| winname | const String& Of winname, The window name used as the window identifier |
| flags | The identification of the window , The general default is WINDOW_AUTOSIZE The size of the window is constrained by the displayed image |
notes:
CV_WINDOW_NORMAL Change the window to normal size or make it resizable ..
CV_WINDOW_AUTOSIZE The size of the window is constrained by the displayed image . The window is not resizable ..
CV_WINDOW_FULLSCREEN Change the window to full screen .
CV_WINDOW_FREERATIO Make windows resizable without ratio constraints .
CV_WINDOW_KEEPRATIO Make the window resizable , But keep the scale of the displayed image
example 3
namedWindow(" window 1", WINDOW_NORMAL);// establish WINDOW_FREERATIO window
int waitKey(int delay = 0);
waitKey The function is to constantly refresh the image , Frequency time delay, Unit is ms, The return value is the value pressed by the current keyboard , Return when there is no key -1
example 4
waitKey(0);// Infinite loop
while(1){
if(waitKey(100)==27)break; }
// In this program , tell OpenCv Wait for the user to trigger the event ,
// The waiting time is 100ms, If within this time period , The user presses ESC(ASCII Code for 27), And then jump out of the loop , otherwise , And then jump out of the loop
Code :
QuickDemo.cpp
#include <iostream>
#include <opencv2\highgui.hpp>
#include <opencv2\imgproc.hpp>
using namespace cv;
using namespace std;
int main()
{
Mat scr = imread("D:\\ Study \\OpenCV Study \\pictures\\image\\1.jpg");// Open a picture
if (!scr.data == 1)// Sentenced to empty
return -1;
namedWindow(" window 1", WINDOW_FREERATIO);// establish WINDOW_FREERATIO window
imshow(" window 1",scr);// Show in the created window
waitKey(0);// Time delay 0-> Constant delay 1-> Time delay 1ms
return 0;
}
notes:
The conditions for judging null ( As shown in the complete code above ):
1,scr.empty();// Determine whether it is a form ,if If it is not loaded successfully, it is blank ,print: could not laod image;
2,scr.data;//if(!scr.data)==1 Failed to read
边栏推荐
- 基于Svelte3.x桌面端UI组件库Svelte UI
- Understanding society at the age of 14 - reading notes on "happiness at work"
- Mmcv expanding CUDA operator beginner level chapter
- 2021-02-19
- C accesses mongodb and performs CRUD operations
- 一次cpu 跌底排查
- 【kotlin 协程】万字协程 一篇完成kotlin 协程进阶
- C#訪問SQL Server數據庫兩種方式的比較(SqlDataReader vs SqlDataAdapter)
- Anchorgenerator for mmdet line by line interpretation
- Wikimedia Foundation announces the first customers of its new commercial product "Wikimedia enterprise"
猜你喜欢

【kotlin 协程】万字协程 一篇完成kotlin 协程进阶

Codeworks 5 questions per day (1700 for each) - the third day

Flink Sql -- toAppendStream doesn‘t support consuming update and delete changes which

Redis设计与实现(五)| Sentinel哨兵

2021-05-06

Flink SQL custom connector

Pytorch BERT

Flink SQL 自定义 Connector

示波器探头对测量电容负荷有影响吗?

How can we get a satisfactory salary? These routines still need to be mastered
随机推荐
Gilbert Strang's course notes on linear algebra - Lesson 2
Redis design and Implementation (IV) | master-slave replication
关于Lombok的@Data注解
Anchorgenerator for mmdet line by line interpretation
[untitled]
Redis设计与实现(三)| 服务器与客户端的交互(事件IO模型)
【付费推广】常见问题合集,推荐榜单FAQ
VIM from dislike to dependence (21) -- cross file search
Unity 基础光照模型
[data analysis and display]
2021-05-06
酒精测试仪方案:酒精测试仪是根据什么原理测酒精溶度?
Is the reverse repurchase of treasury bonds absolutely safe? How to open an account online
[kotlin collaboration process] complete the advanced kotlin collaboration process
[untitled]
Emoji icons supported by markdown
2021-04-29
Interpretation of orientedrcnn papers
Occasionally, Flink data is overstocked, resulting in checkpoint failure
Redis设计与实现(八)| 事务