A monitoring camera calibration method and system for a three-dimensional prior of an upright rod-shaped target
Patent Information
- Application Number
- CN202611102357.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-23
- Publication Date
- 2026-10-27
AI Technical Summary
这类方法能够减少对专用标定板的依赖,适合从自然场景中提取几何约束,但其通常依赖图像中的方向关系或相对几何关系,线段端点的真实三维坐标往往未知,且容易受视角、遮挡、检测误差和图像噪声影响
[0017]相比于现有技术,本发明的优点及有益效果在于:通过获取待标定摄像头可视范围内采集的杆子观测数据,判断杆子数量是否大于或等于预设最小值,若否返回数据不足,若是,对观测数据中的三维数据进行质心化处理,并对每根杆子构造脚点和杆顶的三维-二维对应关系,实现双点三维约束,以增强相机姿态、焦距和空间位置求解的几何可观测性;构建从世界坐标系到像素坐标系的投影模型,并基于其设置三个由低到高的内参自由度等级;基于K折交叉验证选取最优自由度等级,实现精度与稳定性的自适应平衡,采用留二法获取第一候选标定参数,判断第一候选标定参数是否符合物理约束, 若是则得到目标标定参数;若否,则启动兜底流程,根据脚点像素坐标、杆顶像素坐标和杆高拟合CCSV模型,进行焦距估计,得到候选焦距,构造焦距候选集合,采用多种求解器生成初始外参,并对其进行LM精修,采用留二法评估筛选出第二候选标定参数,判断其是否符合物理约束,若是,则将其作为目标标定参数输出,若否,则输出不可计算,通过双层标定流程的调度,提高了标定适用范围,能够在不依赖专用标定板的条件下,实现标定,提高监控摄像头标定结果的稳定性和可用性,且便于监控摄像头在道路、园区、广场等实际场景中的批量标定和部署。
Smart Images

Figure CN122989888A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of camera calibration technology, and in particular to a method and system for calibrating a surveillance camera based on a three-dimensional prior of an upright rod-shaped target. Background Technology
[0002] Existing camera calibration technologies mainly include calibration methods based on regular calibration boards, PnP pose solving methods based on the correspondence between 3D points and 2D pixels, and calibration methods based on vanishing points, vertical line segments, or prior knowledge of scene structure. Among them, methods based on regular calibration boards such as checkerboards and dot arrays typically acquire images of the calibration board in different poses, establish the correspondence between known geometric points and image points, and then solve for camera intrinsic parameters, distortion parameters, and extrinsic parameters through nonlinear optimization. However, these methods rely on dedicated calibration boards and a close-range, controllable acquisition environment. In scenarios where surveillance cameras have already been deployed, such as roads, squares, and parks, redeploying calibration boards is costly, involves many obstructions, results in unstable long-distance imaging quality, and poses problems such as on-site operational safety and difficulties in large-scale implementation.
[0003] Pose-to-pose (PnP) techniques can solve camera pose given several 3D control points and their 2D pixel projections. Representative methods include EPnP, SQPnP, and solvePnP in OpenCV. These techniques address the mathematical problem of "how to solve camera pose given reliable 3D-2D point correspondences," but they don't solve the problem of how to construct these correspondences cost-effectively and stably in surveillance scenarios. For actual surveillance cameras, the number of available pole-shaped targets is limited, their spatial distribution may be uneven, and RTK measurement points and pixel annotations may contain errors. Simply calling PnP or a single nonlinear optimization process can easily lead to problems such as abnormal focal length, principal point drift, abnormal roll angle, or local fitting but overall undeployable issues.
[0004] Other existing technologies utilize scene structural cues such as road edges, building edges, vertical lines, horizons, or vanishing points for camera calibration or pose estimation. These methods reduce reliance on dedicated calibration boards and are suitable for extracting geometric constraints from natural scenes. However, they typically depend on directional or relative geometric relationships within the image, and the true 3D coordinates of line segment endpoints are often unknown. Furthermore, they are susceptible to the influence of viewpoint, occlusion, detection errors, and image noise. Therefore, these methods generally struggle to directly output deployable parameters such as camera latitude, longitude, elevation, azimuth, and pitch angles that are consistent with real geographic coordinates. They also lack comprehensive verification mechanisms for pole height consistency, generalization errors in reserved points, and physical installation constraints.
[0005] In summary, while existing technologies provide technical foundations such as rule-based calibration boards, PnP pose solving, and scene structure prior calibration, they have not yet formed a complete closed-loop solution for deployed surveillance cameras. Furthermore, existing technologies heavily rely on dedicated calibration boards or ideal control points, making it difficult to adapt to large-scale on-site monitoring scenarios. They also lack robustness in the face of occlusion, limited samples, degraded pole distribution, or noise in RTK data, and lack fallback solutions and result availability determination mechanisms after high-precision solution failures. Summary of the Invention
[0006] Therefore, it is necessary to provide a method and system for calibrating a surveillance camera with a three-dimensional prior knowledge of an upright rod-shaped target, in order to address the above-mentioned technical problems.
[0007] A method for calibrating a surveillance camera based on a 3D prior of an upright pole-shaped target includes the following steps: acquiring observation data of poles collected within the field of view of the camera to be calibrated, the observation data including the number of poles, pixel coordinates of the pole's base, pixel coordinates of the pole's top, 3D coordinates of the base, pole height, and image width and height; determining whether the number of poles is greater than or equal to a preset minimum value; if not, returning a data insufficiency status; if so, centroiding processing is performed on the 3D data in the observation data, and a 3D-2D correspondence between the base and the top of each pole is constructed; constructing a projection model from the world coordinate system to the pixel coordinate system, and setting three intrinsic parameter degrees of freedom levels from low to high according to the constructed projection model; selecting the optimal value based on K-fold cross-validation. The optimal degree-of-freedom level is determined, and based on this level, the leave-two rule is used to obtain the first candidate calibration parameter. It is then determined whether the first candidate calibration parameter conforms to the physical constraints. If yes, it is output as the target calibration parameter; otherwise, a CCSV model is fitted based on the foot pixel coordinates, pole top pixel coordinates, and pole height, and focal length estimation is performed to obtain candidate focal lengths. A candidate focal length set is constructed based on these candidate focal lengths, and initial extrinsic parameters are generated using multiple solvers. Each initial extrinsic parameter is refined using the LM method, and the leave-two rule is used to evaluate and select the second candidate calibration parameter. Finally, it is determined whether the second candidate calibration parameter conforms to the physical constraints. If yes, it is output as the target calibration parameter; otherwise, it is output as uncomputable.
[0008] In one embodiment, constructing the projection model from the world coordinate system to the pixel coordinate system includes: setting the camera intrinsic parameter matrix to K, the intrinsic parameter matrix containing the camera focal length. f and principal point coordinates ( c x ,c y ),for: ; Define the camera extrinsic parameters, including the rotation matrix R from the world coordinate system to the camera coordinate system and the translation vector t, and calculate the position of the camera optical center in the world coordinate system. The world coordinates are obtained through the camera extrinsic parameters. P i,j Transform to the camera coordinate system and calculate its coordinates on the normalized imaging plane. x,y According to the radial radius r and first-order radial distortion coefficient k 1 Calculate the distorted coordinates ( x d , y d ),for: , ; The pixel coordinates are obtained from the camera's intrinsic parameters, specifically the focal length and principal point coordinates: , ; In the formula, ( u,v () represents pixel coordinates.
[0009] In one embodiment, the step of setting three intrinsic parameter degrees of freedom levels from low to high according to the constructed projection model includes: the intrinsic parameter degrees of freedom levels include a first degree of freedom level, a second degree of freedom level, and a third degree of freedom level, wherein the first degree of freedom level uses the pixel focal length, rotation matrix, and translation vector as parameters to be optimized, fixes the first-order radial distortion coefficient to 0, and fixes the principal point coordinates to the image center, that is: c x = W / 2, c y = H img / 2; In the formula, W Image width, H img The image height is used; the second degree of freedom level, based on the parameters to be optimized in the first degree of freedom level, uses the principal point coordinates as the parameters to be optimized, and fixes the first-order radial distortion coefficient to 0; the third degree of freedom level, based on the parameters to be optimized in the second degree of freedom level, uses the first-order radial distortion coefficient as the parameters to be optimized; for each degree of freedom level, based on the constructed projection model and with minimizing the reprojection error of the training samples as the optimization objective, the corresponding candidate calibration parameters are solved, where the reprojection optimization function is: ; In the formula, π (·) represents the camera projection function with optional radial distortion. C tr Let P be the set of training samples, where P is the world coordinate point and p is the corresponding pixel observation coordinate.
[0010] In one embodiment, the step of selecting the optimal degree-of-freedom level based on K-cross-validation includes: dividing the rod-shaped target sample into several folds according to a preset random seed; for each degree-of-freedom level, solving for candidate calibration parameters using training rods in each fold division, and calculating ground back-projection error and rod height consistency error on validation rods; and calculating a comprehensive score for each degree-of-freedom level based on the ground back-projection error and rod height consistency error. ; In the formula, E te Let be the median of the ground backprojection error for each validation set. E h To account for the rod height consistency error, α A preset pole height consistency weight is used; for each degree of freedom level, the proportion of folds that satisfy preset physical constraints in each fold is calculated, wherein the physical constraints include a positive focal length, the camera optical center being within the elevation range of the ground object, and the rotation matrix corresponding to the pitch and yaw angles; if the proportion of folds is lower than a preset threshold, the corresponding degree of freedom level is discarded; if the proportion of folds is higher than or equal to the preset threshold, it is considered a valid degree of freedom level; among the valid degree of freedom levels, the level with the smallest comprehensive score is selected as the optimal degree of freedom level.
[0011] In one embodiment, the step of obtaining candidate first-choice calibration parameters based on the optimal degree of freedom level using the leave-two method includes: performing a leave-two traversal on all rod-shaped target samples according to the optimal degree of freedom level; selecting two rod-shaped targets each time as the validation set and the remaining rod-shaped targets as the training set, calculating the first-choice candidate calibration parameters; and for the a-th partition, calculating the comprehensive score using the formula: ; In the formula, and , respectively, are the ground backprojection errors of the training set and the validation set in the a-th partition; the candidate solution with the smallest comprehensive score is taken as the first candidate calibration parameter.
[0012] In one embodiment, the step of fitting a CCSV model based on the foot point pixel coordinates, pole top pixel coordinates, and pole height, and then estimating the focal length to obtain candidate focal lengths, includes: setting the foot point ordinate offset as... y f =c y -v i,0 The height of the pole is H i If the height difference between the camera and the foot point is c, and the pitch angle is θ, then the predicted pixel at the top of the pole is: ; By minimizing the residual between the predicted top pixel and the coordinates of the top pixel, the focal length, pitch angle, and elevation difference are estimated using the following formula: ; The estimated focal length is used as a candidate focal length for focal length search. If the fitting fails, the preset initial focal length value is used as the candidate focal length.
[0013] In one embodiment, the step of constructing a candidate focal length set F based on the candidate focal lengths, generating initial extrinsic parameters using multiple solvers, refining each initial extrinsic parameter using the LM method, and evaluating and selecting second candidate calibration parameters using the leave-two method includes: constructing a candidate focal length set F based on the candidate focal lengths, generating initial extrinsic parameters for each candidate focal length... Construct the intrinsic parameter matrix with fixed principal points as follows: ; Initial extrinsic parameters were generated using three solvers: ACEPnP, SQPnP, and EPnP, and each initial extrinsic parameter was refined using the LM method. For the initial extrinsic parameters obtained by any solver, the root mean square error of pixel reprojection at the corresponding training points was calculated. ; Among the candidate solutions that satisfy the conditions of positive depth and passing the physical constraints, the candidate solutions with small root mean square error of pixel reprojection are retained; a leave-two partition is drawn a preset number of times with a fixed random seed, and a candidate search is performed on each partition, and the comprehensive score of the candidate solutions is calculated. The candidate solution with the smallest comprehensive score is selected to obtain the second candidate calibration parameters.
[0014] In one embodiment, the generation of initial extrinsic parameters using the ACEPnP solver includes: constructing four control points based on the three-dimensional centroid and the three-dimensional PCA principal direction; and representing each three-dimensional point as a combination of the centroids of the control points. , ; Expand the unknown coordinates of the control points in the camera coordinate system into a vector. x∈R 12 Assemble a linear system by pixel projection constraints Mx=0 Combining control point spacing constraints, eigenvalue decomposition, and Kabsch registration rotation matrix and translation vector; when the ratio of the minimum singular value to the maximum singular value of the 3D point cloud PCA is lower than a preset threshold, the ACEPnP solver is determined to be degenerate under the current point cloud distribution and is skipped.
[0015] In one embodiment, determining whether the second candidate calibration parameter conforms to physical constraints includes: extracting the orientation of the camera optical axis in the world coordinate system from the second candidate calibration parameter. The formula for calculating the camera's azimuth and pitch angles is: , ; A zero-roll reference rotation is constructed based on the azimuth and pitch angles, and the roll angle is obtained by comparing it with the actual rotation matrix. θ roll The formula for determining whether the obtained second candidate calibration parameters meet the physical constraints is as follows: , , ; In the formula, θ roll For roll angle, θ a It is the azimuth angle. θ pitch The pitch angle.
[0016] A system for calibrating a surveillance camera with a 3D prior for an upright pole-shaped target is provided to implement a calibrating method for an upright pole-shaped target with a 3D prior, as described above. The system includes: an observation data acquisition module for acquiring observation data of the pole within the field of view of the camera to be calibrated, the observation data including the number of poles, pixel coordinates of the pole's base, pixel coordinates of the pole's top, 3D coordinates of the base, pole height, and image width and height; a pole number judgment module for determining whether the number of poles is greater than or equal to a preset minimum value; if not, a data insufficiency status is returned; a correspondence construction module for centroidalizing the 3D data in the observation data when the number of poles is greater than or equal to the preset minimum value, and constructing a 3D-2D correspondence between the base and top of each pole; and a degree-of-freedom level setting module for constructing a projection model from the world coordinate system to the pixel coordinate system, and setting three intrinsic degree-of-freedom parameters from low to high according to the constructed projection model. The system comprises the following modules: a first calibration parameter acquisition module, used to select the optimal degree-of-freedom level based on K-fold cross-validation, and based on the optimal degree-of-freedom level, use the leave-two method to obtain the first candidate calibration parameter, and determine whether the first candidate calibration parameter meets the physical constraints. If so, it is output as the target calibration parameter. A focal length estimation module is used to fit a CCSV model based on the foot pixel coordinates, pole top pixel coordinates, and pole height when the candidate calibration parameter does not meet the physical constraints, and to estimate the focal length to obtain the candidate focal length. A second calibration parameter acquisition module is used to construct a focal length candidate set based on the candidate focal length, and to generate initial extrinsic parameters using multiple solvers. Each initial extrinsic parameter is refined using LM, and the leave-two method is used to evaluate and screen out the second candidate calibration parameter. A physical constraint judgment module is used to determine whether the second candidate calibration parameter meets the physical constraints. If so, it is output as the target calibration parameter; otherwise, it is output as uncalculated.
[0017] Compared to existing technologies, the advantages and beneficial effects of this invention are as follows: By acquiring observation data of poles collected within the field of view of the camera to be calibrated, it is determined whether the number of poles is greater than or equal to a preset minimum value. If not, insufficient data is returned; if so, the three-dimensional data in the observation data is centroided, and a three-dimensional-two-dimensional correspondence between the foot and top of each pole is constructed to achieve two-point three-dimensional constraints, thereby enhancing the geometric observability of solving camera attitude, focal length, and spatial position. A projection model from the world coordinate system to the pixel coordinate system is constructed, and three intrinsic parameter degrees of freedom levels are set based on it from low to high. The optimal degree of freedom level is selected based on K-fold cross-validation to achieve an adaptive balance between accuracy and stability. The leave-two method is used to obtain the first candidate calibration parameters, and it is determined whether the first candidate calibration parameters meet the physical constraints. If yes, the target calibration parameters are obtained; otherwise, a fallback process is initiated. Based on the foot pixel coordinates, pole top pixel coordinates, and pole height, a CCSV model is fitted to estimate the focal length, obtain candidate focal lengths, construct a candidate focal length set, generate initial extrinsic parameters using multiple solvers, and refine them using the LM method. The leave-two method is used to evaluate and select the second candidate calibration parameters, and it is determined whether they meet the physical constraints. If yes, they are output as the target calibration parameters; otherwise, the output is not computable. Through the scheduling of the two-layer calibration process, the applicable scope of calibration is improved, and calibration can be achieved without relying on a dedicated calibration board. This improves the stability and usability of the calibration results of surveillance cameras and facilitates the batch calibration and deployment of surveillance cameras in actual scenarios such as roads, parks, and squares. Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating a method for calibrating a surveillance camera based on a three-dimensional prior of an upright rod-shaped target, as described in one embodiment.
[0019] Figure 2 This is a schematic diagram of the output of target calibration parameters in one embodiment.
[0020] Figure 3 This is a schematic diagram of the structure of a surveillance camera calibration system for a three-dimensional prior of an upright rod-shaped target, as shown in one embodiment. Detailed Implementation
[0021] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to specific embodiments and accompanying drawings. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0022] In one embodiment, such as Figure 1 As shown, a method for calibrating a surveillance camera based on a three-dimensional prior of an upright rod-shaped target is provided, including the following steps: Specifically, for each camera to be calibrated, observation data of the poles within its field of view is collected. This observation data includes the number of poles and the observation data for each pole. The observation data for each pole includes: i The pixel position of the base of the pole pixel coordinates of the top of the pole , No. i 3D world coordinates of the base of the pole Pole height H i The image width W, image height H, and the central meridian L0 used for coordinate projection are specified.
[0023] In this invention, poles are common or easily measurable upright targets in monitoring scenarios. Using them as a priori calibration eliminates the need for additional on-site calibration grids, dotted discs, or large calibration frames. For surveillance cameras already installed in roads, squares, parks, factories, etc., traditional calibration board solutions typically require closed roads, close-range placement of calibration objects, and multi-angle shooting, and are limited by long-distance field of view, obstructions, and safe operating conditions. This invention, however, only requires collecting the base pixel, top pixel, base RTK or planar coordinates, and pole height of several poles to construct the required 3D-2D correspondence for calibration. Therefore, this invention significantly reduces on-site operating costs, minimizes interference with traffic or business scenarios, and improves the engineering applicability to already deployed cameras.
[0024] Step S120: Determine whether the number of rods is greater than or equal to the preset minimum value. If not, return a data shortage status.
[0025] Specifically, in order to achieve high-precision calibration of the camera, a preset minimum value for the number of poles is set. When the number of poles within the camera's observable range is less than the preset minimum value, a data shortage status is returned. When the number of poles is greater than or equal to the preset minimum value, the camera calibration process is initiated.
[0026] Step S130: If yes, then the three-dimensional data in the observation data is centroided, and the three-dimensional-two-dimensional correspondence between the foot point and the top of the pole is constructed for each pole.
[0027] Specifically, when the number of poles is greater than or equal to a preset minimum value, in order to improve numerical stability, the three-dimensional data in the observation data is centroided. Based on the pixel coordinates of the pole top and the pole height, the three-dimensional coordinates of the pole top are obtained by taking advantage of the property that the pole is approximately vertical. By traversing the foot points of all N poles and the three-dimensional centroided coordinates and two-dimensional coordinates of the pole top, 2N sets of correspondences between three-dimensional world coordinates and two-dimensional pixel coordinates are constructed.
[0028] Each pole's foot and top are constructed as 3D control points, and correspondences are established with the foot and top pixels in the image, respectively. This results in two sets of 3D-2D correspondences, which include both planar position constraints of the foot points and vertical constraints from the pole height. This adds height dimension information and provides a clear and true 3D coordinate relationship, thereby enhancing the geometric observability of solving camera pose, focal length, and spatial position.
[0029] Step S140: Construct a projection model from the world coordinate system to the pixel coordinate system, and set three intrinsic parameter degrees of freedom levels from low to high according to the constructed projection model.
[0030] Specifically, a projection model is constructed from a three-dimensional world coordinate system to a two-dimensional pixel coordinate system. The projection model includes the camera intrinsic parameter matrix, camera extrinsic parameters, and radial distortion model. Three degrees of freedom levels of intrinsic parameters are set according to the projection model from low to high to optimize the camera intrinsic parameters. By setting the gradient degrees of freedom, an adaptive trade-off can be made between model simplicity and expressive power, avoiding the problems of excessive solution space and convergence difficulties caused by directly using high degree of freedom models.
[0031] The projection model construction steps include: setting the camera intrinsic parameter matrix to K, where the intrinsic parameter matrix contains the camera focal length. f and principal point coordinates ( c x ,c y ),for: ; Define the camera extrinsic parameters, including the rotation matrix R from the world coordinate system to the camera coordinate system and the translation vector t, and calculate the position of the camera optical center in the world coordinate system. World coordinates are obtained through camera extrinsic parameters. P i,j Transform to the camera coordinate system and calculate its coordinates on the normalized imaging plane. x,y According to the radial radius r and first-order radial distortion coefficient k 1 Calculate the distorted coordinates ( x d , y d ),for: , ; The pixel coordinates are obtained from the camera's intrinsic parameters, specifically the focal length and principal point coordinates: , ; In the formula, ( u,v () represents pixel coordinates.
[0032] Specifically, a projection model from the world coordinate system to the pixel coordinate system is constructed. The projection model includes a camera intrinsic matrix, camera extrinsic parameters, and a radial distortion model. The camera intrinsic matrix and camera extrinsic parameters are defined. The intrinsic matrix includes the pixel focal length and principal point coordinates, and the camera extrinsic parameters include the rotation matrix and translation vector from the world coordinate system to the camera coordinate system. The position of the camera optical center in the world coordinate system is calculated.
[0033] For a world coordinate point, it is transformed to the camera coordinate system using the camera's extrinsic parameters. The coordinates on the normalized imaging plane are calculated, and then the distorted coordinates are calculated based on the radial radius and the first-order radial distortion coefficient. Finally, the pixel coordinates are obtained using the focal length and principal point coordinates of the intrinsic parameters.
[0034] The intrinsic parameter degree-of-freedom level setting steps include: the intrinsic parameter degree-of-freedom levels include a first degree-of-freedom level, a second degree-of-freedom level, and a third degree-of-freedom level. The first degree-of-freedom level uses the pixel focal length, rotation matrix, and translation vector as parameters to be optimized, fixes the first-order radial distortion coefficient at 0, and fixes the principal point coordinates at the image center, i.e.: c x = W / 2, c y = H img / 2; In the formula, W Image width, H img The image height is used as the parameter. For the second degree of freedom level, based on the parameters to be optimized in the first degree of freedom level, the principal point coordinates are used as the parameters to be optimized, and the first-order radial distortion coefficient is fixed at 0. For the third degree of freedom level, based on the parameters to be optimized in the second degree of freedom level, the first-order radial distortion coefficient is used as the parameters to be optimized. For each degree of freedom level, based on the constructed projection model and with minimizing the reprojection error of the training samples as the optimization objective, the corresponding candidate calibration parameters are solved. The reprojection optimization function is: ; In the formula, π (·) represents the camera projection function with optional radial distortion. C tr Let P be the set of training samples, where P is the world coordinate point and p is the corresponding pixel observation coordinate.
[0035] Specifically, based on the established projection model, three degrees of freedom levels of intrinsic parameters are set from low to high to optimize the camera intrinsic parameters, including: the first degree of freedom level, the second degree of freedom level, and the third degree of freedom level.
[0036] The first degree of freedom (L1) involves releasing the pixel focal length. fRotation matrix R Translation vector t As parameters to be optimized; the principal point coordinates are fixed at the image center, and the first-order radial distortion coefficient is set as the parameter to be optimized. k 1 Fixed at zero.
[0037] Second degree of freedom level (L2): Based on the first degree of freedom level, further release the principal point coordinates. c x , c y As parameters to be optimized, k 1 It remains fixed at zero.
[0038] Third degree of freedom level (L3): Based on the second degree of freedom level, further release the first-order radial distortion coefficient. k 1 As parameters to be optimized.
[0039] By setting different degrees of freedom, higher degrees of freedom can be used to achieve higher accuracy when the rods are sufficiently distributed; when the sample size is small or the spatial distribution is poor, lower degrees of freedom can be selected to reduce the risk of overfitting and ill-conditioned convergence. Through gradient-based degree of freedom settings, the system can adaptively balance model simplicity and expressive power, avoiding convergence difficulties caused by directly using high-degree-of-freedom models. Compared to schemes that use a fixed single camera model or perform a one-time full-parameter optimization, this invention can adaptively balance accuracy and stability according to data conditions.
[0040] Step S150: Select the optimal degree of freedom level based on K-fold cross-validation, and obtain the first candidate calibration parameter based on the optimal degree of freedom level using the leave-two method. Determine whether the first candidate calibration parameter meets the physical constraints. If so, output it as the target calibration parameter.
[0041] Specifically, based on K-fold cross-validation, the optimal degree of freedom (DOF) level for the current camera's pole-shaped target samples is selected to adapt to the number and spatial distribution of poles within the camera's field of view. Simultaneously, based on the optimal DDF level, the leave-two method is used to obtain the first candidate calibration parameters. To determine the rationality of the first candidate calibration parameters, it is also necessary to judge whether they conform to physical constraints. If they do, they are output as target calibration parameters. The output target calibration parameters include pitch angle, azimuth angle, roll angle, focal length, principal point, image size, pole latitude, longitude, latitude, and elevation, etc., thus completing the calibration of the surveillance camera. Figure 2 As shown.
[0042] Steps S130-S150 are a high-precision calibration process based on pole observation data. This process is the preferred process for calibrating surveillance cameras. Multiple intrinsic parameter degrees of freedom levels are introduced into this process to adapt to the number of poles and their spatial distribution, thereby achieving adaptive balance of accuracy and stability based on data conditions.
[0043] The steps for selecting the optimal degree-of-freedom level based on K-fold cross-validation include: dividing the rod-shaped target sample into several folds according to a preset random seed; for each degree-of-freedom level, solving for candidate calibration parameters using training rods in each fold division; and calculating the ground back-projection error and rod height consistency error on the validation rods; and calculating the comprehensive score for each degree-of-freedom level based on the ground back-projection error and rod height consistency error. ; In the formula, E te Let be the median of the ground backprojection error for each validation set. E h To account for the rod height consistency error, α The system assigns a pre-defined weight to the pole height consistency. For each degree of freedom level, it calculates the proportion of folds that satisfy the pre-defined physical constraints in each fold. These physical constraints include a positive focal length, the camera's optical center being within the elevation range of the ground feature, and the rotation matrix corresponding to the pitch and yaw angles. If the proportion of folds is lower than a pre-defined threshold, the corresponding degree of freedom level is discarded. If the proportion of folds is higher than or equal to the pre-defined threshold, it is considered a valid degree of freedom level. Among the valid degree of freedom levels, the level with the lowest overall score is selected as the optimal degree of freedom level.
[0044] Specifically, the rod-shaped target samples are divided into groups according to a preset random seed. K fold For each degree of freedom level, candidate calibration parameters are solved using the training pole in each fold division, and ground back projection error and pole height consistency error are calculated on the validation pole. The calculation process for the ground back projection error includes: performing distortion correction on the pixel coordinates of the foot points of the rod-shaped target to obtain the ray direction vector in the camera coordinate system; transforming the ray direction to the world coordinate system using the current candidate rotation matrix; performing an intersection operation between the ray in the world coordinate system and the elevation plane where the foot point is located to obtain the theoretical ground intersection point; if the ray direction is approximately parallel to the elevation plane (i.e., the vertical component of the ray direction is less than a preset threshold) or the intersection point is located behind the camera (i.e., the scale factor is negative), then the back projection is determined to be invalid; otherwise, the horizontal Euclidean distance between the theoretical ground intersection point and the real ground coordinates is calculated as the single-point ground back projection error; the mean or median of the single-point errors of all valid verification samples is taken to obtain the ground back projection error of that section.
[0045] The calculation process of pole height consistency error includes: based on the current candidate camera parameters, the pixel coordinates of the foot point and the pixel coordinates of the pole target, the theoretical height of the pole target is calculated using the vertical line segment projection model; the absolute error between the theoretical height and the known true height of the pole target is calculated; the average of the absolute errors of all verification samples is taken to obtain the pole height consistency error.
[0046] Based on two errors, a comprehensive score is calculated for each degree of freedom level. For each degree of freedom level, the percentage of folds that satisfy the preset physical constraints in each fold is counted. If the percentage of folds is lower than a preset threshold (preferably 60%), the level is discarded. Among the remaining valid levels, the level with the lowest comprehensive score is selected as the optimal degree of freedom level. The physical constraints include, but are not limited to: a positive focal length, the camera optical center being located within a reasonable elevation range of ground features, and the rotation matrix corresponding to reasonable pitch and yaw angles.
[0047] The steps for obtaining candidate calibration parameters using the leave-two method based on the optimal degree of freedom level include: performing a leave-two traversal on all rod-shaped target samples according to the optimal degree of freedom level; selecting two rod-shaped targets as the validation set each time, and the remaining rod-shaped targets as the training set; solving for the first candidate calibration parameters; and calculating the comprehensive score for the a-th partition, using the following formula: ; In the formula, and , respectively, are the ground backprojection errors of the training set and validation set in the a-th partition; the candidate solution with the smallest comprehensive score is output as the first candidate calibration parameter.
[0048] Specifically, after selecting the highest comprehensive score for each degree of freedom level, a leave-two traversal is performed on all rod-shaped target samples: each time, two rod-shaped targets are selected as the validation set, and the rest are used as the training set to solve for candidate calibration parameters. For the a-th partition, its comprehensive score is calculated, and the candidate solution with the smallest comprehensive score is selected as the first candidate calibration parameter. It is then determined whether the obtained first candidate calibration parameter satisfies the physical constraints. If it does, it is output as the target calibration parameter; otherwise, if all candidate solutions cannot be solved or do not satisfy the physical constraints, the current calibration process is considered to have failed, triggering a degradation mechanism and switching to a backup calibration process.
[0049] Step S160: If not, fit the CCSV model based on the foot pixel coordinates, pole top pixel coordinates and pole height, and perform focal length estimation to obtain candidate focal lengths.
[0050] Specifically, when the candidate calibration parameters obtained by the above method do not meet the physical constraints, a three-parameter CCSV (Center Camera Vertical Scaling) model can be fitted based on the foot pixel coordinates, pole top pixel coordinates, and pole height to estimate the focal length and obtain the candidate focal length.
[0051] If the high-precision method in steps S130-S150 fails, the method in steps S160-S170 is activated as a fallback to improve overall coverage. Similarly, if the above methods fail to output usable results due to abnormal intrinsic parameters, degraded rod spatial distribution, or numerical optimization failure, the current method can be activated for fallback calibration. This avoids the problem of termination upon failure of a single solver and improves calibration coverage in degraded scenarios such as few samples, occlusion, scattered rods on both sides, and rods on the edge.
[0052] Step S160 includes: setting the vertical coordinate offset of the foot point as... y f =c y -v i,0 The height of the pole is H i If the height difference between the camera and the foot point is c, and the pitch angle is θ, then the predicted pixel at the top of the pole is: ; The focal length, pitch angle, and elevation difference are estimated by minimizing the residual between the predicted top pixel and the top pixel coordinates, using the following formula: ; The estimated focal length is used as a candidate focal length for focal length search. If the fitting fails, the preset initial focal length value is used as the candidate focal length.
[0053] Step S170: Construct a candidate focal length set based on the candidate focal lengths, generate initial extrinsic parameters using multiple solvers, refine each initial extrinsic parameter using the LM method, and evaluate and select the second candidate calibration parameters using the leave-two method.
[0054] Specifically, a candidate focal length set is constructed based on the obtained candidate focal lengths, and initial extrinsic parameters are generated using multiple solvers. Each initial extrinsic parameter is refined using the LM method, and finally, the leave-two method is used to evaluate and screen out candidate calibration parameters. By combining the candidate focal lengths and multiple solvers, a second candidate calibration parameter is generated.
[0055] Step S170 includes: constructing a candidate focal length set F based on the candidate focal lengths, and processing each candidate focal length... Construct the intrinsic parameter matrix with fixed principal points as follows: ; Initial extrinsic parameters were generated using three solvers: ACEPnP, SQPnP, and EPnP, and each initial extrinsic parameter was refined using the LM method. For the initial extrinsic parameters obtained by any solver, the root mean square error of pixel reprojection at the corresponding training points was calculated. ; Among the candidate solutions that satisfy the conditions of positive depth and passing the physical constraints, the candidate solutions with small root mean square error of pixel reprojection are retained; a leave-two partition is drawn a preset number of times with a fixed random seed, and a candidate search is performed on each partition, and the comprehensive score of the candidate solutions is calculated. The candidate solution with the smallest comprehensive score is selected to obtain the second candidate calibration parameters.
[0056] Specifically, a candidate focal length set is constructed based on the candidate focal lengths, for example... For each candidate focal length, an intrinsic parameter matrix with a fixed principal point is constructed. Initial extrinsic parameters are generated using three solvers: ACEPnP, SQPnP, and EpnP. LM (Levenberg-Marquardt) refinement is then performed on each initial value. For the rotation matrix R and translation vector t obtained by any solver, the root mean square error of pixel reprojection at the corresponding training point is calculated. Among candidate solutions that satisfy the conditions of positive depth and passing physical constraints, those with smaller root mean square errors in pixel reprojection are preferentially retained.
[0057] Leave-two partitioning is performed a preset number of times using a fixed random seed. The candidate search described above is performed on each partition. This leave-two method is the same as in step S150, and a preset scoring function Q is used. hold As the final score, the candidate solution with the smallest score is selected as the second candidate calibration parameter.
[0058] The steps for generating initial extrinsic parameters using the ACEPnP solver include: constructing four control points based on the 3D centroid and the 3D PCA principal directions; and representing each 3D point as a combination of the centroids of the control points. , ; Expand the unknown coordinates of the control points in the camera coordinate system into a vector. x∈R 12 Assemble a linear system by pixel projection constraints Mx=0 Combining control point spacing constraints, eigenvalue decomposition, and Kabsch registration rotation matrix and translation vector; when the ratio of the minimum singular value to the maximum singular value of the 3D point cloud PCA is lower than a preset threshold, the ACEPnP solver is determined to be degenerate under the current point cloud distribution and is skipped.
[0059] Specifically, when generating initial extrinsic parameters using the ACEPnP solver, four control points are constructed using the centroid of the three-dimensional point and the three principal PCA directions. Each three-dimensional point is represented as a combination of the centroids of the four control points, and the position coordinates of the control points in the camera coordinate system are expanded into vectors. A linear system is assembled using pixel projection constraints. This is combined with control point spacing constraints, eigenvalue decomposition, and Kabsch registration rotation matrix and translation vector.
[0060] In 3D point cloud PCA (principal components analysis), the maximum singular value corresponds to the principal direction with the largest data dispersion, and the minimum singular value corresponds to the direction with the smallest dispersion. When the ratio of the minimum singular value to the maximum singular value is lower than a preset threshold, it indicates that the point cloud is close to a planar structure, which obviously does not meet the physical constraints in the current calibration. Therefore, the ACEPnP solver is determined to be degenerate under the current point cloud distribution, and other solvers are used to solve the extrinsic parameters. Otherwise, the corresponding rotation matrix and translation vector are output.
[0061] Step S180: Determine whether the second candidate calibration parameter meets the physical constraints. If yes, output it as the target calibration parameter; otherwise, output that it cannot be calculated.
[0062] Specifically, in order to determine the accuracy of the final output calibration parameters, it is determined whether the second candidate calibration parameters meet the physical constraints. If so, they are output as the target calibration parameters to complete the calibration of the surveillance camera. Otherwise, it indicates that neither method can be calculated, the output is uncalculated, and the number of poles, image size, central meridian, and reason for failure are recorded.
[0063] Steps S160-S180 estimate the initial focal length by fixing the principal point distortion and reducing the degrees of freedom to be estimated, using the CCVS vertical line segment model. They then combine multiple discrete focal length candidates with various PnP solvers such as ACEPnP, SQPnP, and EPnP to generate candidate extrinsic parameters. Finally, LM refinement and error filtering are used to obtain usable results. This, along with steps S130-S150, forms a two-layer scheduling mechanism, avoiding the problem of termination upon failure of a single solver, and improving the calibration coverage in degraded scenarios such as few samples, occlusion, wing dispersion, and edge-mounted poles.
[0064] The step of determining whether the second candidate calibration parameter meets the physical constraints includes: extracting the direction of the camera optical axis in the world coordinate system from the second candidate calibration parameter. The formula for calculating the camera's azimuth and pitch angles is: , ; A zero-roll reference rotation is constructed based on the azimuth and pitch angles, and the roll angle is obtained by comparing it with the actual rotation matrix. θroll The formula for determining whether the obtained second candidate calibration parameters meet the physical constraints is as follows: , , ; In the formula, θ roll For roll angle, θ a It is the azimuth angle. θ pitch It is the pitch angle.
[0065] Specifically, the azimuth angle of a point relative to the origin is calculated using the atan2 function, thereby obtaining the camera azimuth and pitch angles based on the direction of the camera's optical axis in the world coordinate system. A zero roll reference rotation is constructed based on the azimuth and pitch angles, and the roll angle is obtained by comparing it with the actual rotation matrix. It is then determined whether the roll angle, pitch angle, and focal length meet the physical constraints in the calibration of the surveillance camera. These physical constraints also apply to the first candidate calibration parameters calculated in steps S130-S150, ensuring that the final target parameters meet the requirements.
[0066] In this embodiment, by acquiring observation data of poles collected within the field of view of the camera to be calibrated, it is determined whether the number of poles is greater than or equal to a preset minimum value. If not, insufficient data is returned; if so, the 3D data in the observation data is centroided, and a 3D-2D correspondence between the foot and top of each pole is constructed to achieve two-point 3D constraints, thereby enhancing the geometric observability of solving for camera attitude, focal length, and spatial position. A projection model from the world coordinate system to the pixel coordinate system is constructed, and three intrinsic parameter degrees of freedom levels are set based on it from low to high. The optimal degree of freedom level is selected based on K-fold cross-validation to achieve an adaptive balance between accuracy and stability. The leave-two method is used to obtain the first candidate calibration parameters, and it is determined whether the first candidate calibration parameters meet the physical constraints. If yes, the target calibration parameters are obtained; otherwise, a fallback process is initiated. Based on the foot pixel coordinates, pole top pixel coordinates, and pole height, a CCSV model is fitted to estimate the focal length, obtain candidate focal lengths, construct a candidate focal length set, generate initial extrinsic parameters using multiple solvers, and refine them using the LM method. The leave-two method is used to evaluate and select the second candidate calibration parameters, and it is determined whether they meet the physical constraints. If yes, they are output as the target calibration parameters; otherwise, the output is not computable. Through the scheduling of the two-layer calibration process, the applicable scope of calibration is improved, and calibration can be achieved without relying on a dedicated calibration board. This improves the stability and usability of the calibration results of surveillance cameras and facilitates the batch calibration and deployment of surveillance cameras in actual scenarios such as roads, parks, and squares.
[0067] The above method can operate without relying on checkerboard patterns, calibration boards, or large manually deployed control objects. Instead, it utilizes measurable upright pole-shaped targets in the monitoring scene as weak 3D priors. Each pole-shaped target provides at least the following information: foot pixel, pole top pixel, foot RTK or planar coordinates, elevation, and pole height. The foot and pole top of each pole are constructed as 3D control points, forming two sets of 3D-2D correspondences with the foot and pole top pixels in the image. Subsequently, a high-precision calibration process with adaptive degrees of freedom is first executed. If this process fails due to insufficient samples, occlusion, pole distribution degradation, or constraint failure, it automatically switches to a fallback calibration process with low degrees of freedom, multiple focal lengths, and multiple PnP solvers. Finally, candidate solutions are selected based on allowance error, pole height consistency error, and physical installation constraints, outputting the deployable camera geographical location, attitude, and intrinsic parameter summary, or outputting an unusable state.
[0068] like Figure 3 As shown, a monitoring camera calibration system 20 based on a three-dimensional prior of an upright pole-shaped target is provided to implement the monitoring camera calibration method for a three-dimensional prior of an upright pole-shaped target as described above. The system includes: an observation data acquisition module 21, a pole quantity determination module 22, a correspondence construction module 23, a degree-of-freedom level setting module 24, a first calibration parameter acquisition module 25, a focal length estimation module 26, a second calibration parameter acquisition module 27, and a physical constraint determination module 28, wherein: The observation data acquisition module 21 is used to acquire observation data of the pole collected within the field of view of the camera to be calibrated. The observation data includes the number of poles, the pixel coordinates of the foot points, the pixel coordinates of the pole top, the three-dimensional coordinates of the foot points, the pole height, and the width and height of the image. The pole quantity judgment module 22 is used to determine whether the number of poles is greater than or equal to the preset minimum value. If not, it returns a data shortage status. The correspondence construction module 23 is used to perform centroid processing on the three-dimensional data in the observation data when the number of poles is greater than or equal to the preset minimum value, and to construct a three-dimensional-two-dimensional correspondence between the foot point and the top of each pole. The degree-of-freedom level setting module 24 is used to construct a projection model from the world coordinate system to the pixel coordinate system, and to set three intrinsic parameter degree-of-freedom levels from low to high according to the constructed projection model. The first calibration parameter acquisition module 25 is used to select the optimal degree of freedom level based on K-fold cross-validation, and to obtain the first candidate calibration parameter based on the optimal degree of freedom level using the leave-two method. It then determines whether the first candidate calibration parameter meets the physical constraints. If so, it outputs the parameter as the target calibration parameter. The focal length estimation module 26 is used to fit a CCSV model based on the foot pixel coordinates, pole top pixel coordinates and pole height when the candidate calibration parameters do not meet the physical constraints, and to estimate the focal length to obtain the candidate focal length. The second calibration parameter acquisition module 27 is used to construct a focal length candidate set based on the candidate focal lengths, generate initial extrinsic parameters using multiple solvers, refine each initial extrinsic parameter using the LM method, and evaluate and screen out the second candidate calibration parameters using the leave-two method. The physical constraint judgment module 28 is used to determine whether the second candidate calibration parameter meets the physical constraints. If it does, it is output as the target calibration parameter; otherwise, it is output as uncalculated.
[0069] Using the above system, the correspondence between three-dimensional spatial points and two-dimensional image points is established by utilizing the measurable vertical rod-shaped target and its geographic measurement information. Combined with camera projection model, PnP pose solution, nonlinear optimization and verification of calibration results, deployable calibration parameters such as focal length, principal point, distortion parameters, geographic location and attitude angle of the monitoring camera are obtained.
[0070] In summary, this invention can adapt to situations where deployed surveillance cameras face difficulties in setting up traditional calibration boards, have a limited number of available control points, exhibit uneven distribution of pole-shaped targets, and experience localized obstruction. By utilizing the measurable coordinates of the pole's base, pole height, base pixel count, and pole top pixel count, calibration constraints are constructed between 3D points and 2D image points. Furthermore, through adaptive parameter degree-of-freedom selection, candidate solution verification, physical installation constraint filtering, and a low-degree-of-freedom fallback solution mechanism, the stability and usability of the surveillance camera calibration results are improved. Through these methods, this invention can output deployment parameters such as the camera's geographical location, attitude angle, focal length, principal point, and image size without relying on a dedicated calibration board. It also provides an unusable status for scenarios with insufficient data, abnormal solutions, or failure to meet physical constraints, thereby facilitating the batch calibration and deployment of surveillance cameras in real-world scenarios such as roads, parks, and squares.
[0071] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0072] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a computer storage medium (ROM / RAM, magnetic disk, optical disk) for execution by the computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Therefore, the present invention is not limited to any particular hardware and software combination.
[0073] The above description, in conjunction with specific embodiments, provides a further detailed explanation of the present invention. It should not be construed that the specific implementation of the present invention is limited to these descriptions. For those skilled in the art, various simple deductions or substitutions can be made without departing from the inventive concept, and all such modifications and substitutions should be considered within the scope of protection of the present invention.
Claims
1. A method for calibrating a surveillance camera based on three-dimensional prior knowledge of an upright rod-shaped target, characterized in that, Includes the following steps: Acquire observation data of poles collected within the field of view of the camera to be calibrated. The observation data includes the number of poles, the pixel coordinates of the foot points, the pixel coordinates of the pole top, the three-dimensional coordinates of the foot points, the pole height, and the image width and height. Determine if the number of rods is greater than or equal to the preset minimum value; if not, return a data shortage status. If so, the three-dimensional data in the observation data is centroided, and the three-dimensional-two-dimensional correspondence between the foot points and the top of each pole is constructed. Construct a projection model from the world coordinate system to the pixel coordinate system, and set three intrinsic parameter degrees of freedom levels from low to high based on the constructed projection model; The optimal degree of freedom level is selected based on K-fold cross-validation, and the first candidate calibration parameter is obtained by leaving two points to two based on the optimal degree of freedom level. It is then determined whether the first candidate calibration parameter meets the physical constraints. If so, it is output as the target calibration parameter. If not, then fit the CCSV model based on the foot pixel coordinates, pole top pixel coordinates and pole height, and perform focal length estimation to obtain the candidate focal length; Based on the candidate focal lengths, a set of candidate focal lengths is constructed, and initial extrinsic parameters are generated using multiple solvers. Each initial extrinsic parameter is refined using the LM method, and the second candidate calibration parameter is selected by evaluation and screening using the leave-two method. Determine whether the second candidate calibration parameter meets the physical constraints. If it does, output it as the target calibration parameter; otherwise, output that it cannot be calculated.
2. The method for calibrating a surveillance camera based on a three-dimensional prior of an upright rod-shaped target according to claim 1, characterized in that, The construction of the projection model from the world coordinate system to the pixel coordinate system includes: Let the camera intrinsic parameter matrix be K, which contains the camera focal length. f and principal point coordinates ( c x ,c y ),for: ; Define the camera extrinsic parameters, including the rotation matrix R from the world coordinate system to the camera coordinate system and the translation vector t, and calculate the position of the camera optical center in the world coordinate system. ; The world coordinates are obtained through the camera's extrinsic parameters. P i,j Transform to the camera coordinate system and calculate its coordinates on the normalized imaging plane. x,y According to the radial radius r and first-order radial distortion coefficient k 1 Calculate the distorted coordinates ( x d , y d ),for: , ; The pixel coordinates are obtained from the camera's intrinsic parameters, specifically the focal length and principal point coordinates: , ; In the formula, ( u,v () represents pixel coordinates.
3. The method for calibrating a surveillance camera based on a three-dimensional prior of an upright rod-shaped target according to claim 2, characterized in that, The process involves setting three levels of intrinsic parameter freedom from low to high based on the constructed projection model, including: The intrinsic parameter degrees of freedom levels include a first degree of freedom level, a second degree of freedom level, and a third degree of freedom level. The first degree of freedom level uses the pixel focal length, rotation matrix, and translation vector as parameters to be optimized, fixes the first-order radial distortion coefficient at 0, and fixes the principal point coordinates at the image center. c x = W / 2, c y = H img / 2; In the formula, W Image width, H img Image height; The second degree of freedom level takes the principal point coordinates as the parameter to be optimized based on the parameters to be optimized in the first degree of freedom level, and fixes the first-order radial distortion coefficient to 0. The third degree of freedom level takes the first-order radial distortion coefficient as the parameter to be optimized, based on the parameters to be optimized in the second degree of freedom level. For each degree of freedom level, based on the constructed projection model and with the optimization objective of minimizing the reprojection error of the training samples, the corresponding candidate calibration parameters are solved. The reprojection optimization function is: ; In the formula, π (·) represents the camera projection function with optional radial distortion. C tr Let P be the set of training samples, where P is the world coordinate point and p is the corresponding pixel observation coordinate.
4. The method for calibrating a surveillance camera based on a three-dimensional prior of an upright rod-shaped target according to claim 3, characterized in that, The selection of the optimal degree of freedom level based on K-cross-validation includes: The rod-shaped target sample is divided into several folds according to a preset random seed. For each degree of freedom level, the candidate calibration parameters are solved with the training rod in each fold division, and the ground back projection error and rod height consistency error are calculated on the verification rod. Based on the ground back projection error and pole height consistency error, the comprehensive score for each degree of freedom level is calculated as follows: ; In the formula, E te Let be the median of the ground backprojection error for each validation set. E h To account for the rod height consistency error, α The preset pole height consistency weight; For each degree of freedom level, the percentage of folds that satisfy the preset physical constraints in each fold is counted. The physical constraints include a positive focal length, the camera optical center being located within the elevation range of the ground object, and the rotation matrix corresponding to the pitch and yaw angles. If the fold ratio is lower than a preset threshold, the corresponding degree of freedom level is discarded; If the ratio of the number of folds is higher than or equal to a preset threshold, it is considered to be an effective degree of freedom level; Among the effective degrees of freedom levels, the level with the smallest overall score is selected as the optimal degrees of freedom level.
5. The method for calibrating a surveillance camera based on a three-dimensional prior of an upright rod-shaped target according to claim 4, characterized in that, The method of obtaining candidate first-choice calibration parameters based on the optimal degree-of-freedom level and using the leave-two method includes: Based on the optimal degree of freedom level, perform a leave-two traversal on all rod-shaped target samples; Each time, two rod-shaped targets are selected as the validation set, and the remaining rod-shaped targets are used as the training set. The calibration parameters of the first candidate solution are calculated. For the a-th partition, the comprehensive score is calculated using the following formula: ; In the formula, and denoted as the ground backprojection error of the training set and validation set in the a-th partition; The candidate solution with the smallest comprehensive score is selected as the first candidate calibration parameter.
6. The method for calibrating a surveillance camera based on a three-dimensional prior of an upright rod-shaped target according to claim 5, characterized in that, The step of fitting a CCSV model based on the foot pixel coordinates, pole top pixel coordinates, and pole height, and then estimating the focal length to obtain candidate focal lengths, includes: Let the offset of the foot point's ordinate be... y f =c y -v i,0 The height of the pole is H i If the height difference between the camera and the foot point is c, and the pitch angle is θ, then the predicted pixel at the top of the pole is: ; By minimizing the residual between the predicted top pixel and the coordinates of the top pixel, the focal length, pitch angle, and elevation difference are estimated using the following formula: ; The estimated focal length is used as a candidate focal length for focal length search. If the fitting fails, the preset initial focal length value is used as the candidate focal length.
7. The method for calibrating a surveillance camera based on a three-dimensional prior of an upright rod-shaped target according to claim 6, characterized in that, The process involves constructing a candidate focal length set based on the candidate focal lengths, generating initial extrinsic parameters using multiple solvers, refining each initial extrinsic parameter using the LM method, and evaluating and selecting second candidate calibration parameters using the leave-two method, including: Construct a candidate focal length set F based on the candidate focal lengths, and for each candidate focal length... Construct the intrinsic parameter matrix with fixed principal points as follows: ; Initial extrinsic parameters were generated using three solvers: ACEPnP, SQPnP, and EPnP, and each initial extrinsic parameter was refined using the LM algorithm. For any initial extrinsic parameters obtained by the solver, calculate the root mean square error of pixel reprojection at the corresponding training points: ; Among the candidate solutions that satisfy the condition of positive depth and pass the physical constraints, retain the candidate solutions with small root mean square error of pixel reprojection. A leave-two partition is drawn a preset number of times using a fixed random seed. A candidate search is performed on each partition, and the comprehensive score of the candidate solutions is calculated. The candidate solution with the smallest comprehensive score is selected to obtain the second candidate calibration parameter.
8. The method for calibrating a surveillance camera based on a three-dimensional prior of an upright rod-shaped target according to claim 7, characterized in that, The generation of initial extrinsic parameters using the ACEPnP solver includes: Four control points are constructed using the three-dimensional centroid and the principal direction of the three-dimensional PCA. Each 3D point is represented as a combination of the centroids of the control points: , ; Expand the unknown coordinates of the control points in the camera coordinate system into a vector. x∈R 12 Assemble a linear system by pixel projection constraints Mx=0 ; Combining control point spacing constraints, eigendecomposition, and Kabsch registration rotation matrix and translation vector; When the ratio of the minimum singular value to the maximum singular value in the PCA of the 3D point cloud is lower than a preset threshold, the ACEPnP solver is determined to be degenerate under the current point cloud distribution and is skipped.
9. The method for calibrating a surveillance camera based on a three-dimensional prior of an upright rod-shaped target according to claim 8, characterized in that, The step of determining whether the second candidate calibration parameter meets the physical constraints includes: Extract the direction of the camera optical axis in the world coordinate system from the second candidate calibration parameters. The formula for calculating the camera's azimuth and pitch angles is: , ; A zero-roll reference rotation is constructed based on the azimuth and pitch angles, and the roll angle is obtained by comparing it with the actual rotation matrix. θ roll ; The formula for determining whether the obtained second candidate calibration parameters meet the physical constraints is: , , ; In the formula, θ roll For roll angle, θ a It is the azimuth angle. θ pitch The pitch angle.
10. A surveillance camera calibration system for a three-dimensional prior of an upright rod-shaped target, characterized in that, The method for calibrating a surveillance camera based on a three-dimensional prior of an upright rod-shaped target, as described in any one of claims 1-9, includes: The observation data acquisition module is used to acquire observation data of the pole collected within the field of view of the camera to be calibrated. The observation data includes the number of poles, the pixel coordinates of the foot points, the pixel coordinates of the pole top, the three-dimensional coordinates of the foot points, the pole height, and the image width and height. The pole quantity determination module is used to determine whether the number of poles is greater than or equal to the preset minimum value. If not, it returns a data shortage status. The correspondence construction module is used to perform centroid processing on the three-dimensional data in the observation data when the number of poles is greater than or equal to a preset minimum value, and to construct a three-dimensional-two-dimensional correspondence between the foot point and the top of each pole. The degree-of-freedom level setting module is used to construct a projection model from the world coordinate system to the pixel coordinate system, and to set three intrinsic parameter degree-of-freedom levels from low to high according to the constructed projection model; The first calibration parameter acquisition module is used to select the optimal degree of freedom level based on K-fold cross-validation, and obtain the first candidate calibration parameter based on the optimal degree of freedom level using the leave-two method. It then determines whether the first candidate calibration parameter meets the physical constraints. If so, it outputs the first candidate calibration parameter as the target calibration parameter. The focal length estimation module is used to fit a CCSV model based on the foot pixel coordinates, pole top pixel coordinates and pole height when the candidate calibration parameters do not meet the physical constraints, and then perform focal length estimation to obtain the candidate focal length. The second calibration parameter acquisition module is used to construct a focal length candidate set based on the candidate focal lengths, generate initial extrinsic parameters using multiple solvers, perform LM refinement on each initial extrinsic parameter, and evaluate and screen out the second candidate calibration parameters using the leave-two method. The physical constraint judgment module is used to determine whether the second candidate calibration parameter meets the physical constraints. If it does, it is output as the target calibration parameter; otherwise, it is output as uncalculated.
