CN111857708A - Qt interface-based multi-image splicing software implementation method and system - Google Patents

Qt interface-based multi-image splicing software implementation method and system Download PDF

Info

Publication number
CN111857708A
CN111857708A CN202010480639.XA CN202010480639A CN111857708A CN 111857708 A CN111857708 A CN 111857708A CN 202010480639 A CN202010480639 A CN 202010480639A CN 111857708 A CN111857708 A CN 111857708A
Authority
CN
China
Prior art keywords
function
parameter
slot
file
image
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010480639.XA
Other languages
Chinese (zh)
Other versions
CN111857708B (en
Inventor
张纯杨
张昊徳
笪庆
韩玉兵
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing University of Science and Technology
Original Assignee
Nanjing University of Science and Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing University of Science and Technology filed Critical Nanjing University of Science and Technology
Priority to CN202010480639.XA priority Critical patent/CN111857708B/en
Publication of CN111857708A publication Critical patent/CN111857708A/en
Application granted granted Critical
Publication of CN111857708B publication Critical patent/CN111857708B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformation in the plane of the image
    • G06T3/40Scaling the whole image or part thereof
    • G06T3/4038Scaling the whole image or part thereof for image mosaicing, i.e. plane images composed of plane sub-images
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Stored Programmes (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The invention discloses a software implementation method and a system for multi-image splicing based on a Qt interface, wherein the method comprises the following steps: configuring Qt and OpenCV, and creating a Qt Gui Application project; drawing a window in the ui file, adding a Push Button and a Scroll Area, and designing a dialog box; adding required member objects in the ". h" file; declaring in the ". h" header the required member functions, i.e. the slot functions corresponding to the button components; establishing a relation between a slot function and a component signal in a 'cpp' file with the same name as the project, and defining the slot function; compiling and running a Debug version and a Release version; and packaging and releasing the executable file generated by the Release version. The invention adopts a Qt interface, greatly improves the cross-platform characteristic of the program, uses a self-carrying method in OpenCV for splicing, greatly improves the splicing effect, leads the code to be simpler, can input a plurality of images by the program, and also reduces the requirements of shooting panoramic images on the shooting technology and the space position of a camera.

Description

Qt interface-based multi-image splicing software implementation method and system
Technical Field
The invention relates to a multi-image splicing software implementation technology, in particular to a software implementation method and a system for multi-image splicing based on a Qt interface.
Background
At present, single-source imaging is difficult to meet the daily life needs of people, for example, when panoramic photos need to be taken, the panoramic function of a mobile phone camera may be used, sometimes two cameras or even three cameras may be needed, and the positions and heights of the cameras need to be strictly determined to complete the production of panoramic images. However, the direct use of the panoramic function may cause poor shooting effect due to unstable camera holding, and the requirement for the position and height of the camera by using the splicing of a plurality of cameras is too high. Therefore, a technology that requires neither a photographing technology nor a spatial position of a camera is required to facilitate the production of a panoramic image.
Disclosure of Invention
The invention aims to provide a software implementation method and a system for multi-image splicing based on a Qt interface.
The technical solution for realizing the purpose of the invention is as follows: a software implementation method for multi-image splicing based on a Qt interface comprises the following steps:
step 1, configuring Qt and OpenCV and creating a Qt Gui Application project;
Step 2, drawing a window in the ui file, adding a Push Button and a Scroll Area, and designing a dialog box;
step 3, adding the required member object in the h file;
step 4, declaring required member functions, namely slot functions corresponding to required components, in the head file of the h;
step 5, establishing a relation between a slot function and a component signal in a 'cpp' file with the same name as the project, and defining the slot function;
step 6, compiling and operating a Debug version and a Release version;
and 7, packaging and releasing the executable file generated by the Release version.
Further, in step 2, drawing a window in the ui file, adding a Push Button and a Scroll Area, and designing a dialog form, wherein the specific method comprises the following steps:
drawing a window in the ui file, wherein 6 Push buttons are added, 4 paths are used for reading pictures after clicking, one path is used for starting splicing after clicking, and the other path is used for exiting a program after clicking; and adding 4 Scroll areas for displaying the pictures to be spliced.
Further, in step 3, adding a required member object in the ". h" file, the specific method is as follows:
adding a QString type object for receiving a character string of the read path;
Adding a Mat type object for temporarily storing the picture under the path and then pressing the picture into a container;
adding a vector container for storing the Mat type object data in the step (II), and transmitting the Mat type object data serving as a parameter of a splicing function in the later step to realize splicing;
(IV) adding string type objects for determining the file name for storing the splicing result, and paying attention to carrying extension names, such as "[" dst1.jpg "]";
adding four QLabel type pointers for displaying the image acquired in the step (II) on the ui interface;
and (VI) adding a Mat type object for storing the spliced images.
Further, in step 4, a required member function, that is, a slot function corresponding to the button component, is declared in the ". h" header file, and the specific method is as follows:
the macro 'slots' is added after the 'private' key, namely, the 'private slots:' is declared, and the member functions of the declaration are as follows:
function one: component one — button one corresponding slot function 1;
function two: component two-slot function 2 corresponding to button two;
(III) function three: component three-slot function 3 corresponding to button three;
(IV) function four: component four-slot function 4 for button four;
(V) function five: component five-slot function b corresponding to button five;
(VI) function six: component six — slot function exit for button six.
Further, in step 5, the association between the slot function and the component signal is established in the "cpp" file having the same name as the item, by the following specific method:
first, the "connect" function is used to establish the connection between the slot function and the component signal, and the function parameter list is different, and the parameter profile is as follows:
the first parameter is: XXX represents the name of the member under the ui object whose part object name is obtained when the part is added in step (2);
the second parameter is as follows: SIGNAL (clicked ()), all the slot functions are SIGNALs of clicking buttons, and therefore SIGNAL (clicked ());
the third parameter is as follows: this, because there is only one window and only one receiver, all of them are fixed as this;
the fourth parameter: SLOT (corresponding to SLOT function name ()), and the corresponding component executes the SLOT function when receiving the corresponding signal;
the execution of the connect function can be summarized as: when the component corresponding to the first parameter receives the signal in the form of the second parameter, the receiver of the third parameter executes the slot function of the fourth parameter, thus successfully associating all the button components with the slot function.
Further, the slot function is defined in the ". cpp" file with the same name as the project, and the specific method is as follows:
slot function 1: reading an image path and function parameters by using a member function getOpenFileName of a QFileDialog class:
the first parameter is: for specifying a parent component, here fixed as this;
the second parameter is as follows: a dialog box title string;
the third parameter is as follows: defaulting the read path name character string, and leaving the character string empty in order to find a path at will, namely directly inputting double quotation marks, wherein the inside of the quotation marks has no content;
the fourth parameter: the file suffix name filters the string, since the read file must be a picture, so here is filled: "Images (. png. bmp. jpg. tif. gif)";
the function returns a value to be assigned to the QString object;
detecting whether an input path is found successfully or not, using an if statement and a member function isEmpty under a QString object, wherein the function has no parameter and only returns the pool type data, if the corresponding object data is null, returning true, judging a return value by using the if statement, and if the return value is true, directly finishing the return of the slot function 1, namely returning; if the return value is false, continuing to execute the next step;
Next, initializing a string type object, and assigning a value to the string type object by using a return value of a member function toStdString () of the QString type object, wherein a path character string of a function parameter is a standard string type because of a function used for reading an image under a path;
the next step is to read the image using the OpenCV function "immed", and receive the read image data using the Mat type object;
then, pressing the image which is just read into a vector container for splicing;
a Mat type object is initialized again for the following steps:
then, image size adjustment is carried out, a "resize" function of OpenCV is utilized, note that there is a homonymy function in Qt, and a namespace "cv" needs to be added, namely "cv:: resize", and function parameters are as follows:
the first parameter is: an image to be adjusted, here a Mat type object;
the second parameter is as follows: receiving the used image after adjustment, here, a;
the third parameter is as follows: the Size to be adjusted, namely Size (length, width);
next, converting the Mat class object into a QImage class object, initializing a QImage type object, wherein parameters of a constructor are required to be input during object initialization, and each parameter is as follows:
The first parameter is: image data, using the object 'data' of A to obtain data, and converting the data into 'const unscented char' type data by taking the forced type conversion into attention;
the second parameter is as follows: the number of image columns is the same as that of the nail after the size adjustment, and data is acquired by using the object 'cols' of the nail;
the third parameter is as follows: the number of image lines is the same as that of the nail after the size adjustment, and the object 'rows' of the nail is used for acquiring data;
the fourth parameter: the image storage Format, here, is enumerated type data in the QImage class, since the order of image data channels in OpenCV is B, G, R, here, "QImage:: Format _ BGR 888";
then initializing a QLabel type pointer, and using an operator new;
performing a member function using the "- >" operator of this pointer;
first is the "setPixmap" function, with the parameters as follows:
unique parameters: QPixmap:: fromImage (QImage type object name just initialized);
secondly, the method comprises the following steps: the "resize" function, parameters are as follows:
unique parameters: QSize (width of the just initialized QImage type object, height of the just initialized QImage type object), where the width and height can be obtained by using the member variable width () of the just initialized QImage type object, height ();
Finally, the object "ui" is used to make the Scroll Area display the image of the QImage type object;
ui. [ object name corresponding to Scroll Area ] - > setWidget ([ QLabel type pointer name ]);
so far, the definition of the slot function 1 is finished;
although the definition flows of the slot function 2, the slot function 3, the slot function 4, and the slot function 1 are basically the same, in terms of the use of the QLabel type pointer, the QLabel type pointers corresponding to different slot functions are different, and it should be noted that, when the object "ui" is used to display an image of a QImage type object in a ScrollArea, the object names corresponding to different slot functions in "[ object name corresponding to ScrollArea ]";
the slot function b: this bin function is used to start stitching the images;
firstly, initializing a Sticher class object, and assigning values to the object by using a member function 'Sticher:: createDefault ()' of the Sticher class, wherein the function 'Sticher:: createDefault ()' has no parameter;
initializing a Status class object of a subclass of a Sttcher class, and assigning a value to the just initialized Status class object while splicing by using a member function 'stitch' of the Sticher class so as to detect whether the images in the container can be spliced; the "sticch" function parameters are as follows:
The first parameter is: a name of the container;
the second parameter is as follows: a Mat class object;
then, judging whether the splicing is successful or not by utilizing the if statement and the Status class object, wherein if the splicing is successful, the Status class object result is 'stutcher:: OK'; if yes, the function returns directly to indicate that the input image can not be spliced, and at the moment, the program needs to be quitted, and the proper image is read again; if the judgment is not true, the splicing is successful, and the image can be displayed by directly using the function ' image ' of the OpenCV, wherein the function parameters of the image ' are as follows:
the first parameter is: display window title strings, which may be named arbitrarily, e.g., "[" panoramic image "]";
the second parameter is as follows: a Mat type object for storing the spliced images, which is the spliced panoramic image and is the same as the second parameter of the 'stich' function;
then keeping the window displayed by using the waitKey function, wherein the function does not need to add parameters;
so far, the definition of the slot function b is completed;
the slot function exit: saving the picture and exiting the program;
firstly, whether the previous splicing is successful or not is determined by using an if statement and a function "empty" of OpenCV, so that a Mat type object used for storing a spliced image is required to call the function, the function has no parameter, and returns a pool type value, if no data exists in the corresponding Mat type object, the function returns "true", the judgment here is that the returned value of the function is not taken, if yes, the splicing is successful, and a splicing result can be stored by using an "imwrite" function of OpenCV, wherein the function parameters are as follows:
The first parameter is: saving the path and the file name, and directly saving the path and the file name under the same path as the program, wherein the path and the file name are the character strings in the string type object;
the second parameter is as follows: the Mat type object is an image needing to be stored, and is a Mat type object used for storing the spliced image;
then, an OpenCV function "destroyAllWindows" is used to close all windows opened by OpenCV, the function having no parameters;
finally, a program exit function 'exit' only has one parameter and is filled with a number 0 to indicate that the program exits normally;
this completes the definition of the slot function exit.
Further, in step 6, after the Debug and Release versions are compiled and run, the third parameter of the "cv:: resize" function is adjusted.
A software implementation system for multi-image stitching based on a Qt interface comprises:
the compiling environment setting module is used for configuring Qt and OpenCV and creating a Qt Gui Application project;
the dialog box setting module is used for drawing a window in the ui file, adding a Push Button and a Scroll Area and designing a dialog box;
a member object setting module, which is used for adding the required member objects in the h file;
a member function setting module for declaring a required member function, i.e., a slot function corresponding to a required component, in the ". h" header file;
The device comprises a slot function association defining module, a component signal generating module and a processing module, wherein the slot function association defining module is used for establishing the association between a slot function and a component signal in a 'cpp' file with the same name as a project and defining the slot function;
the compiling module is used for compiling and operating the Debug version and the Release version;
and the Release module is used for packaging and releasing the executable file generated by the Release version.
A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
step 1, configuring Qt and OpenCV and creating a Qt Gui Application project;
step 2, drawing a window in the ui file, adding a Push Button and a Scroll Area, and designing a dialog box;
step 3, adding the required member object in the h file;
step 4, declaring required member functions, namely slot functions corresponding to required components, in the head file of the h;
step 5, establishing a relation between a slot function and a component signal in a 'cpp' file with the same name as the project, and defining the slot function;
step 6, compiling and operating a Debug version and a Release version;
and 7, packaging and releasing the executable file generated by the Release version.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
step 1, configuring Qt and OpenCV and creating a Qt Gui Application project;
step 2, drawing a window in the ui file, adding a Push Button and a Scroll Area, and designing a dialog box;
step 3, adding the required member object in the h file;
step 4, declaring required member functions, namely slot functions corresponding to required components, in the head file of the h;
step 5, establishing a relation between a slot function and a component signal in a 'cpp' file with the same name as the project, and defining the slot function;
step 6, compiling and operating a Debug version and a Release version;
and 7, packaging and releasing the executable file generated by the Release version.
Compared with the prior art, the invention has the remarkable advantages that: the Qt interface is adopted, the cross-platform characteristic of the program is greatly improved, in the aspect of splicing, a self-carrying method in OpenCV is used for splicing, the splicing effect is greatly improved, the codes are simpler, a plurality of images can be input into the program, and the requirements of the shooting technology and the camera space position for shooting the panoramic image are reduced.
Drawings
Fig. 1 is a flowchart of the program operation.
Fig. 2 is a flow chart of splicing.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
A Visual Studio 2017IDE is installed on a 64-bit Windows OS, and is matched with Qt 5.14.2 and OpenCV3.4.2, C + + is taken as a main language, and software is used for splicing four pictures at most as an example, so that the Qt interface-based multi-image speed splicing method is described in detail. Fig. 1 shows a program running flow, fig. 2 shows a splicing flow, and the method mainly comprises the following steps:
(1) and building a compiling environment according to the existing configuration method. This part is a prerequisite part, and does not belong to the invention part, but must be executed, so it is not described in detail.
(2) And drawing a window in the ui file, wherein 6 Push buttons are added, four paths are used for reading the picture after clicking, one path is used for starting splicing after clicking, and the other path is used for exiting the program after clicking. And adding 4 Scroll areas for displaying the pictures to be spliced.
(3) The required member objects are added to the automatically generated ". h" file, where the addition is as follows:
a QString type object for receiving a string of the read path;
(II) Mat type objects are used for temporarily storing the pictures under the path and then pressing the pictures into a container;
a vector container which is a dynamic container and is used for storing the Mat type object data in the second container, and the vector container is used as a parameter of a splicing function to be transmitted in the later step to realize splicing;
(IV) string type object for determining the file name for storing the splicing result, and paying attention to the extension, such as "[" dst1.jpg "]";
(V) four QLabel type pointers for displaying the image obtained in (II) onto the ui interface;
and (VI) the Mat type object is used for storing the spliced images.
The above member objects are all private class (private) members, and need to declare "private:" in the class by itself;
(4) the required member functions, namely the slot functions corresponding to the required components, are declared in the automatically generated ". h" header file, the slot function declaration method is slightly different from that of the common member functions, and macros "slots" need to be added after the "private" keyword, namely, the macro slots are declared after the "private slots:". The declared membership functions are as follows:
Function one: component one — button one corresponds to slot function 1 (hereinafter referred to as slot function 1);
function two: component two, slot function 2 corresponding to button two (hereinafter referred to as slot function 2);
(III) function three: component three-slot function 3 corresponding to button three (hereinafter referred to as slot function 3);
(IV) function four: a slot function 4 corresponding to a component four-button four (hereinafter referred to as slot function 4);
(V) function five: a component five, namely a groove function b corresponding to the button five (hereinafter referred to as the groove function b);
(VI) function six: component six — slot function exit (hereinafter referred to as slot function exit) corresponding to button six.
For example, according to the above addition, the following code segments may be added:
private slots:
void on_1_clicked();
void on_2_clicked();
void on_3_clicked();
void on_4_clicked();
void on_b_clicked();
void on _ exit _ clicked (); (5) adding necessary codes to an automatically generated ". cpp" file with the same name as the project, mainly establishing the connection between the slot function and the component signal and defining the slot function, as follows:
first, the "connect" function is used to establish the connection between the slot function and the component signal, and the function parameter list is different, and the parameter profile is as follows:
the first parameter is: XXX represents the name of the member under the ui object, and the name of the part object can be obtained when the part is added in the step (2);
The second parameter is as follows: SIGNAL (clicked ()), all the slot functions are SIGNALs of clicking buttons, and therefore SIGNAL (clicked ());
the third parameter is as follows: this, because there is only one window and only one receiver, all of them are fixed as this;
the fourth parameter: SLOT (corresponding to the SLOT function name ()), and the corresponding component executes the SLOT function upon receiving the corresponding signal.
The execution of the connect function can be summarized as: when the component corresponding to the first parameter receives the signal in the form of the second parameter, the receiver of the third parameter executes the slot function of the fourth parameter. This successfully associates all button members with the slot function.
Next is the definition of the individual slot functions:
slot function 1: reading an image path by using a member function getOpenFileName of a QFileDialog class, wherein the function parameters are as follows:
the first parameter is: the method is used for specifying a parent component, and the parent component is fixed as this;
the second parameter is as follows: dialog box title strings, such as: "Select Picture";
the third parameter is as follows: defaulting the read path name character string, and leaving the character string empty in order to find a path at will, namely directly inputting double quotation marks, wherein the inside of the quotation marks has no content;
the fourth parameter: the file suffix name filters the string, since the read file must be a picture, so here is filled: "Images (. png. bmp. jpg. tif. gif)".
This function returns a value assignment to said QString object in (3) (one).
Detecting whether an input path is found successfully or not, using an if statement and a member function isEmpty under a QString object, wherein the function has no parameter and only returns the pool type data, if the corresponding object data is null, returning true, judging a return value by using the if statement, and if the return value is true, directly finishing the return of the slot function 1, namely returning; if the return value is false, the next steps are continuously executed.
Next, a string type object is initialized, and the string type object is assigned with the return value of the member function toStdString () of the QString type object in (3) (one), because the path character string of the function parameter should be a standard string type for the function used for reading the image under the path.
The next step is to read the image using the OpenCV function "immed", and receive the read image data using the Mat type object in (3) (two).
The image just read is then pushed into the vector container in (3) (three) for stitching.
A Mat type object (we call it a) is initialized again for the following steps.
Then, image size adjustment is carried out, a "resize" function of OpenCV is utilized, note that there is a homonymy function in Qt, and a namespace "cv" needs to be added, namely "cv:: resize", and function parameters are as follows:
The first parameter is: an image to be adjusted, here a Mat type object in (3) (two);
the second parameter is as follows: receiving the used image after adjustment, here, a;
the third parameter is as follows: the Size to be adjusted can be directly input into Size (length, width).
Because the interface size is limited, the size of the Scroll Area is also limited, and we can obtain a suitable size by drawing the Scroll Area in (2), here, the size can also be set to be much smaller than the size of the Scroll Area, and it is more suitable to wait for the final compiling run and then make a proper adjustment.
Next, converting the Mat class object into a QImage class object, initializing a QImage type object, wherein parameters of a constructor are required to be input during object initialization, and each parameter is as follows:
the first parameter is: image data, which can be obtained by using the object 'data' of A, and is converted into 'const unscented char' type data by taking the mandatory type conversion into consideration;
the second parameter is as follows: the number of image columns is the same as that of the nail after the size adjustment, and the data can be acquired by using the object 'cols' of the nail;
the third parameter is as follows: the number of image lines is the same as that of the nail after the size adjustment, and the object 'rows' of the nail can be used for acquiring data;
The fourth parameter: the image storage Format, here enumerated type data in the QImage class, is "QImage:: Format _ BGR 888" because the order of image data lanes in OpenCV is B, G, R.
Then, the QLabel type pointer of (3) (five) is initialized, and the operator new is used, for example:
[ (3) (five) one of the QLabel type pointer names ] ═ new QLabel ();
the member function is executed using the "- >" operator of this pointer.
First is the "setPixmap" function, with the parameters as follows:
unique parameters: QPixmap:: fromImage (QImage type object name just initialized).
Secondly, the method comprises the following steps: the "resize" function, parameters are as follows:
unique parameters: QSize (width of the just initialized QImage type object, height of the just initialized QImage type object), where the width and height can be obtained by the member variable width () and height () of the just initialized QImage type object, respectively.
In the last step, the object "ui" is used to make the Scroll Area display the image of the QImage type object.
ui. [ object name corresponding to Scroll Area ] - > setWidget ([ (3) (five) one of the QLabel type pointer names ]);
so far, the definition flows of the slot function 2, the slot function 3, the slot function 4 and the slot function 1 are basically the same, but the QLabel type pointers corresponding to different slot functions are different in the use of the QLabel type pointers (more than one is added in (3) (five), namely, the QLabel type pointers are used separately here). It should also be noted that, in the last step mentioned above, when the object "ui" is used to make the ScrollArea display the image of the QImage type object, the object names corresponding to different slot functions in "[ object name corresponding to ScrollArea ]", which can be viewed in (2), are different.
The slot function b: this slot function is used to start stitching the images.
A Sticher class object is first initialized, a member function of the Sticher class, Sticher:: createDefault (), is used to assign a value to the object, and the function "Sticher:: createDefault ()" has no parameters.
And initializing a Status class object of a subclass of the Sttcher class, and assigning a value to the just initialized Status class object while splicing by using a member function 'stitch' of the Sticher class so as to detect whether the images in the container can be spliced. The "sticch" function parameters are as follows:
the first parameter is: (3) the container name in (III);
the second parameter is as follows: (3) the Mat class object in (VI).
Then, the if statement and the Status class object are used for judging whether the splicing is successful or not, and if the splicing is successful, the Status class object result is 'stutcher:: OK'. If yes, the function returns directly to indicate that the input image can not be spliced, and at the moment, the program needs to be quitted, and the proper image is read again; if the judgment is not true, the splicing is successful, and the image can be displayed by directly using the function ' image ' of the OpenCV, wherein the function parameters of the image ' are as follows:
The first parameter is: display window title strings, which may be named arbitrarily, e.g., "[" panoramic image "]";
the second parameter is as follows: the Mat type object, here the stitched panoramic image, is the same as the second parameter of the "stich" function above.
The waitKey function is then used to keep the window displayed. The function does not require the addition of parameters.
At this point, the definition of the slot function b is complete.
The slot function exit: and saving the picture and exiting the program. Firstly, if the function "empty" of the if statement and OpenCV is used to determine whether the previous concatenation is successful, so it should be the Mat class object in (3) (six) to call the function, this function has no parameter, it will return a pool type value, if there is no data in the corresponding Mat type object (here, it can be directly understood that concatenation fails, and there is no data written to the Mat class object in (3) (six)), it will return "true", here, it is determined that the function return value is not taken, if true, concatenation is successful, and the "imwrite" function of OpenCV may be used to store the concatenation result, where the function parameters are as follows:
the first parameter is: saving the path and the file name, and directly saving the path and the file name under the same path as the program, wherein the path and the file name are the character strings in (3) and (four);
The second parameter is as follows: mat type object, the image to be saved, is the Mat type object in (3) (six).
The OpenCV function "destroyAllWindows" is then used to close all windows opened by OpenCV, which has no parameters.
And finally, a program exit function 'exit', wherein the function only has one parameter and is filled with a number 0 to indicate that the program exits normally.
This completes the definition of the slot function exit.
(6) In the Debug and Release version compiling operation, the third parameter of the cv:: resize function can be adjusted incidentally at this time, so that the image display is more suitable.
(7) The last step is packaging and publishing, the part does not belong to the invention part, and a publishing method of a corresponding platform can be searched by self, for example, a 64-bit Windows OS and Visual Studio 2017 can be published by using a Qt own MSVC201764-bit tool. And will not be described in detail herein.
Based on the method, the invention also provides a software implementation system for multi-image splicing based on the Qt interface, which comprises the following steps:
the compiling environment setting module is used for configuring Qt and OpenCV and creating a Qt Gui Application project;
the dialog box setting module is used for drawing a window in the ui file, adding a Push Button and a Scroll Area and designing a dialog box;
A member object setting module, which is used for adding the required member objects in the h file;
a member function setting module for declaring a required member function, i.e., a slot function corresponding to a required component, in the ". h" header file;
the device comprises a slot function association defining module, a component signal generating module and a processing module, wherein the slot function association defining module is used for establishing the association between a slot function and a component signal in a 'cpp' file with the same name as a project and defining the slot function;
the compiling module is used for compiling and operating the Debug version and the Release version;
and the Release module is used for packaging and releasing the executable file generated by the Release version.
A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
step 1, configuring Qt and OpenCV and creating a Qt Gui Application project;
step 2, drawing a window in the ui file, adding a Push Button and a Scroll Area, and designing a dialog box;
step 3, adding the required member object in the h file;
step 4, declaring required member functions, namely slot functions corresponding to required components, in the head file of the h;
step 5, establishing a relation between a slot function and a component signal in a 'cpp' file with the same name as the project, and defining the slot function;
Step 6, compiling and operating a Debug version and a Release version;
and 7, packaging and releasing the executable file generated by the Release version.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
step 1, configuring Qt and OpenCV and creating a Qt Gui Application project;
step 2, drawing a window in the ui file, adding a Push Button and a Scroll Area, and designing a dialog box;
step 3, adding the required member object in the h file;
step 4, declaring required member functions, namely slot functions corresponding to required components, in the head file of the h;
step 5, establishing a relation between a slot function and a component signal in a 'cpp' file with the same name as the project, and defining the slot function;
step 6, compiling and operating a Debug version and a Release version;
and 7, packaging and releasing the executable file generated by the Release version.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A software implementation method for multi-image splicing based on a Qt interface is characterized by comprising the following steps:
step 1, configuring Qt and OpenCV and creating a Qt Gui Application project;
step 2, drawing a window in the ui file, adding a Push Button and a Scroll Area, and designing a dialog box;
step 3, adding the required member object in the h file;
step 4, declaring required member functions, namely, slot functions corresponding to the button parts in the head file of the h;
Step 5, establishing a relation between a slot function and a component signal in a 'cpp' file with the same name as the project, and defining the slot function;
step 6, compiling and operating a Debug version and a Release version;
and 7, packaging and releasing the executable file generated by the Release version.
2. The software implementation method for multi-image stitching based on the Qt interface as claimed in claim 1, wherein in step 2, a window is drawn in the ui file, a Push Button and a Scroll Area are added, and a dialog box form is designed, and the specific method is as follows:
drawing a window in the ui file, wherein 6 Push buttons are added, 4 paths are used for reading pictures after clicking, one path is used for starting splicing after clicking, and the other path is used for exiting a program after clicking; and adding 4 Scroll areas for displaying the pictures to be spliced.
3. The software implementation method for multi-image stitching based on the Qt interface according to claim 1, wherein in step 3, the required member objects are added to the ". h" file by the following specific method:
adding a QString type object for receiving a character string of the read path;
adding a Mat type object for temporarily storing the picture under the path and then pressing the picture into a container;
Adding a vector container for storing the Mat type object data in the step (II), and transmitting the Mat type object data serving as a parameter of a splicing function in the later step to realize splicing;
(IV) adding string type objects for determining the file name for storing the splicing result, and paying attention to carrying extension names, such as "[" dst1.jpg "]";
adding four QLabel type pointers for displaying the image acquired in the step (II) on the ui interface;
and (VI) adding a Mat type object for storing the spliced images.
4. The software implementation method for multi-image stitching based on the Qt interface as claimed in claim 1, wherein in step 4, the required member function, that is, the slot function corresponding to the button component, is declared in the ". h" header file by:
the macro 'slots' is added after the 'private' key, namely, the 'private slots:' is declared, and the member functions of the declaration are as follows:
function one: component one — button one corresponding slot function 1;
function two: component two-slot function 2 corresponding to button two;
(III) function three: component three-slot function 3 corresponding to button three;
(IV) function four: component four-slot function 4 for button four;
(V) function five: component five-slot function b corresponding to button five;
(VI) function six: component six — slot function exit for button six.
5. The software-implemented method for multi-image stitching based on the Qt interface of claim 1, wherein in step 5, the association between the slot function and the component signal is established in a ". cpp" file having the same name as the project, by:
first, the "connect" function is used to establish the connection between the slot function and the component signal, and the function parameter list is different, and the parameter profile is as follows:
the first parameter is: XXX represents the name of the member under the ui object whose part object name is obtained when the part is added in step (2);
the second parameter is as follows: SIGNAL (clicked ()), all the slot functions are SIGNALs of clicking buttons, and therefore SIGNAL (clicked ());
the third parameter is as follows: this, because there is only one window and only one receiver, all of them are fixed as this;
the fourth parameter: SLOT (corresponding to SLOT function name ()), and the corresponding component executes the SLOT function when receiving the corresponding signal;
the execution of the connect function can be summarized as: when the component corresponding to the first parameter receives the signal in the form of the second parameter, the receiver of the third parameter executes the slot function of the fourth parameter, thus successfully associating all the button components with the slot function.
6. The software implementation method for multi-image stitching based on the Qt interface of claim 1, wherein in step 5, the slot function is defined in a ". cpp" file having the same name as the project, by the following specific method:
slot function 1: reading an image path and function parameters by using a member function getOpenFileName of a QFileDialog class:
the first parameter is: for specifying a parent component, here fixed as this;
the second parameter is as follows: a dialog box title string;
the third parameter is as follows: defaulting the read path name character string, and leaving the character string empty in order to find a path at will, namely directly inputting double quotation marks, wherein the inside of the quotation marks has no content;
the fourth parameter: the file suffix name filters the string, since the read file must be a picture, so here is filled: "Images (. png. bmp. jpg. tif. gif)";
the function returns a value to be assigned to the QString object;
detecting whether an input path is found successfully or not, using an if statement and a member function isEmpty under a QString object, wherein the function has no parameter and only returns the pool type data, if the corresponding object data is null, returning true, judging a return value by using the if statement, and if the return value is true, directly finishing the return of the slot function 1, namely returning; if the return value is false, continuing to execute the next step;
Next, initializing a string type object, and assigning a value to the string type object by using a return value of a member function toStdString () of the QString type object, wherein a path character string of a function parameter is a standard string type because of a function used for reading an image under a path;
the next step is to read the image using the OpenCV function "immed", and receive the read image data using the Mat type object;
then, pressing the image which is just read into a vector container for splicing;
a Mat type object is initialized again for the following steps:
then, image size adjustment is carried out, a "resize" function of OpenCV is utilized, note that there is a homonymy function in Qt, and a namespace "cv" needs to be added, namely "cv:: resize", and function parameters are as follows:
the first parameter is: an image to be adjusted, here a Mat type object;
the second parameter is as follows: receiving the used image after adjustment, here, a;
the third parameter is as follows: the Size to be adjusted, namely Size (length, width);
next, converting the Mat class object into a QImage class object, initializing a QImage type object, wherein parameters of a constructor are required to be input during object initialization, and each parameter is as follows:
The first parameter is: image data, using the object 'data' of A to obtain data, and converting the data into 'const unscented char' type data by taking the forced type conversion into attention;
the second parameter is as follows: the number of image columns is the same as that of the nail after the size adjustment, and data is acquired by using the object 'cols' of the nail;
the third parameter is as follows: the number of image lines is the same as that of the nail after the size adjustment, and the object 'rows' of the nail is used for acquiring data;
the fourth parameter: the image storage Format, here, is enumerated type data in the QImage class, since the order of image data channels in OpenCV is B, G, R, here, "QImage:: Format _ BGR 888";
then initializing a QLabel type pointer, and using an operator new;
performing a member function using the "- >" operator of this pointer;
first is the "setPixmap" function, with the parameters as follows:
unique parameters: QPixmap:: fromImage (QImage type object name just initialized);
secondly, the method comprises the following steps: the "resize" function, parameters are as follows:
unique parameters: QSize (width of the just initialized QImage type object, height of the just initialized QImage type object), where the width and height can be obtained by using the member variable width () of the just initialized QImage type object, height ();
Finally, the object "ui" is used to make the Scroll Area display the image of the QImage type object;
ui. [ object name corresponding to Scroll Area ] - > setWidget ([ QLabel type pointer name ]);
so far, the definition of the slot function 1 is finished;
although the definition flows of the slot function 2, the slot function 3, the slot function 4, and the slot function 1 are basically the same, in terms of the use of the QLabel type pointer, the QLabel type pointers corresponding to different slot functions are different, and it should be noted that, when the object "ui" is used to display an image of a QImage type object in a ScrollArea, the object names corresponding to different slot functions in "[ object name corresponding to ScrollArea ]";
the slot function b: this bin function is used to start stitching the images;
firstly, initializing a Sticher class object, and assigning values to the object by using a member function 'Sticher:: createDefault ()' of the Sticher class, wherein the function 'Sticher:: createDefault ()' has no parameter;
initializing a Status class object of a subclass of a Sttcher class, and assigning a value to the just initialized Status class object while splicing by using a member function 'stitch' of the Sticher class so as to detect whether the images in the container can be spliced; the "sticch" function parameters are as follows:
The first parameter is: a name of the container;
the second parameter is as follows: a Mat class object;
then, judging whether the splicing is successful or not by utilizing the if statement and the Status class object, wherein if the splicing is successful, the Status class object result is 'stutcher:: OK'; if yes, the function returns directly to indicate that the input image can not be spliced, and at the moment, the program needs to be quitted, and the proper image is read again; if the judgment is not true, the splicing is successful, and the image can be displayed by directly using the function ' image ' of the OpenCV, wherein the function parameters of the image ' are as follows:
the first parameter is: display window title strings, which may be named arbitrarily, e.g., "[" panoramic image "]";
the second parameter is as follows: a Mat type object for storing the spliced images, which is the spliced panoramic image and is the same as the second parameter of the 'stich' function;
then keeping the window displayed by using the waitKey function, wherein the function does not need to add parameters;
so far, the definition of the slot function b is completed;
the slot function exit: saving the picture and exiting the program;
firstly, whether the previous splicing is successful or not is determined by using an if statement and a function "empty" of OpenCV, so that a Mat type object used for storing a spliced image is required to call the function, the function has no parameter, and returns a pool type value, if no data exists in the corresponding Mat type object, a "true" is returned, the judgment here is that the returned value of the function is not taken, if yes, the splicing is successful, and a splicing result can be stored by using an "imwrite" function of OpenCV, wherein the function parameters are as follows:
The first parameter is: saving the path and the file name, and directly saving the path and the file name under the same path as the program, wherein the path and the file name are character strings in string type objects;
the second parameter is as follows: the Mat type object is an image needing to be stored, and is a Mat type object used for storing the spliced image;
then, an OpenCV function "destroyAllWindows" is used to close all windows opened by OpenCV, the function having no parameters;
finally, a program exit function 'exit' only has one parameter and is filled with a number 0 to indicate that the program exits normally;
this completes the definition of the slot function exit.
7. The software implementation method for multi-image stitching based on Qt interface as claimed in claim 1, wherein in step 6, after the Debug and Release versions are compiled and run, the third parameter of the "cv:: resize" function is adjusted.
8. A software implementation system for multi-image stitching based on a Qt interface is characterized by comprising:
the compiling environment setting module is used for configuring Qt and OpenCV and creating a Qt Guiapplication project;
the dialog box setting module is used for drawing a window in the ui file, adding a Push Button and a ScrollArea and designing a dialog box;
a member object setting module, which is used for adding the required member objects in the h file;
A member function setting module for declaring a required member function, i.e., a slot function corresponding to the button part, in the ". h" header file;
the device comprises a slot function association defining module, a component signal generating module and a processing module, wherein the slot function association defining module is used for establishing the association between a slot function and a component signal in a 'cpp' file with the same name as a project and defining the slot function;
the compiling module is used for compiling and operating the Debug version and the Release version;
and the Release module is used for packaging and releasing the executable file generated by the Release version.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
step 1, configuring Qt and OpenCV and creating a Qt Guiapplication project;
step 2, drawing a window in the ui file, adding a Push Button and a ScrollArea, and designing a dialog box;
step 3, adding the required member object in the h file;
step 4, declaring required member functions, namely, slot functions corresponding to the button parts in the head file of the h;
step 5, establishing a relation between a slot function and a component signal in a 'cpp' file with the same name as the project, and defining the slot function;
Step 6, compiling and operating a Debug version and a Release version;
and 7, packaging and releasing the executable file generated by the Release version.
10. A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
step 1, configuring Qt and OpenCV and creating a Qt Guiapplication project;
step 2, drawing a window in the ui file, adding a Push Button and a ScrollArea, and designing a dialog box;
step 3, adding the required member object in the h file;
step 4, declaring required member functions, namely, slot functions corresponding to the button parts in the head file of the h;
step 5, establishing a relation between a slot function and a component signal in a 'cpp' file with the same name as the project, and defining the slot function;
step 6, compiling and operating a Debug version and a Release version;
and 7, packaging and releasing the executable file generated by the Release version.
CN202010480639.XA 2020-05-30 2020-05-30 Realization method and system of multi-image splicing software based on Qt interface Active CN111857708B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010480639.XA CN111857708B (en) 2020-05-30 2020-05-30 Realization method and system of multi-image splicing software based on Qt interface

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010480639.XA CN111857708B (en) 2020-05-30 2020-05-30 Realization method and system of multi-image splicing software based on Qt interface

Publications (2)

Publication Number Publication Date
CN111857708A true CN111857708A (en) 2020-10-30
CN111857708B CN111857708B (en) 2023-05-12

Family

ID=72986019

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010480639.XA Active CN111857708B (en) 2020-05-30 2020-05-30 Realization method and system of multi-image splicing software based on Qt interface

Country Status (1)

Country Link
CN (1) CN111857708B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112732258A (en) * 2021-01-11 2021-04-30 中国船舶重工集团公司第七0七研究所 Dynamic switch button software implementation method based on state machine
CN115904353A (en) * 2023-03-02 2023-04-04 上海合见工业软件集团有限公司 Method and system for generating target source file of user interface

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6243859B1 (en) * 1998-11-02 2001-06-05 Hu Chen-Kuang Method of edit program codes by in time extracting and storing
CN105468366A (en) * 2015-11-21 2016-04-06 成都飞机工业(集团)有限责任公司 Intelligent interface based on Qt ground station
CN111192199A (en) * 2019-12-31 2020-05-22 武汉兴图新科电子股份有限公司 Method for splicing computer desktop and camera images across Windows and Linux platforms

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6243859B1 (en) * 1998-11-02 2001-06-05 Hu Chen-Kuang Method of edit program codes by in time extracting and storing
CN105468366A (en) * 2015-11-21 2016-04-06 成都飞机工业(集团)有限责任公司 Intelligent interface based on Qt ground station
CN111192199A (en) * 2019-12-31 2020-05-22 武汉兴图新科电子股份有限公司 Method for splicing computer desktop and camera images across Windows and Linux platforms

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
使用QT实现图片拼接功能: "嗜血的蚂蚁@", 《HTTPS://BLOG.CSDN.NET/WEIXIN_42054950/ARTICLE/DETAILS/84987037》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112732258A (en) * 2021-01-11 2021-04-30 中国船舶重工集团公司第七0七研究所 Dynamic switch button software implementation method based on state machine
CN115904353A (en) * 2023-03-02 2023-04-04 上海合见工业软件集团有限公司 Method and system for generating target source file of user interface
CN115904353B (en) * 2023-03-02 2023-06-23 上海合见工业软件集团有限公司 Method and system for generating target source file of user interface

Also Published As

Publication number Publication date
CN111857708B (en) 2023-05-12

Similar Documents

Publication Publication Date Title
Laganiere OpenCV computer vision application programming cookbook second edition
CN111857708A (en) Qt interface-based multi-image splicing software implementation method and system
US20100211865A1 (en) Cross-browser page visualization generation
JP2009163742A (en) Object oriented method of structuring software step program
CN103377119A (en) Automatic nonstandard control testing method and device
CN111459541B (en) Application program packaging method and device, computer equipment and storage medium
US20170090886A1 (en) System and Method for Using Ubershader Variants Without Preprocessing Macros
CN101714249A (en) Improving the portability of digital images
CN112711403B (en) Method, device, computer equipment and storage medium for synchronizing game development
US20230291994A1 (en) Photographing information management method and worker terminal in which program for executing photographing information management method is installed
KR20130047071A (en) Apparatus and method for developing mixed reality application for mobile terminal
CN112667212A (en) Buried point data visualization method and device, terminal and storage medium
US20080184144A1 (en) Display screen generating apparatus
Escrivá et al. OpenCV 4 Computer Vision Application Programming Cookbook: Build complex computer vision applications with OpenCV and C++
US20080028283A1 (en) Document production support device, methods thereof and storage medium
CN115543324A (en) Method, device, equipment and medium for generating interactive interface
CN113608727A (en) Code processing method, device and system for visual programming
CN114281341A (en) Compiling method and device of data structure definition file, computer equipment and medium
JP5657183B2 (en) Method and apparatus for enabling a first computer program to execute application logic of a second computer program, for interfacing the first computer program and the second computer program And apparatus for generating computer program code for the same, a computer program, and a software interface for enabling a first computer program to execute application logic of a second computer program For providing information (computer program interface)
US20220413810A1 (en) Program executing device, program executing method, and non-transitory computer-readable storage medium
CN111435313A (en) Method and device for changing skin of software
CN116882032B (en) Building design atlas digitizing and visualizing method and device for applying same
CN114327176B (en) Page element query method and device, electronic equipment and storage medium
JP2011118467A (en) Information processor, information processing method and computer program
CN115640095B (en) Method for generating WEB front-end image by XML and method for generating XML by WEB front-end image

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB03 Change of inventor or designer information

Inventor after: Han Yubing

Inventor after: Zhang Chunyang

Inventor after: Zhang Haode

Inventor after: Da Qing

Inventor before: Zhang Chunyang

Inventor before: Zhang Haode

Inventor before: Da Qing

Inventor before: Han Yubing

CB03 Change of inventor or designer information
GR01 Patent grant
GR01 Patent grant