Basketball game video portrait screen tracking and exporting method and device, equipment, medium and program product
Patent Information
- Application Number
- CN202611151879.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-15
- Publication Date
- 2026-10-30
AI Technical Summary
然而,在篮球比赛场景中,球体尺寸小、运动速度快、遮挡频繁、画面中可能同时出现静止球、误检球或多个候选球体,导致现有方法在横转竖过程中容易出现如下问题:其一,因漏检或断轨造成跟踪目标丢失;其二,因把静止球误认为跟踪对象而导致镜头跟错;其三,因镜头响应滞后造成球已接近裁剪边缘甚至出框;其四,直接在带有轨迹、水印或其他图形叠加的画面上做检测,容易降低目标检测稳定性;其五,在移动终端上重复执行检测、渲染和裁剪时,计算量较高且导出成功率不稳定;
1. 通过对静止球干扰进行抑制,减少误跟静止球导致的裁剪中心偏移;
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This invention relates to the fields of video processing and computer vision technology, and in particular to a method, apparatus, device, computer-readable storage medium, and computer program product for generating vertical tracking and exporting basketball game horizontal video. Background Technology
[0002] With the widespread adoption of short videos on mobile devices, users often want to export basketball games or shooting clips from their original landscape videos to 9:16 portrait videos suitable for mobile viewing. Existing solutions typically involve fixed center cropping, simple cropping based on the target frame center, or relying solely on frame-by-frame detection results for image reconstruction. However, in basketball game scenarios, the small size of the ball, its high speed, frequent occlusion, and the simultaneous presence of stationary balls, falsely detected balls, or multiple candidate balls in the frame cause existing methods to easily encounter the following problems during horizontal-to-vertical transitions: First, the tracking target may be lost due to missed detections or track breaks; second, the camera may follow the wrong target by mistaking a stationary ball for the tracking object; third, the ball may be close to the cropping edge or even out of the frame due to camera response lag; fourth, performing detection directly on images with tracks, watermarks, or other graphic overlays can easily reduce the stability of target detection; and fifth, when repeatedly performing detection, rendering, and cropping on mobile terminals, the computational load is high and the export success rate is unstable. Therefore, a more suitable vertical screen tracking and export technology solution for basketball games is still needed to improve the accuracy of ball tracking, image stability and export quality of vertical screen exported videos while ensuring the processing performance of mobile devices.
[0003] Technical problems to be solved This invention aims to solve the technical problems existing in the export of horizontal basketball game videos to vertical videos, such as target loss, mistracking of stationary balls, camera response lag, insufficient detection stability, and low export success rate on mobile devices.
[0004] Technical solution To address the aforementioned technical problems, this invention provides a method for vertical screen tracking and exporting basketball game videos. This method can be executed by a mobile terminal, tablet device, edge computing device, or other electronic device with video processing capabilities. The method includes the following steps: Step S1: Obtain the horizontal video of the basketball game, the start and end time range of the segment to be exported, and the basketball trajectory data associated with the segment to be exported. The trajectory data may come from existing shooting trajectory analysis results on the client side, native target detection results, or a combination of both. Step S2: Perform time normalization on the trajectory data according to the start and end time range, extract the original sample points representing the lateral position of the basketball, and preferentially use the horizontal coordinate of the center of the hoop as the sample value; when the hoop information is missing, use the horizontal coordinate of the trajectory point position as a supplement. Step S3: Perform static ball interference suppression on the original sample points, retain the start point, end point, and sample points whose lateral displacement reaches a preset threshold, so as to reduce the impact of static balls or false detection points on the vertical screen cropping center; when the filtered samples are empty, revert to using the sample set before filtering. Step S4: Sort the sample points by time and fuse multiple sample points corresponding to the same time to obtain a deduplicated target position sequence; preferably, average multiple horizontal coordinates at the same time to generate a fused horizontal position value at a unified time. Step S5: Sample the entire timeline of the segment to be exported at preset time intervals, and generate a horizontal position sequence of the entire timeline based on the interpolation results of the sample points; maintain the first target position before the trajectory starts and maintain the last target position after the trajectory ends; Step S6: Perform peak removal and dynamic smoothing on the sampled horizontal position sequence to generate vertical screen tracking keyframes. Preferably, first suppress single-frame false detections based on sliding window mid-range filtering, and then dynamically update the center position of the cropping window by combining the preset dead zone, edge forced response zone, and future time prediction values; Step S7: Based on the vertical screen tracking keyframes, construct a 9:16 dynamic cropping window that changes over time on the horizontal screen video, and crop and scale the video frames based on the dynamic cropping window to obtain the vertical screen tracking exported video. Step S8: When the detection stability is insufficient or the trajectory data is incomplete, a temporary detection segment without trajectory superposition information is first generated. Frame-by-frame basketball detection is performed on the temporary detection segment and a new keyframe is generated. Then, the video obtained from the first rendering is cropped and exported in a second pass based on the new keyframe. Step S9: After the vertical screen cropping and export are completed, watermarks, logos or other overlay elements are superimposed according to the export strategy to avoid size distortion of the overlay elements during the cropping and scaling process. Preferably, the preset threshold in step S3 is a normalized lateral displacement threshold, which can be set to 0.008 for example; the preset time interval in step S5 can be about 33ms, so as to balance the real-time performance of the mobile device and the smoothness of the keyframe. Preferably, the future time prediction in step S6 can be obtained by the position value corresponding to a preset lead time after the current time, and the lead time can be about 66ms; and different response coefficients are selected according to the magnitude of the prediction error, so as to reduce the phenomenon of "the lens not keeping up with the ball" while reducing lens shake; Preferably, after detecting that the basketball has completed a critical event, the center position of the cropping window can be fixed at the last effective tracking center to maintain a stable image for a short period after the basket. The critical event may include a successful shot, the ball reaching the vicinity of the basket, or the climax of its trajectory. Preferably, the width of the 9:16 dynamic cropping window is determined by multiplying the height of the source video by 9 / 16, and the height of the cropping window remains consistent with the height of the source video; by scaling the cropping area, a vertical screen video resolution adapted to mobile device display can be output.
[0005] Beneficial effects Compared with the prior art, the present invention has at least the following beneficial effects: 1. By suppressing interference from stationary balls, the offset of the cutting center caused by mis-following stationary balls is reduced; 2. Improve the continuity of keyframe sequences by fusing multiple samples at the same time, interpolating across the entire time axis, and performing peak removal and smoothing. 3. By controlling dead zones, forcing edge responses, and predicting future positions, both camera stability and ball tracking timeliness are achieved; 4. By adopting a two-stage rendering mechanism that first exports temporary detection fragments without overlap and then generates keyframes, the stability of target detection and the success rate of vertical screen export are improved. 5. By delaying the overlay of watermarks and other covering elements until after the vertical screen cropping is completed, the risk of size distortion caused by cropping and scaling is reduced; 6. This invention is suitable for deployment on mobile terminals and can output vertical tracking videos of basketball games that are more suitable for short video dissemination while taking into account the limitations of computing resources. Attached Figure Description
[0006] Figure 1 is a schematic diagram of the overall process for exporting vertical screen tracking data from basketball game videos. Figure 2 is a schematic diagram of the target trajectory sample filtering, deduplication, and keyframe generation process. Figure 3 is a schematic diagram of dynamic cropping of landscape video based on portrait-oriented keyframe tracking. Figure 4 is a schematic diagram of the two-stage rendering and export process. Detailed Implementation
[0007] The present invention will be further described below with reference to illustrative embodiments. These embodiments are used to explain the present invention and are not intended to limit the scope of protection of the present invention. In one embodiment, the electronic device acquires a landscape video of a basketball game and a user-selected time range for an exported segment. The landscape video may be a 16:9 aspect ratio video, with an exemplary resolution of 1920×1080. The electronic device reads a set of trajectory points associated with the exported segment from a local shooting analysis module. Each trajectory point may contain a timestamp, target location, and optional hoop information. The electronic device sorts the set of trajectory points and performs time normalization on the trajectory points falling within the time range to be exported. For each trajectory point, if sphere frame information exists, the x-coordinate of the sphere frame center is used as the target lateral position value; otherwise, the x-coordinate of the trajectory point position is used. Afterward, the electronic device only retains the start point, end point, and samples whose lateral displacement compared to the previous valid sample reaches a preset threshold, to exclude spheres that have been stationary for a long time or noise points. When the filtered sample points are empty, the electronic device reverts to using the unfiltered sample set to avoid failing to generate keyframes due to overly strict threshold settings. Subsequently, the electronic device merges sample points from multiple trajectories, averages multiple x-coordinates at the same time, and samples at fixed intervals across the entire time segment. For time periods without trajectory coverage, the electronic device maintains the most recently known x-coordinate, thus forming a continuous sequence of horizontal positions across the entire time axis. To reduce spikes caused by false detections in a single frame, the electronic device can employ median filtering using a sliding window encompassing the current frame and several frames before and after it. Subsequently, the electronic device dynamically updates the center of the vertical screen cropping window based on at least one of the following factors: whether the predicted position exceeds the dead zone, whether the current observed position is close to the edge of the cropping window, the magnitude of the deviation between the current and desired positions, and the response coefficient corresponding to the deviation. This reduces camera movement when the ball is within an acceptable visual range and allows for rapid camera movement to catch up with the target when the ball is about to go out of frame. In one example implementation, the electronic device determines the critical event moment based on the moment of the last valid trajectory point in the segment to be exported, and fixes the center of the cropping window as the final stable center position after that moment to make the vertical screen image after a goal or climax more stable. For dynamic cropping, the electronic device calculates the 9:16 cropping window width based on the source video height, ensuring the cropping window height matches the source video height. Then, it calculates the left boundary of the cropping window based on the center positions of keyframes at different time points and applies boundary cropping constraints to the left boundary to guarantee that the cropping window always remains within the effective area of the source video. The electronic device can perform cropping and translation on each frame based on a graphics transformation matrix, and then scale the cropping result for output to obtain a video file with the target vertical screen resolution. In another embodiment, when trajectory data is insufficient, video with overlay elements is unsuitable for direct object detection, or improved export robustness is required, the electronic device first exports a temporary segment without trajectory overlay information and additional overlay elements. Then, frame-by-frame basketball detection is performed on this temporary segment to generate a new target keyframe sequence. Finally, the new keyframe sequence is used to perform a second vertical screen cropping on the first rendering result. If frame-by-frame detection fails to obtain enough keyframes, it falls back to using keyframes generated based on the trajectory, or further falls back to a center-cropping strategy. In the post-processing stage, electronic devices can overlay watermarks or logos after the vertical screen is cropped, and set the size of the overlay element according to the width ratio of the vertical screen image to reduce the size deformation caused by adding watermarks first and then cropping. Based on the above method, the present invention can also be implemented as a vertical screen tracking and export device for basketball game videos. The device includes a data acquisition module, a sample filtering module, a key frame generation module, a dynamic cropping module, a detection rollback module, and a post-processing module. Each module can be implemented by software or a combination of software and hardware. The present invention can also be implemented as an electronic device, the electronic device including a processor, a memory, and a computer program stored in the memory and executable on the processor; when the computer program is executed, it causes the electronic device to perform all or part of the steps in the above method embodiments; The aforementioned numerical parameters such as displacement threshold, sampling interval, lead time, and response coefficient can be adjusted according to the actual scenario. As long as the technical idea of generating vertical screen tracking keyframes based on the basketball target trajectory and / or detection results, and thereby completing the vertical screen tracking export of horizontal screen video, is generally achieved, it falls within the protection scope of this invention.
Claims
1. A method for vertical screen tracking and exporting basketball game videos, characterized in that, The method, applied to electronic devices, includes: acquiring a horizontal basketball game video, the start and end time range of the segment to be exported, and basketball trajectory data associated with the segment to be exported; extracting original sample points representing the horizontal position of the basketball based on the basketball trajectory data, and performing time normalization processing on the original sample points; performing stationary ball interference suppression and time deduplication processing on the original sample points to obtain a target position sequence; generating vertical screen tracking keyframes on the time axis of the segment to be exported based on the target position sequence; constructing a 9:16 dynamic cropping window that changes over time on the horizontal basketball game video based on the vertical screen tracking keyframes; and cropping and scaling the horizontal basketball game video based on the dynamic cropping window to obtain a vertical screen tracking exported video.
2. The method according to claim 1, characterized in that, The extraction of the original sample points representing the lateral position of the basketball includes: when the trajectory point contains information about the basketball hoop, using the horizontal coordinate of the center of the basketball hoop as the sample value; when the trajectory point does not contain information about the basketball hoop, using the horizontal coordinate of the trajectory point's position as the sample value.
3. The method according to claim 1, characterized in that, The static ball interference suppression of the original sample points includes: retaining the starting sample point, the ending sample point, and the sample point whose lateral displacement reaches a preset threshold compared with the previous valid sample point; when no sample point is retained after static ball interference suppression, it reverts to the original sample point before suppression.
4. The method according to claim 1, characterized in that, The process of performing time deduplication on the original sample points includes: fusing multiple sample points corresponding to the same time moment, and using the average horizontal position of the multiple sample points as the fusion result at the same time moment.
5. The method according to claim 1, characterized in that, The process of generating vertical screen tracking keyframes based on the target position sequence includes: sampling the segment to be exported along the entire time axis at preset time intervals; generating a sampling position sequence based on the interpolation result of the target position sequence; and performing peak removal and dynamic smoothing processing on the sampling position sequence to obtain the vertical screen tracking keyframes.
6. The method according to claim 5, characterized in that, The dynamic smoothing process is based on at least one or more of the following factors: whether the predicted position exceeds the dead zone, whether the current observation position is close to the edge of the clipping window, the magnitude of the deviation between the current position and the target position, and the response coefficient corresponding to the magnitude of the deviation.
7. The method according to claim 1, characterized in that, The method of constructing a 9:16 dynamic cropping window that changes over time based on vertical screen tracking keyframes includes: determining the width of the cropping window according to the height of the source video, so that the width of the cropping window and the height of the source video satisfy a 9:16 ratio; determining the horizontal center of the cropping window according to the center position of the keyframes at different time points; calculating the left boundary of the cropping window based on the horizontal center, and imposing boundary restrictions on the left boundary.
8. The method according to claim 1, characterized in that, Also includes: First, generate a temporary detection segment that does not contain trajectory overlay information; Frame-by-frame basketball detection is performed on the temporary detection segment to generate detection keyframes; a second vertical screen cropping and export is performed on the first rendering result based on the detection keyframes.
9. The method according to claim 8, characterized in that, When the frame-by-frame basketball detection fails to generate a valid detection keyframe, the fallback strategy is to use a vertical screen tracking keyframe generated based on basketball trajectory data, or to use a center-cropping strategy.
10. The method according to claim 1, characterized in that, Also includes: After the vertical screen tracking video is generated, a watermark or logo overlay element is then added to reduce the size distortion of the overlay element during the cropping and scaling process.
11. A vertical screen tracking and export device for basketball game videos, characterized in that, include: The data acquisition module is used to acquire the start and end time range of the basketball game landscape video, the segment to be exported, and the basketball trajectory data associated with the segment to be exported. The sample processing module is used to extract the original sample points representing the lateral position of the basketball, and to perform stationary ball interference suppression and time deduplication processing on the original sample points. The keyframe generation module is used to generate vertical screen tracking keyframes based on the processed target position sequence; the dynamic cropping module is used to construct a 9:16 dynamic cropping window that changes over time on the horizontal screen video of the basketball game based on the vertical screen tracking keyframes, and to crop and scale the horizontal screen video of the basketball game based on the dynamic cropping window to obtain the vertical screen tracking exported video.
12. An electronic device, characterized in that, The method includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the method according to any one of claims 1 to 10.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method according to any one of claims 1 to 10.
14. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method according to any one of claims 1 to 10.
