当前位置:网站首页>Opencv learning notes -day8 (keyboard typing (waitkey()); Wait for typing) action: triggers some action when the appropriate character is typed using the keyboard)
Opencv learning notes -day8 (keyboard typing (waitkey()); Wait for typing) action: triggers some action when the appropriate character is typed using the keyboard)
2022-06-30 08:47:00 【Chasing foot dream】
OpenCV Learning notes
day8- Keyboard response operation
function
waitKey(); Waiting for typing
When using the keyboard to type the appropriate characters Trigger certain actions
Code
quickopencv.h
#pragma once
#include <opencv2\highgui.hpp>
#include <opencv2\imgproc.hpp>
using namespace cv;
// Defining classes
class QuickDemo{
public:
void colorSpace_Demo(Mat &image);// Color space conversion function 2021-12-24
void mat_creation_demo(Mat &image);//Mat Object and creation 2021-12-27
void pixel_vist_Demo(Mat &image);// Read and write operation of image pixels 2022-1-3
void operators_demo(Mat &image);// Arithmetic operation of image pixels 2022-1-4
void tracking_bar_demo(Mat &image);// Scroll bar operation demonstration 2022-1-7
void key_demo(Mat &image);// Keyboard response operation 2022-1-12
};
OpencvTest.cpp
#include <iostream>
#include <opencv2\highgui.hpp>
#include <opencv2\imgproc.hpp>
#include<quickopencv.h>
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_NORMAL);// establish WINDOW_FREERATIO window
imshow(" window 1",scr);// Show in the created window
QuickDemo qd;
qd.key_demo(scr);// Type action
waitKey(0);
return 0;
}
#include <opencv2\highgui.hpp>
#include <opencv2\imgproc.hpp>
#include<quickopencv.h>
#include <iostream>
void QuickDemo::key_demo(Mat &image)
{
Mat dst = Mat::zeros(image.size(), image.type());
while (true)
{
int c = waitKey(100);
if (c == 27)// Key in ESC key sign out
{
break;
}
if (c == 49){
// Key in 1 You can type 1 when Add some features For example, convert to grayscale image
//std::cout << "you enter key #1" << std::endl;
cvtColor(image, dst, COLOR_BGR2GRAY);// Go gray
}
if (c == 50){
// Key in 2 turn hsv
//std::cout << "you enter key #2" << std::endl;
cvtColor(image, dst, COLOR_BGR2HSV);// turn hsv
}
if (c == 51){
// Key in 3 adjust brightness
Mat m = Mat::zeros(image.size(), image.type());
m = Scalar(50, 50, 50);
add(image,m,dst);
std::cout << "you enter key #3" << std::endl;
}
imshow(" Keyboard response ", dst);
}//while
}
Show results
When no characters are typed 
Key in 1 Convert to grayscale image 
Key in 2 Convert to hsv Images 
Key in 3 Pictures increase brightness 
type ESC key sign out
边栏推荐
- Gilbert Strang's course notes on linear algebra - Lesson 1
- Does the oscilloscope probe affect the measurement of capacitive load?
- Rew acoustic test (III): generate test signal
- About Lombok's @data annotation
- C#访问MongoDB并执行CRUD操作
- Use Huawei performance management service to configure the sampling rate on demand
- 挖财开户安全吗?怎么有人说不靠谱。
- Tidb 6.0: making Tso more efficient tidb Book rush
- JVM tuning related commands and explanations
- 2021-02-27
猜你喜欢

Rew acoustic test (III): generate test signal

Redis设计与实现(一)| 数据结构 & 对象

Redis design and Implementation (VIII) | transaction

Wechat official account third-party platform development, zero foundation entry. I want to teach you
![[kotlin collaboration process] complete the advanced kotlin collaboration process](/img/43/9c4b337caf406537e317dea2ed5f17.png)
[kotlin collaboration process] complete the advanced kotlin collaboration process

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

Redis design and Implementation (IV) | master-slave replication

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

Summary of common pytoch APIs

El input limit can only input numbers
随机推荐
Graffiti Wi Fi & ble SoC development slide strip
Comparison of two ways for C to access SQL Server database (SqlDataReader vs SqlDataAdapter)
Redis design and Implementation (VII) | publish & subscribe
mysql基础入门 动力节点[老杜]课堂作业
Maxiouassigner of mmdet line by line interpretation
自制GIF动态图-gifcam
Redis design and Implementation (IV) | master-slave replication
Flink Sql -- toAppendStream doesn‘t support consuming update and delete changes which
Alcohol tester scheme: what principle does the alcohol tester measure alcohol solubility based on?
php api获取二维码、组合生成图片
Detailed explanation of pytoch's scatter function
[data analysis and display]
【NVMe2.0b 14】NVMe Admin Command Set
2021-04-29
layer. Open processing method when the passed value is an array or the value is too long
Interference source current spectrum test of current probe
Unsupportedclassversionerror is reported when starting jar package. How to repair it
Anchorgenerator for mmdet line by line interpretation
Rew acoustic test (IV): test principle of rew
Pytorch BERT