Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize batch picture stitching on C++

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces C++ how to achieve batch picture stitching related knowledge, the content is detailed and easy to understand, simple and fast operation, has a certain reference value, I believe that after reading this C++ article on how to achieve batch picture stitching will have something to gain, let's take a look.

The specific code is as follows

/ * * function function: different image stitching * parameters: * vector pic_list: picture name list * int pic_cols_rows: horizontal==true,pic_cols_rows is the number of lines of the image generated horizontal==false Pic_cols_rows to generate the number of columns of the picture * bool horizontal: true- first horizontally and then vertically synthesize the picture false- first vertically and then horizontally * bool draw_rect: true- draws a rectangle on the edge of the picture false- does not draw a rectangle on the edge of the picture * * / void mergeDiffPic (vector pic_list, int pic_cols_rows, string output_file, bool horizontal=true Bool draw_rect=false) {int pic_cols = 0 Int pic_rows = 0; int max_cols=0; int max_rows=0; int size_cols=0; int size_rows=0; vector tmp_cols; vector tmp_rows; / / get the number of pictures int pic_num = pic_list.size (); vectorinput (pic_num); Mat merge; for (int iTuno; isize_cols?max_cols:size_cols); size_rows + = max_rows If ((i*pic_cols+j) > = pic_num) break;} / / create a blank image the size of size_ cols×size _ rows, which is used to display small images Size mergesize (size_cols,size_rows); merge.create (mergesize, CV_MAKETYPE (input [0] .depth (3)); / / rgb 3-channel merge = Scalar::all (0); vectortemp (pic_num) / / display the picture for (iFix I = pic_num) break;}} else {pic_rows = pic_cols_rows; pic_cols = pic_num/pic_rows; if (pic_num%pic_rows! = 0) pic_cols + = 1; int iTun0; int j = 0; for (iTun0) Max_rows [I * pic_rows+j] .cols? max_cols: input [I * pic_rows+j] .cols);} size_rows = (max_rows > size_rows?max_rows:size_rows); size_cols + = max_cols; if ((i*pic_rows+j) > = pic_num) break;} / / std::cout

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report