Image processing-based simple pendulum harmonic motion parameter measurement method and device
Patent Information
- Application Number
- CN202610942625.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-29
- Publication Date
- 2026-10-13
AI Technical Summary
该方法为非接触式,不干扰摆锤运动,但为获得足够的测量精度,需要摄像头达到极高的帧率(例如60fps以上)以确保不遗漏关键帧,对硬件性能要求较高,难以在树莓派、智能手机等低算力终端设备上实现实时高精度测量
[0035](1)本申请提出的一种基于图像处理的单摆简谐运动参数测量方法通过滑动窗口多点验证策略确认摆动极限位置,要求连续三帧运动图像的摆锤的坐标均满足运动方向反转条件后才确认极限位置,有效过滤了因设备抖动或图像噪声导致的假信号,克服了低帧率条件下直接采样精度不足的缺陷,可部署于树莓派3B+/4B、智能手机、笔记本电脑及Arduino开发板等低算力终端设备上,成本低廉,便于在教学实验中普及推广。
Smart Images

Figure CN122906136A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image data processing technology, and specifically to a method, apparatus, and readable medium for measuring the simple harmonic motion parameters of a pendulum based on image processing. Background Technology
[0002] The simple pendulum experiment is a classic method for measuring gravitational acceleration and verifying the laws of simple harmonic motion. Since Galileo discovered the isochronism of the pendulum, the periodic motion of the simple pendulum has attracted the attention of the scientific community. When the pendulum swings under small angle conditions (less than 5 degrees), its motion can be approximated as simple harmonic motion, with a period of oscillation... With pendulum length and gravitational acceleration They satisfy a definite mathematical relationship, as shown in the following formula:
[0003] .
[0004] Therefore, by accurately measuring the oscillation period of a simple pendulum, the gravitational acceleration can be solved given the pendulum length, or the pendulum length can be solved given the gravitational acceleration.
[0005] Currently, there are two main methods for measuring the motion parameters of a simple pendulum:
[0006] (1) Contact sensor method: Ultrasonic sensors, accelerometers, magnetic sensors, etc. are attached to the pendulum, and the oscillation period is determined by the change of sensor signal. The principle of this method is intuitive, but the sensor attached to the pendulum will change its mass distribution and center of mass position, which can easily cause the pendulum to deviate from the ideal plane oscillation and produce a conical pendulum phenomenon, especially under small oscillation angle conditions. In addition, the accelerometer is susceptible to electromagnetic interference, and the ambient light sensor will also be greatly affected in strong light or complex light change environments.
[0007] (2) High-speed camera direct sampling method: This method uses a high frame rate camera to capture the motion of a pendulum and directly captures key frames of the pendulum reaching its limit position to determine the period. This method is non-contact and does not interfere with the motion of the pendulum. However, in order to obtain sufficient measurement accuracy, the camera needs to reach an extremely high frame rate (e.g., above 60fps) to ensure that no key frames are missed. This method has high hardware performance requirements and is difficult to implement in real-time high-precision measurement on low-computing-power terminal devices such as Raspberry Pi and smartphones.
[0008] In summary, existing technologies struggle to balance measurement accuracy, device portability, and non-contact operation, lacking a solution that can maintain high measurement accuracy even at low frame rates. Summary of the Invention
[0009] The purpose of this application is to provide a method, apparatus, and readable medium for measuring the simple harmonic motion parameters of a pendulum based on image processing, addressing the aforementioned technical problems.
[0010] In a first aspect, the present invention provides a method for measuring the simple harmonic motion parameters of a pendulum based on image processing, comprising the following steps:
[0011] Real-time acquisition of motion images of a simple pendulum, and extraction of the coordinates of the pendulum bob in the image coordinate system from each frame of motion image, including the horizontal and vertical coordinates;
[0012] A sliding window is constructed to store the coordinates of the pendulum in several consecutively acquired motion images. The coordinates of the first frame in the sliding window are the historical coordinates, and the coordinates of the other frames are the coordinates to be determined. The motion direction reversal determination is performed on all the coordinates to be determined and the historical coordinates in turn. The motion direction reversal determination specifically includes: when the pendulum swings to one side, it is determined whether the motion direction of the coordinates to be determined relative to the historical coordinates is reversed in both the horizontal and vertical directions. If not, the sliding window is moved, the coordinates to be determined are used as the historical coordinates in the sliding window, and new motion images are acquired to fill in the coordinates in the sliding window. The process is then repeated to perform the motion direction reversal determination on all the coordinates to be determined and the historical coordinates in turn. Otherwise, the historical coordinates are closer to the swing limit position relative to the coordinates to be determined. In response to the determination that the historical coordinates are closer to the swing limit position relative to all the coordinates to be determined, the historical coordinates are determined to be the swing limit position coordinates.
[0013] The time interval between the pendulum bob starting from the coordinates of the pendulum's extreme swing position and returning to the coordinates of the same side's extreme swing position is recorded as a single swing period;
[0014] The average oscillation period is obtained by averaging multiple individual oscillation periods.
[0015] Obtain one of the parameters of a simple pendulum, namely its length and gravitational acceleration, and calculate the other parameter based on its average oscillation period.
[0016] Preferably, the sliding window stores four coordinates; in response to determining that all three coordinates to be determined satisfy the motion direction reversal condition relative to the historical coordinates, the historical coordinates are determined as the swing limit position coordinates.
[0017] Preferably, when the pendulum swings to the left, the motion direction reversal determination is as follows: determine whether the horizontal coordinate of the coordinate to be determined increases and the vertical coordinate decreases relative to the historical coordinate. If the horizontal coordinate increases and the vertical coordinate decreases, the motion direction is determined to have reversed; otherwise, the coordinate to be determined is closer to the swing limit position relative to the historical coordinate. Move the sliding window, use the coordinate to be determined as the historical coordinate within the sliding window, and collect new motion images to fill in the coordinates within the sliding window. Return to execute the motion direction reversal determination for all coordinates to be determined and the historical coordinate in turn.
[0018] When the pendulum swings to the right, the motion direction reversal determination is as follows: determine whether the x-coordinate and y-coordinate of the coordinate to be determined relative to the historical coordinates have decreased. If both the x-coordinate and y-coordinate have decreased, the motion direction is determined to have reversed; otherwise, the coordinate to be determined is closer to the swing limit position relative to the historical coordinates. Move the sliding window, use the coordinate to be determined as the historical coordinate within the sliding window, and collect new motion images to fill in the coordinates within the sliding window. Return to the previous step and perform motion direction reversal determination on all coordinates to be determined and the historical coordinates in turn.
[0019] Preferably, a first camera and a second camera are used to acquire motion images of the pendulum. The horizontal plane on which the first camera and the second camera are located is the first plane. The line connecting the projection point of the pendulum bob on the first plane when it is at rest and the first camera is the first reference axis. The line connecting the projection point of the pendulum bob on the first plane when it is at rest and the second camera is the second reference axis. The first reference axis and the second reference axis are perpendicular to each other, and the distance from the first camera to the projection point is equal to the distance from the second camera to the projection point.
[0020] Preferably, the method further includes calculating the angle between the projection of the pendulum's trajectory onto the first plane and the first reference axis, as shown in the following formula:
[0021] ;
[0022] in, This represents the angle between the projection of the pendulum's trajectory onto the first plane and the first reference axis. This represents the horizontal displacement amplitude of the pendulum ball within the field of view of the first camera; This represents the horizontal displacement amplitude of the pendulum ball within the field of view of the second camera; This represents the arctangent function.
[0023] As a preferred option The acquisition process specifically includes: calculating the difference in abscissa between the left and right extreme positions of the pendulum in the motion image captured by the first camera;
[0024] The acquisition process specifically includes: statistically analyzing the difference in horizontal coordinates between the left and right extreme positions of the pendulum in the motion image captured by the second camera.
[0025] Secondly, the present invention provides a device for measuring the simple harmonic motion parameters of a pendulum based on image processing, comprising:
[0026] The image acquisition module is configured to acquire motion images of a simple pendulum in real time and extract the coordinates of the pendulum bob in the image coordinate system from each frame of motion image. The coordinates include the horizontal and vertical coordinates.
[0027] The extreme position determination module is configured to construct a sliding window, which stores the coordinates of the pendulum in several consecutively acquired motion images. The coordinates of the first frame in the sliding window are historical coordinates, and the coordinates of other frames are coordinates to be determined. The module performs motion direction reversal determination on all coordinates to be determined in turn with the historical coordinates. The motion direction reversal determination specifically includes: when the pendulum swings to one side, it determines whether the motion direction of the coordinates to be determined relative to the historical coordinates is reversed in both the horizontal and vertical directions. If not, the sliding window is moved, the coordinates to be determined are used as the historical coordinates in the sliding window, and new motion images are acquired to fill in the coordinates in the sliding window. The module then returns to perform motion direction reversal determination on all coordinates to be determined in turn with the historical coordinates. Otherwise, the historical coordinates are closer to the swing limit position relative to the coordinates to be determined. In response to the determination that the historical coordinates are closer to the swing limit position relative to all coordinates to be determined, the historical coordinates are determined to be the swing limit position coordinates.
[0028] The single swing cycle calculation module is configured to record the time interval between the pendulum bob starting from the swing limit position coordinate and returning to the same side swing limit position coordinate as a single swing cycle;
[0029] The average oscillation period calculation module is configured to average multiple individual oscillation periods to obtain the average oscillation period.
[0030] The parameter calculation module is configured to obtain one of the parameters of the pendulum, namely the pendulum length and gravitational acceleration, and calculate the other parameter based on the average oscillation period.
[0031] Thirdly, the present invention provides an electronic device including one or more processors; and a memory for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to implement the method as described in any implementation of the first aspect.
[0032] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method as described in any of the implementations of the first aspect.
[0033] Fifthly, the present invention provides a computer program product, including a computer program that, when executed by a processor, implements the method as described in any of the implementations in the first aspect.
[0034] Compared with the prior art, the present invention has the following beneficial effects:
[0035] (1) The simple harmonic motion parameter measurement method of a pendulum based on image processing proposed in this application confirms the swing limit position through a sliding window multi-point verification strategy. It requires that the coordinates of the pendulum in three consecutive frames of motion images meet the motion direction reversal condition before the limit position is confirmed. This effectively filters out false signals caused by device jitter or image noise, overcomes the defect of insufficient direct sampling accuracy under low frame rate conditions, and can be deployed on low computing power terminal devices such as Raspberry Pi 3B+ / 4B, smartphones, laptops and Arduino development boards. It is low in cost and easy to popularize and promote in teaching experiments.
[0036] (2) The image processing-based method for measuring the simple harmonic motion parameters of a pendulum proposed in this application combines a multi-period averaging strategy to reduce the initial and final positioning errors and further reduce the pendulum length error.
[0037] (3) The simple harmonic motion parameter measurement method of a pendulum based on image processing proposed in this application calculates the angle between the projection of the pendulum trajectory onto the first plane and the first reference axis by using the geometric constraint of two cameras arranged vertically and at equal distances, thereby expanding the spatial dimension analysis capability of the measurement system. Attached Figure Description
[0038] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0039] Figure 1 This is a flowchart illustrating an image processing-based method for measuring the simple harmonic motion parameters of a pendulum, as described in an embodiment of this application.
[0040] Figure 2 This is a schematic diagram of the structure of a simple pendulum simple harmonic motion parameter measurement system based on image processing, according to an embodiment of this application.
[0041] Figure 3 This is a schematic diagram showing the angle between the projection of the trajectory of the pendulum onto the first plane and the first reference axis, according to an embodiment of this application.
[0042] Figure 4 This is a schematic diagram of an image processing-based simple pendulum simple harmonic motion parameter measuring device according to an embodiment of this application;
[0043] Figure 5 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention.
[0044] Reference numerals: 11, cycloid; 12, pendulum; 131, first camera; 132, second camera. Detailed Implementation
[0045] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0046] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0047] Figure 1 The first aspect of this application, as illustrated by an embodiment, provides a method for measuring the simple harmonic motion parameters of a pendulum based on image processing, comprising the following steps:
[0048] S1 acquires motion images of a simple pendulum in real time and extracts the coordinates of the pendulum bob in the image coordinate system from each frame of motion image. The coordinates include the horizontal and vertical coordinates.
[0049] Specifically, the image processing-based method for measuring the simple harmonic motion parameters of a pendulum proposed in this application is based on the following physical principle: According to Newtonian mechanics, the gravitational torque of a pendulum is as follows:
[0050] ;
[0051] Where M represents the gravitational torque, m represents the mass, g represents the gravitational acceleration, and L represents the pendulum length. Let be the pendulum angle. From the angular momentum theorem, the equation of motion for a simple pendulum can be obtained as follows:
[0052] ;
[0053] Where d represents the differential operator. The dynamic equation of a simple pendulum is a nonlinear differential equation. When the pendulum angle... Approximately 0.08726 rad, or at 5 degrees. The difference between the two is only a few parts per thousand, therefore the equation of motion of a simple pendulum can be approximated as the equation of simple harmonic motion, the general solution of which is: A and Let be an arbitrary constant determined by the initial conditions, and Therefore, the oscillation period of a simple pendulum can be calculated. As shown in the following formula:
[0054] .
[0055] By measuring the period T, the pendulum length L can be calculated given the gravitational acceleration g, or the gravitational acceleration g can be calculated given the pendulum length L.
[0056] refer to Figure 2 This application proposes an image processing-based system for measuring the simple harmonic motion parameters of a pendulum, comprising at least one CMOS camera, preferably with a frame rate of 30 frames per second. The camera is positioned to capture the entire trajectory of the pendulum, without needing to capture the entire pendulum string. The pendulum's swing angle is less than 5 degrees. The camera is connected to a processor, such as a Raspberry Pi 4B, Raspberry Pi 3B+, smartphone, or laptop, via a data cable or wirelessly.
[0057] In step S1, a video of the pendulum motion is captured by a camera, and each frame of the video is processed to extract the horizontal and vertical coordinates of the pendulum bob 12 in the image coordinate system.
[0058] S2. Construct a sliding window to store the coordinates of the pendulum in several consecutively acquired motion images. The coordinates of the first frame in the sliding window are historical coordinates, and the coordinates of other frames are coordinates to be determined. Perform motion direction reversal judgment on all coordinates to be determined and historical coordinates in turn. The motion direction reversal judgment specifically includes: when the pendulum swings to one side, determine whether the motion direction of the coordinates to be determined relative to the historical coordinates is reversed in both the horizontal and vertical directions. If not, move the sliding window, use the coordinates to be determined as the historical coordinates in the sliding window, and acquire new motion images to fill in the coordinates in the sliding window. Return to perform motion direction reversal judgment on all coordinates to be determined and historical coordinates in turn. Otherwise, the historical coordinates are closer to the swing limit position relative to the coordinates to be determined. In response to determining that the historical coordinates are closer to the swing limit position relative to all coordinates to be determined, the historical coordinates are determined to be the swing limit position coordinates.
[0059] In a specific embodiment, the sliding window stores four coordinates; in response to determining that all three coordinates to be determined satisfy the motion direction reversal condition relative to the historical coordinates, the historical coordinates are determined as the swing limit position coordinates.
[0060] In a specific embodiment, when the pendulum swings to the left, the motion direction reversal determination is as follows: determine whether the horizontal coordinate of the coordinate to be determined increases and the vertical coordinate decreases relative to the historical coordinate. If the horizontal coordinate increases and the vertical coordinate decreases, the motion direction is determined to have reversed; otherwise, the coordinate to be determined is closer to the swing limit position relative to the historical coordinate. Move the sliding window, use the coordinate to be determined as the historical coordinate within the sliding window, and collect new motion images to fill in the coordinates within the sliding window. Return to execute the motion direction reversal determination for all coordinates to be determined and the historical coordinate in turn.
[0061] When the pendulum swings to the right, the motion direction reversal determination is as follows: determine whether the x-coordinate and y-coordinate of the coordinate to be determined relative to the historical coordinates have decreased. If both the x-coordinate and y-coordinate have decreased, the motion direction is determined to have reversed; otherwise, the coordinate to be determined is closer to the swing limit position relative to the historical coordinates. Move the sliding window, use the coordinate to be determined as the historical coordinate within the sliding window, and collect new motion images to fill in the coordinates within the sliding window. Return to the previous step and perform motion direction reversal determination on all coordinates to be determined and the historical coordinates in turn.
[0062] Specifically, step S2 confirms the swing limit position through a sliding window multi-point verification strategy and combines it with a multi-cycle averaging strategy to reduce the initial and final positioning errors. This allows the pendant length error to be controlled within 2 cm at a frame rate of 30 frames per second, overcoming the deficiency of insufficient accuracy in direct sampling under low frame rate conditions. In the embodiments of this application, a sliding window is constructed, which stores the coordinates of the pendant ball 12 in the latest four continuously acquired motion images. The coordinates of the first frame in the sliding window are historical coordinates, and the coordinates of the other three frames are coordinates to be determined. Whenever the camera acquires a new motion image and extracts the new coordinates, the window moves forward one position, and the new coordinates enter the last position of the window.
[0063] For all coordinates to be determined within the sliding window, a motion direction reversal judgment is performed sequentially compared to the historical coordinates. Taking the determination of the left extreme position as an example: when pendulum 12 swings to the left, the horizontal coordinate decreases and the vertical coordinate increases. When the pendulum reaches the left extreme position and begins to fall back to the right, the motion direction is reversed. The motion direction reversal judgment condition is: the horizontal coordinate of the coordinate to be determined increases and the vertical coordinate decreases relative to the historical coordinates.
[0064] If a certain coordinate to be determined does not meet the condition for reversing the motion direction, then the coordinate to be determined is closer to the swing limit position than the historical coordinate. Move the sliding window, take the coordinate to be determined as the new historical coordinate, and collect a new motion image. Extract the coordinates of the pendulum ball 12 in the new motion image to complete the coordinates of the sliding window. Return to execute the motion direction reversal determination for all coordinates to be determined and the historical coordinates in turn.
[0065] If all three coordinates to be determined satisfy the motion direction reversal condition relative to the historical coordinates, then the historical coordinates are confirmed as the coordinates of the swing limit position. This strategy ensures that the reversal is a continuous fall after the pendulum 12 has truly passed the highest point, rather than a false signal caused by device jitter or image noise, by requiring that three consecutive sampling steps show a reversal.
[0066] S3 records the time interval between the pendulum bob starting from the extreme position coordinate and returning to the extreme position coordinate on the same side as a single swing cycle.
[0067] Specifically, in the embodiments of this application, when the sliding window saves the coordinates of the pendulum 12 in each frame of motion image, it also saves the acquisition timestamp of that frame of motion image. After determining that the historical coordinates are the swing limit position coordinates in step S3, the acquisition timestamp of the frame of motion image corresponding to the historical coordinates is read, and the timestamp of the pendulum 12 reaching the same side swing limit position coordinate again is recorded to calculate a single swing cycle; furthermore, the timestamp of the pendulum 12 reaching the same side swing limit position coordinate again is used as the start time of the next swing cycle, and the process continues to wait for the timestamp of the next pendulum reaching the same side swing limit position coordinate, and so on, until a preset number of single swing cycles are collected, so as to facilitate the subsequent calculation of the average swing cycle.
[0068] S4, take the average value of multiple individual oscillation periods to obtain the average oscillation period.
[0069] Specifically, during the measurement of the swing period, some keyframes may be missed due to insufficient frame rate, resulting in an error of one frame interval in the positioning of the extreme swing position in a single swing. Taking a camera frame rate of 30 frames / second and a preset quantity of 10 as an example, the single positioning error is approximately 33ms. However, the total time of 10 cycles only includes the two beginning and end errors (approximately 67ms). After averaging over each cycle, the error drops to approximately 6.7ms, which is far below the allowable cycle error threshold (approximately 16ms). Therefore, the swing length error can be controlled within 2cm. In the embodiments of this application, the average swing period is obtained by measuring the first 10 swing cycles and taking the average value. Using the average oscillation period when calculating the simple harmonic motion parameters of a pendulum can eliminate the error of measuring a single oscillation period.
[0070] S5 obtains one of the parameters of the pendulum, namely the pendulum length and gravitational acceleration, and calculates the other parameter based on the average oscillation period.
[0071] Specifically, a correction value d is introduced to compensate for the deviation between the end of the pendulum 11 and the center of mass of the pendulum 12. The correction value d can be determined by analyzing the systematic deviation of multiple measurement data. When the acceleration due to gravity is known... At that time, the pendulum length L is calculated according to the following formula:
[0072] .
[0073] When the pendulum length L is known, the local gravitational acceleration can be calculated using the following formula. :
[0074] .
[0075] In a specific embodiment, a first camera and a second camera are used to acquire motion images of a simple pendulum. The horizontal plane on which the first camera and the second camera are located is a first plane. The line connecting the projection point of the pendulum bob on the first plane when it is at rest and the first camera is a first reference axis. The line connecting the projection point of the pendulum bob on the first plane when it is at rest and the second camera is a second reference axis. The first reference axis and the second reference axis are perpendicular to each other, and the distance from the first camera to the projection point is equal to the distance from the second camera to the projection point.
[0076] In a specific embodiment, the calculation further includes calculating the angle between the projection of the pendulum's trajectory onto the first plane and the first reference axis, as shown in the following formula:
[0077] ;
[0078] in, This represents the angle between the projection of the pendulum's trajectory onto the first plane and the first reference axis. This represents the horizontal displacement amplitude of the pendulum ball within the field of view of the first camera; This represents the horizontal displacement amplitude of the pendulum ball within the field of view of the second camera; This represents the arctangent function.
[0079] In a specific embodiment, The acquisition process specifically includes: calculating the difference in abscissa between the left and right extreme positions of the pendulum in the motion image captured by the first camera;
[0080] The acquisition process specifically includes: statistically analyzing the difference in horizontal coordinates between the left and right extreme positions of the pendulum in the motion image captured by the second camera.
[0081] Specifically, the image processing-based method for measuring the simple harmonic motion parameters of a pendulum proposed in this application also includes measuring the spatial trajectory angle. (Reference) Figure 2 and Figure 3The angle between the projection of the pendulum's trajectory onto the first plane and the first reference axis is the spatial trajectory angle. Two cameras are needed to simultaneously capture the pendulum's motion images; these two cameras are the first camera 131 and the second camera 132. The line connecting the projection point O on the first plane when the pendulum bob 12 is stationary and the first camera 131 is the first reference axis. The line connecting the projection point O on the first plane when the pendulum bob 12 is stationary and the second camera 132 is the second reference axis. The first and second reference axes are perpendicular to each other, and the distance from the first camera 131 to the projection point O is equal to the distance from the second camera 132 to the projection point O. Step S2 is used to confirm the coordinates of the left extreme position and the left extreme position of the swing in the motion images captured by the first camera 131 and the second camera 132, respectively, thereby extracting the horizontal displacement amplitude. and .
[0082] In the embodiments of this application, and The horizontal displacement amplitude can also be extracted from the sinusoidal fitting curve functions corresponding to the first camera 131 and the second camera 132, respectively. Specifically, this involves constructing a discrete coordinate sequence with time as the independent variable and the abscissa of the pendulum 12 in all frames of motion images as the dependent variable, and then fitting the discrete coordinate sequence with a sine curve to obtain the fitted curve function, angular frequency, and horizontal displacement amplitude. Specifically, since the horizontal position of the pendulum can be considered as simple harmonic motion within a small angle range, and the horizontal position exhibits a sinusoidal relationship with time, a sine function is used... By performing curve fitting on a discrete coordinate sequence, the angular frequency can be obtained from the fitting result. And horizontal displacement amplitude. By recovering the period parameters of simple harmonic motion from the overall trend of the pendulum's position change in continuous multi-frame motion images, high-precision angular frequency parameters and horizontal displacement amplitude can still be obtained at frame rates as low as 7 frames / second.
[0083] According to the formula Calculate the angle between the projection of the pendulum's trajectory onto the first plane and the first reference axis.
[0084] The simple harmonic motion of a pendulum is measured using the image processing-based method for measuring its simple harmonic motion parameters proposed in this application. Multiple pendulums with different lengths are determined within a pendulum length range of 0.5-1.5 meters, and their periods are measured. The simple harmonic motion parameters of the pendulum calculated by the image processing-based method are shown in Table 1. Table 1 shows that the pendulum length error calculated based on the average oscillation period is less than 2 cm, and the gravitational acceleration error is less than... The simple harmonic motion parameters of a pendulum, calculated using an image processing-based method, were obtained. As shown in Table 2 The error range is extremely small.
[0085] Table 1. Simple harmonic motion parameters of a pendulum obtained by the image processing-based method.
[0086]
[0087] Table 2. Parameters of Simple Harmonic Motion of Pendulum Calculated Using Image Processing-Based Measurement Method
[0088]
[0089] The image processing-based method for measuring the simple harmonic motion parameters of a pendulum proposed in this application can be deployed on mobile phones, Raspberry Pi, and some low-computing-power terminal devices. Taking a Raspberry Pi 4B as an example, the method proposed in this application takes 25-30 seconds from the start of measurement to obtaining the measurement result, effectively improving the camera's measurement accuracy, with the error range within the experimental random error range. It performs excellently in low frame rate environments and is perfectly compatible with low-computing-power devices such as mobile phones, Raspberry Pi, Arduino development boards, and microcontrollers, showing broad application prospects and facilitating its popularization and promotion in teaching experiments.
[0090] The steps S1-S5 above do not necessarily represent the order of the steps, but are represented by step symbols. The order of the steps can be adjusted.
[0091] Further reference Figure 4 As an implementation of the methods shown in the above figures, this application provides an embodiment of a simple pendulum simple harmonic motion parameter measuring device based on image processing. This device embodiment is similar to... Figure 1 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.
[0092] This application provides an image processing-based device for measuring the simple harmonic motion parameters of a pendulum, including:
[0093] Image acquisition module 1 is configured to acquire motion images of a simple pendulum in real time and extract the coordinates of the pendulum bob in the image coordinate system from each frame of motion image, including the horizontal and vertical coordinates.
[0094] The limit position determination module 2 is configured to construct a sliding window, which stores the coordinates of the pendulum in several consecutively acquired motion images. The first frame coordinates in the sliding window are historical coordinates, and the coordinates of other frames are coordinates to be determined. The module performs a motion direction reversal determination on all coordinates to be determined in turn with the historical coordinates. The motion direction reversal determination specifically includes: when the pendulum swings to one side, it determines whether the motion direction of the coordinates to be determined relative to the historical coordinates is reversed in both the horizontal and vertical directions. If not, the sliding window is moved, the coordinates to be determined are used as the historical coordinates in the sliding window, and new motion images are acquired to fill in the coordinates in the sliding window. The module then returns to perform a motion direction reversal determination on all coordinates to be determined in turn with the historical coordinates. Otherwise, the historical coordinates are closer to the swing limit position than the coordinates to be determined. In response to the determination that the historical coordinates are closer to the swing limit position than all coordinates to be determined, the historical coordinates are determined to be the swing limit position coordinates.
[0095] The single swing cycle calculation module 3 is configured to record the time interval between the pendulum bob starting from the swing limit position coordinate and returning to the same side swing limit position coordinate as a single swing cycle;
[0096] The average oscillation period calculation module 4 is configured to take the average value of multiple individual oscillation periods to obtain the average oscillation period.
[0097] Parameter calculation module 5 is configured to obtain one of the parameters of the pendulum, namely the pendulum length and gravitational acceleration, and calculate the other parameter based on the average oscillation period.
[0098] Figure 5 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention. For example... Figure 5 As shown, the electronic device of this embodiment includes a processor 501 and a memory 502; wherein the memory 502 is used to store computer execution instructions; and the processor 501 is used to execute the computer execution instructions stored in the memory to implement the various steps performed by the electronic device in the above embodiment. For details, please refer to the relevant descriptions in the foregoing method embodiments.
[0099] Alternatively, the memory 502 can be either standalone or integrated with the processor 501.
[0100] When the memory 502 is set up independently, the electronic device also includes a bus 503 for connecting the memory 502 and the processor 501.
[0101] This invention also provides a computer storage medium storing computer execution instructions, which, when executed by processor 501, implement the above method.
[0102] This invention also provides a computer program product, including a computer program that, when executed by a processor 501, implements the above-described method.
[0103] In the embodiments provided by this invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or modules, and may be electrical, mechanical, or other forms.
[0104] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to implement the solution of this embodiment according to actual needs.
[0105] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The unit composed of the above modules can be implemented in hardware or in the form of hardware plus software functional units.
[0106] The integrated modules implemented as software functional modules described above can be stored in a computer-readable storage medium. These software functional modules, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor 501 to execute some steps of the methods of the various embodiments of this application.
[0107] It should be understood that the processor 501 described above can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor, or the processor 501 can be any conventional processor 501. The steps of the method disclosed in this invention can be directly manifested as the hardware processor 501 executing the steps, or as a combination of hardware and software modules within the processor 501 executing the steps.
[0108] The memory 502 may include high-speed RAM memory, and may also include non-volatile memory NVM, such as at least one disk storage device, and may also be a USB flash drive, portable hard drive, read-only memory, disk or optical disc, etc.
[0109] Bus 503 can be an Industry Standard Architecture (ISA), a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Bus 503 can be divided into address bus, data bus, control bus, etc. For ease of illustration, the bus 503 in the accompanying drawings of this application is not limited to only one bus 503 or one type of bus 503.
[0110] The aforementioned storage medium can be implemented from any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage medium can be any available medium accessible to general-purpose or special-purpose computers.
[0111] An exemplary storage medium is coupled to processor 501, enabling processor 501 to read information from and write information to the storage medium. Alternatively, the storage medium can be an integral part of processor 501. Processor 501 and storage medium can reside in application-specific integrated circuits (ASICs). Alternatively, processor 501 and storage medium can exist as discrete components in an electronic device or host device.
[0112] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0113] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for measuring the simple harmonic motion parameters of a pendulum based on image processing, characterized in that, Includes the following steps: Real-time acquisition of motion images of a simple pendulum, and extraction of the coordinates of the pendulum bob in the image coordinate system from each frame of the motion image, the coordinates including the horizontal coordinate and the vertical coordinate; A sliding window is constructed to store the coordinates of the pendulum in several consecutively acquired motion images. The coordinates of the first frame in the sliding window are historical coordinates, and the coordinates of the other frames are coordinates to be determined. The motion direction reversal determination is performed on all the coordinates to be determined and the historical coordinates in turn. The motion direction reversal determination specifically includes: when the pendulum swings to one side, it is determined whether the motion direction of the coordinates to be determined relative to the historical coordinates is reversed in both the horizontal and vertical directions. If not, the sliding window is moved, the coordinates to be determined are used as the historical coordinates in the sliding window, and new motion images are acquired to fill in the coordinates in the sliding window. The process is then repeated to perform the motion direction reversal determination on all the coordinates to be determined and the historical coordinates in turn. Otherwise, the historical coordinates are closer to the swing limit position relative to the coordinates to be determined. In response to the determination that the historical coordinates are closer to the swing limit position relative to all the coordinates to be determined, the historical coordinates are determined to be the swing limit position coordinates. The time interval between the pendulum bob starting from the aforementioned swing limit position coordinates and returning to the same side swing limit position coordinates is recorded as a single swing cycle; The average oscillation period is obtained by averaging the multiple individual oscillation periods. Obtain one of the parameters of the pendulum, namely the pendulum length and gravitational acceleration, and calculate the other parameter based on the average oscillation period.
2. The method for measuring the simple harmonic motion parameters of a pendulum based on image processing according to claim 1, characterized in that, The sliding window stores four coordinates; in response to determining that all three coordinates to be determined satisfy the motion direction reversal condition relative to the historical coordinates, the historical coordinates are determined as the swing limit position coordinates.
3. The method for measuring the simple harmonic motion parameters of a pendulum based on image processing according to claim 1, characterized in that, When the pendulum swings to the left, the motion direction reversal determination is as follows: determine whether the horizontal coordinate of the coordinate to be determined increases and the vertical coordinate decreases relative to the historical coordinate. If the horizontal coordinate increases and the vertical coordinate decreases, the motion direction is determined to have reversed; otherwise, the coordinate to be determined is closer to the swing limit position relative to the historical coordinate. Move the sliding window, use the coordinate to be determined as the historical coordinate within the sliding window, and collect new motion images to fill in the coordinates within the sliding window. Return to execute the motion direction reversal determination for all the coordinates to be determined and the historical coordinate in turn. When the pendulum swings to the right, the motion direction reversal determination is as follows: determine whether the horizontal coordinate of the coordinate to be determined decreases and whether the vertical coordinate decreases relative to the historical coordinate. If both the horizontal and vertical coordinates decrease, the motion direction is determined to have reversed; otherwise, the coordinate to be determined is closer to the swing limit position relative to the historical coordinate. Move the sliding window, use the coordinate to be determined as the historical coordinate within the sliding window, and collect new motion images to fill in the coordinates within the sliding window. Return to execute the motion direction reversal determination for all the coordinates to be determined and the historical coordinates in sequence.
4. The method for measuring the simple harmonic motion parameters of a pendulum based on image processing according to claim 1, characterized in that, The motion images of a simple pendulum are acquired using a first camera and a second camera. The horizontal plane on which the first camera and the second camera are located is a first plane. The line connecting the projection point of the pendulum bob on the first plane when it is at rest and the first camera is a first reference axis. The line connecting the projection point of the pendulum bob on the first plane when it is at rest and the second camera is a second reference axis. The first reference axis and the second reference axis are perpendicular to each other, and the distance from the first camera to the projection point is equal to the distance from the second camera to the projection point.
5. The method for measuring the simple harmonic motion parameters of a pendulum based on image processing according to claim 4, characterized in that, It also includes calculating the angle between the projection of the pendulum's trajectory onto the first plane and the first reference axis, as shown in the following formula: ; in, This represents the angle between the projection of the pendulum's trajectory onto the first plane and the first reference axis. This represents the horizontal displacement amplitude of the pendulum ball within the field of view of the first camera; This represents the horizontal displacement amplitude of the pendulum ball within the field of view of the second camera; This represents the arctangent function.
6. The method for measuring the simple harmonic motion parameters of a pendulum based on image processing according to claim 5, characterized in that, The acquisition process specifically includes: calculating the difference in abscissa between the left and right extreme positions of the pendulum in the motion image captured by the first camera; The acquisition process specifically includes: calculating the difference in the horizontal coordinates between the left and right extreme positions of the pendulum in the motion image captured by the second camera.
7. A device for measuring the simple harmonic motion parameters of a pendulum based on image processing, characterized in that, include: The image acquisition module is configured to acquire motion images of a simple pendulum in real time and extract the coordinates of the pendulum bob in the image coordinate system from each frame of the motion image, the coordinates including the horizontal coordinate and the vertical coordinate. The extreme position determination module is configured to construct a sliding window, which stores the coordinates of the pendulum in several consecutively acquired motion images. The first frame coordinates in the sliding window are historical coordinates, and the coordinates of other frames are coordinates to be determined. The module performs a motion direction reversal determination on all the coordinates to be determined and the historical coordinates in turn. The motion direction reversal determination specifically includes: when the pendulum swings to one side, determining whether the motion direction of the coordinates to be determined relative to the historical coordinates is simultaneously reversed in the horizontal and vertical directions. If not, the module moves the sliding window, uses the coordinates to be determined as the historical coordinates in the sliding window, and acquires new motion images to fill in the coordinates in the sliding window. The module then returns to perform a motion direction reversal determination on all the coordinates to be determined and the historical coordinates in turn. Otherwise, the historical coordinates are closer to the swing limit position relative to the coordinates to be determined. In response to determining that the historical coordinates are closer to the swing limit position relative to all the coordinates to be determined, the historical coordinates are determined to be the swing limit position coordinates. The single swing cycle calculation module is configured to record the time interval between the pendulum bob starting from the swing limit position coordinate and returning to the same side swing limit position coordinate as a single swing cycle; The average oscillation period calculation module is configured to take the average value of multiple individual oscillation periods to obtain the average oscillation period. The parameter calculation module is configured to obtain one of the parameters of the pendulum, namely the pendulum length and gravitational acceleration, and to calculate the other parameter based on the average oscillation period.
8. An electronic device, characterized in that, include: One or more processors; Memory, used to store one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-6.