Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize batch picture stitching on C++

Shulou Source: shulou.com Published: 2022-05-31 13:51:04 09月25日 Update

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

Tags: Picture cantilever position width knowledge rectangle maximum content horizontal article vertical edge channel height difference code value function function parameter Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Microsoft macOS Xiaomi Huawei