A method for measuring gravity acceleration based on real-time video transmission via UDP protocol
Through the real-time video transmission method based on the UDP protocol, the motion video data of a single pendulum is collected and processed, and the problem of large timing errors in traditional single pendulum measurement of gravity acceleration is solved, achieving higher measurement accuracy and real-timeness.
Patent Information
- Application Number
- CN202210767792.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-01
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2042-07-01
AI Technical Summary
When measuring gravity acceleration in traditional single pendulum, due to manual operation of the stopwatch, it is easy to have advanced or lag timing, resulting in large timing errors.
Using the real-time video transmission method based on the UDP protocol, by arranging the pendulum ball and the camera nodes A and B, the moving video of the pendulum ball is collected, the image frame data is extracted, the spatial position data and gravity acceleration of the pendulum ball are calculated, and the data is performed through the terminal node. Processing and transfer.
Through two data acquisition and image processing, the accuracy of single pendulum gravity acceleration measurement is improved, and real-time video transmission through UDP protocol is ensured to the real-time and accuracy of measurement.
Smart Images

Figure CN115236761B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the fields of video data processing, network video transmission and university physics experimental instruments, and more specifically, to a gravity acceleration measurement method based on UDP protocol real-time video transmission. Background Art
[0002] In high school and college physics teaching, the methods for measuring gravity acceleration include electromagnetic dot timer method, simple pendulum method, free fall method, etc. When using a simple pendulum to measure gravity acceleration, the general method is to measure the period of the pendulum. When measuring the period, because the stopwatch is manually operated to start or stop timing, it is inevitable that there will be advance or lag timing, resulting in a large timing error.
[0003] With the development of video technology, the real-time images collected by the camera can be viewed in real time through the terminal, so as to grasp the activities of the target objects in the camera monitoring area; furthermore, the present invention proposes a gravity acceleration measurement method based on real-time video transmission of UDP protocol. Summary of the invention
[0004] The purpose of the invention is to solve the problem that the accuracy of gravity acceleration extraction in motion video is not high, and to propose a gravity acceleration measurement method based on UDP protocol real-time video transmission.
[0005] The technical solution of the present invention is:
[0006] The present invention provides a method for measuring gravity acceleration based on real-time video transmission of a UDP protocol, the method comprising the following steps:
[0007] S1, arranging a swinging ball and camera nodes A and B, wherein the camera nodes A and B are symmetrically distributed on both sides of the swinging ball to collect motion video of the swinging ball;
[0008] S2, the camera nodes A and B respectively extract the image frame data in the motion video for processing, and obtain the spatial position data cx and cy of the swinging ball in each frame image; and calculate the swing period T at the corresponding node respectively within the sampling period;
[0009] S3, camera nodes A and B respectively use the following formula to calculate the gravity acceleration g obtained by the corresponding node:
[0010]
[0011] Where: l is the length of the pendulum, T is the swing period of the pendulum measured at the corresponding node;
[0012] S4, camera nodes A and B are connected to the terminal node through a Gigabit Ethernet switch, and data transmission is performed through the UDP protocol to send image data frames and measurement data frames; the measurement data includes gravity acceleration g and spatial position data;
[0013] S5, the terminal node parses the data frame and extracts the image data and measurement data obtained by the corresponding camera node respectively;
[0014] S6, use the mean filtering algorithm to obtain the gravity acceleration g of the two nodes A , g B Processing is performed to obtain the actual gravitational acceleration G;
[0015]
[0016] Where: g local is the estimated value of the local gravitational acceleration, and T0 is the maximum acceptable error.
[0017] Furthermore, the static position of the swinging ball is taken as point O, and the camera nodes A and B are symmetrically distributed on both sides of the swinging ball and are orthogonal along directions AO and BO. The camera nodes A and B collect motion video of the swinging ball and display it in real time through a local monitor.
[0018] Furthermore, the image frame data processing in S2 specifically includes:
[0019] S21, each frame image Frame collected by the camera node A With Frame B Select the region of interest (ROI);
[0020] S22, convert the image after extracting the region of interest into the HSV color space using the following formula:
[0021]
[0022]
[0023] V=max(R,G,B)
[0024] When H<0 appears in the calculation results, the following formula is used for further processing:
[0025]
[0026] S23, perform OTSU binarization filtering on the converted HSV image:
[0027] S24, performing contour scanning on the HSV image after the binary processing by using a raster scanning method, and extracting the preliminary contour of the pendulum ball by using a maximum contour area algorithm;
[0028] S25, obtaining the coordinates, length and width of the preliminary outline of the swinging ball, marking the outline of the swinging ball with an external rectangular frame; extracting the position coordinates (x, y, w, h) of the swinging ball and the center coordinates (cx, cy) of the swinging ball according to the outline of the swinging ball, wherein the center coordinates (cx, cy) of the swinging ball are the spatial position data of the swinging ball in each frame image obtained by the camera node.
[0029] S26, the camera node continuously records the coordinates (cx, cy) of the center of the swinging ball obtained from each frame of the swinging ball motion video during the entire acquisition period, and uses the median absolute deviation method MAD to filter the horizontal coordinate cx of the center of the swinging ball during the sampling period, i.e., perform outlier processing;
[0030]
[0031] Where: i represents the image frame number obtained during the sampling period; cx i represents the horizontal coordinate of the center of the pendulum ball in the image frame numbered i; cx median is the median value of the horizontal coordinates of all pendulum centers within the sampling period, and MAD is |cx i -cx median |Median value of absolute deviation; n is the filter coefficient;
[0032] S27, using the fast Fourier transform algorithm FFT to process the filtered pendulum ball center horizontal coordinate data to obtain the corresponding frequency domain value, taking the frequency corresponding to the point with the largest amplitude as the swing frequency f of the simple pendulum, and calculating the corresponding swing period T=1 / f.
[0033] Further, in S21, the ROI area is the size of the swing area of the swing ball in the image.
[0034] Furthermore, in S25, the coordinates of the center of the swing ball are obtained using the following formula:
[0035]
[0036]
[0037] Furthermore, in S4, the camera nodes A and B use the OpenCV encoding function to encode the image data into JPEG format, making it a data stream img_data, and the corresponding image data frame format is: [frame header, img_data]; the measurement data frame format is: [frame header, cx_data, cy_data, gravity acceleration].
[0038] Furthermore, in S5, the terminal node uses the OpenCV decoding function imdecode(buf, flags) to parse the received data packet, and judges the frame header to determine whether it is image data or measured data, and restores the data.
[0039] Furthermore, during the entire acquisition cycle, the terminal node is controlled through the GUI to display the real-time video and measurement data of the two camera nodes A and B, that is, the currently captured swing ball position, separately or simultaneously.
[0040] Furthermore, the method also includes: calculating the swing angle according to the swing ball spatial position data in the measurement data, performing two-dimensional modeling according to the swing angle and the swing ball spatial position data, and restoring the swing trajectory of the swing ball on the XOY plane.
[0041] Furthermore, the swing angle
[0042] Beneficial effects of the present invention:
[0043] The present invention collects motion video of the swinging ball by arranging the swinging ball and the camera nodes A and B; the camera nodes A and B respectively extract image frame data for processing, obtain spatial position data of the swinging ball in each frame image, calculate the gravity acceleration obtained by the corresponding node and send it to the terminal node, and then the terminal node analyzes the data and uses the mean filter algorithm to process the gravity acceleration obtained by the two nodes to obtain the actual gravity acceleration G. The present invention collects data at two places, performs image processing and calculation respectively to obtain the gravity acceleration of each node, and then performs fitting, thereby effectively improving the accuracy of the single pendulum gravity acceleration measurement.
[0044] The image transmission part of the present invention is based on UDP (User Datagram Protocol), which belongs to the transport layer in the TCP / IP protocol family. It is a protocol that is widely used in real-time video transmission and is connectionless. Compared with TCP, another connected protocol in the transport layer, it has no complicated control process and can better ensure the real-time performance of the video, thereby ensuring the measurement accuracy of its gravity acceleration.
[0045] The present invention provides a device and method for measuring gravity acceleration, which are used to solve the problem that when measuring the swing period of a simple pendulum by a traditional method, due to the manual operation of a stopwatch to start or stop timing, it is inevitable that advance or lag timing will occur, resulting in a large timing error.
[0046] Other features and advantages of the present invention will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The above and other objects, features and advantages of the present invention will become more apparent through a more detailed description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, wherein like reference numerals generally represent like components throughout the exemplary embodiments of the present invention.
[0048] Figure 1 The schematic diagram of the structure of the present invention is shown. DETAILED DESCRIPTION
[0049] The preferred embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the preferred embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein.
[0050] The present invention provides a method for measuring gravity acceleration based on real-time video transmission of a UDP protocol, the method comprising the following steps:
[0051] S1. Arrange a swinging ball and camera nodes A and B. The camera nodes A and B are symmetrically distributed on both sides of the swinging ball to collect motion video of the swinging ball.
[0052] S2, the camera nodes A and B respectively extract the image frame data in the motion video for processing, and obtain the spatial position data cx and cy of the swinging ball in each frame image; calculate the swing period T at the corresponding node respectively within the sampling period, and the image frame data processing specifically includes:
[0053] S21, each frame image Frame collected by the camera node A With Frame B The ROI region is selected; the ROI region is the size of the swinging area of the pendulum ball in the image, and the outer frame background objects are removed; the static position of the pendulum ball is taken as point O, and the camera nodes A and B are symmetrically distributed on both sides of the pendulum ball and are orthogonal along the AO and BO directions. The camera nodes A and B collect the motion video of the pendulum ball and display it in real time through the local monitor.
[0054] S22, convert the image after extracting the region of interest into the HSV color space using the following formula:
[0055]
[0056]
[0057] V=max(R,G,B)
[0058] When H<0 appears in the calculation results, the following formula is used for further processing:
[0059]
[0060] S23, perform OTSU binarization filtering on the converted HSV image:
[0061]
[0062] S24, use the raster scanning method to perform contour scanning on the binarized HSV image img_hsv, obtain the contour data in the HSV image, and use the maximum contour area algorithm to extract the contour max_contour that is most likely to be the pendulum ball:
[0063]
[0064] S25, obtaining the coordinates, length and width of the preliminary outline of the swinging ball, and marking the outline of the swinging ball Contour by an external rectangular frame; extracting the position coordinates (x, y, w, h) of the swinging ball and the center coordinates (cx, cy) of the swinging ball according to the outline of the swinging ball, wherein the center coordinates (cx, cy) of the swinging ball are the spatial position data of the swinging ball in each frame image obtained by the camera node; the center coordinates of the swinging ball are obtained by the following formula:
[0065]
[0066]
[0067] S26, the camera node continuously records the coordinates (cx, cy) of the center of the swinging ball obtained from each frame of the swinging ball motion video during the entire acquisition period, and uses the median absolute deviation method MAD to filter the horizontal coordinate cx of the center of the swinging ball during the sampling period, i.e., perform outlier processing;
[0068]
[0069] Where: i represents the image frame number obtained during the sampling period; cx i represents the horizontal coordinate of the center of the pendulum ball in the image frame numbered i; cx median is the median value of the horizontal coordinates of all pendulum centers within the sampling period, and MAD is |cx i -cx median |Median value of absolute deviation; n is the filter coefficient;
[0070] S27, using the fast Fourier transform algorithm FFT to process the filtered pendulum ball center horizontal coordinate data to obtain the corresponding frequency domain value, taking the frequency corresponding to the point with the largest amplitude as the swing frequency f of the simple pendulum, and calculating the corresponding swing period T=1 / f.
[0071] S3, camera nodes A and B respectively use the following formula to calculate the gravity acceleration g obtained by the corresponding node:
[0072]
[0073] Where: l is the length of the pendulum, T is the swing period of the pendulum measured at the corresponding node.
[0074] S4, camera nodes A and B are connected to the terminal node through a Gigabit Ethernet switch, and data transmission is performed through the UDP protocol to send image data frames and measurement data frames; the measurement data includes gravity acceleration g and spatial position data;
[0075] Camera nodes A and B use OpenCV encoding functions to encode image data into JPEG format, making it a data stream img_data. The corresponding image data frame format is: [frame header, img_data]; the measurement data frame format is: [frame header, cx_data, cy_data, gravity acceleration]; according to the specified data frame format, it becomes a data stream img_data A ,img_data B , assigned to the memory buffer to reduce the amount of data during transmission and thus achieve stable and low-latency transmission of image data.
[0076] S5. The terminal node parses the data frame and extracts the image data and measurement data obtained by the corresponding camera node respectively; the terminal node uses the OpenCV decoding function imdecode(buf,flags) to parse the received data packet, and judges the frame header to determine whether it is image data or measured data, and restores the data; during the entire acquisition cycle, the terminal node is controlled by the GUI to display the real-time video and measurement data of the two camera nodes A and B separately or simultaneously, that is, the currently captured swing ball position.
[0077] S6, use the mean filtering algorithm to obtain the gravity acceleration g of the two nodes A , g B The actual gravitational acceleration G is obtained by processing; the gravitational acceleration obtained by the two nodes is processed by using a mean filtering algorithm that removes outliers, which can further ensure the measurement accuracy.
[0078]
[0079] Where: g local is the estimated value of the local gravitational acceleration, and T0 is the maximum acceptable error.
[0080] Furthermore, the method further comprises: calculating the swing angle according to the swing ball spatial position data in the measurement data, performing two-dimensional modeling according to the swing angle and the swing ball spatial position data, and restoring the swing trajectory of the swing ball on the XOY plane; swing angle
[0081] The image transmission part of the present invention is based on UDP (User Datagram Protocol), which belongs to the transport layer in the TCP / IP protocol family. It is a protocol that is widely used in real-time video transmission and is connectionless. Compared with TCP, another connected protocol in the transport layer, it has no complicated control process and can better ensure the real-time performance of the video, thereby ensuring the measurement accuracy of its gravity acceleration.
[0082] The embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments.
Claims
1. A method for measuring gravity acceleration based on real-time video transmission using UDP protocol, characterized in that: The method comprises the following steps: S1, arranging a swinging ball and camera nodes A and B, wherein the camera nodes A and B are symmetrically distributed on both sides of the swinging ball to collect motion video of the swinging ball; S2, the camera nodes A and B respectively extract the image frame data in the motion video for processing, and obtain the spatial position data cx and cy of the swinging ball in each frame image; and calculate the swing period T at the corresponding node respectively within the sampling period; S3, camera nodes A and B use the following formulas to calculate the gravity acceleration g obtained by the corresponding nodes: Where: l is the length of the pendulum, T is the swing period of the pendulum measured at the corresponding node; S4, camera nodes A and B are connected to the terminal node through a Gigabit Ethernet switch, and data transmission is performed through the UDP protocol to send image data frames and measurement data frames; the measurement data includes gravity acceleration g and spatial position data; S5, the terminal node parses the data frame and extracts the image data and measurement data obtained by the corresponding camera node respectively; S6, use the mean filtering algorithm to obtain the gravity acceleration g of the two nodes A , g B Processing is performed to obtain the actual gravitational acceleration G; Where: g local is the estimated value of the local gravitational acceleration, and T0 is the maximum acceptable error.
2. The method for measuring gravity acceleration based on real-time video transmission via UDP protocol according to claim 1, characterized in that: The static position of the swinging ball is taken as point O, and the camera nodes A and B are symmetrically distributed on both sides of the swinging ball and are orthogonal along directions AO and BO. The camera nodes A and B collect the motion video of the swinging ball and display it in real time through a local monitor.
3. The method for measuring gravity acceleration based on real-time video transmission using UDP protocol according to claim 1, characterized in that: The image frame data processing in S2 specifically includes: S21, each frame image Frame collected by the camera node A With Frame B Select the region of interest (ROI); S22, convert the image after extracting the region of interest into the HSV color space using the following formula: V=max(R,G,B) When H<0 appears in the calculation results, the following formula is used for further processing: S23, perform OTSU binarization filtering on the converted HSV image: S24, performing contour scanning on the HSV image after the binary processing by using a raster scanning method, and extracting the preliminary contour of the pendulum ball by using a maximum contour area algorithm; S25, obtaining the coordinates, length and width of the preliminary outline of the swinging ball, marking the outline of the swinging ball by an external rectangular frame; extracting the position coordinates (x, y, w, h) of the swinging ball and the center coordinates (cx, cy) of the swinging ball according to the outline of the swinging ball, wherein the center coordinates (cx, cy) of the swinging ball are the spatial position data of the swinging ball in each frame image obtained by the camera node; S26, the camera node continuously records the coordinates (cx, cy) of the center of the swinging ball obtained from each frame of the swinging ball motion video during the entire acquisition period, and uses the median absolute deviation method MAD to filter the horizontal coordinate cx of the center of the swinging ball during the sampling period, i.e., perform outlier processing; Where: i represents the image frame number obtained during the sampling period; cx i represents the horizontal coordinate of the center of the pendulum ball in the image frame numbered i; cx median is the median value of the horizontal coordinates of all pendulum centers within the sampling period, and MAD is |cx i -cx median |Median value of absolute deviation; n is the filter coefficient; S27, using the fast Fourier transform algorithm FFT to process the filtered pendulum ball center horizontal coordinate data to obtain the corresponding frequency domain value, taking the frequency corresponding to the point with the largest amplitude as the swing frequency f of the simple pendulum, and calculating the corresponding swing period T=1 / f.
4. The method for measuring gravity acceleration based on real-time video transmission via UDP protocol according to claim 3 is characterized in that In S21, the ROI area is the size of the swing area of the swing ball in the image.
5. The method for measuring gravity acceleration based on real-time video transmission via UDP protocol according to claim 3 is characterized in that In S25, the coordinates of the center of the swing ball are obtained using the following formula:
6. The method for measuring gravity acceleration based on real-time video transmission via UDP protocol according to claim 3 is characterized in that In S4, camera nodes A and B use OpenCV encoding functions to encode image data into JPEG format, making it a data stream img_data. The corresponding image data frame format is: [frame header, img_data]; the measurement data frame format is: [frame header, cx_data, cy_data, gravity acceleration].
7. The method for measuring gravity acceleration based on real-time video transmission via UDP protocol according to claim 6, characterized in that In S5, the terminal node uses the OpenCV decoding function imdecode(buf, flags) to parse the received data packet, and judges the frame header to determine whether it is image data or measured data, and restores the data.
8. The method for measuring gravity acceleration based on real-time video transmission via UDP protocol according to claim 1, characterized in that During the entire acquisition cycle, the terminal node is controlled through the GUI to display the real-time video and measurement data of the two camera nodes A and B separately or simultaneously, that is, the currently captured swing ball position.
9. The method for measuring gravity acceleration based on real-time video transmission via UDP protocol according to claim 3, characterized in that The method also includes: calculating the swing angle according to the swing ball spatial position data in the measurement data, performing two-dimensional modeling according to the swing angle and the swing ball spatial position data, and restoring the swing trajectory of the XOY plane swing ball.
10. The method for measuring gravity acceleration based on real-time video transmission via UDP protocol according to claim 9, characterized in that Swing angle
Citation Information
Patent Citations
Remotely-controllable system for measuring gravitational acceleration by using simple pendulum method
CN102646348A
Gravity acceleration experimental instrument
CN202003549U