当前位置:网站首页>Opencv learning (5) mouse operation normalized zoom image flipping
Opencv learning (5) mouse operation normalized zoom image flipping
2022-07-20 15:18:00 【@[email protected]】
1. Mouse events
Mouse events are mainly through setMouseCallback Function to bind .
void setMousecallback(const string& winname, MouseCallback onMouse, void* userdata=0)
winname: The name of the window
onMouse: Mouse response function , Callback function . Specifies when each mouse time occurs in the window , Pointer to the called function . The prototype of this function should be void onMouse(int event, int x, int y, int flags, void* param);
userdate: Parameters passed to the callback function
event:
#defineCV_EVENT_MOUSEMOVE 0 Move
#defineCV_EVENT_LBUTTONDOWN 1 Left key press
#defineCV_EVENT_RBUTTONDOWN 2 Right click to press the
#defineCV_EVENT_MBUTTONDOWN 3 Press the key
#defineCV_EVENT_LBUTTONUP 4 Left key up
#defineCV_EVENT_RBUTTONUP 5 Right click to raise
#defineCV_EVENT_MBUTTONUP 6 The middle key rises
#defineCV_EVENT_LBUTTONDBLCLK 7 Next, double-left click on
#defineCV_EVENT_RBUTTONDBLCLK 8 Right click double-click
#defineCV_EVENT_MBUTTONDBLCLK 9 Double-click the key
flag:
#defineCV_EVENT_FLAG_LBUTTON 1 Left drag
#defineCV_EVENT_FLAG_RBUTTON 2 Right click and drag
#defineCV_EVENT_FLAG_MBUTTON 4 Middle drag
#defineCV_EVENT_FLAG_CTRLKEY 8 (8~15) Press Ctrl No release event
#defineCV_EVENT_FLAG_SHIFTKEY 16 (16~31) Press Shift No release event
#defineCV_EVENT_FLAG_ALTKEY 32 (32~39) Press Alt No release event
Once the callback function is run, it will listen to the mouse action , It's equivalent to opening a and main Parallel processes , The process will follow main End and end .
2. normalization
Normalization is to convert the data into an interval of 【0.1】 Data between . Use normalize function .
// Normalization function Original image Output image Maximum minimum value Algorithm
normalize(image, dst, 1.0, 0, NORM_MINMAX);
Mat dst;
std::cout << image.type() << std::endl;
//cv_8uc3 turn CV_32F
image.convertTo(image, CV_32F);
std::cout << image.type() << std::endl;
// Normalization function
normalize(image, dst, 1.0, 0, NORM_MINMAX);
std::cout << dst.type() << std::endl;
imshow(" Image data normalization ", dst);
// CV_8UC3, CV_32FC3
3. Shrinkage
Zoom function :resize
src Input diagram
dst Output chart , The shape is the same as the input diagram , When dsize It's not equal to 0, The size of the output drawing will match dsize identical , When dsize be equal to 0, The output drawing size will be determined by the input drawing size 、fx、fy Calculated
dsize Output size , When the input is 0 when ,fx、fy Nothing can be done 0,dsize =
Size(round(fxsrc.cols),round(fysrc.rows))
fx Horizontal scaling , When the input is 0 when ,fx=(double)dsize.width/src.cols
fy Vertical scaling , When the input is 0 when ,fy=(double)dsize.height/src.rows
interpolation Interpolation Interpolation methods include
CV_INTER_NEAREST Nearest interpolation point method
CV_INTER_LINEAR Bilinear interpolation
CV_INTER_AREA Neighborhood pixel resampling interpolation
CV_INTER_CUBIC Bicube interpolation ,4*4 Complementary points of size
4. Image reversal , rotate
function :flip
CV_EXPORTS_W void flip(
InputArray src, // The input image
OutputArray dst, // Output graph image
int flipCode // <0 Turn left and right upside down ; 0 Upside down ;>0 Turn left and right
);
Mat dst;
// flip(image, dst, 0); // Flip up and down
// flip(image, dst, 1); // Flip left and right
flip(image, dst, -1); // 180° rotate
imshow(" Image reversal ", dst);
版权声明
本文为[@[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/201/202207191212430084.html
边栏推荐
- Use masonry to realize width adaptation and height adaptation of controls (including uitableview) according to content
- Read write separation standby backup error
- CB insights released seven trends in the AI industry: synthetic data and the rise of multimodal AI
- mysql 设置外键约束SET FOREIGN_KEY_CHECKS=1
- 容斥【玲珑杯】咸鱼值
- Meiker Studio - Huawei 14 day Hongmeng equipment development practical notes 5
- Build a full stack web application framework in 1 hour, support secondary development, and update and expand at any time
- Conway's Law -- organization decides products, and domain drives design
- Zhiyuan admitted plagiarizing the paper, and the relevant responsible person has resigned!
- mos管的输入输出特性曲线及gm/id仿真曲线(cadence IC617)
猜你喜欢
面试官:你确定 Redis 是单线程的进程吗?
雲原生核心技術之:Service Mesh 的實現—— Istio
【Mindspore】【读取图数据】无法读取Mindrecord格式图数据
Is machine translation finished? Meta open source nllb translation model supports the translation of 200 languages
分布式链路日志minbox-logging使用文档
Silvaco二极管、三极管、CMOS的制备
机器学习(1)环境配置
npm warn config global `--global`, `--local` are deprecated. use `--location 解决方法
Devops has been practiced for many years. What is the most painful thing?
云原生指南:什么是云原生基础架构
随机推荐
Comparison of eolink and JMeter interface tests
容斥【玲珑杯】咸鱼值
中信证券是国企嘛?安全嘛?
实例|APICloud AVM框架封装滑动单元格组件
面试官:你确定 Redis 是单线程的进程吗?
25、继承与派生
装饰器解决TypeError: ‘NoneType‘ object is not callable
电机控制---SVPWM扇区判断的实现以及推导过程
Import word document pictures kernel synchronization and mutual exclusion
省选专练之【PKUSC2018】主斗地
Usage, advantages and disadvantages of MySQL on duplicate key update
Go要点新解(二)map小解
Socket error Event: 32 Error: 10053. Connection closing...Socket close
Example | apicloud AVM framework encapsulates sliding cell components
Oracle的$sqlarea 是不是无法查出来这些SQL是那台主机执行的?
APICloud AVM框架打造数字滚动组件
请问下flinksql有类似ifnull的函数吗?
Leetcode | 滑动窗口
分析脚手架
Use of & & operators