当前位置:网站首页>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



边栏推荐
- Positive and negative sample division and architecture understanding in image classification and target detection
- Wireshark use
- RESNET code details
- 2021-10-27
- 01仿B站项目业务架构
- Assignment to '*' form incompatible pointer type 'linkstack' {aka '*'} problem solving
- [combinatorics] combinatorial existence theorem (three combinatorial existence theorems | finite poset decomposition theorem | Ramsey theorem | existence theorem of different representative systems |
- Modelcheckpoint auto save model
- LeetCode - 919. 完全二叉树插入器 (数组)
- Drive and control program of Dianchuan charging board for charging pile design
猜你喜欢

I didn't think so much when I was in the field of single chip microcomputer. I just wanted to earn money to support myself first

Opencv notes 20 PCA

Opencv feature extraction sift

Pymssql controls SQL for Chinese queries

Exception handling of arm

LeetCode - 705 设计哈希集合(设计)

LeetCode 面试题 17.20. 连续中值(大顶堆+小顶堆)

LeetCode - 919. 完全二叉树插入器 (数组)

LeetCode - 1670 设计前中后队列(设计 - 两个双端队列)

For new students, if you have no contact with single-chip microcomputer, it is recommended to get started with 51 single-chip microcomputer
随机推荐
The data read by pandas is saved to the MySQL database
Application of external interrupts
When you need to use some functions of STM32, but 51 can't realize them, 32 naturally doesn't need to learn
Problems encountered when MySQL saves CSV files
getopt_ Typical use of long function
Adaptiveavgpool1d internal implementation
Design of charging pile mqtt transplantation based on 4G EC20 module
要選擇那種語言為單片機編寫程序呢
Swing transformer details-1
使用密钥对的形式连接阿里云服务器
4G module board level control interface designed by charging pile
Swing transformer details-2
Opencv notes 20 PCA
ADS simulation design of class AB RF power amplifier
Yocto Technology Sharing Phase 4: Custom add package support
Pycharm cannot import custom package
Vscode markdown export PDF error
Of course, the most widely used 8-bit single chip microcomputer is also the single chip microcomputer that beginners are most easy to learn
Exception handling of arm
El table X-axis direction (horizontal) scroll bar slides to the right by default