当前位置:网站首页>Opencv image rotation
Opencv image rotation
2022-07-03 10:06:00 【Σίσυφος one thousand and nine hundred】
One 、 Image rotation
operator :transpose(src, src);
transpose() Pixel subscript can be realized x and y Adjust the axis coordinates :dst(i,j)=src(j,i), Interface form
transpose(
InputArray src, // The input image
OutputArray dst, // Output
)
operator :flip(src, src, 1);
flip() Function to flip the image horizontally 、 Flip vertically and flip Bi directionally
void flip(
InputArray src, // The input image
OutputArray dst, // Output
int flipCode = 0 // >0: Along the y- The axis turns , 0: Along the x- The axis turns , <0: x、y The axis turns at the same time
);
flip(img1,0)# Flip the horizontal axis ( Flip up and down )
flip(img1,1)# Flip the vertical axis ( Flip left and right )
flip(img1,-1)# Flip both ways
Two 、 Code shows
#if 1 // Rotation Angle
Mat rotate_img(Mat src, int idx) {
// rotate 90 degree
if (idx == 1) {
transpose(src, src);
flip(src, src, 1);
return src;
}
// rotate 180 degree
else if (idx == 2) {
flip(src, src, 0);
flip(src, src, 1);
return src;
}
// rotate 270 degree
else if (idx == 3) {
transpose(src, src);
flip(src, src, 0);
return src;
}
else {
return src;
}
}
int main() {
Mat src = imread("C:\\Users\\19473\\Desktop\\opencv_images\\33.jpg");
if (!src.data)
{
printf("could not load image....\n");
}
imshow(" Original picture ", src);
Mat m1= rotate_img(src,1); //90 degree
imshow("90 degree ", m1);
Mat m2 = rotate_img(src, 2); //180 degree
imshow("180 degree ", m2);
Mat m3 = rotate_img(src, 3); //270 degree
imshow("270 degree ", m3);
waitKey(0);
return 0;
}
#endif
边栏推荐
- (1) What is a lambda expression
- Exception handling of arm
- My openwrt learning notes (V): choice of openwrt development hardware platform - mt7688
- 使用sed替换文件夹下文件
- Leetcode - 1670 conception de la file d'attente avant, moyenne et arrière (conception - deux files d'attente à double extrémité)
- The 4G module designed by the charging pile obtains NTP time through mqtt based on 4G network
- STM32 running lantern experiment - library function version
- 01仿B站项目业务架构
- 4G module at command communication package interface designed by charging pile
- Octave instructions
猜你喜欢
LeetCode - 1670 設計前中後隊列(設計 - 兩個雙端隊列)
STM32 interrupt switch
LeetCode - 1670 设计前中后队列(设计 - 两个双端队列)
The underlying principle of vector
Retinaface: single stage dense face localization in the wild
The new series of MCU also continues the two advantages of STM32 product family: low voltage and energy saving
Yocto technology sharing phase IV: customize and add software package support
[Li Kou brush question notes (II)] special skills, module breakthroughs, classification and summary of 45 classic questions, and refinement in continuous consolidation
Leetcode bit operation
El table X-axis direction (horizontal) scroll bar slides to the right by default
随机推荐
RESNET code details
openEuler kernel 技術分享 - 第1期 - kdump 基本原理、使用及案例介紹
Openeuler kernel technology sharing - Issue 1 - kdump basic principle, use and case introduction
JS基础-原型原型链和宏任务/微任务/事件机制
Seven sorting of ten thousand words by hand (code + dynamic diagram demonstration)
Notes on C language learning of migrant workers majoring in electronic information engineering
Toolbutton property settings
Wireshark use
[combinatorics] combinatorial existence theorem (three combinatorial existence theorems | finite poset decomposition theorem | Ramsey theorem | existence theorem of different representative systems |
Yocto Technology Sharing Phase 4: Custom add package support
Installation and removal of MySQL under Windows
2020-08-23
JS foundation - prototype prototype chain and macro task / micro task / event mechanism
Sending and interrupt receiving of STM32 serial port
STM32 general timer 1s delay to realize LED flashing
Not many people can finally bring their interests to college graduation
4G module at command communication package interface designed by charging pile
is_ power_ of_ 2 judge whether it is a multiple of 2
Synchronization control between tasks
Serial communication based on 51 single chip microcomputer