Method for developing sonar signal processing software based on QT and MATLAB hybrid programming

By adopting a hybrid programming method of QT and MATLAB in signal processing software development, the complex problem of programming language conversion in the process of new algorithm engineering is solved, and an efficient development process is achieved, reducing costs and workloads, and improving efficiency and integration are improved.

CN119829034APending Publication Date: 2025-04-15THE 715TH RES INST OF CHINA SHIPBUILDING IND CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411918656.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-04-15

AI Technical Summary

Technical Problem

In signal processing research, complex programming language conversion is required in the engineering process of new algorithms, resulting in high development costs and low efficiency. Especially when the algorithm changes greatly, more software developers are required to participate, which increases the workload.

Method used

The method of developing sonar signal processing software based on hybrid programming based on QT and MATLAB is adopted. The algorithm part is implemented through MATLAB, dynamic link libraries are generated, and these libraries are called in QT to realize the parallel processing of the module and the CPU affinity setting.

Benefits of technology

It effectively reduces the workload of algorithm transplantation, improves development efficiency, shortens project cycles, and reduces development costs, while allowing algorithm research and engineering implementation to be more effectively combined.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119829034A_ABST
    Figure CN119829034A_ABST
Patent Text Reader

Abstract

The invention discloses a method for developing sonar signal processing software based on QT and MATLAB hybrid programming, which comprises the following steps of: (1) algorithm implementation: compiling codes of an algorithm part through MATLAB to generate a MATLAB file 'cbf.m'; (2) generating a dynamic link library: creating a C + + dynamic link library through a Library Compiler tool; (3) calling a dynamic link library: calling an MATLAB dynamic link library part in the QT; (4) module construction: realizing the function of a single module through a multi-thread mode; and (5) module integration: distributing an independent process for each module to realize parallel processing of each module. According to the method, MATLAB and QT software are combined, signal processing software is divided into an algorithm implementation part and a module integration part, signal processing research work and engineering implementation can be effectively combined together, the real-time performance of system software is improved, development cost is reduced, and meanwhile development efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of sonar signal processing software, and in particular relates to a method for developing sonar signal processing software based on QT and MATLAB hybrid programming. Background Art

[0002] In signal processing research, when a new algorithm needs to be engineered, complex programming language conversion is required. Especially when the update iteration speed is too fast and the algorithm changes a lot, more software developers need to be added, which greatly increases development costs and reduces development efficiency. Summary of the invention

[0003] Since the current equipment is developed in C / C++ in DSP or server environment, the algorithm research and engineering practice are not effectively combined. In order to effectively reduce the workload of transplantation, improve development efficiency and shorten the project cycle, the present invention proposes a method for developing sonar signal processing software based on QT and MATLAB hybrid programming.

[0004] The technical solution of the present invention is: A method for developing sonar signal processing software based on QT and MATLAB hybrid programming, comprising the following steps: (1) Algorithm implementation: Write the code of the algorithm part through MATLAB and generate the MATLAB file "cbf.m"; (2) Generate dynamic link library: Create C++ dynamic link library through Library Compiler tool; (3) Calling the dynamic link library: The part of calling the MATLAB dynamic link library in QT includes: 1) CBF module initialization; 2) libcbf initialization; 3) data reception; 4) calling the libcbf library; 5) data transmission; (4) Module construction: Implement the functions of a single module through multi-threading; Thread 1 receives the data and sends it to thread 2; Thread 2 reads the data sent by thread 1 and calls the dynamic link library, and sends the result to thread 3; Thread three reads the result sent by thread two, and so on, until the last thread result is obtained and sent to the next module; (5) Module integration: Assign a separate process to each module to achieve parallel processing of modules.

[0005] In the step (1), the algorithm is programmed in Python or other programming languages ​​in combination with MATLAB.

[0006] In step (2), open "Library Compiler", select "C++ Shared Library", click the "+" button to add a MATLAB file, such as "cbf.m", and click "Package" to generate a dynamic link library.

[0007] In the step (5), CPU affinity is set for the processes of each module, and the modules are bound to the cores of the CPU to achieve independent processing of each process to avoid mutual influence.

[0008] The sonar signal processing software is active signal processing software, including an array simulation module, an array arrangement module, a frequency shift filter downsampling module, a matched filter module, a beam forming module, a post-processing module and a tracking module which are performed sequentially.

[0009] Preferably, the matrix arrangement module is provided with control parameters by the control module, the post-processing module outputs warning data to the display module, and the tracking module outputs tracking information to the display module.

[0010] Preferably, the array simulation module, frequency shift filtering and downsampling module, matched filtering module, beam forming module, post-processing module and tracking module all include algorithm parts, and the six algorithm parts are respectively written in MATLAB to generate dynamic link libraries.

[0011] The beneficial effects of the present invention are: 1. Aiming at the limited energy and heavy tasks of algorithm researchers, as well as the relatively complex engineering of new algorithms, a software development method is proposed. Algorithm researchers use MATLAB to implement the algorithm part, and software developers use QT to implement the interface packaging of the algorithm part and the integration of various modules. This can relatively reduce the development difficulty and improve the development efficiency, while meeting the real-time nature of the system software, reducing the development cost and improving the development efficiency. 2. By calling the MATLAB software dynamic link library through QT software, the signal processing software is divided into two parts: algorithm implementation and module integration, which is convenient for subsequent algorithm research, update and iteration, and reduces the workload of developers to a certain extent, so that algorithm research and practical application can be more effectively combined; 3. It can free researchers from tedious and repetitive low-level labor and allow them to spend more time on the innovation of programming algorithms, thereby improving the coding efficiency and problem-solving ability of coders, and has a very broad application prospect; 4. The present invention can effectively combine signal processing research work with engineering implementation, thereby reducing development costs and improving development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Figure 1 A flow chart of the method for developing sonar signal processing software based on QT and MATLAB hybrid programming of the present invention; Figure 2 It is a flow chart of the method for calling the MATLAB dynamic link library part in QT of the present invention; Figure 3 This is a structural diagram of the active signal processing software module composition in the present invention. DETAILED DESCRIPTION

[0013] The technical solutions in the embodiments of the present invention are described clearly and completely below; it is obvious that the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of the present invention.

[0014] In the current equipment, when new algorithms are applied to engineering, the transplantation workload is large, the development efficiency is low, and the project cycle is long for developers. However, this method can effectively reduce the transplantation workload, improve development efficiency, and shorten the project cycle.

[0015] Specifically, MATLAB is a programming language and environment for scientific computing and visualization, integrating many functions such as numerical calculation, signal processing, computer simulation, image processing, etc. It is widely used in data analysis, signal processing, image processing and other fields. Because of its high programming efficiency and efficient and convenient matrix and array operations, it is often used in rapid verification of algorithm research and exploration. However, its shortcomings such as low loop operation efficiency and poor encapsulation often cannot fully meet the needs of users. It is widely used in algorithm research, but due to its poor interactivity and poor real-time performance, it is often not used in engineering implementation.

[0016] QT is a cross-platform C++ graphical user interface application development framework that enables developers to quickly build fully functional applications through rich graphics and user interface tools. It has powerful cross-platform features, high code running efficiency, strong window interface design functions, and convenient peripheral interface operation.

[0017] This method combines the two and integrates the advantages of both for hybrid programming. It can not only give full play to the powerful computing power contained in the matrix, but also improve the execution speed. At the same time, it can utilize the powerful algorithm function library of object-oriented programming languages ​​such as C++, saving time, thereby effectively reducing the workload of transplantation, improving development efficiency, and shortening the project cycle. Example 1

[0018] See also Figure 1The embodiment of the present invention provides a method for developing sonar signal processing software based on QT and MATLAB hybrid programming. The method includes four processing steps: algorithm implementation, dynamic link library generation, dynamic link library call, module construction and software integration. The specific steps are as follows: (1) Algorithm implementation Use MATLAB to write the code for the algorithm part and generate the MATLAB file "cbf.m", as follows: function [bfmout, timeout, freout] = cbf(datain, fs, c, d, fre, theta) / / Conventional beamforming [len, channel] = size(datain); / / Input data persistent fft_in / / data storage nfft = 2*len; / / fft points if isempty(fft_in) fft_in = zeros(nfft, channel); end fft_in(len+1:end, :) = datain; / / overlap data_fft = fft(fft_in). / nfft; fft_in(1:len, :) = fft_in(len+1:end, :); delay_theta = d.' / c*cosd(theta); / / driving vector calculation f = fs / nfft; / / frequency resolution pos = [nfft / 2+(1:nfft / 2), 1:nfft / 2]; data_fft = data_fft(pos, :); f_start = fre(1); / / Starting frequency f_stop = fre(2); / / cutoff frequency f_shift = fre(3); fl = nfft / 2 + 1 + floor((f_start-f_shift) / f); / / lowest frequency fh = nfft / 2 + 1 + ceil((f_stop-f_shift) / f); / / highest frequency beam_num = length(theta); / / beam number f0 = f_start; detaf0 = exp(1i*2*pi*f0*delay_theta); / / Start delay detaf = exp(1i*2*pi*f*delay_theta); / / frequency delay bf_data = zeros(nfft, beam_num); for k = fl:fh bf_data(pos(k), :) = data_fft(k, :)*detaf0; detaf0 = detaf0.*detaf; end bfmout = sum(abs(1 / channel*bf_data).^2) * 2; / / beam output data_ifft = ifft(bf_data, nfft).*nfft; beam_data = data_ifft.*2; timeout = beam_data(len / 2+(1:len), :); / / Time domain output freout = bf_data; / / frequency output.

[0019] (2) Generate dynamic link library Use the Library Compiler tool to create a C++ dynamic link library. The steps are as follows: 1) Open "Library Compiler"; 2) Select "C++ Shared Library", click the "+" button to add the MATLAB file, such as "cbf.m", and click "Package" to generate the dynamic link library.

[0020] (3) Calling the dynamic link library like Figure 2 As shown, in the part where QT calls the MATLAB dynamic link library, the steps include: 1) CBF module initialization; 2) libcbf initialization; 3) data reception; 4) calling the libcbf library; 5) data sending.

[0021] The code for QT calling the MATLAB dynamic link library is as follows: mclmcrInitialize(); / / Initialize the MATLAB runtime agent library mclInitializeApplication(NULL, 0); / / Set the application state shared by all MATLAB runtime instances created in the current process if (!cbfInitialize()) / / Initialize the beamforming lib library (cbf) return; … / / Call the matlab library mwArray para_out; / / output parameters mwArray data_out; / / output data mwArray para_in (1, PARA_LEN, mxSINGLE_CLASS); / / Input parameters para_in.SetData(para, PARA_LEN); mwArray data_in (BEAM_NUM, DATA_LEN_IN, mxSINGLE_CLASS); / / Input data data_in.SetData(data, BEAM_NUM* DATA_LEN_IN); cbf(2, para_out, data_out, para_in, data_in); / / Call lib library (cbf) … mclTerminateApplication(); / / Close the internal application state of MATLAB runtime.

[0022] (4) Module construction The functions of a single module are realized by multi-threading. Thread 1 receives data and sends it to thread 2. Thread 2 reads the data sent by thread 1 and calls the dynamic link library, and sends the result to thread 3. Thread 3 reads the result sent by thread 2, and so on, until the last thread result is obtained and sent to the next module.

[0023] (5) Module integration Assign a separate process to each module to achieve parallel processing of each module.

[0024] Furthermore, in step (1), this embodiment can also perform mixed programming with MATLAB through other programming languages, such as Python.

[0025] Furthermore, in step (5), CPU affinity is set for each process, and the module is bound to the CPU core to achieve the purpose of not affecting each other between processes, as follows: Use the taskset command to set CPU affinity. For example, if the module runtime is "cbf" and the bound CPU is core 3, the corresponding code is "taskset -c 3 cbf".

[0026] The following is a code / text description of the process of the active signal processing software. The module structure of this part of the software is as follows: Figure 3 As shown, it is mainly divided into sequential array simulation, array arrangement, frequency shift filtering and downsampling, matched filtering, beam forming, post-processing, tracking and other modules. The array arrangement module is provided with control parameters by the control module, the post-processing module outputs warning data to the display module, and the tracking module outputs tracking information to the display module.

[0027] Furthermore, the array simulation module, frequency shift filter downsampling module, matched filter module, beamforming module, post-processing module and tracking module all include algorithm parts. The six algorithm parts are written in MATLAB and then generate dynamic link libraries. Then, the dynamic link libraries are called in QT, and module construction and module integration are performed to complete the development of the active signal processing software.

[0028] The invention is characterized in that: 1. only the algorithm part is realized by MATLAB; 2. the MATLAB dynamic link library is called by QT; 3. a separate CPU affinity is set for each module.

[0029] During the software development process, algorithm researchers only need to focus on the coding implementation of the algorithm part of each module (implemented through MATLAB) and generate the corresponding dynamic link library. The construction and integration of each module can be implemented by other software developers, which greatly liberates the labor of algorithm researchers.

[0030] In summary, the present invention can effectively combine signal processing research work with engineering implementation, thereby reducing development costs and improving development efficiency.

[0031] It should be noted that the above embodiments are merely preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. All equivalent modifications made on the basis of the above embodiments belong to the protection scope of the present invention.

Claims

1. A method for developing sonar signal processing software based on QT and MATLAB hybrid programming, characterized in that: The steps include: (1) Algorithm implementation: Write the code of the algorithm part through MATLAB and generate the MATLAB file "cbf.m"; (2) Generate dynamic link library: Create C++ dynamic link library through Library Compiler tool; (3) Calling the dynamic link library: The part of calling the MATLAB dynamic link library in QT includes: 1) CBF module initialization; 2) libcbf initialization; 3) data reception; 4) calling the libcbf library; 5) data transmission; (4) Module construction: Implement the functions of a single module through multi-threading; Thread 1 receives the data and sends it to thread 2; Thread 2 reads the data sent by thread 1 and calls the dynamic link library, and sends the result to thread 3; Thread three reads the result sent by thread two, and so on, until the last thread result is obtained and sent to the next module; (5) Module integration: Assign a separate process to each module to achieve parallel processing of modules.

2. A method for developing sonar signal processing software based on QT and MATLAB hybrid programming according to claim 1, characterized in that: In the step (1), the algorithm is programmed in a hybrid manner using Python and MATLAB.

3. A method for developing sonar signal processing software based on QT and MATLAB hybrid programming according to claim 1, characterized in that: In step (2), open "Library Compiler", select "C++ Shared Library", click the "+" button to add a MATLAB file, such as "cbf.m", and click "Package" to generate a dynamic link library.

4. A method for developing sonar signal processing software based on QT and MATLAB hybrid programming according to claim 1, characterized in that: In the step (5), CPU affinity is set for the processes of each module, and the modules are bound to the cores of the CPU to achieve independent processing of each process.

5. A method for developing sonar signal processing software based on QT and MATLAB hybrid programming according to claim 1, characterized in that: The sonar signal processing software is active signal processing software, including an array simulation module, an array arrangement module, a frequency shift filter downsampling module, a matched filter module, a beam forming module, a post-processing module and a tracking module which are performed sequentially.

6. A method for developing sonar signal processing software based on QT and MATLAB hybrid programming according to claim 5, characterized in that: The matrix arrangement module is provided with control parameters by the control module, the post-processing module outputs warning data to the display module, and the tracking module outputs tracking information to the display module.

7. A method for developing sonar signal processing software based on QT and MATLAB hybrid programming according to claim 5 or 6, characterized in that: The array simulation module, frequency shift filtering and downsampling module, matched filtering module, beam forming module, post-processing module and tracking module all include algorithm parts. The six algorithm parts are respectively written in MATLAB and then a dynamic link library is generated.