A gravity acceleration measurement method and system based on YOLOv8

By constructing a simple pendulum bob dataset and training a YOLOv8 model, continuous and real-time detection of the pendulum bob position in simple pendulum experiments was achieved. Combined with Fourier spectrum analysis, the problems of human error and data fluctuation in the simple pendulum method for measuring gravitational acceleration were solved, thus improving the measurement accuracy and reliability.

CN122048994BActive Publication Date: 2026-07-07NANCHANG CAMPUS OF EAST CHINA UNIV OF TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NANCHANG CAMPUS OF EAST CHINA UNIV OF TECH
Filing Date
2026-04-17
Publication Date
2026-07-07

Smart Images

  • Figure CN122048994B_ABST
    Figure CN122048994B_ABST
Patent Text Reader

Abstract

The application provides a gravity acceleration measurement method and system based on YOLOv8, which comprises the following steps: labeling the pendulum position data in each picture in the pendulum picture data set to construct a corresponding pendulum labeling data set; taking the pendulum picture data set as the model input and synchronously taking the pendulum labeling data set as the label to train and fine-tune a preset YOLOv8 model to generate a corresponding pendulum detection model; based on the video frame rate and the video length, detecting the pendulum in the pendulum swing video through the pendulum detection model to output the center coordinates of the pendulum; normalizing the center coordinates of the pendulum and synchronously combining Fourier spectrum analysis to obtain the corresponding swing period, and calculating the corresponding gravity acceleration according to a preset formula and the swing period. The application can effectively improve the measurement accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of experimental measurement technology, and in particular to a method and system for measuring gravitational acceleration based on YOLOv8. Background Technology

[0002] Gravitational acceleration is a core fundamental physical quantity. The simple pendulum method for determining gravitational acceleration, with its clear principles, simple apparatus, and easy operation, is a classic project in university physics teaching and introductory science experiments. Its core principle is that a simple pendulum follows the laws of simple harmonic motion when oscillating at small angles, and its period satisfies the formula... By measuring the pendulum length L and the oscillation period T, the local gravitational acceleration g can be calculated.

[0003] In existing experiments measuring gravitational acceleration using a simple pendulum, the most commonly used method is manual timing with a stopwatch. This method is suitable for large-scale teaching experiments, but it suffers from unavoidable human error. The judgment of the start and end of the timing relies on the experimenter's visual reaction and manual operation, inevitably introducing systematic errors due to reaction delays. Furthermore, differences in timing habits among different operators introduce random errors. Especially in short-cycle, multi-group control experiments, the impact of these errors is significantly amplified, reducing the accuracy of the measurement results and the repeatability of the experiment.

[0004] To reduce human error, a photoelectric gate electronic timing scheme has been introduced in this field. This scheme automatically triggers timing when the pendulum bob passes through the optical path, improving the accuracy and stability of time measurement. However, this scheme has inherent technical bottlenecks. The photoelectric gate can only detect time at specific points and cannot continuously monitor the entire motion of the pendulum bob in real time. When non-ideal conditions such as amplitude decay, trajectory deviation, or external disturbances occur during the experiment, it cannot promptly identify anomalies and remove invalid data, easily causing fluctuations in measurement data and affecting the reliability of experimental conclusions. Therefore, there is an urgent need in this field to develop a gravity acceleration measurement scheme that combines high-precision period measurement with continuous monitoring of the entire motion of a single pendulum to solve the aforementioned problems of existing technologies. Summary of the Invention

[0005] Based on this, the purpose of this invention is to provide a gravitational acceleration measurement method and system based on YOLOv8, so as to solve the problem that the existing technology cannot continuously monitor the entire motion process of the pendulum bob in real time, and the measurement data is prone to fluctuation, resulting in experimental errors.

[0006] The first aspect of the present invention proposes:

[0007] A method for measuring gravitational acceleration based on YOLOv8, wherein the method includes:

[0008] A simple pendulum bob image dataset is constructed, and the pendulum bob position data inside each image in the simple pendulum bob image dataset are simultaneously labeled to construct a corresponding simple pendulum bob labeled dataset.

[0009] The single pendulum bob image dataset is used as the model input, and the single pendulum bob annotation dataset is used as the label to train and fine-tune the preset YOLOv8 model to generate the corresponding pendulum bob detection model.

[0010] A complete video of a pendulum swing is acquired to detect the corresponding video frame rate and video duration. Simultaneously, based on the video frame rate and video duration, the pendulum ball detection model is used to detect and process the pendulum ball in the video to output the center coordinates of the pendulum ball.

[0011] The center coordinates of the pendulum are normalized, and the corresponding oscillation period is obtained by combining Fourier spectrum analysis. The corresponding gravitational acceleration is calculated according to the preset formula and the oscillation period.

[0012] The beneficial effects of this invention are as follows: This solution completes the fine-tuning training of the YOLOv8 model by constructing a fully labeled simple pendulum bob dataset, which can accurately identify the position of the pendulum bob in the entire pendulum swing video, and realize continuous, real-time, and uninterrupted monitoring of the entire pendulum bob motion process. This effectively solves the core pain points of traditional technologies, such as the inability to continuously monitor the entire process and the easy fluctuation of measurement data. Combined with coordinate normalization processing and Fourier spectrum analysis, the swing period parameter can be accurately extracted, which greatly reduces the measurement error of the simple pendulum experiment and significantly improves the accuracy and reliability of the gravitational acceleration calculation results. At the same time, the solution is easy to operate, adaptable to conventional simple pendulum experimental scenarios, and has strong practicality and anti-interference capabilities.

[0013] Furthermore, the step of constructing the simple pendulum bob image dataset includes:

[0014] Using the physical parameters of the pendulum bob, the shooting environment parameters, and the swing motion parameters as the corresponding control dimensions, a corresponding gradient parameter range is set, and the original images of the pendulum bob corresponding to the gradient parameter range are acquired synchronously to form a corresponding original sample library.

[0015] For each image in the original sample library, differential enhancement processing is performed based on the physical constraints of simple pendulum harmonic motion. Specifically, feature enhancement and interference suppression enhancement processing are performed for difficult samples, and motion continuity lightweight enhancement processing is performed for regular samples to generate a corresponding enhanced sample library.

[0016] The target images in the enhanced sample library are classified and integrated to form the pendulum bob image dataset.

[0017] Furthermore, the step of classifying and integrating the target images in the enhanced sample library to form the pendulum bob image dataset includes:

[0018] Physical compliance verification is performed based on the simple harmonic motion law of a pendulum. Invalid samples are removed from each of the target images, and corresponding feature labels are added to the valid samples that pass the verification.

[0019] Based on the error propagation coefficient of the pendulum center detection error to the gravitational acceleration calculation result, and combined with the feature labels, all valid samples are divided into high, medium and low measurement sensitivity to complete the directional classification of valid samples.

[0020] The valid samples after classification are subjected to motion trajectory continuity verification. After the verification is passed, the corresponding single pendulum bob image dataset is formed.

[0021] Furthermore, the step of using the simple pendulum bob image dataset as model input and simultaneously using the simple pendulum bob annotation dataset as labels to train and fine-tune the preset YOLOv8 model to generate the corresponding pendulum bob detection model includes:

[0022] Based on the pendulum bob image dataset and the pendulum bob annotation dataset, a feature extraction network with two parallel branches, namely the pendulum bob spatial morphology feature and the pendulum motion temporal feature, is constructed inside the preset YOLOv8 model. At the same time, a weight mechanism is set in the output layer that prioritizes the regression of the pendulum bob center coordinates over the bounding box and the classification task to complete the model pre-adaptation.

[0023] Using a time-series sample group with a continuous oscillation cycle as the core training unit, fine-tuning training with dual closed-loop constraints of detection accuracy and physical quantity transfer is performed. In each iteration cycle, the detection loss is first backpropagated based on the deviation between the detection result and the labeled true value. Then, the physical constraint loss is generated based on the deviation between the gravitational acceleration prediction calculated by the model output coordinates and the true value. The model weights are updated by incorporating the total loss function. At the same time, the training weights are dynamically adjusted based on the error transfer coefficient of the sample.

[0024] The trained model is subjected to structured pruning to remove redundant network structures, and the pendulum detection model is generated simultaneously.

[0025] Furthermore, the trained model undergoes structured pruning to remove redundant network structures and simultaneously generate the pendulum detection model:

[0026] For the trained model, the physical error contribution coefficient between each model channel and network layer is quantified, and the pruning safety boundary is anchored based on the measurement allowable error threshold to delineate the core protection domain and the redundant candidate domain accordingly.

[0027] Based on the defined core protection domain and redundant candidate domain, progressive pruning with dual-branch collaborative constraints is performed, and the core protection domain is frozen synchronously after each round of pruning.

[0028] The pruned model undergoes a full-link physical accuracy closed-loop verification. For scenarios where errors exceed the standard, incremental fine-tuning and repair are performed. Simultaneously, the model inference speed is optimized by combining the actual video acquisition frame rate to generate the pendulum detection model accordingly.

[0029] Furthermore, the step of detecting the pendulum ball in the pendulum swing video based on the video frame rate and the video duration using the pendulum ball detection model to output the center coordinates of the pendulum ball includes:

[0030] The pendulum swing video is decoded to obtain the corresponding full time frame sequence. Invalid frames with non-harmonic motion at the beginning and end are removed simultaneously to obtain the valid frame sequence. The valid frame sequence is then adaptively sampled based on the phase law of the pendulum motion to generate the time detection frame sequence.

[0031] The time-series detection frame sequence is divided into batch detection units according to the swing period, and the batches are synchronously input into the pendulum ball detection model so as to output the initial center coordinates of the pendulum ball in a single frame through spatial feature branching.

[0032] The initial center coordinates are subjected to time-constrained correction to correspond to the center coordinates of the output pendulum ball.

[0033] Furthermore, the step of performing time-constrained correction processing on the initial center coordinates to correspond to the center coordinates of the output pendulum bob includes:

[0034] For the initial center coordinates of each batch of output, the spatial features of the pendulum ball, the temporal index and the video frame rate of the corresponding frame are matched, and a ternary association dataset is constructed accordingly. At the same time, abnormal coordinate points of the whole sequence are identified based on the ternary association dataset, and the hierarchical labeling and initial screening of abnormal coordinates are completed by combining spatial feature deviation.

[0035] Based on the hierarchical markers of the abnormal coordinates, a two-way temporal-physical dual-constraint differential correction is performed to generate a preliminary corrected coordinate temporal sequence of the pendulum center.

[0036] The coordinate time series is subjected to Fast Fourier Analysis and simple harmonic motion fitting processing to output the center coordinates of the pendulum ball.

[0037] The second aspect of the present invention proposes:

[0038] A gravity acceleration measurement system based on YOLOv8, wherein the system comprises:

[0039] The construction module is used to build a simple pendulum bob image dataset and simultaneously annotate the bob position data inside each image in the simple pendulum bob image dataset to build a corresponding simple pendulum bob annotation dataset.

[0040] The training module is used to take the single pendulum bob image dataset as model input and simultaneously take the single pendulum bob annotation dataset as labels to train and fine-tune the preset YOLOv8 model in order to generate the corresponding pendulum bob detection model.

[0041] The detection module is used to acquire a complete video of a pendulum swinging, to detect the corresponding video frame rate and video duration, and simultaneously, based on the video frame rate and video duration, to detect the pendulum ball in the video of the pendulum swinging through the pendulum ball detection model, so as to output the center coordinates of the pendulum ball.

[0042] The calculation module is used to normalize the center coordinates of the pendulum bob, simultaneously combine Fourier spectrum analysis to obtain the corresponding oscillation period, and calculate the corresponding gravitational acceleration according to a preset formula and the oscillation period.

[0043] Furthermore, the building module is specifically used for:

[0044] Using the physical parameters of the pendulum bob, the shooting environment parameters, and the swing motion parameters as the corresponding control dimensions, a corresponding gradient parameter range is set, and the original images of the pendulum bob corresponding to the gradient parameter range are acquired synchronously to form a corresponding original sample library.

[0045] For each image in the original sample library, differential enhancement processing is performed based on the physical constraints of simple pendulum harmonic motion. Specifically, feature enhancement and interference suppression enhancement processing are performed for difficult samples, and motion continuity lightweight enhancement processing is performed for regular samples to generate a corresponding enhanced sample library.

[0046] The target images in the enhanced sample library are classified and integrated to form the pendulum bob image dataset.

[0047] Furthermore, the building module is specifically used for:

[0048] Physical compliance verification is performed based on the simple harmonic motion law of a pendulum. Invalid samples are removed from each of the target images, and corresponding feature labels are added to the valid samples that pass the verification.

[0049] Based on the error propagation coefficient of the pendulum center detection error to the gravitational acceleration calculation result, and combined with the feature labels, all valid samples are divided into high, medium and low measurement sensitivity to complete the directional classification of valid samples.

[0050] The valid samples after classification are subjected to motion trajectory continuity verification. After the verification is passed, the corresponding single pendulum bob image dataset is formed.

[0051] Furthermore, the training module is specifically used for:

[0052] Based on the pendulum bob image dataset and the pendulum bob annotation dataset, a feature extraction network with two parallel branches, namely the pendulum bob spatial morphology feature and the pendulum motion temporal feature, is constructed inside the preset YOLOv8 model. At the same time, a weight mechanism is set in the output layer that prioritizes the regression of the pendulum bob center coordinates over the bounding box and the classification task to complete the model pre-adaptation.

[0053] Using a time-series sample group with a continuous oscillation cycle as the core training unit, fine-tuning training with dual closed-loop constraints of detection accuracy and physical quantity transfer is performed. In each iteration cycle, the detection loss is first backpropagated based on the deviation between the detection result and the labeled true value. Then, the physical constraint loss is generated based on the deviation between the gravitational acceleration prediction calculated by the model output coordinates and the true value. The model weights are updated by incorporating the total loss function. At the same time, the training weights are dynamically adjusted based on the error transfer coefficient of the sample.

[0054] The trained model is subjected to structured pruning to remove redundant network structures, and the pendulum detection model is generated simultaneously.

[0055] Furthermore, the training module is specifically used for:

[0056] For the trained model, the physical error contribution coefficient between each model channel and network layer is quantified, and the pruning safety boundary is anchored based on the measurement allowable error threshold to delineate the core protection domain and the redundant candidate domain accordingly.

[0057] Based on the defined core protection domain and redundant candidate domain, progressive pruning with dual-branch collaborative constraints is performed, and the core protection domain is frozen synchronously after each round of pruning.

[0058] The pruned model undergoes a full-link physical accuracy closed-loop verification. For scenarios where errors exceed the standard, incremental fine-tuning and repair are performed. Simultaneously, the model inference speed is optimized by combining the actual video acquisition frame rate to generate the pendulum detection model accordingly.

[0059] Furthermore, the detection module is specifically used for:

[0060] The pendulum swing video is decoded to obtain the corresponding full time frame sequence. Invalid frames with non-harmonic motion at the beginning and end are removed simultaneously to obtain the valid frame sequence. The valid frame sequence is then adaptively sampled based on the phase law of the pendulum motion to generate the time detection frame sequence.

[0061] The time-series detection frame sequence is divided into batch detection units according to the swing period, and the batches are synchronously input into the pendulum ball detection model so as to output the initial center coordinates of the pendulum ball in a single frame through spatial feature branching.

[0062] The initial center coordinates are subjected to time-constrained correction to correspond to the center coordinates of the output pendulum ball.

[0063] Furthermore, the detection module is specifically used for:

[0064] For the initial center coordinates of each batch of output, the spatial features of the pendulum ball, the temporal index and the video frame rate of the corresponding frame are matched, and a ternary association dataset is constructed accordingly. At the same time, abnormal coordinate points of the whole sequence are identified based on the ternary association dataset, and the hierarchical labeling and initial screening of abnormal coordinates are completed by combining spatial feature deviation.

[0065] Based on the hierarchical markers of the abnormal coordinates, a two-way temporal-physical dual-constraint differential correction is performed to generate a preliminary corrected coordinate temporal sequence of the pendulum center.

[0066] The coordinate time series is subjected to Fast Fourier Analysis and simple harmonic motion fitting processing to output the center coordinates of the pendulum ball.

[0067] The third aspect of the present invention proposes:

[0068] A computer includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the YOLOv8-based gravity acceleration measurement method as described above.

[0069] The fourth aspect of the present invention proposes:

[0070] A readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the YOLOv8-based gravity acceleration measurement method as described above.

[0071] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0072] Figure 1 A flowchart of a gravity acceleration measurement method based on YOLOv8 provided in the first embodiment of the present invention;

[0073] Figure 2 The diagram shows the structure of the gravity acceleration measurement system based on YOLOv8 provided in the third embodiment of the present invention.

[0074] The following detailed description, in conjunction with the accompanying drawings, will further illustrate the present invention. Detailed Implementation

[0075] To facilitate understanding of the present invention, a more complete description will be given below with reference to the accompanying drawings. Several embodiments of the invention are illustrated in the drawings. However, the invention can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete.

[0076] It should be noted that when a component is said to be "fixed to" another component, it can be directly on the other component or there may be an intervening component. When a component is said to be "connected to" another component, it can be directly connected to the other component or there may be an intervening component. The terms "vertical," "horizontal," "left," "right," and similar expressions used in this document are for illustrative purposes only.

[0077] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.

[0078] Please see Figure 1 The figure shows the gravitational acceleration measurement method based on YOLOv8 provided in the first embodiment of the present invention. The gravitational acceleration measurement method based on YOLOv8 provided in this embodiment can significantly reduce the measurement error of the pendulum experiment, significantly improve the accuracy and reliability of the gravitational acceleration calculation results, and the scheme is easy to operate, adaptable to conventional pendulum experiment scenarios, and has strong practicality and anti-interference ability.

[0079] Specifically, this embodiment provides:

[0080] A method for measuring gravitational acceleration based on YOLOv8, wherein the method includes:

[0081] Step S10: Construct a simple pendulum bob image dataset, and simultaneously annotate the pendulum bob position data inside each image in the simple pendulum bob image dataset to construct a corresponding simple pendulum bob annotation dataset.

[0082] It's important to note that traditional general-purpose object detection datasets are unsuitable for detecting pendulum bobs. During the swing, the bob experiences motion blur, lighting changes, background interference, and scale variations. Furthermore, pendulum bobs are often small, solid-colored balls with limited visual features. Models trained on general-purpose datasets are prone to missed detections and inaccurate center coordinate localization. The accuracy of the pendulum bob's center coordinates directly determines the accuracy of the final gravitational acceleration measurement. This step addresses the specific scenario of pendulum measurement by constructing a dedicated pendulum bob image dataset. This dataset covers full-scene samples with different pendulum bob parameters, shooting environments, and motion states. It also precisely labels the position of the pendulum bob in each image, focusing on its center coordinates rather than just the bounding box. This provides accurate labeled data for subsequent model training, ensuring the accuracy of pendulum bob center coordinate detection from the data source.

[0083] Step S20: Use the single pendulum bob image dataset as model input and simultaneously use the single pendulum bob annotation dataset as labels to train and fine-tune the preset YOLOv8 model to generate the corresponding pendulum bob detection model.

[0084] It's important to note that while YOLOv8, as a mainstream single-stage object detection model, boasts advantages such as fast detection speed, strong generalization, and high accuracy in detecting small objects, its native model is designed for general object detection scenarios. Its core optimization goals are classification accuracy and bounding box regression accuracy. However, the core requirement of this method is sub-pixel-level regression accuracy of the pendulum ball's center coordinates, a specific requirement that general models cannot directly adapt to. This step uses a single pendulum-specific dataset as input and precise pendulum ball center coordinate annotations as labels to perform targeted fine-tuning and optimization of the native YOLOv8 model. This involves adjusting the model's feature extraction branches, loss function weights, and output priorities, shifting the core optimization focus from general object classification and bounding box detection to accurate regression of the pendulum ball's center coordinates. Ultimately, this generates a dedicated model specifically adapted for single pendulum ball detection scenarios, providing a core tool for continuous and accurate pendulum ball detection in subsequent videos.

[0085] Step S30: Acquire a complete video of a pendulum swing to detect the corresponding video frame rate and video duration. Simultaneously, based on the video frame rate and video duration, use the pendulum ball detection model to detect and process the pendulum ball in the video of the pendulum swing to output the center coordinates of the pendulum ball.

[0086] It is important to note that the accurate calculation of the pendulum's oscillation period relies on the positional changes of the pendulum bob over a continuous time series. Traditional manual measurement methods involve visually reading the moment the pendulum bob passes through its equilibrium position and averaging the total duration of multiple cycles using a stopwatch. This not only suffers from significant human error but also fails to capture the complete temporal trajectory of the pendulum bob's motion. This step, however, involves acquiring a complete video of the pendulum's oscillation. First, the frame rate and duration of the video are extracted to establish a one-to-one correspondence between video frames and real physical time, achieving precise calibration of the time dimension. Then, each frame of the time-series image is input into a trained pendulum bob detection model, which continuously detects the pendulum bob in each frame and outputs the corresponding center coordinates of the pendulum bob for each frame. This forms a complete temporal sequence of the pendulum bob's position changing over time, completely eliminating the human error of manual timing and reading, and providing continuous and accurate temporal position data for subsequent period calculations.

[0087] Step S40: Normalize the center coordinates of the pendulum bob, simultaneously combine Fourier spectrum analysis to obtain the corresponding oscillation period, and calculate the corresponding gravitational acceleration according to the preset formula and the oscillation period.

[0088] It should be noted that after obtaining the time series of the pendulum bob's center coordinates, traditional methods calculate the period by finding the moment of the pendulum bob's highest point or equilibrium position. This method is highly susceptible to coordinate noise and extreme point identification bias, leading to errors in period calculation. This step first normalizes the pendulum bob's center coordinates to eliminate coordinate deviations caused by shooting angle and image scale, converting the coordinate series into a standardized displacement series that conforms to the laws of simple harmonic motion. Then, through Fourier spectrum analysis, the normalized displacement time series is transformed in the frequency domain to accurately extract the dominant frequency of the pendulum's oscillation. The reciprocal of the dominant frequency is the pendulum's oscillation period. Fourier analysis can effectively filter out the interference of coordinate noise, extracting the most accurate oscillation period from the overall time series and avoiding errors caused by extreme point identification. Finally, based on the period formula of simple harmonic motion of a pendulum, the accurately measured oscillation period and the known pendulum length are substituted into a preset formula to calculate the corresponding gravitational acceleration, completing the closed loop of the entire measurement process.

[0089] Second Embodiment

[0090] Furthermore, the step of constructing the simple pendulum bob image dataset includes:

[0091] Using the physical parameters of the pendulum bob, the shooting environment parameters, and the swing motion parameters as the corresponding control dimensions, a corresponding gradient parameter range is set, and the original images of the pendulum bob corresponding to the gradient parameter range are acquired synchronously to form a corresponding original sample library.

[0092] For each image in the original sample library, differential enhancement processing is performed based on the physical constraints of simple pendulum harmonic motion. Specifically, feature enhancement and interference suppression enhancement processing are performed for difficult samples, and motion continuity lightweight enhancement processing is performed for regular samples to generate a corresponding enhanced sample library.

[0093] The target images in the enhanced sample library are classified and integrated to form the pendulum bob image dataset.

[0094] It should be noted that the core interference in pendulum bob detection comes from three dimensions: First, the differences in the physical parameters of the pendulum bob itself, including its diameter, color, material, and surface texture. Pendulum bobs with different parameters have vastly different visual characteristics. Second, the differences in shooting environment parameters, including light intensity, light angle, background complexity, shooting angle, and lens focal length. The shooting environment in student experimental scenarios is often not fixed, resulting in strong environmental interference. Third, the differences in swing motion parameters, including the swing angle, swing speed, and degree of motion blur. During the swing, the speed of the pendulum bob varies at different positions. The speed is fastest and the motion blur is most severe near the equilibrium position, which is also the key position that has the greatest impact on the period calculation. This step uses these three core dimensions as control variables, setting gradient parameter ranges covering the entire scene for each dimension. For example, the gradient range for pendulum diameter is from 5mm to 50mm, the range for lighting is from backlight to low light, and the range for pendulum angle is from 5° to 15°, which is within the range of simple harmonic motion compliance. Under each combination of gradient parameters, the corresponding original images of the pendulum are collected to form an original sample library covering the entire scene and all variables. This ensures that the sample library can adapt to all scenarios that may occur in the actual measurement process, thus solving the problem of insufficient model generalization from the root.

[0095] Traditional image enhancement methods typically employ indiscriminate flipping, mirroring, and random cropping, which not only disrupts the physical continuity of the pendulum's motion but also fails to address the specific challenges of detecting difficult samples. This enhancement process adheres entirely to the physical constraints of simple harmonic motion of a pendulum, avoiding any enhancement operations that violate the laws of motion. Differential enhancements are performed for different types of samples: For difficult samples—those with severe motion blur, backlight / low light interference, background colors similar to the pendulum bob, or partial occlusion—feature enhancement and interference suppression enhancements are performed. For example, deblurring is used to highlight the edge features of the pendulum bob, illumination equalization suppresses backlight interference, and contrast enhancement strengthens the difference between the pendulum bob and the background, enabling the model to learn the core features of difficult samples and addressing false negatives and missed detections in extreme scenarios. For normal samples—those with normal lighting, no obvious blur, and clear features—lightweight motion continuity enhancements are performed. These include small translations along the pendulum bob's trajectory, slight blur simulations consistent with the laws of motion, and minor brightness adjustments. This expands the sample size without disrupting motion continuity, balances the dataset distribution, and avoids redundant computations caused by over-enhancement, ultimately generating an enhanced sample library that balances generalization and physical compliance.

[0096] After the sample library is enhanced, the samples need to be standardized, classified and integrated, invalid samples need to be removed, and the sample format needs to be standardized to ensure the uniformity and compliance of the dataset. Finally, a standardized pendulum bob image dataset is formed to provide standardized and high-quality input for subsequent model training.

[0097] Furthermore, the step of classifying and integrating the target images in the enhanced sample library to form the pendulum bob image dataset includes:

[0098] Physical compliance verification is performed based on the simple harmonic motion law of a pendulum. Invalid samples are removed from each of the target images, and corresponding feature labels are added to the valid samples that pass the verification.

[0099] Based on the error propagation coefficient of the pendulum center detection error to the gravitational acceleration calculation result, and combined with the feature labels, all valid samples are divided into high, medium and low measurement sensitivity to complete the directional classification of valid samples.

[0100] The valid samples after classification are subjected to motion trajectory continuity verification. After the verification is passed, the corresponding single pendulum bob image dataset is formed.

[0101] It is important to note that the core premise of pendulum measurement is that the oscillation process conforms to the laws of simple harmonic motion. Samples that do not conform to these laws not only fail to provide effective information for model training but also interfere with the model's learning of the pendulum bob's motion, leading to systematic deviations in subsequent period calculations. This step first performs physical compliance checks on all target images in the augmented sample library based on the simple harmonic motion laws of the pendulum. The checks include whether the pendulum angle is within the allowable range of simple harmonic motion, whether the pendulum bob's trajectory conforms to the circular motion laws of a simple pendulum, whether the pendulum bob has any abnormal displacements not driven by gravity, and whether the sample has severe deformation or distortion. All invalid samples that do not conform to the physical laws are removed. At the same time, corresponding feature labels are added to the valid samples that pass the checks. The labels include the pendulum bob's physical parameters, shooting environment parameters, motion state parameters, and the phase position of the pendulum bob during the oscillation (equilibrium position / highest point / ascending segment / descending segment), providing clear feature basis for subsequent sample classification and model training.

[0102] Traditional dataset classification relies solely on the visual difficulty of samples. However, this method aims for precise measurement of gravitational acceleration. The detection error of the pendulum bob's center coordinates is propagated to the gravitational acceleration result through period calculation. The impact of coordinate detection error on the final result varies significantly depending on the pendulum bob's position: near the equilibrium position, the bob moves at its fastest speed and serves as the core reference point for period calculation; even a small error in coordinate detection can lead to a significant deviation in period calculation, thus greatly affecting the gravitational acceleration result – these are high-sensitivity samples. Near the highest point of the swing, the bob's speed is zero, and the impact of coordinate error on period calculation is minimal – these are low-sensitivity samples. Samples at other positions are medium-sensitivity samples. This step uses the error propagation coefficient as the core basis, combined with the sample's phase position feature label, to classify all valid samples into three levels of measurement sensitivity: high, medium, and low. This targeted classification of samples provides a clear basis for dynamic weight adjustment during subsequent model training, allowing the model to focus on optimizing the detection accuracy of high-sensitivity samples, fundamentally reducing the final measurement error of gravitational acceleration.

[0103] The oscillation of a simple pendulum is a continuous periodic motion. The model needs to learn not only the visual features of the pendulum bob in a single frame, but also the temporal continuity of the pendulum bob's motion to maintain stable output in subsequent continuous video detection. This step performs motion trajectory continuity verification on the classified valid samples according to the pendulum bob's motion phase and oscillation period. This ensures that the samples can cover all motion states within a complete cycle of the simple pendulum, and that samples from adjacent phases conform to the continuity of motion trajectory, without any abrupt changes in trajectory or missing phases. Only samples that pass the motion trajectory continuity verification will be finally included in the simple pendulum bob image dataset. This ensures that the dataset not only has high-precision annotation at the single-frame level, but also conforms to the motion law of the simple pendulum at the temporal level, providing complete and continuous sample support for the subsequent temporal feature learning of the model.

[0104] Furthermore, the step of using the simple pendulum bob image dataset as model input and simultaneously using the simple pendulum bob annotation dataset as labels to train and fine-tune the preset YOLOv8 model to generate the corresponding pendulum bob detection model includes:

[0105] Based on the pendulum bob image dataset and the pendulum bob annotation dataset, a feature extraction network with two parallel branches, namely the pendulum bob spatial morphology feature and the pendulum motion temporal feature, is constructed inside the preset YOLOv8 model. At the same time, a weight mechanism is set in the output layer that prioritizes the regression of the pendulum bob center coordinates over the bounding box and the classification task to complete the model pre-adaptation.

[0106] Using a time-series sample group with a continuous oscillation cycle as the core training unit, fine-tuning training with dual closed-loop constraints of detection accuracy and physical quantity transfer is performed. In each iteration cycle, the detection loss is first backpropagated based on the deviation between the detection result and the labeled true value. Then, the physical constraint loss is generated based on the deviation between the gravitational acceleration prediction calculated by the model output coordinates and the true value. The model weights are updated by incorporating the total loss function. At the same time, the training weights are dynamically adjusted based on the error transfer coefficient of the sample.

[0107] The trained model is subjected to structured pruning to remove redundant network structures, and the pendulum detection model is generated simultaneously.

[0108] It should be noted that the feature extraction network of the native YOLOv8 model is designed for general multi-class object detection, focusing only on the spatial morphological features of a single frame image and failing to capture the temporal continuity features of a pendulum motion. Furthermore, the loss function of its output layer is dominated by classification loss and bounding box regression loss, while the only detection target of this method is the pendulum ball, and the classification task is not of practical significance. The core requirement is the accurate regression of the center coordinates of the pendulum ball. This step involves two core pre-adaptation modifications to the native YOLOv8 model: First, a dual-branch parallel feature extraction network is constructed. The spatial morphology feature branch specifically learns the shape, texture, and edges of the pendulum in a single frame to solve the problem of pendulum recognition under motion blur and environmental interference. The pendulum motion temporal feature branch specifically learns the temporal features of the pendulum in continuous frames, such as the trajectory, velocity changes, and phase changes, to ensure the continuity and stability of coordinate output in continuous video detection. Second, the weighting mechanism is reconstructed in the output layer, setting the loss weight of pendulum center coordinate regression to the highest level, with a much higher priority than bounding box regression and classification tasks. Even meaningless classification losses are directly eliminated, allowing the core optimization of the model to focus entirely on the accurate regression of the pendulum center coordinates, thus adapting the model structure to the specific needs of pendulum measurement.

[0109] Traditional model fine-tuning only focuses on the detection loss as the sole optimization objective, paying attention only to the visual deviation between the model output and the labeled true value, ignoring the impact of the detection deviation on the final physical quantity measurement result. This easily leads to the disconnect between "high visual detection accuracy but large physical measurement error". This step employs a fine-tuning training mode with dual closed-loop constraints, using a time-series sample group with continuous swing cycles as the core training unit, rather than isolated single-frame samples. This allows the model to learn the pendulum's motion patterns within a complete cycle. Within each training iteration, the first closed loop optimizes detection accuracy. Based on the deviation between the pendulum's center coordinates output by the model and the labeled ground truth, the detection loss is calculated and backpropagation is performed to optimize the model's basic detection accuracy. The second closed loop optimizes physical quantity transfer. The time-series sequence of the model's output center coordinates is substituted into the cycle calculation formula and the gravitational acceleration calculation formula to obtain the estimated gravitational acceleration. The deviation between the estimated value and the local true gravitational acceleration is then calculated to generate a physical constraint loss. This physical constraint loss is integrated into the total loss function, and the model weights are updated again. This ensures that the model optimization not only meets the accuracy requirements of visual detection but also the accuracy requirements of the final physical quantity measurement. Simultaneously, based on the error transfer coefficients obtained from the previous sample classification, the training weights of samples with different sensitivities are dynamically adjusted. Samples with high measurement sensitivity are given higher training weights, allowing the model to focus on optimizing the detection accuracy of key areas such as the equilibrium position. This achieves a deep binding between detection accuracy and physical measurement accuracy at the training level.

[0110] While the trained model met the accuracy requirements, it contained numerous redundant network layers and channels, resulting in a large number of parameters and slow inference speed. This made it unsuitable for low-computing-power devices such as ordinary laptops and embedded development boards used in student experiments, and also unable to meet the real-time detection requirements of high frame rate videos. This step performs structured pruning on the trained model, removing redundant network structures that have no significant impact on detection and physical measurement accuracy. Without sacrificing core measurement accuracy, the model's parameter count is significantly reduced, and its inference speed is improved. The result is a lightweight, high-precision, and fast-inference pendulum detection model tailored to the measurement needs of devices with varying computing power.

[0111] Furthermore, the trained model undergoes structured pruning to remove redundant network structures and simultaneously generate the pendulum detection model:

[0112] For the trained model, the physical error contribution coefficient between each model channel and network layer is quantified, and the pruning safety boundary is anchored based on the measurement allowable error threshold to delineate the core protection domain and the redundant candidate domain accordingly.

[0113] Based on the defined core protection domain and redundant candidate domain, progressive pruning with dual-branch collaborative constraints is performed, and the core protection domain is frozen synchronously after each round of pruning.

[0114] The pruned model undergoes a full-link physical accuracy closed-loop verification. For scenarios where errors exceed the standard, incremental fine-tuning and repair are performed. Simultaneously, the model inference speed is optimized by combining the actual video acquisition frame rate to generate the pendulum detection model accordingly.

[0115] It should be noted that traditional structured pruning usually judges importance based solely on the absolute value of the network channel weights, pruning channels with low weights. However, in the application scenario of this method, some channels with relatively small absolute weights may have a significant impact on the detection accuracy of the pendulum's center coordinates, thereby significantly affecting the final measurement result of gravitational acceleration. Blindly pruning will lead to a substantial decrease in the accuracy of physical measurements. This step abandons the traditional absolute value judgment standard for weights and uses the contribution of physical error as the core quantitative indicator. The physical error contribution coefficient is defined as the magnitude of the relative error change in the gravitational acceleration measurement result after the channel or network layer is pruned. The larger the magnitude of the change, the higher the contribution of the channel to the physical measurement accuracy and the stronger its importance. Subsequently, based on the allowable error threshold of the single pendulum gravitational acceleration measurement, the safety boundary of pruning is anchored, that is, the measurement error of gravitational acceleration after pruning cannot exceed the allowable threshold. Based on this, channels and network layers with high contribution to physical error and directly affecting the core measurement accuracy are defined as core protection domains, which are absolutely frozen and cannot be pruned during the pruning process. Channels and network layers with extremely low contribution to physical error and no impact on measurement accuracy are defined as redundant candidate domains, which are used as the target objects for pruning. From the perspective of pruning rules, this ensures that model compression will not affect the final physical measurement accuracy.

[0116] The previously constructed feature extraction network has a dual-branch structure of spatial morphology and temporal features. The two branches have different core functions and different distributions of redundant channels. Using a uniform pruning ratio would lead to over-pruning of one branch and under-pruning of the other. This step performs progressive pruning with dual-branch collaborative constraints. Appropriate pruning ratios and pruning step sizes are set for each branch. The core of the spatial morphology feature branch is pendulum recognition, requiring a smaller pruning step size and stricter constraints. The core of the temporal feature branch is motion continuity fitting, with relatively higher redundancy, allowing for a larger pruning step size. Simultaneously, a progressive pruning approach is used, removing only the few channels with the lowest contribution from the redundant candidate domains in each round. After each round of pruning, the weights of the core protection domain are immediately frozen, and the remaining network is fine-tuned to compensate for the slight accuracy loss caused by pruning. The next round of pruning is then performed until the preset model compression target is reached or the pruning safety boundary is touched. This avoids a precipitous drop in accuracy caused by a single pruning, achieving an optimal balance between model compression and accuracy preservation.

[0117] After pruning and fine-tuning, the accuracy cannot be judged solely by the mAP detection. A closed-loop verification of physical accuracy across the entire chain must be performed. This involves using the pruned model to process pendulum swing videos in different scenarios, completing the entire measurement process from pendulum ball detection and period calculation to gravitational acceleration solution, and verifying whether the measurement errors in different scenarios are within the allowable range. For difficult scenarios with excessive errors, corresponding incremental samples are collected, and the model is fine-tuned to ensure that the measurement accuracy meets the requirements in all scenarios. At the same time, the inference speed of the model is optimized by combining the video acquisition frame rate in the actual measurement scenario, ensuring that the model's inference speed is higher than the video acquisition frame rate, enabling real-time detection and processing of high frame rate videos, and finally generating a lightweight, high-precision, fast inference, and all-scenario adaptable pendulum ball detection model.

[0118] Furthermore, the step of detecting the pendulum ball in the pendulum swing video based on the video frame rate and the video duration using the pendulum ball detection model to output the center coordinates of the pendulum ball includes:

[0119] The pendulum swing video is decoded to obtain the corresponding full time frame sequence. Invalid frames with non-harmonic motion at the beginning and end are removed simultaneously to obtain the valid frame sequence. The valid frame sequence is then adaptively sampled based on the phase law of the pendulum motion to generate the time detection frame sequence.

[0120] The time-series detection frame sequence is divided into batch detection units according to the swing period, and the batches are synchronously input into the pendulum ball detection model so as to output the initial center coordinates of the pendulum ball in a single frame through spatial feature branching.

[0121] The initial center coordinates are subjected to time-constrained correction to correspond to the center coordinates of the output pendulum ball.

[0122] It should be noted that the beginning and end of the acquired pendulum swing video usually include footage of the experimenter releasing and catching the pendulum ball. The motion of the pendulum ball in this part of the footage does not conform to the laws of simple harmonic motion and is considered an invalid frame. If it is included in the detection range, it will seriously interfere with the subsequent period calculation. At the same time, the number of frames in the full time-series frame sequence is extremely large, and frame-by-frame detection will generate a lot of computational redundancy, affecting processing efficiency. This step first decodes the pendulum swing video to obtain a full sequence of time-series frames arranged in chronological order, establishing the correspondence between each frame and the actual physical time. Then, invalid frames with non-harmonic motion at the beginning and end are removed, retaining only the valid frame sequence of the pendulum bob performing stable harmonic motion, thus eliminating interference from invalid data. Next, combining the phase characteristics of the pendulum motion, adaptive sampling is performed on the valid frame sequence. The sampling density is strongly correlated with the pendulum bob's speed: in the high-sensitivity range where the pendulum bob passes through the equilibrium position, the speed is high, significantly impacting period calculation; therefore, high-density sampling is used to retain more frames to ensure coordinate accuracy. In the low-sensitivity range where the pendulum bob reaches its highest point, the speed is slow, having little impact on period calculation; therefore, low-density sampling is used to reduce unnecessary computational redundancy. Finally, a time-series detection frame sequence that balances accuracy and efficiency is generated, significantly reducing the subsequent detection computation load without sacrificing core measurement accuracy.

[0123] The oscillation of a simple pendulum is a periodic simple harmonic motion. Dividing the detection sequence into batches according to the oscillation period ensures that each batch of frame sequences covers a complete oscillation period, guaranteeing the integrity and phase continuity of the pendulum bob's trajectory within each batch, facilitating subsequent temporal constraint correction. This step first divides the temporal detection frame sequence into multiple batches of detection units based on the preset pendulum length and estimated period, with each batch corresponding to one or more complete oscillation periods. Then, the batch detection units are input batch by batch into a trained pendulum bob detection model. Through the model's spatial morphological feature branch, the pendulum bob in each frame is accurately detected, and the initial center coordinates of the pendulum bob in each frame are output, forming the coordinate temporal sequence corresponding to each batch, providing basic data for subsequent temporal correction.

[0124] The initial center coordinates output by the model may be affected by motion blur, background interference, and local occlusion, resulting in a small number of outliers and noise points. If used directly for period calculation, the results will be biased. It is necessary to perform time-series constraint correction to eliminate coordinate noise and outliers, ensure the continuity and accuracy of the coordinate time series, and finally output a precise time series of pendulum center coordinates.

[0125] Furthermore, the step of performing time-constrained correction processing on the initial center coordinates to correspond to the center coordinates of the output pendulum bob includes:

[0126] For the initial center coordinates of each batch of output, the spatial features of the pendulum ball, the temporal index and the video frame rate of the corresponding frame are matched, and a ternary association dataset is constructed accordingly. At the same time, abnormal coordinate points of the whole sequence are identified based on the ternary association dataset, and the hierarchical labeling and initial screening of abnormal coordinates are completed by combining spatial feature deviation.

[0127] Based on the hierarchical markers of the abnormal coordinates, a two-way temporal-physical dual-constraint differential correction is performed to generate a preliminary corrected coordinate temporal sequence of the pendulum center.

[0128] The coordinate time series is subjected to Fast Fourier Analysis and simple harmonic motion fitting processing to output the center coordinates of the pendulum ball.

[0129] It should be noted that the outliers in the initial center coordinates are not randomly generated, but are strongly correlated with the spatial features and temporal position of the corresponding frame. For example, frames with severe motion blur have low confidence in spatial features and a high probability of coordinate anomalies. For temporal frames near the equilibrium position, coordinate anomalies have a greater impact on period calculation. This step first matches the spatial features of the pendulum (including detection confidence, bounding box sharpness, and feature matching degree), temporal index (frame number, corresponding physical time, and pendulum motion phase), and video frame rate of each initial center coordinate to construct a ternary association dataset of "spatial features - temporal index - video frame rate," fully presenting the detection reliability and measurement sensitivity of each coordinate point. Then, based on the ternary association dataset, anomalous coordinate points in the entire sequence are identified using the Laida criterion and the isolated forest algorithm. Combining spatial feature bias and measurement sensitivity, anomalous coordinates are graded and labeled: coordinates with extremely low detection confidence, severe coordinate abrupt changes, and complete non-compliance with motion patterns are labeled as Level 1 severe anomalies; coordinates with moderate detection confidence, minor biases, and no disruption to the overall motion trend are labeled as Level 2 minor anomalies. This initial screening of anomalous coordinates provides a clear basis for subsequent differential correction.

[0130] Traditional coordinate correction typically employs uniform mean and median filtering, which fails to differentiate between different levels of anomalies and does not adhere to the physical laws of a simple pendulum's motion. The corrected coordinates may thus distort the true trend of simple harmonic motion. This step utilizes a differentiated correction strategy with dual temporal and physical constraints, employing different correction methods for different levels of anomaly coordinates: For coordinates with minor level two anomalies, bidirectional temporal constraints are primary, combined with normal coordinates from adjacent frames, using linear or spline interpolation for correction. Physical constraints serve as boundaries to ensure the corrected coordinates conform to the pendulum's velocity and trajectory changes. For coordinates with severe level one anomalies, physical constraints are primary, based on the sinusoidal / cosine motion laws of simple harmonic motion, combined with in-phase coordinates from adjacent complete cycles, using simple harmonic motion fitting for completion correction. Bidirectional temporal constraints are used as an auxiliary measure to ensure the corrected coordinates maintain continuity with the motion trend of adjacent frames. For normal coordinates without anomalies, the original values ​​are retained without modification to avoid over-correction that could damage the true coordinate data. By using differentiated dual-constraint correction, the interference of abnormal coordinates is eliminated, while the true temporal characteristics of the pendulum bob motion are preserved to the maximum extent, generating a preliminary corrected, continuous and smooth temporal sequence of the pendulum bob center coordinates.

[0131] Even after initial calibration, the coordinate time series may still contain minor random noise, which can affect the accuracy of period calculation. The motion of a simple pendulum is standard harmonic motion, and its displacement time series follows a standard sine / cosine curve. This step first performs a Fast Fourier Transform on the initially calibrated coordinate time series, transforming the time-domain coordinate sequence to the frequency domain and extracting the dominant frequency component, which is the true frequency of the pendulum's oscillation, while filtering out high-frequency random noise components. Then, based on the extracted dominant frequency and the equations of motion for harmonic motion, a least-squares fit is performed on the coordinate time series to obtain the harmonic motion fitting curve that best matches the actual motion. The coordinates corresponding to each time point on the fitting curve are the final optimized coordinates of the pendulum's center. The final output time series of the pendulum's center coordinates perfectly conforms to the physical laws of simple harmonic motion, eliminating all noise and outlier interference, and possesses extremely high accuracy and stability. This provides absolutely reliable core data for subsequent calculations of the oscillation period and the solution of gravitational acceleration, fundamentally ensuring the accuracy and reproducibility of the gravitational acceleration measurement results.

[0132] In addition, it should be noted in this embodiment that, based on the above steps, the gravity acceleration measurement method based on YOLOv8 provided in this embodiment is specifically implemented by the following steps:

[0133] Step S1: Construct a dataset of images of a simple pendulum bob;

[0134] Step S2: Label the position data of the pendulum bob in each image of the dataset to construct a single pendulum bob labeled dataset;

[0135] Step S3: Use the aforementioned image dataset as input and the labeled dataset as labels to train and fine-tune the YOLOv8 model;

[0136] Step S4: Record a video of the pendulum swinging, and record the video frame rate (frame_rate) and duration (t_total);

[0137] Step S5: Use the trained YOLOv8 model to detect the pendulum in the recorded video and output the center coordinates (cx, cy) of the pendulum.

[0138] Step S6: Normalize the horizontal coordinate cx of the pendulum center and obtain the oscillation period T by combining it with Fourier spectrum analysis;

[0139] Step S7: According to the formula Calculate the acceleration due to gravity, g.

[0140] In one specific embodiment of this example, the source of the simple pendulum bob image dataset is:

[0141] This embodiment uses a camera and mobile phone to capture image data. The pendulum balls are divided into two categories: metal balls and black plastic balls. Images were captured under different lighting conditions, backgrounds, and angles. The dataset contains 400 images, with metal balls and black plastic balls in a 1:1 ratio.

[0142] In one specific embodiment of this example, the process of annotating acquired image data includes:

[0143] Import the image data into LabelImg software sequentially, manually label the target pendulum type, position, and bounding box information, and store the labeling information in YOLO format.

[0144] In one specific embodiment of this example, the annotation information stored in YOLO format includes:

[0145] Classes.txt: Contains a list of class names referenced by YOLO tags;

[0146] ImageName.txt: Each line represents a recognition target, with data separated by spaces. It represents the target's category ID, the normalized bounding box's x and y coordinates, and the target bounding box's width w and height h, all in pixels.

[0147] In one specific implementation of this embodiment, a self-constructed pendulum image dataset is used to train and optimize the YOLOv8 pendulum recognition model. The dataset contains 400 images, which are divided into training, validation, and test sets in an 8:1:1 ratio. The training parameters are set as follows:

[0148] Pre-trained weights: COCO dataset pre-trained model;

[0149] Training epochs: 100;

[0150] Batch size: 16;

[0151] Optimizer: AdamW;

[0152] Initial learning rate: 0.001;

[0153] momentum: 0.9;

[0154] Data augmentation includes random rotation, brightness adjustment, and Gaussian noise addition.

[0155] After training, the model achieved an average precision (mAP50) of 99.5% on the test set and an average precision (mAP50-95) of 91% for IoU thresholds ranging from 0.5 to 0.95.

[0156] The trained YOLOv8 model can accurately identify metal balls and black plastic balls in different environments.

[0157] In one specific embodiment of this example, the recording of a pendulum swing video includes:

[0158] As shown in Table 1, the length of the simple pendulum is changed. The pendulum is pulled up at an angle of less than 5° to start swinging, and the swinging process is recorded by electronic devices with a video frame rate of 60fps and a duration of t_total of 120s.

[0159] Table 1. Pendulum length in this embodiment

[0160]

[0161] In one specific implementation of this embodiment, a trained YOLOv8 model is used to detect the pendulum in the recorded video and output a sequence of the pendulum's center coordinates (cx, cy) changing over time.

[0162] In one specific embodiment of this example, the horizontal coordinate cx of the pendulum bob center is normalized, including:

[0163] Analyze the coordinates of the pendulum in all frames of the video, find the lowest point (cx_0, cy_0), cy_0 = min(cy), and normalize the horizontal coordinate cx: cx_renorm = cx - cx_0.

[0164] In one specific implementation of this embodiment, Fourier spectrum analysis is performed on the normalized horizontal coordinate cx_renorm, including:

[0165] For the time series cx_renorm(t), its Fourier transform is: By analyzing the spectrum peak position Determine the main frequency component, its reciprocal This is the period of motion. Using the Fourier transform formula, the frequency distribution of the horizontal displacement cx_renorm(t) of a simple pendulum bob with a length of 156.04 cm can be calculated, yielding the dominant frequency. f 0 = 0.3980 Hz, period of motion T = 2.512 s. By changing the pendulum length and recording the oscillation process, the oscillation period of a simple pendulum with different lengths can be calculated by following the same analysis steps.

[0166] In one specific implementation of this embodiment, according to the formula The acceleration due to gravity g was calculated, and the results are shown in Table 2.

[0167] Table 2 Experimental Results

[0168]

[0169] Experimental local gravitational acceleration The experimental results show that the average gravitational acceleration measured by the method provided in this invention is 9.775. m / s 2 The relative measurement error is only 0.17%.

[0170] Please see Figure 2 The third embodiment of the present invention provides:

[0171] A gravity acceleration measurement system based on YOLOv8, wherein the system comprises:

[0172] The construction module is used to build a simple pendulum bob image dataset and simultaneously annotate the bob position data inside each image in the simple pendulum bob image dataset to build a corresponding simple pendulum bob annotation dataset.

[0173] The training module is used to take the single pendulum bob image dataset as model input and simultaneously take the single pendulum bob annotation dataset as labels to train and fine-tune the preset YOLOv8 model in order to generate the corresponding pendulum bob detection model.

[0174] The detection module is used to acquire a complete video of a pendulum swinging, to detect the corresponding video frame rate and video duration, and simultaneously, based on the video frame rate and video duration, to detect the pendulum ball in the video of the pendulum swinging through the pendulum ball detection model, so as to output the center coordinates of the pendulum ball.

[0175] The calculation module is used to normalize the center coordinates of the pendulum bob, simultaneously combine Fourier spectrum analysis to obtain the corresponding oscillation period, and calculate the corresponding gravitational acceleration according to a preset formula and the oscillation period.

[0176] Furthermore, the building module is specifically used for:

[0177] Using the physical parameters of the pendulum bob, the shooting environment parameters, and the swing motion parameters as the corresponding control dimensions, a corresponding gradient parameter range is set, and the original images of the pendulum bob corresponding to the gradient parameter range are acquired synchronously to form a corresponding original sample library.

[0178] For each image in the original sample library, differential enhancement processing is performed based on the physical constraints of simple pendulum harmonic motion. Specifically, feature enhancement and interference suppression enhancement processing are performed for difficult samples, and motion continuity lightweight enhancement processing is performed for regular samples to generate a corresponding enhanced sample library.

[0179] The target images in the enhanced sample library are classified and integrated to form the pendulum bob image dataset.

[0180] Furthermore, the building module is specifically used for:

[0181] Physical compliance verification is performed based on the simple harmonic motion law of a pendulum. Invalid samples are removed from each of the target images, and corresponding feature labels are added to the valid samples that pass the verification.

[0182] Based on the error propagation coefficient of the pendulum center detection error to the gravitational acceleration calculation result, and combined with the feature labels, all valid samples are divided into high, medium and low measurement sensitivity to complete the directional classification of valid samples.

[0183] The valid samples after classification are subjected to motion trajectory continuity verification. After the verification is passed, the corresponding single pendulum bob image dataset is formed.

[0184] Furthermore, the training module is specifically used for:

[0185] Based on the pendulum bob image dataset and the pendulum bob annotation dataset, a feature extraction network with two parallel branches, namely the pendulum bob spatial morphology feature and the pendulum motion temporal feature, is constructed inside the preset YOLOv8 model. At the same time, a weight mechanism is set in the output layer that prioritizes the regression of the pendulum bob center coordinates over the bounding box and the classification task to complete the model pre-adaptation.

[0186] Using a time-series sample group with a continuous oscillation cycle as the core training unit, fine-tuning training with dual closed-loop constraints of detection accuracy and physical quantity transfer is performed. In each iteration cycle, the detection loss is first backpropagated based on the deviation between the detection result and the labeled true value. Then, the physical constraint loss is generated based on the deviation between the gravitational acceleration prediction calculated by the model output coordinates and the true value. The model weights are updated by incorporating the total loss function. At the same time, the training weights are dynamically adjusted based on the error transfer coefficient of the sample.

[0187] The trained model is subjected to structured pruning to remove redundant network structures, and the pendulum detection model is generated simultaneously.

[0188] Furthermore, the training module is specifically used for:

[0189] For the trained model, the physical error contribution coefficient between each model channel and network layer is quantified, and the pruning safety boundary is anchored based on the measurement allowable error threshold to delineate the core protection domain and the redundant candidate domain accordingly.

[0190] Based on the defined core protection domain and redundant candidate domain, progressive pruning with dual-branch collaborative constraints is performed, and the core protection domain is frozen synchronously after each round of pruning.

[0191] The pruned model undergoes a full-link physical accuracy closed-loop verification. For scenarios where errors exceed the standard, incremental fine-tuning and repair are performed. Simultaneously, the model inference speed is optimized by combining the actual video acquisition frame rate to generate the pendulum detection model accordingly.

[0192] Furthermore, the detection module is specifically used for:

[0193] The pendulum swing video is decoded to obtain the corresponding full time frame sequence. Invalid frames with non-harmonic motion at the beginning and end are removed simultaneously to obtain the valid frame sequence. The valid frame sequence is then adaptively sampled based on the phase law of the pendulum motion to generate the time detection frame sequence.

[0194] The time-series detection frame sequence is divided into batch detection units according to the swing period, and the batches are synchronously input into the pendulum ball detection model so as to output the initial center coordinates of the pendulum ball in a single frame through spatial feature branching.

[0195] The initial center coordinates are subjected to time-constrained correction to correspond to the center coordinates of the output pendulum ball.

[0196] Furthermore, the detection module is specifically used for:

[0197] For the initial center coordinates of each batch of output, the spatial features of the pendulum ball, the temporal index and the video frame rate of the corresponding frame are matched, and a ternary association dataset is constructed accordingly. At the same time, abnormal coordinate points of the whole sequence are identified based on the ternary association dataset, and the hierarchical labeling and initial screening of abnormal coordinates are completed by combining spatial feature deviation.

[0198] Based on the hierarchical markers of the abnormal coordinates, a two-way temporal-physical dual-constraint differential correction is performed to generate a preliminary corrected coordinate temporal sequence of the pendulum center.

[0199] The coordinate time series is subjected to Fast Fourier Analysis and simple harmonic motion fitting processing to output the center coordinates of the pendulum ball.

[0200] The fourth embodiment of the present invention provides a computer, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the gravity acceleration measurement method based on YOLOv8 as described above.

[0201] The fifth embodiment of the present invention provides a readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the gravity acceleration measurement method based on YOLOv8 as described above.

[0202] In summary, the YOLOv8-based gravitational acceleration measurement method and system provided by the above embodiments of the present invention can significantly reduce the measurement error of a simple pendulum experiment, significantly improve the accuracy and reliability of the gravitational acceleration calculation results, and the solution is easy to operate, adaptable to conventional simple pendulum experiment scenarios, and has strong practicality and anti-interference capabilities.

[0203] It should be noted that the above modules can be functional modules or program modules, and can be implemented through software or hardware. For modules implemented through hardware, the above modules can reside in the same processor; or the above modules can be located in different processors in any combination.

[0204] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-including system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device.

[0205] More specific examples of computer-readable media (a non-exhaustive list) include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.

[0206] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0207] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0208] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the appended claims.

Claims

1. A method for measuring gravitational acceleration based on YOLOv8, characterized in that, The method includes: A simple pendulum bob image dataset is constructed, and the pendulum bob position data inside each image in the simple pendulum bob image dataset are simultaneously labeled to construct a corresponding simple pendulum bob labeled dataset. The single pendulum bob image dataset is used as the model input, and the single pendulum bob annotation dataset is used as the label to train and fine-tune the preset YOLOv8 model to generate the corresponding pendulum bob detection model. A complete video of a pendulum swing is acquired to detect the corresponding video frame rate and video duration. Simultaneously, based on the video frame rate and video duration, the pendulum ball detection model is used to detect and process the pendulum ball in the video to output the center coordinates of the pendulum ball. The center coordinates of the pendulum bob are normalized, and the corresponding oscillation period is obtained by combining Fourier spectrum analysis. The corresponding gravitational acceleration is calculated according to the preset formula and the oscillation period. The steps of using the single pendulum bob image dataset as model input and simultaneously using the single pendulum bob annotation dataset as labels to train and fine-tune a preset YOLOv8 model to generate a corresponding pendulum bob detection model include: Based on the pendulum bob image dataset and the pendulum bob annotation dataset, a feature extraction network with two parallel branches, namely the pendulum bob spatial morphology feature and the pendulum motion temporal feature, is constructed inside the preset YOLOv8 model. At the same time, a weight mechanism is set in the output layer that prioritizes the regression of the pendulum bob center coordinates over the bounding box and the classification task to complete the model pre-adaptation. Using a time-series sample group with a continuous oscillation cycle as the core training unit, fine-tuning training with dual closed-loop constraints of detection accuracy and physical quantity transfer is performed. In each iteration cycle, the detection loss is first backpropagated based on the deviation between the detection result and the labeled true value. Then, the physical constraint loss is generated based on the deviation between the gravitational acceleration prediction calculated by the model output coordinates and the true value. The model weights are updated by incorporating the total loss function. At the same time, the training weights are dynamically adjusted based on the error transfer coefficient of the sample. The trained model is subjected to structured pruning to remove redundant network structures and the pendulum detection model is generated simultaneously. The step of detecting the pendulum ball in the pendulum swing video based on the video frame rate and the video duration, and outputting the center coordinates of the pendulum ball, includes: The pendulum swing video is decoded to obtain the corresponding full time frame sequence. Invalid frames with non-harmonic motion at the beginning and end are removed simultaneously to obtain the valid frame sequence. The valid frame sequence is then adaptively sampled based on the phase law of the pendulum motion to generate the time detection frame sequence. The time-series detection frame sequence is divided into batch detection units according to the swing period, and the batches are synchronously input into the pendulum ball detection model so as to output the initial center coordinates of the pendulum ball in a single frame through spatial feature branching. The initial center coordinates are subjected to time-constrained correction to correspond to the center coordinates of the output pendulum ball; The step of performing time-constrained correction processing on the initial center coordinates to correspond to the center coordinates of the output pendulum ball includes: For the initial center coordinates of each batch of output, the spatial features of the pendulum ball, the temporal index and the video frame rate of the corresponding frame are matched, and a ternary association dataset is constructed accordingly. At the same time, abnormal coordinate points of the whole sequence are identified based on the ternary association dataset, and the hierarchical labeling and initial screening of abnormal coordinates are completed by combining spatial feature deviation. Based on the hierarchical markers of the abnormal coordinates, a two-way temporal-physical dual-constraint differential correction is performed to generate a preliminary corrected coordinate temporal sequence of the pendulum center. The coordinate time series is subjected to Fast Fourier Analysis and simple harmonic motion fitting processing to output the center coordinates of the pendulum ball.

2. The gravitational acceleration measurement method based on YOLOv8 according to claim 1, characterized in that, The steps for constructing the simple pendulum bob image dataset include: Using the physical parameters of the pendulum bob, the shooting environment parameters, and the swing motion parameters as the corresponding control dimensions, a corresponding gradient parameter range is set, and the original images of the pendulum bob corresponding to the gradient parameter range are acquired synchronously to form a corresponding original sample library. For each image in the original sample library, differential enhancement processing is performed based on the physical constraints of simple pendulum harmonic motion. Specifically, feature enhancement and interference suppression enhancement processing are performed for difficult samples, and motion continuity lightweight enhancement processing is performed for regular samples to generate a corresponding enhanced sample library. The target images in the enhanced sample library are classified and integrated to form the pendulum bob image dataset.

3. The gravitational acceleration measurement method based on YOLOv8 according to claim 2, characterized in that, The step of classifying and integrating the target images in the enhanced sample library to form the single pendulum bob image dataset includes: Physical compliance verification is performed based on the simple harmonic motion law of a pendulum. Invalid samples are removed from each of the target images, and corresponding feature labels are added to the valid samples that pass the verification. Based on the error propagation coefficient of the pendulum center detection error to the gravitational acceleration calculation result, and combined with the feature labels, all valid samples are divided into high, medium and low measurement sensitivity to complete the directional classification of valid samples. The valid samples after classification are subjected to motion trajectory continuity verification. After the verification is passed, the corresponding single pendulum bob image dataset is formed.

4. The gravitational acceleration measurement method based on YOLOv8 according to claim 1, characterized in that, The trained model undergoes structured pruning to remove redundant network structures, and the pendulum detection model is generated simultaneously. For the trained model, the physical error contribution coefficient between each model channel and network layer is quantified, and the pruning safety boundary is anchored based on the measurement allowable error threshold to delineate the core protection domain and the redundant candidate domain accordingly. Based on the defined core protection domain and redundant candidate domain, progressive pruning with dual-branch collaborative constraints is performed, and the core protection domain is frozen synchronously after each round of pruning. The pruned model undergoes a full-link physical accuracy closed-loop verification. For scenarios where errors exceed the standard, incremental fine-tuning and repair are performed. Simultaneously, the model inference speed is optimized by combining the actual video acquisition frame rate to generate the pendulum detection model accordingly.

5. A gravity acceleration measurement system based on YOLOv8, characterized in that, For implementing the YOLOv8-based gravitational acceleration measurement method as described in any one of claims 1 to 4, the system comprises: The construction module is used to build a simple pendulum bob image dataset and simultaneously annotate the pendulum bob position data inside each image in the simple pendulum bob image dataset to build a corresponding simple pendulum bob annotation dataset. The training module is used to take the single pendulum bob image dataset as model input and simultaneously take the single pendulum bob annotation dataset as labels to train and fine-tune the preset YOLOv8 model in order to generate the corresponding pendulum bob detection model. The detection module is used to acquire a complete video of a pendulum swinging, to detect the corresponding video frame rate and video duration, and simultaneously, based on the video frame rate and video duration, to detect the pendulum ball in the video of the pendulum swinging through the pendulum ball detection model, so as to output the center coordinates of the pendulum ball. The calculation module is used to normalize the center coordinates of the pendulum bob, simultaneously combine Fourier spectrum analysis to obtain the corresponding oscillation period, and calculate the corresponding gravitational acceleration according to a preset formula and the oscillation period.

6. A computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the gravity acceleration measurement method based on YOLOv8 as described in any one of claims 1 to 4.

7. A readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements the YOLOv8-based gravity acceleration measurement method as described in any one of claims 1 to 4.