A time calibration method and related apparatus

By employing pre-calibration and target calibration strategies on the device awaiting calibration, and utilizing the switching of second-level elements in video frames to calculate the actual time difference, the problem of time calibration accuracy differences between high- and low-precision devices is solved, achieving accurate time calibration of the device awaiting calibration.

CN122159991APending Publication Date: 2026-06-05ZHEJIANG DAHUA TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHEJIANG DAHUA TECH CO LTD
Filing Date
2026-01-20
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

In existing technologies, the time calibration accuracy is poor due to the time accuracy difference between high-precision time synchronization servers and low-precision time-to-be-calibrated devices.

Method used

By obtaining the reference time from the time synchronization server and the calibration time of the device to be synchronized, pre-calibration is performed to determine the switching of second-level elements in the video frame, calculate the actual time difference, and implement a target calibration strategy based on this difference to improve the time calibration accuracy of the device to be synchronized.

Benefits of technology

It enables precise time calibration on devices awaiting calibration, improving the accuracy of time calibration and ensuring that the time difference between the devices awaiting calibration and the calibration server is reduced to the millisecond level.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122159991A_ABST
    Figure CN122159991A_ABST
Patent Text Reader

Abstract

The application discloses a time calibration method and related device, the method comprises the following steps: obtaining the reference time of the current time calibration server and the to-be-calibrated time of the to-be-calibrated device, pre-calibrating the to-be-calibrated time by using the reference time to obtain an initial time; obtaining the video frame continuously collected after the pre-calibration of the to-be-calibrated device, determining the first video frame corresponding to the second-level element switching in the reference time and the second video frame corresponding to the second-level element switching in the initial time; determining the actual time difference between the current initial time and the reference time based on the frame number difference between the first video frame and the second video frame; determining the target calibration strategy matched with the to-be-calibrated device based on the actual time difference, and obtaining the target time of the to-be-calibrated device after calibration by using the target calibration strategy. Through the above method, the precision of time calibration can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of video calibration technology, and in particular to a time calibration method and related apparatus. Background Technology

[0002] In the field of time calibration, there are often scenarios where a high-precision time calibration server calibrates the time of a large number of low-precision devices awaiting calibration. The time calibration server's time can reach the millisecond level, while the devices awaiting calibration, due to hardware limitations, only have a time accuracy at the second level. This difference in accuracy renders the direct transmission of millisecond-level time information ineffective, resulting in poor time calibration accuracy.

[0003] Therefore, improving the accuracy of time calibration has become an urgent problem to be solved. Summary of the Invention

[0004] The main technical problem addressed by this application is to provide a time calibration method and related apparatus that can improve the accuracy of time calibration.

[0005] To address the aforementioned technical problems, this application provides a time calibration method comprising: acquiring the reference time of the current time synchronization server and the time to be calibrated of the device to be calibrated; pre-calibrating the time to be calibrated using the reference time to obtain an initial time; acquiring continuously captured video frames from the device to be calibrated after pre-calibration; determining the first video frame corresponding to the second-level element switching in the reference time and the second video frame corresponding to the second-level element switching in the initial time; determining the actual time difference between the current initial time and the reference time based on the frame number difference between the first video frame and the second video frame; determining a target calibration strategy matching the device to be calibrated based on the actual time difference; and acquiring the target time after calibration of the device to be calibrated using the target calibration strategy.

[0006] To solve the above-mentioned technical problems, another technical solution adopted in this application is to provide an electronic device, including a memory and a processor coupled to each other, wherein the memory stores program instructions and the processor executes the program instructions to implement the method mentioned in the above technical solution.

[0007] To solve the above-mentioned technical problems, another technical solution adopted in this application is to provide a computer-readable storage medium that stores program instructions thereon, which, when executed by a processor, implement the method mentioned in the above technical solution.

[0008] The beneficial effects of this application are as follows: Unlike existing technologies, the time calibration method proposed in this application is used to calibrate the time of a device under test. Since the device under test has second-level time accuracy, after pre-calibrating the device's time to be calibrated using the reference time of the time calibration server to obtain the initial time, the first video frame corresponding to the second-level element switching in the reference time and the second video frame corresponding to the second-level element switching in the initial time are determined from the continuously acquired video frames of the device under test. Based on the first and second video frames, the actual time difference between the current initial time and the reference time is determined. This actual time difference is used to characterize the number of milliseconds between the initial time and the reference time. Based on the actual time difference, a target calibration strategy matching the device under test is determined, and this target calibration strategy is used to further accurately calibrate the initial time, ultimately obtaining a target time with higher accuracy. Attached Figure Description

[0009] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Wherein: Figure 1 This is a flowchart illustrating one embodiment of the time calibration method of this application; Figure 2 yes Figure 1 The flowchart of step S101 corresponds to another embodiment; Figure 3 yes Figure 1 The flowchart of step S103 corresponds to another embodiment; Figure 4 This is a schematic diagram of one implementation method for video frames captured by the device during calibration. Figure 5 yes Figure 1 The flowchart of step S104 corresponds to another embodiment; Figure 6 yes Figure 1 The flowchart of step S104 corresponds to another embodiment; Figure 7 yes Figure 6 The flowchart of step S501 corresponds to another embodiment; Figure 8 This is a schematic diagram of the structure of one embodiment of the electronic device of this application; Figure 9 This is a schematic diagram of one embodiment of the computer-readable storage medium of this application. Detailed Implementation

[0010] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments, and different embodiments can be adaptively combined. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0011] The time calibration method proposed in this application is applied to a time calibration system, which is coupled to both a current time synchronization server and a device to be calibrated. This system uses the current reference time of the time synchronization server as a basis to control the device to be calibrated to the corresponding time. The time synchronization server supports millisecond-level precision, while the device to be calibrated, due to hardware limitations, only supports second-level precision. For example, the time format of the time synchronization server is "2025-08-06 00:01:23:600", where multiple fields correspond to time-level elements of "year-month-day hour:minute:second:millisecond"; the time format of the device to be calibrated is "2025-08-06 00:01:23", where multiple fields correspond to time-level elements of "year-month-day hour:minute:second".

[0012] In some implementation scenarios, the aforementioned time synchronization server is a Network Video Recorder (NVR), and the aforementioned device to be synchronized is a Network Camera (IP Camera, IPC).

[0013] Please see Figure 1 , Figure 1 This is a flowchart illustrating one embodiment of the time calibration method of this application. The method includes: S101: Obtain the reference time of the current time synchronization server and the time to be calibrated of the device to be calibrated. Use the reference time to pre-calibrate the time to be calibrated to obtain the initial time.

[0014] In one embodiment, the current reference time of the time synchronization server and the current time to be calibrated of the device to be calibrated are obtained. The reference time is used to pre-calibrate the time to be calibrated, resulting in the initial time of the device after pre-calibration.

[0015] In some implementation scenarios, the current reference time of the time synchronization server and the current time to be calibrated of the device to be synchronized are obtained in real time, and the reference time and the time to be calibrated are compared. If the difference in seconds between the reference time and the time to be calibrated is greater than a first value, time pre-calibration is triggered to pre-calibrate the time to be calibrated using the reference time. When the time synchronization method of the device to be synchronized is step synchronization, the pre-calibration process includes switching the seconds element of the time to be calibrated to be consistent with the seconds element of the reference time.

[0016] In a specific application scenario, the aforementioned first value is 1. When the difference in seconds between the reference time and the time to be calibrated is greater than 1, it indicates that the time difference between the reference time and the time to be calibrated is greater than 1 second, triggering a time pre-calibration condition to switch the seconds element of the time to be calibrated to match the seconds element of the current reference time. For example, if the time to be calibrated is "2025-08-06 00:01:23" and the reference time is "2025-08-06 00:01:25:600", then the seconds element "23" in the time to be calibrated will be adjusted to "25", resulting in the pre-calibrated initial time being "2025-08-06 00:01:25".

[0017] It should be noted that due to hardware limitations, the device does not directly display specific millisecond-level elements during the calibration process. However, the millisecond-level elements corresponding to the initial time after pre-calibration can remain consistent with the millisecond-level elements in the time to be calibrated before pre-calibration. For example, if the time to be calibrated before pre-calibration is "2025-08-06 00:01:23", and its corresponding millisecond-level element should be "200", then after pre-calibration, the theoretical initial time should be "2025-08-06 00:01:25:200". However, due to hardware limitations, the initial time is only displayed as "2025-08-06 00:01:25".

[0018] Alternatively, the millisecond element corresponding to the initial time after precalibration can also be reset to 0. For example, the time to be calibrated before the above precalibration is "2025-08-06 00:01:23", and its corresponding millisecond element should be "200". After the precalibration is completed, the theoretical initial time should be "2025-08-06 00:01:25:000", but due to hardware limitations, the initial time is only displayed as "2025-08-06 00:01:25".

[0019] In one embodiment, the time calibration method of the device to be calibrated can also be smooth time calibration. After triggering pre-calibration, the second-level difference between the reference time and the time to be calibrated is used as the calibration duration, and a calibration gain matching the calibration duration is determined. Based on the calibration duration and calibration gain, the time advancement frequency of the device to be calibrated is adjusted so that the time difference between the time to be calibrated and the reference time is eliminated during subsequent time advancement, resulting in the pre-calibrated initial time.

[0020] In a specific application scenario, the time to be calibrated is "2025-08-06 00:01:23", and the reference time is "2025-08-06 00:01:25:600". Due to hardware limitations of the device under test, it cannot perceive the specific millisecond-level elements of the current time to be calibrated. Therefore, the time difference between the time to be calibrated and the reference time is assumed to be 2 seconds. Since the device under test is performing smooth time calibration, by determining the calibration gain, the time advance frequency within the next 1000 milliseconds is accelerated, so that smooth time calibration is completed after 1000 milliseconds. That is, after 1000 milliseconds, the reference time is "2025-08-06 00:01:26:600", while the initial time of the device under test after pre-calibration is "2025-08-06 00:01:26".

[0021] In one embodiment, after obtaining the initial time through pre-calibration, step S101 further includes obtaining the difference between the second-level element corresponding to the initial time and the second-level element corresponding to the reference time, and determining whether the absolute value of the difference is less than or equal to 1. If yes, then proceed with the subsequent steps. If no, then re-execute step S101 to perform a new round of pre-calibration until the difference between the second-level element corresponding to the latest obtained initial time and the second-level element corresponding to the reference time is less than or equal to 1.

[0022] S102: Acquire video frames continuously collected by the time-to-be-calibrated device after pre-calibration, and determine the first video frame corresponding to the second-level element switching in the reference time and the second video frame corresponding to the second-level element switching in the initial time.

[0023] In one embodiment, video frames are acquired in real time by the device to be calibrated after pre-calibration. Each video frame is labeled with its initial acquisition time.

[0024] Specifically, after pre-calibrating the device to be calibrated, video frames are captured using the device to obtain multiple consecutive video frames. Each video frame has a time stamp area, which contains the initial time corresponding to the acquisition of that video frame.

[0025] In some implementation scenarios, in response to the first switching of the second-level element in the current reference time after pre-calibration, the corresponding video frame is taken as the first video frame. And, in response to the first switching of the second-level element in the initial time corresponding to the current video frame, the current video frame is taken as the second video frame.

[0026] In a specific application scenario, for each video frame acquired by the device to be calibrated, its time-marked region is dynamically detected to check whether the second-level element in the initial time has switched. After the pre-calibration of the device to be calibrated is completed, if a switch in the second-level element in the time-marked region of the video frame acquired by the device to be calibrated is detected, the first video frame after the switch is taken as the second video frame.

[0027] S103: Based on the frame number difference between the first video frame and the second video frame, determine the actual time difference between the current initial time and the reference time.

[0028] In one embodiment, the video frames acquired by the pre-calibrated time-to-be-calibrated device are sequentially sorted to obtain a video frame sequence. The frame count difference between the first and second video frames is determined based on their positions within the video frame sequence. The actual time difference between the current initial time and the reference time is then determined based on this frame count difference. This actual time difference characterizes the millisecond difference between the reference time and the initial time.

[0029] In a specific application scenario, after pre-calibration is completed, video frames acquired by the device during calibration are sequentially acquired and sorted to obtain a video frame sequence. Since the first video frame is the fifth frame in the video frame sequence and the second video frame is the eighth frame, the frame difference between the first and second video frames is determined to be 3.

[0030] Furthermore, by combining the acquisition interval between adjacent video frames acquired by the device during the calibration period and the aforementioned frame difference, the actual time difference between the current initial time and the reference time is determined.

[0031] S104: Based on the actual time difference, determine the target calibration strategy that matches the device to be calibrated, and use the target calibration strategy to obtain the target time after calibration of the device to be calibrated.

[0032] In one implementation, a target standard strategy matching the time to be calibrated is determined based on the actual time difference. The time to be calibrated is then calibrated using the target calibration strategy to obtain the calibrated target time.

[0033] In some implementation scenarios, it is determined whether the absolute value of the actual time difference is greater than a preset time difference threshold. If the absolute value of the actual time difference is greater than the preset time difference threshold, the reference time is used to calibrate the initial time of the device to be calibrated. Alternatively, if the absolute value of the actual time difference is less than or equal to the preset time difference threshold, the time difference between the reference time and the initial time is considered small, no calibration is required, and the current initial time is directly used as the target time for the device to be calibrated.

[0034] In a specific application scenario, the aforementioned preset time difference threshold is 500 milliseconds.

[0035] The time calibration method proposed in this application is used to calibrate the time of a device under test. Since the device under test has second-level time accuracy, after pre-calibrating the device's time to be calibrated using the reference time of a time calibration server to obtain an initial time, the method identifies a first video frame corresponding to the second-level element switching in the reference time and a second video frame corresponding to the second-level element switching in the initial time from continuously acquired video frames from the device under test. Based on the first and second video frames, the actual time difference between the current initial time and the reference time is determined. This actual time difference characterizes the number of milliseconds between the initial time and the reference time. Based on the actual time difference, a target calibration strategy matching the device under test is determined, and this target calibration strategy is used to further refine the initial time, ultimately obtaining a target time with higher accuracy.

[0036] Please see Figure 2 , Figure 2 yes Figure 1 The flowchart of step S101 corresponds to another embodiment. Specifically, the implementation process of step S101 includes: S201: Obtain a pre-time synchronization command that matches the device to be synchronized, and based on the pre-time synchronization command, use the synchronization server to send the reference time after the second-level element is switched to the device to be synchronized.

[0037] In one embodiment, a pre-time synchronization command matching the device to be synchronized is obtained, the pre-time synchronization command is executed, and the reference time after the second-level element is switched is sent to the device to be synchronized using the time synchronization server.

[0038] In some implementation scenarios, a pre-calibration command matching the device to be calibrated is generated every preset time interval.

[0039] In one implementation scenario, after receiving the pre-time synchronization command, the command is sent to the time synchronization server. The time synchronization server verifies the current reference time to determine if the original millisecond element in the current reference time is 0. If the millisecond element in the reference time is not zero, the reference time is sent to the device to be synchronized after the millisecond element changes to 0 over time.

[0040] In a specific application scenario, if the reference time of the time synchronization server is "2025-08-06 00:01:25:600", then wait for 400 milliseconds until the reference time changes to "2025-08-06 00:01:26:000", and then send the reference time to the device to be synchronized.

[0041] S202: Control the device to be calibrated to adjust the current time to be calibrated based on the received reference time to obtain the initial time.

[0042] In one embodiment, after the device to be calibrated receives the reference time sent by the time calibration server, it uses the reference time to calibrate the current time to be calibrated to obtain the pre-calibrated initial time.

[0043] In some implementation scenarios, different types of devices awaiting time calibration perform time calibration differently. In response to some types of devices using step-time calibration, where the corresponding millisecond-level elements are reset after calibration, the second-level elements of the current time to be calibrated are switched to match the second-level elements of the current reference time, and the millisecond-level elements of the time to be calibrated are reset to 0, resulting in the pre-calibrated initial time. Since the second-level elements of the reference time have just been switched, their corresponding millisecond-level elements are infinitely close to 0, thus the initial time after the millisecond-level elements are reset tends to match the reference time.

[0044] Alternatively, in response to certain types of devices undergoing time calibration using smooth time synchronization and the reset of millisecond-level elements after time calibration, the second-level difference between the reference time and the time to be calibrated is used as the calibration duration, and a calibration gain matching this calibration duration is determined. Based on the calibration duration and calibration gain, the time advancement frequency of the device to be calibrated is adjusted to eliminate the time difference between the time to be calibrated and the reference time during subsequent time advancement, resulting in a pre-calibrated initial time. Similarly, the millisecond-level elements corresponding to the initial time are reset to 0.

[0045] In the above scheme, after the second-level element of the reference time switches, its corresponding millisecond-level element becomes 0, and the current reference time is synchronized to the device to be calibrated for pre-calibration. Because the hardware limitations of the device to be calibrated prevent it from accurately identifying the millisecond-level element in the current time to be calibrated, and because some types of devices actually reset their millisecond-level element to 0 after pre-calibration, this ensures that the initial time of these types of devices is consistent with the reference time after pre-calibration, thus improving the accuracy of time calibration.

[0046] Please see Figure 3 , Figure 3 yes Figure 1 The flowchart of step S103 corresponds to another embodiment. Specifically, the implementation process of step S103 includes: S301: Obtain the first frame difference between the first video frame and the second video.

[0047] In one embodiment, the video frames acquired by the device to be calibrated after pre-calibration are sequentially sorted to obtain a video frame sequence. Based on the positions of the first and second video frames in the video frame sequence, a first frame difference between the first and second video frames is determined.

[0048] S302: Based on the time advancement information corresponding to the millisecond-level elements in the reference time, obtain the second frame difference between the termination video frame and the start video frame collected by the time calibration device within the target duration.

[0049] In one embodiment, the first video frame acquired by the device under calibration after pre-calibration is taken as the starting video frame, and the ending video frame acquired by the device under calibration in the current time calibration round is determined based on the time progression information of the millisecond-level elements in the reference time. The millisecond difference between the starting and ending video frames is a fixed value. A second frame difference between the ending and starting video frames is determined based on their respective positions in the video frame sequence. The fixed value is 1000.

[0050] Specifically, since the reference time includes accurate millisecond-level elements, the aforementioned time advancement information is used to characterize the specific changes in the millisecond-level elements in the reference time. Based on the specific changes in the millisecond-level elements, all video frames acquired by the time-to-be-calibrated device within 1000 milliseconds after pre-calibration are obtained, and the last video frame is used as the aforementioned termination video frame.

[0051] S303: Determine the actual time difference based on the target duration and the ratio between the first frame difference and the second frame difference.

[0052] In one embodiment, the ratio between the first frame difference and the second frame difference is obtained. This ratio is multiplied by the fixed value to obtain the actual time difference between the current initial time and the reference time. This actual time difference is used to characterize the millisecond difference between the current initial time and the current reference time.

[0053] For a specific application scenario, please refer to Figure 4 , Figure 4 This is a schematic diagram illustrating one implementation method for video frames captured by the device during calibration. For example... Figure 4As shown, after pre-calibration, the device to be calibrated acquires video frames every 100 milliseconds, forming a video frame sequence: F1, F2, F3, ... Using video frame F1 as the starting video frame, when acquiring the starting video frame, the millisecond element in the reference time of the calibration server is 600 milliseconds, while the millisecond element in the initial time of the device to be calibrated is 400 milliseconds. It should be noted that the millisecond element in the initial time is imperceptible during the statistical period; this is assumed for easier explanation of the calibration principle of this scheme. In response to acquiring video frame F5, if the millisecond element in the reference time is 1000 (actually displayed as the second element plus one, while the millisecond element is reset to 000), then it is considered the first change in the second element of the reference time after pre-calibration, and video frame F5 is taken as the first video frame. In response to acquiring video frame F7, if the millisecond element in the initial time is 1000, then the first change in the second element of the initial time, and video frame F7 is taken as the second video frame. In response to the fact that when video frame F11 is acquired, the millisecond element in the reference time is 1600, meaning the millisecond difference between the reference time corresponding to video frame F11 and the reference time corresponding to the initial video frame reaches a fixed value, video frame F11 is designated as the termination video frame. Based on the positions of the initial video frame, the first video frame, the second video frame, and the termination video frame in the video frame sequence, the actual time difference between the current initial time and the reference time is determined. The specific formula for calculating the actual time difference is as follows:

[0054] in, The first frame number difference between the first video frame and the second video frame is represented by a value of -2. The second frame difference, which represents the difference between the terminating video frame and the initial video frame, is 10. The ratio of the first frame difference to the second frame difference is multiplied by a fixed value of 1000 to obtain the actual time difference between the initial time and the reference time, which is 200 milliseconds. The initial time of the device to be calibrated is lagging behind the current reference time.

[0055] The above scheme, because the device cannot display specific millisecond-level elements during calibration, cannot directly calculate the actual time difference based on the millisecond-level elements corresponding to the initial time and reference time. By determining the first video frame, second video frame, initial video frame, and ending video frame, the actual time difference can be calculated based on the corresponding frame number difference. This improves the flexibility of time difference calculation and facilitates further calibration of the initial time based on the actual time difference.

[0056] Please see Figure 5 , Figure 5 yes Figure 1The flowchart of step S104 corresponds to another implementation method. In response to the actual time difference being greater than a preset time difference threshold, and the time synchronization method of the device to be synchronized being step synchronization, the specific implementation process of step S104 includes: S401: In response to the current initial time lagging behind the current reference time, obtain the reference time when the millisecond element is zero, use the reference time to calibrate the initial time, and obtain the calibrated target time.

[0057] In one embodiment, since the actual time difference determined by the corresponding implementation method described above is greater than a preset time difference threshold, it indicates that a significant time difference still exists between the initial time and the reference time after pre-calibration. Therefore, it can be determined that the device to be calibrated does not reset the millisecond-level elements when performing time calibration based on the reference time, but rather keeps the millisecond-level elements consistent with those before pre-calibration. To further improve the accuracy of time calibration, the timing relationship between the current initial time and the current reference time is determined. In response to the current initial time lagging behind the current reference time, i.e., the actual time difference calculated by the corresponding implementation method described above is less than 0, the system waits for the millisecond-level elements of the reference time to change to zero, and then controls the time calibration server to send the reference time with zero millisecond-level elements to the device to be calibrated, so that the device to be calibrated can calibrate the current initial time based on the reference time to obtain the target time after final calibration.

[0058] In some implementation scenarios, in response to the step-time calibration device in this embodiment, after the device obtains a reference time with millisecond-level elements of zero, it uses the device to switch the second-level elements in the corresponding initial time to be consistent with the second-level elements in the current reference time, so as to obtain the final calibrated target time and reduce the time difference between the target time and the reference time.

[0059] In a specific application scenario, the current reference time is "2025-08-06 00:01:45:800", and the current initial time is "2025-08-06 00:01:45". The millisecond element corresponding to the initial time is actually "000", meaning the initial time lags behind the reference time by 800 milliseconds. After 200 milliseconds, the millisecond element of the reference time changes to zero. The time synchronization server then sends the current reference time to the device awaiting time synchronization, specifically sending the reference time "2025-08-06 00:01:46:000". The initial time of the device under test is "2025-08-06 00:01:45", and its corresponding millisecond element is actually "200". The device under test is then used to perform a final calibration on the initial device according to the received reference time, switching the corresponding second element to match the reference time. The resulting target time for the device under test is "2025-08-06 00:01:46". However, because the device under test uses step-time calibration and the millisecond element is not reset after calibration, the actual millisecond element corresponding to the target time remains "200". Therefore, after final calibration, the time difference between the target time and the reference time is 200 milliseconds. Compared to the initial time lagging behind the reference time by 800 milliseconds before final calibration, this time difference is significantly reduced, greatly improving the accuracy of time calibration.

[0060] S402: In response to the current reference time lagging behind the current initial time, when the second-level element of the initial time changes, control the time synchronization device to adjust the second-level element of the initial time to be consistent with the second-level element of the current reference time, so as to obtain the target time.

[0061] In one embodiment, in response to the current reference time lagging behind the current initial time, i.e., the actual time difference calculated by the above-described corresponding embodiments is greater than 0, when waiting for the second-level element of the initial time to switch, the control time synchronization server sends the reference time to the time synchronization device to be synchronized, so that the time synchronization device to be synchronized can calibrate the current initial time according to the reference time to obtain the final calibrated target time.

[0062] In some implementation scenarios, in response to the reference time lagging behind the initial time, the initial time is dynamically detected to determine whether the corresponding second-level element has switched. It is assumed that when the second-level element switches, the actual millisecond-level element corresponding to the initial time is zero. Therefore, when the second-level element of the initial time switches, the time synchronization server sends the current reference time to the device to be synchronized, and uses the device to adjust the second-level element in the initial time to match the second-level element in the current reference time, thus obtaining the final calibrated target time for the device.

[0063] In a specific application scenario, the current reference time is "2025-08-06 00:01:45:000", and the current initial time is "2025-08-06 00:01:45". The actual millisecond element of the initial time is "800", meaning the reference time lags behind the initial time by 800 milliseconds. After 200 milliseconds, the second element of the initial time changes, and the time synchronization server sends the current reference time to the device awaiting time synchronization, i.e., the reference time "2025-08-06 00:01:45:200" is sent to the device awaiting time synchronization. At this point, the initial time of the device under test is "2025-08-06 00:01:46", and its corresponding millisecond element is actually infinitely close to "000". The device under test is used to perform a final calibration on the initial device according to the received reference time, switching the corresponding second element to be consistent with the reference time. The resulting target time for the device under test is "2025-08-06 00:01:45". Here, the millisecond element corresponding to the target time is still actually "000". Therefore, after final calibration, the time difference between the target time and the reference time is 200 milliseconds. Compared to before final calibration, when the reference time lagged behind the initial time by 800 milliseconds, the time difference is greatly reduced, significantly improving the accuracy of time calibration.

[0064] The above scheme, when the absolute value of the actual time difference is greater than a preset time difference threshold, performs a final calibration on the initial time based on the timing relationship between the initial time and the reference time to improve the accuracy of the target time. The preset time difference threshold is 500. By setting the preset time difference threshold to 500, when the absolute value of the actual time difference is greater than the preset time difference threshold, the final calibration ensures that the time difference between the target time and the reference time of the device to be calibrated changes to the difference between 1000 and the actual time difference.

[0065] Please see Figure 6 , Figure 6 yes Figure 1 The flowchart of step S104 corresponds to another implementation method. In response to the absolute value of the actual time difference being greater than a preset time difference threshold, and the time synchronization method of the device to be synchronized being smooth time synchronization, the specific implementation process of step S104 includes: S501: Obtain a preset time interval and use the time interval to adjust the initial time at least once until the adjusted initial time meets the final calibration conditions.

[0066] In one embodiment, in response to the time calibration method of the device to be calibrated being smooth time calibration, a preset time interval is obtained, such that the initial time is adjusted at least once using the time interval to adjust the actual millisecond-level elements in the initial time until the millisecond-level elements in the initial time meet the final calibration conditions.

[0067] In some implementation scenarios, the final calibration condition is considered met when the difference between 1000 milliseconds and the millisecond-level elements in the initial time is less than the aforementioned time interval. Since the millisecond-level elements in the reference time are determined, the specific value of the millisecond-level elements in the initial time is determined by calculating the actual time difference between the initial time and the reference time. The specific calculation process for the actual time difference can be referred to the corresponding implementation method described above, and will not be elaborated upon here.

[0068] S502: Based on the timing relationship between the current reference time and the initial time, control the device to be calibrated to use the current reference time to calibrate the initial time and obtain the target time.

[0069] In one embodiment, after the final calibration conditions are met, the device to be calibrated is controlled to calibrate the initial time using the current reference time, based on the timing relationship between the current reference time and the initial time, to obtain the target time.

[0070] In some implementation scenarios, in response to the current initial time lagging behind the current reference time, a reference time with a millisecond element of zero is obtained. The initial time is then calibrated using this reference time to obtain the calibrated target time. Alternatively, in response to the current reference time lagging behind the current initial time, when the second element of the initial time switches, the time calibration device is controlled to adjust the second element of the initial time to be consistent with the second element of the current reference time to obtain the target time. The specific process of calibrating the initial time to obtain the target time in this embodiment can be referred to steps S401 to S402 above, and will not be elaborated further here.

[0071] In the above scheme, when the device to be calibrated uses smooth time calibration and the absolute value of the actual time difference is greater than a preset time difference threshold, the millisecond-level elements corresponding to the initial time are adjusted at least once using a preset time interval, so that the millisecond-level elements in the adjusted initial time are close to the value 999. Then, based on the timing relationship between the initial time and the reference time, the initial time is finally calibrated to improve the accuracy of the target time.

[0072] Please see Figure 7 , Figure 7 yes Figure 6 The flowchart of step S501 corresponds to another embodiment. Specifically, the implementation process of step S501 includes: S601: Generate a time adjustment instruction that matches the initial time; wherein, the time adjustment instruction includes a first sub-instruction and a second sub-instruction for adjusting the initial time, the time adjustment direction of the first sub-instruction is opposite to that of the second sub-instruction, and a time interval is set between adjacent sub-instructions and the second sub-instruction.

[0073] In one embodiment, in response to the device undergoing smooth time synchronization and the absolute value of the actual time difference being greater than a preset time difference threshold, a time adjustment command matching the current initial time is generated. This time adjustment command includes a first sub-command and a second sub-command with opposite time adjustment directions, and a time interval is set between the first and second sub-commands. Specifically, the first sub-command is used to calibrate the initial time so that the calibrated initial time is consistent with a reference time shifted backward by N seconds; the second sub-command is used to calibrate the initial time so that the calibrated initial time is consistent with a reference time shifted forward by N seconds.

[0074] In a specific application scenario, to improve calibration efficiency, the time interval between the first sub-instruction and the second sub-instruction is set to 100 milliseconds. The first sub-instruction is used to make the initial time after calibration consistent with the reference time after shifting backward by 2 seconds, and the second sub-instruction is used to make the initial time after calibration consistent with the reference time after shifting forward by 2 seconds.

[0075] S602: In response to the current initial time lag and the current reference time, when the millisecond element of the reference time changes to zero, a time adjustment command is sent to the time-to-be-calibrated device, and the current initial time is advanced at least once using the time interval until the millisecond element of the initial time after the advancement is greater than the preset value.

[0076] In one embodiment, when the actual time difference between the current initial time and the current reference time (i.e., the actual time difference between the initial time and the reference time) is less than zero, the reference time adjusted by the first sub-instruction and the second sub-instruction are sequentially sent to the time-calibrating device when the millisecond-level element of the reference time changes to zero. There is a time interval between the first and second sub-instructions. Since the first and second sub-instructions have opposite time-calibration directions, they cannot be merged. After sending the first sub-instruction, the second sub-instruction is sent after the aforementioned time interval, so that the millisecond-level element of the initial time is advanced for the current cycle using the aforementioned time interval.

[0077] Furthermore, the target time difference between the current initial time and the reference time after each propulsion round is obtained. Based on the millisecond-level elements in the current reference time and the target time difference, the millisecond-level elements corresponding to the initial time after each propulsion round are determined. If the millisecond-level element corresponding to the current initial time is greater than a preset value, the final calibration condition is deemed met.

[0078] In some implementation scenarios, after advancing the initial time's millisecond-level elements using the aforementioned time interval for the current round, the target time difference between the current initial time and the current reference time is immediately determined. This target time difference is determined based on multiple video frames acquired by the time-testing device after advancing using the time interval. The specific process for determining the target time difference can refer to the actual time difference determination process in the corresponding implementation above, and will not be elaborated here. Based on the millisecond-level elements in the current reference time and the target time difference, the millisecond-level elements corresponding to the initial time after advancing using the time interval for the current round are calculated. It is determined whether the millisecond-level elements corresponding to the current initial time are greater than a preset value. If so, it is determined that the final calibration condition is met, and step S502 is executed to obtain the target time after final calibration. If not, the time adjustment command is resent to the time-testing device to advance using the time interval for the next round.

[0079] In a specific application scenario, the reference time is "2025-08-06 00:01:45:800", and the initial time is "2025-08-06 00:01:45". The initial time's millisecond element is actually "000", meaning the initial time lags behind the reference time by 800 milliseconds. After 200 milliseconds, the reference time changes to "2025-08-06 00:01:46:000", and the initial time is "2025-08-06 00:01:45". The initial time's millisecond element is actually "200". A time adjustment command is sent to the device to be synchronized to perform a round of adjustment using the time interval. Responding to a time interval of 100 milliseconds, the millisecond element corresponding to the initial time after the adjustment is "300". Since the difference between 1000 milliseconds and the millisecond element corresponding to the initial time is not less than the time interval... The time adjustment command continues to be sent to the device to be calibrated until the millisecond element corresponding to the initial time is within the interval [900, 999], at which point the final calibration condition is met. For example, after seven rounds of propulsion, the millisecond element corresponding to the initial time is "900", and the reference time at this time is "2025-08-06 00:01:46:700", then the final calibration condition is met, and final calibration is performed using step S401, ultimately making the time difference between the obtained target time and the initial time 200 milliseconds.

[0080] It should be noted that in practical applications, since the device to be calibrated uses smooth time calibration, when the time adjustment command is sent to the device, the corresponding time adjustment gain is determined, the aforementioned time interval is updated using the time adjustment gain, and the initial time is advanced using the updated time interval. That is, the actual advancement time for each round is... ,in, Indicates time interval, This indicates the time-adjusted gain.

[0081] S603: In response to the current reference time lagging behind the current initial time, when the second-level element of the initial time changes, a time adjustment command is sent to the time-to-be-calibrated device, and the current initial time is advanced at least once using the time interval until the millisecond-level element of the initial time after the advancement is greater than the preset value.

[0082] In one embodiment, when the current reference time lags behind the current initial time, i.e., the actual time difference between the initial time and the reference time is greater than zero, after issuing the first sub-instruction, a second sub-instruction is issued at the aforementioned time interval, so that the current round is advanced by using the millisecond-level elements of the initial time using the aforementioned time interval.

[0083] Furthermore, the target time difference between the current initial time and the reference time after each round of propulsion is obtained. Based on the millisecond-level elements in the current reference time and the target time difference, the millisecond-level elements corresponding to the initial time after each round of propulsion are determined. If the millisecond-level element corresponding to the current initial time is greater than a preset value, the final calibration condition is deemed met. The specific implementation process can be referred to the corresponding implementation method described above.

[0084] Please see Figure 8 , Figure 8 This is a schematic diagram of one embodiment of the electronic device of this application. The electronic device includes a memory 10 and a processor 20 coupled to each other. The memory 10 stores program instructions, and the processor 20 executes the program instructions to implement the methods mentioned in any of the above embodiments. Specifically, the electronic device includes, but is not limited to, desktop computers, laptops, tablets, servers, etc., and is not limited thereto. In addition, the processor 20 may also be called a CPU (Center Processing Unit). The processor 20 may be an integrated circuit chip with signal processing capabilities. The processor 20 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The general-purpose processor may be a microprocessor or any conventional processor. In addition, the processor 20 may be implemented by integrated circuit chips.

[0085] Please see Figure 9 , Figure 9This is a schematic diagram of a computer-readable storage medium according to an embodiment of the present application. The computer-readable storage medium 30 stores program instructions 40 that can be executed by a processor. When the program instructions 40 are executed by the processor, they implement the methods mentioned in any of the above embodiments.

[0086] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus implementations described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0087] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.

[0088] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0089] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0090] The above are merely embodiments of this application and do not limit the scope of this patent application. Any equivalent structural or procedural changes made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of this application.

Claims

1. A time calibration method, characterized in that, include: Obtain the reference time of the current time synchronization server and the calibration time of the device to be synchronized. Use the reference time to pre-calibrate the time to be synchronized to obtain the initial time. Acquire video frames continuously collected by the time-to-be-calibrated device after pre-calibration, and determine the first video frame corresponding to the second-level element switching in the reference time and the second video frame corresponding to the second-level element switching in the initial time. Based on the frame number difference between the first video frame and the second video frame, determine the actual time difference between the current initial time and the reference time; Based on the actual time difference, a target calibration strategy matching the device to be calibrated is determined, and the target time after calibration of the device to be calibrated is obtained using the target calibration strategy.

2. The time calibration method according to claim 1, characterized in that, Obtain the reference time of the current time synchronization server and the calibration time of the device to be synchronized. Use the reference time to pre-calibrate the time to be synchronized to obtain the initial time, including: Obtain the pre-time synchronization command that matches the device to be synchronized, and based on the pre-time synchronization command, use the time synchronization server to send the reference time after the second-level element is switched to the device to be synchronized; The device under control adjusts the current time to be calibrated based on the received reference time to obtain the initial time.

3. The time calibration method according to claim 1, characterized in that, Acquire video frames continuously captured by the device to be calibrated after pre-calibration, and determine the first video frame corresponding to the second-level element switching in the reference time and the second video frame corresponding to the second-level element switching in the initial time, including: Acquire video frames captured in real time by the device to be calibrated after pre-calibration; the video frames are marked with the initial time of acquisition; In response to the first switching of the second-level element in the current reference time after pre-calibration, the corresponding video frame is taken as the first video frame; and, In response to the first switching of the second-level element in the initial time corresponding to the current video frame, the current video frame is used as the second video frame.

4. The time calibration method according to claim 1, characterized in that, Based on the frame number difference between the first video frame and the second video frame, the actual time difference between the current reference time and the initial time is determined, including: Obtain the first frame number difference between the first video frame and the second video; and, Based on the time advancement information corresponding to the millisecond-level elements in the reference time, the second frame difference between the termination video frame and the start video frame collected by the time-calibration device within the target duration is obtained; The actual time difference is determined based on the target duration and the ratio between the first frame difference and the second frame difference.

5. The time calibration method according to claim 1, characterized in that, In response to an actual time difference absolute value exceeding a preset time difference threshold, and the time calibration method of the device to be calibrated being step-time calibration, a target calibration strategy matching the device to be calibrated is determined based on the actual time difference. The target calibration strategy is then used to obtain the calibrated target time of the device to be calibrated, including: In response to the current initial time lagging behind the current reference time, obtain the reference time when the millisecond-level element is zero, use the reference time to calibrate the initial time, and obtain the calibrated target time; In response to the current reference time lagging behind the current initial time, when the second-level element of the initial time changes, the device to be synchronized is controlled to adjust the second-level element of the initial time to be consistent with the second-level element of the current reference time, so as to obtain the target time.

6. The time calibration method according to claim 1, characterized in that, In response to the situation where the absolute value of the actual time difference is greater than a preset time difference threshold, and the time calibration method of the device to be calibrated is smooth time calibration, a target calibration strategy matching the device to be calibrated is determined based on the actual time difference. The target time after calibration of the device to be calibrated is obtained using the target calibration strategy, including: Obtain a preset time interval and use the time interval to adjust the initial time at least once until the adjusted initial time meets the final calibration conditions; Based on the timing relationship between the current reference time and the initial time, the device to be calibrated is controlled to use the current reference time to calibrate the initial time and obtain the target time.

7. The time calibration method according to claim 6, characterized in that, Obtain a preset time interval, and adjust the initial time at least once using the time interval until the adjusted initial time meets the final calibration conditions, including: Generate a time adjustment instruction that matches the initial time; wherein the time adjustment instruction includes a first sub-instruction and a second sub-instruction for adjusting the initial time, the time adjustment direction of the first sub-instruction is opposite to that of the second sub-instruction, and a time interval is set between adjacent sub-instructions; In response to the current initial time lagging behind the current reference time, when the millisecond element of the reference time changes to zero, a time adjustment command is sent to the time-to-be-calibrated device, and the current initial time is advanced at least once using the time interval until the millisecond element of the initial time after the advancement is greater than the preset value. In response to the current reference time lagging behind the current initial time, when the second-level element of the initial time changes, the time adjustment command is sent to the time-synchronization device. The current initial time is advanced at least once using the time interval until the millisecond-level element of the initial time after the advancement is greater than the preset value.

8. The time calibration method according to claim 7, characterized in that, The time adjustment command is sent to the device to be synchronized, and the current initial time is advanced at least once using time intervals until the millisecond element corresponding to the advanced initial time is greater than a preset value, including: Obtain the target time difference between the current initial time and the reference time after each round of advancement; Based on the millisecond-level elements in the current reference time and the target time difference, determine the millisecond-level elements corresponding to the initial time after each round of advancement; If the millisecond element corresponding to the current initial time is greater than the preset value, the final calibration condition is determined to be met.

9. An electronic device, characterized in that, include: A memory and a processor are coupled to each other, the memory storing program instructions and the processor executing the program instructions to implement the method as claimed in any one of claims 1-8.

10. A computer-readable storage medium having program instructions stored thereon, characterized in that, When the program instructions are executed by the processor, they implement the method as described in any one of claims 1-8.