A camera calibration service method for coupling edge-aware perception devices

CN121482170BActive Publication Date: 2026-10-30CHINA INST OF WATER RESOURCES & HYDROPOWER RES +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511881860.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-15
Publication Date
2026-10-30
Estimated Expiration
2045-12-15

AI Technical Summary

Technical Problem

[0003]然而,传统的相机标定方法存在诸多局限性

Benefits of technology

服务器端采用高效的标定算法和分布式计算架构,能够快速处理大量边端设备的标定请求,显著提高了标定效率,缩短了设备部署和调试周期,通过在服务器端集中进行标定计算和参数管理,避免了边端设备独立标定可能带来的误差和不一致性问题,确保了所有边端设备使用的标定参数准确可靠。当相机参数发生变化时,只需在边端设备上重新拍摄标定图像并上传至服务器端即可完成参数更新,无需对每个设备进行现场维护,降低了维护成本和工作量。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121482170B_ABST
    Figure CN121482170B_ABST
Patent Text Reader

Abstract

The application provides a camera calibration service method for coupling edge perception devices, belonging to the technical field of computer vision and edge computing, comprising: the server side builds a camera calibration interface service based on FastAPI, the edge perception device uploads the required parameters for calibration through the service interface, the server side starts the camera calibration algorithm after analyzing the request, and the server side feeds back the optimized intrinsic matrix, distortion coefficient and coordinate mapping scale to the edge perception device through the interface response; the interface service is deployed in the intranet server based on the container, and supports remote calling and parameter updating of the edge perception device. The server side adopts an efficient calibration algorithm and a distributed computing architecture, can quickly process a large number of calibration requests of edge devices, significantly improves the calibration efficiency, avoids errors and inconsistency problems caused by independent calibration of edge devices through centralized calibration calculation and parameter management on the server side, and ensures that the calibration parameters are accurate and reliable.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of computer vision and edge computing technology, and in particular to a camera calibration service method for coupled edge sensing devices. Background Technology

[0002] With the widespread application of computer vision technology in various fields, such as intelligent security, autonomous driving, and industrial inspection, edge sensing devices (such as cameras and smart cameras) are key data acquisition devices, and their performance and accuracy are crucial to the entire vision system. Camera calibration is a fundamental and critical step in computer vision. It determines the camera's internal parameters (such as focal length and principal point coordinates) and external parameters (such as the camera's position and orientation in the world coordinate system), thereby accurately converting image coordinates to real-world coordinates and providing an accurate data foundation for subsequent tasks such as target detection, recognition, and measurement.

[0003] However, traditional camera calibration methods have many limitations. On the one hand, for a large number of sensing devices deployed at the edge, performing independent calibration on each device is not only inefficient, but also makes it difficult to guarantee the consistency and accuracy of calibration parameters. On the other hand, when camera parameters change (such as lens replacement, camera position adjustment, etc.), recalibration is required, further increasing maintenance costs and workload.

[0004] Therefore, there is an urgent need for a new technical solution that can simplify the camera calibration process of edge sensing devices, improve calibration efficiency and the convenience of parameter acquisition, while ensuring the accuracy and consistency of calibration parameters. Summary of the Invention

[0005] This invention provides a camera calibration service method for coupled edge sensing devices to solve the aforementioned technical problems.

[0006] This invention provides a camera calibration service method for coupled edge sensing devices, comprising: Step 1: The server-side builds a camera calibration interface service based on FastAPI. The interface service includes an interface for receiving requests from edge sensing devices and adopts the POST method. The request parameters include ground control point calibration information file, image width, and image height. Step 2: The edge sensing device uploads the required calibration parameters through the service interface. After parsing the request, the server starts the camera calibration algorithm. The specific operations of the camera calibration algorithm include: Initialize the camera intrinsic parameter matrix, where the initial value of the focal length is set to the image width, and the initial value of the principal point coordinates is set to the image center. The distortion coefficients are initialized to [0,0,0,0,0], where the first three terms are radial distortion coefficients and the last two terms are tangential distortion coefficients; Extract the world coordinates (Xn, Yn, Zn) and corresponding pixel coordinates (in, jn) of at least four ground control points from the ground control point calibration information file; Based on the coordinates of the ground control points and the initial intrinsic parameter matrix, the camera rotation matrix R and translation vector t are solved to determine the camera pose. Based on the camera intrinsic parameter matrix, camera pose and distortion coefficient, calculate the ideal projected coordinates of the ground control points and the actual projected coordinates after radial distortion correction. Calculate the reprojection error and optimize the focal length based on the differential evolution algorithm. and radial distortion coefficient This minimizes the reprojection error. Based on the optimized intrinsic parameter matrix and distortion coefficients, the maximum and minimum values ​​of the corrected image coordinates and corresponding world coordinates of the ground control points in the horizontal and vertical directions are calculated to obtain the pixel-world coordinate mapping ratio. Step 3: The server sends the optimized intrinsic parameter matrix, distortion coefficients, and coordinate mapping ratio back to the edge sensing device via an interface response; Step 4: The interface service is deployed on an intranet server based on a container, supporting remote calls and parameter updates from edge sensing devices.

[0007] Preferably, the focal length optimization range is 0.25 to 2 times the image width. The optimization range is [-0.9, 0.9]. The optimization range is [-0.5, 0.5], and the termination condition is absolute tolerance atol = 0.002.

[0008] Preferably, the initial form of the camera intrinsic parameter matrix for: in, This indicates the focal length; the initial default focal length is the image width. This represents the principal point coordinates, with the initial default principal point coordinates being the image center.

[0009] Preferably, the actual projected coordinates after radial distortion correction are calculated using the following formula: Where (u,v) are the ideal projection coordinates; r is the coordinates from point (u,v) to the principal point. The distance; These are the projected coordinates after radial distortion correction.

[0010] Preferably, the reprojection error is: in, This represents the pixel coordinates of the ground control points on the image. This represents the theoretical coordinates of the control points projected onto the image plane using the current camera parameters, where N represents the number of control points.

[0011] Preferably, the response parameters of the service interface include status code, request timestamp, runtime, error code, error description, and calibration result, wherein the calibration result includes coordinate mapping ratio, intrinsic parameter matrix, and distortion coefficient.

[0012] Preferably, step 2 includes: Based on the preset parameter mapping table, the fields of the calibration request body are extracted, the ground control point calibration information file is converted into structured data, and the data type and range rationality of the image width and image height are verified. After parsing, a multi-level verification mechanism is initiated, including: verifying whether the number of ground control points is not less than 4 and whether the correspondence between world coordinates and pixel coordinates is unique; and verifying whether the aspect ratio of the image conforms to common resolution standards. When all verification items pass, a calibration task token containing the parsed parameters is automatically generated. The task token is bound to the unique identifier of the request through a hash algorithm. Then, the task scheduler is triggered to call the initialization function of the camera calibration algorithm and the parameter set corresponding to the token is passed to the algorithm execution environment through memory mapping. At the same time, the process monitoring thread is started to detect the algorithm initialization status in real time. If the algorithm startup success signal is not received within a preset time period, the call is automatically re-initiated and the exception log is recorded. The server-side verification of the correspondence between the world coordinates (Xn, Yn, Zn) and pixel coordinates (in, jn) of ground control points includes: The mapping confidence score between world coordinates and pixel coordinates is calculated. When the same world coordinate corresponds to multiple pixel coordinates and the mapping confidence score for each pixel coordinate exceeds the confidence score threshold, the correspondence between world coordinates and pixel coordinates is determined to be non-unique. If it is determined to be non-unique, cluster analysis is performed on the multiple pixel coordinates corresponding to the same world coordinate, the cluster center coordinates are selected as the optimal matching pixel coordinates, and the intra-cluster divergence is calculated as the ambiguity. ,in, The preset attenuation coefficient; For pixel coordinates pi1= The Euclidean distance to the center coordinates of the field of view of the edge sensing device; n1 represents the center coordinates of the corresponding cluster; n1 represents the total number of pixel coordinates in the cluster. For pixel coordinates pi1= The penalty coefficient, For the judgment function, and , The preset planar distance threshold; For pixel coordinates pi1= The corresponding three-dimensional world coordinates, AX+BY+CZ+D=0, are the fitted plane equations; If the ambiguity exceeds a preset pixel threshold, a secondary verification process is triggered, sending a request to the edge sensing device to upload a local high-resolution image of the point corresponding to the world coordinates.

[0013] Preferably, the process of the interface response being fed back to the edge sensing device includes: The optimized parameter set is then processed according to the encryption function. Encryption is performed, and additional verification information including a parameter digest, timestamp, and server digital signature is generated. This is the data set obtained by concatenating the optimized parameter set; The matrix is ​​a pre-defined random permutation matrix; This is a dynamic offset generated based on the device's unique identifier; For random selection and with Coprime integers, , It is a large prime number; The bitwise XOR symbol; The encrypted parameter set and additional verification information are packaged into a response body and sent back to the edge sensing device via the HTTPS protocol.

[0014] Compared with the prior art, the beneficial effects of this application are: The server employs a highly efficient calibration algorithm and a distributed computing architecture, enabling it to quickly process a large number of calibration requests from edge devices. This significantly improves calibration efficiency and shortens device deployment and debugging cycles. By centralizing calibration calculations and parameter management on the server side, it avoids the errors and inconsistencies that may arise from independent calibration of edge devices, ensuring the accuracy and reliability of calibration parameters used by all edge devices. When camera parameters change, simply re-capture calibration images on the edge device and upload them to the server to update the parameters, eliminating the need for on-site maintenance of each device and reducing maintenance costs and workload.

[0015] Other features and advantages of the invention will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the written description and the accompanying drawings.

[0016] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description

[0017] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is a flowchart of a camera calibration service method for a coupled edge sensing device according to an embodiment of the present invention; Figure 2 This is a flowchart illustrating the execution of the camera calibration algorithm in an embodiment of the present invention. Figure 3 This is an example diagram of interface access in an embodiment of the present invention; Figure 4 This is a comparison chart of camera calibration results in an embodiment of the present invention. Detailed Implementation

[0018] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.

[0019] This invention provides a camera calibration service method for coupled edge sensing devices, such as... Figure 1 As shown, it includes: Step 1: The server-side builds a camera calibration interface service based on FastAPI. The interface service includes an interface for receiving requests from edge sensing devices and adopts the POST method. The request parameters include ground control point calibration information file, image width, and image height. Step 2: The edge sensing device uploads the required calibration parameters through the service interface. After parsing the request, the server starts the camera calibration algorithm. The specific operations of the camera calibration algorithm include, for example... Figure 2 As shown: Initialize the camera intrinsic parameter matrix, where the initial value of the focal length is set to the image width, and the initial value of the principal point coordinates is set to the image center. The distortion coefficients are initialized to [0,0,0,0,0], where the first three terms are radial distortion coefficients and the last two terms are tangential distortion coefficients; Extract the world coordinates (Xn, Yn, Zn) and corresponding pixel coordinates (in, jn) of at least four ground control points from the ground control point calibration information file; Based on the coordinates of the ground control points and the initial intrinsic parameter matrix, the camera rotation matrix R and translation vector t are solved to determine the camera pose. Based on the camera intrinsic parameter matrix, camera pose and distortion coefficient, calculate the ideal projected coordinates of the ground control points and the actual projected coordinates after radial distortion correction. Calculate the reprojection error and optimize the focal length based on the differential evolution algorithm. and radial distortion coefficient This minimizes the reprojection error. Based on the optimized intrinsic parameter matrix and distortion coefficients, the maximum and minimum values ​​of the corrected image coordinates and corresponding world coordinates of the ground control points in the horizontal and vertical directions are calculated to obtain the pixel-world coordinate mapping ratio. Step 3: The server sends the optimized intrinsic parameter matrix, distortion coefficients, and coordinate mapping ratio back to the edge sensing device via an interface response; Step 4: The interface service is deployed on an intranet server based on a container, supporting remote calls and parameter updates from edge sensing devices.

[0020] Preferably, the focal length optimization range is 0.25 to 2 times the image width. The optimization range is [-0.9, 0.9]. The optimization range is [-0.5, 0.5], and the termination condition is absolute tolerance atol = 0.002.

[0021] Preferably, the initial form of the camera intrinsic parameter matrix for: in, This indicates the focal length; the initial default focal length is the image width. This represents the principal point coordinates, with the initial default principal point coordinates being the image center.

[0022] Preferably, the actual projected coordinates after radial distortion correction are calculated using the following formula: Where (u,v) are the ideal projection coordinates; r is the coordinates from point (u,v) to the principal point. The distance; These are the projected coordinates after radial distortion correction.

[0023] Preferably, the reprojection error is: in, This represents the pixel coordinates of the ground control points on the image. This represents the theoretical coordinates of the control points projected onto the image plane using the current camera parameters, where N represents the number of control points.

[0024] Preferably, the response parameters of the service interface include status code, request timestamp, runtime, error code, error description, and calibration result, wherein the calibration result includes coordinate mapping ratio, intrinsic parameter matrix, and distortion coefficient.

[0025] In this embodiment, the intrinsic parameter matrix is ​​initialized. The camera intrinsic parameter matrix is ​​used to describe the internal geometric characteristics of the camera, including focal length, principal point coordinates, etc.

[0026] Initialize the distortion coefficients. Distortion coefficients are used to correct radial and tangential distortion of the lens. Common distortion coefficients are shown in Formula 2: Formula 2 Where: k1, k2, k3 represent radial distortion coefficients, p1, p2 represent tangential distortion coefficients, and the initial distortion coefficients are set to [0,0,0,0,0].

[0027] Obtain ground control points. A ground control point consists of the world coordinates and pixel coordinates of at least four points within the image, as shown in Formula 3: Formula 3 Where X n ,Y n Z n Represents the 3D coordinates of the ground control point in the corresponding world coordinate system, i n ,j n The 2D pixel coordinates of the control point in the image.

[0028] To determine the camera pose, the solvePnP (Perspective-n-Point) algorithm, a built-in feature of the OpenCV library, is used. The solvePnP algorithm is a classic algorithm for estimating the camera pose by mapping 3D points to 2D points. Given a set of 3D world coordinates and their corresponding 2D image coordinates (GCPs), along with the camera's intrinsic parameter matrix `camera_matrix`, it estimates the camera's rotation matrix `R` and translation vector `t`, thereby determining the camera pose. This minimizes the projection error (Error).

[0029] Solve for the projected coordinates. In an ideal pinhole model (distortion-free), given the intrinsic parameter matrix camera_matrix and the camera pose... Then the spatial point Projected coordinates in the image The calculation method is shown in Formula 4: Formula 4 However, due to errors in the camera manufacturing process, the actual image points will deviate from the ideal position due to radial distortion. Considering practical applications, the distortion formula is simplified, and only radial distortion correction is performed. Given the distortion parameters dist_coeffs=[k1,k2,p1,p2,k3], then the image projection coordinates after radial distortion correction are... As shown in Formula 5: Formula 5 Calculate the reprojection error.

[0030] Optimize parameters. The differential evolution algorithm is an optimization algorithm suitable for nonlinear and nonconvex problems, effectively avoiding local optima. Based on the differential evolution algorithm, the focal length and distortion coefficients are adjusted to minimize the reprojection error. This invention performs global optimization based on the differential_evolution algorithm from the scipy repository.

[0031] In this embodiment, based on the iteratively optimized intrinsic parameter matrix camera_matrix and distortion coefficients dist_coeffs, distortion correction is performed on the image coordinates of at least four ground control points to obtain the corrected image coordinates. Simultaneously, obtain the world coordinates corresponding to the ground control points. Calculate image coordinates The maximum and minimum values ​​in the horizontal and vertical directions are represented as follows: , , , World coordinates are calculated in the same way. Maximum and minimum values ​​in the horizontal and vertical directions , , , The calculation methods for the horizontal and vertical mapping ratios Dx and Dy of this camera calibration are as follows: Normally, the values ​​of Dx and Dy will not differ significantly. In practical applications, the average of Dx and Dy is used to obtain the image-world mapping ratio value ppm (pixelpermeter) applicable to the entire image. This value represents the number of pixels represented by one meter in the world coordinate system in the image coordinate system. This value has an important practical application role in camera calibration engineering.

[0032] like Figure 4 The image shown is a diagram of the camera calibration results.

[0033] This invention builds a camera calibration service based on FastAPI, and the specific implementation steps are as follows: Step 01: Create the API application and camera calibration interface. Start an ASGI (Asynchronous Server Gateway Interface) main application based on the uvivorn library, and create the get_calibration_para interface to retrieve camera calibration parameters. The interface settings are as follows:

[0034] Step 02: Define the request and response parameters of the interface. Based on the camera calibration algorithm and service requirements, the request parameters are determined as follows:

[0035] The response parameters are as follows:

[0036] Step 03: Interface Code Implementation. Implement the camera calibration algorithm based on its underlying principles, and expose interfaces to obtain three calibration parameters: 'ppm (pixel / m mapping size)', 'camera_matrix (intrinsic parameter matrix)', and 'dist_coeffs (distortion parameters)'. Parse the request parameters at the HTTP interface and pass them to the camera calibration algorithm. After obtaining the three calibration parameters returned by the algorithm, construct the response body and return it to the requesting client.

[0037] Step 04: Package the program and deploy the service. Package the interface program and its environment, and transfer it to an intranet server accessible to edge sensing devices. Set up a Docker environment on the server, and write a Dockerfile to configure the base image, install dependencies, common working directory, application port, and program entry point. Deploy the program with one click based on the Dockerfile.

[0038] Step 05: Interface Access Test. Access the interface address http: / / {ip}:{port} / get_calibration_para in the browser based on the deployed server IP and port. For example... Figure 3 The interface test is performed as shown.

[0039] Through the above steps, we can quickly build a camera calibration interface based on FastAPI and deploy a Docker service with one click, which can be used to couple the calls of edge sensing device camera calibration related application projects.

[0040] The beneficial effects of the above technical solution are as follows: The server-side employs a highly efficient calibration algorithm and a distributed computing architecture, enabling rapid processing of calibration requests from a large number of edge devices. This significantly improves calibration efficiency, shortens device deployment and debugging cycles, and avoids errors and inconsistencies that may arise from independent calibration of edge devices by centrally performing calibration calculations and parameter management on the server side. This ensures that the calibration parameters used by all edge devices are accurate and reliable. When camera parameters change, simply re-capture the calibration image on the edge device and upload it to the server to update the parameters, eliminating the need for on-site maintenance of each device and reducing maintenance costs and workload.

[0041] This invention provides a camera calibration service method for coupled edge sensing devices, step 2 of which includes: Based on the preset parameter mapping table, the fields of the calibration request body are extracted, the ground control point calibration information file is converted into structured data, and the data type and range rationality of the image width and image height are verified. After parsing, a multi-level verification mechanism is initiated, including: verifying whether the number of ground control points is not less than 4 and whether the correspondence between world coordinates and pixel coordinates is unique; and verifying whether the aspect ratio of the image conforms to common resolution standards. When all verification items pass, a calibration task token containing the parsed parameters is automatically generated. The task token is bound to the unique identifier of the request through a hash algorithm. Then, the task scheduler is triggered to call the initialization function of the camera calibration algorithm and the parameter set corresponding to the token is passed to the algorithm execution environment through memory mapping. At the same time, the process monitoring thread is started to detect the algorithm initialization status in real time. If the algorithm startup success signal is not received within a preset time period, the call is automatically re-initiated and the exception log is recorded. The server-side verification of the correspondence between the world coordinates (Xn, Yn, Zn) and pixel coordinates (in, jn) of ground control points includes: The mapping confidence score between world coordinates and pixel coordinates is calculated. When the same world coordinate corresponds to multiple pixel coordinates and the mapping confidence score for each pixel coordinate exceeds the confidence score threshold, the correspondence between world coordinates and pixel coordinates is determined to be non-unique. If it is determined to be non-unique, cluster analysis is performed on the multiple pixel coordinates corresponding to the same world coordinate, the cluster center coordinates are selected as the optimal matching pixel coordinates, and the intra-cluster divergence is calculated as the ambiguity. ,in, The preset attenuation coefficient; For pixel coordinates pi1= The Euclidean distance to the center coordinates of the field of view of the edge sensing device; n1 represents the center coordinates of the corresponding cluster; n1 represents the total number of pixel coordinates in the cluster. For pixel coordinates pi1= The penalty coefficient, For the judgment function, and , The preset planar distance threshold; For pixel coordinates pi1= The corresponding three-dimensional world coordinates, AX+BY+CZ+D=0, are the fitted plane equations; If the ambiguity exceeds a preset pixel threshold, a secondary verification process is triggered, sending a request to the edge sensing device to upload a local high-resolution image of the point corresponding to the world coordinates.

[0042] In this embodiment, the preset parameter mapping table is a predefined set of rules used to associate fields of ground control point files of different formats with the internal data structure of the server. It includes field names, data types, coordinate dimensions (3D world coordinates, 2D pixel coordinates) and verification rules. For example, if the ground control point file is in CSV format, the mapping table can define (X,Y,Z) as corresponding to world coordinates (Xn,Yn,Zn), and u,v as corresponding to pixel coordinates (in,jn). It is also specified that X,Y,Z,u,v are all floating-point data.

[0043] The ground control point calibration information file is a file uploaded by the edge device that contains the world coordinates and corresponding pixel coordinates of the ground control points (reference points used for calibration). It supports formats such as CSV and JSON. For example, the content of a CSV file may be X,Y,Z,u,v\n1.0,2.0,0.0,500,300\n1.5,2.5,0.0,600,350 (each line represents the world coordinates (X,Y,Z) and pixel coordinates (u,v) of a control point).

[0044] In this embodiment, structured data is the conversion of the original file content into a standardized data format that the server can directly process. It is usually a dictionary list containing coordinate type markers, indexes, and values. After extracting fields according to the parameter mapping table, type markers and indexes are added through code logic to generate a Python dictionary list.

[0045] In this embodiment, the data type verification of image width and image height is to verify whether the image width and height uploaded by the edge device are of a preset data type (usually an integer) to avoid non-numerical data causing algorithm errors. For example, if the uploaded image width is 1920.5 (floating-point) or abc (string), the verification will fail and return an error that the data type must be an integer. Specifically, the isinstance() function is used to determine the data type, and if it is not an integer, error handling is triggered.

[0046] In this embodiment, the reasonableness verification of the image width and height range is to verify whether the image width and height are within the reasonable range of actual application (avoiding invalid values ​​that are too large or too small). For example, the image width range is set to [640, 8192] (a common camera resolution range), and the height range is [480, 4320]. If the uploaded width is 500 (less than 640), the verification fails.

[0047] The multi-level verification mechanism verifies the parsed data step by step in multiple dimensions to ensure that the input data meets the basic requirements of the calibration algorithm. For example, it first verifies the number of control points, then verifies the coordinate correspondence, and finally verifies the aspect ratio. If any step fails, the subsequent process will be terminated.

[0048] Image aspect ratio conforms to common resolution standards, meaning the ratio of image width to height must conform to mainstream resolution ratios (such as 16:9, 4:3) to avoid calibration parameter deviations caused by non-standard ratios.

[0049] The calibration task token is a unique identifier containing a digest of the parsed parameters. It is used to associate the request with the calibration task, ensuring the accuracy and traceability of parameter transmission. Based on the parsed parameters (such as control point coordinates, image width and height), the token a1b2c3 is generated using the SHA-256 hash algorithm. The parameter string is then encrypted using hashlib.sha256() to generate a fixed-length token.

[0050] The unique identifier for a request is a unique ID (such as a UUID) assigned to each calibration request, used to distinguish requests from different edge devices.

[0051] The task scheduler is a module used to manage the calibration task queue. It calls the camera calibration algorithm according to the order of requests or priority. For example, when requests are received from 3 devices at the same time, the scheduler starts the algorithm in the order of receipt time to avoid resource conflicts.

[0052] The camera calibration algorithm's initialization function is a preparatory function before starting the calibration algorithm. It is responsible for initializing basic parameters such as the intrinsic parameter matrix and distortion coefficients. For example, in the function init_calibration(), the initial focal length is set to the image width and the principal point coordinates are set to the image center.

[0053] Memory mapping directly maps the parameter set to the memory address of the algorithm execution environment, achieving efficient data transfer (avoiding the time consumption of traditional IO). For example, the parameter set can be written to shared memory through the mmap module, and the algorithm can read directly from memory, with a transfer speed more than 10 times faster than file IO.

[0054] The process monitoring thread is independent of the main process and is used to detect in real time whether the algorithm has started successfully, so as to avoid task stagnation caused by the algorithm freezing. For example, the thread checks the algorithm process status every 100ms. If no start success signal is received within 500ms, a retry is triggered.

[0055] The preset time period is the maximum time threshold allowed for the algorithm to start; if this time is exceeded, the algorithm is considered to have failed to start.

[0056] The exception log is a file that records the reasons why the algorithm failed to start, and is used for subsequent troubleshooting.

[0057] In this embodiment, the mapping confidence is a quantitative indicator (range 0-1) that measures the degree of matching between world coordinates and pixel coordinates. It is usually calculated based on Euclidean distance (the smaller the distance, the higher the confidence). The confidence is calculated as 1 - (distance / maximum allowable distance), and the maximum allowable distance is set to 50 pixels.

[0058] In this embodiment, the confidence threshold is the minimum confidence level required to determine that the coordinate mapping is valid; if the confidence level is lower than this value, the match is considered invalid.

[0059] In this embodiment, cluster analysis involves grouping multiple pixel coordinates according to similarity (such as Euclidean distance), with each group forming a cluster. This reduces redundant data. The K-means algorithm is used, and the number of clusters is set to 2 (dynamically adjusted according to the actual data distribution).

[0060] The cluster center coordinates are the average of all pixel coordinates in each cluster, representing the center position of that cluster, and are used as the optimal matching pixel coordinates.

[0061] Intra-cluster divergence is an indicator that measures the degree of dispersion of pixel coordinates within a cluster. It takes into account pixel position, field weight, and world coordinate plane constraints. The larger the value, the higher the degree of dispersion.

[0062] The preset attenuation coefficient controls the impact of the distance from the pixel coordinates to the center of the field of view on the weights.

[0063] The penalty coefficient is the weight applied to the corresponding pixel coordinates when world coordinates violate planar constraints (increasing the weight denominator to reduce its impact). For example, =2 (when When 1 hour, the weight of pixels that violate the constraint is reduced by 50%.

[0064] The preset plane distance threshold Yd ​​is the maximum distance that the world coordinates are allowed to deviate from the fitted plane. Exceeding this distance is considered a violation of the constraint. For example, Yd = 0.05 meters (5 centimeters), which is suitable for ground calibration scenarios (control points need to be close to the ground).

[0065] The fitted plane equation AX+BY+CZ+D=0 is a three-dimensional plane equation fitted using all world coordinates. It is used to determine whether control points are on the same plane (such as the ground). The least squares method is used to fit the plane to the world coordinates (Xn,Yn,Zn) and solve for the coefficients A, B, C, and D.

[0066] The preset pixel threshold is the critical value for determining whether the ambiguity is too high. If it is exceeded, data needs to be supplemented. For example, if the threshold is set to 5 pixels, and the scatter within a cluster is D1=6 pixels (exceeding the threshold), then a secondary check is triggered.

[0067] The secondary verification process is a process that requires edge devices to supplement data to reduce mapping ambiguity when the ambiguity is too high.

[0068] The beneficial effects of the above technical solution are as follows: through structured data conversion, multi-level verification, cluster analysis and dynamic retry mechanism, accurate verification and anomaly handling of calibration request data are achieved, effectively reducing the impact of coordinate mapping ambiguity and invalid data on the algorithm, ensuring the reliable start-up of the camera calibration algorithm and the accuracy of parameters, while improving adaptability in complex scenarios through secondary verification, and improving the efficiency and robustness of edge device camera calibration as a whole.

[0069] This invention provides a camera calibration service method for coupled edge sensing devices, wherein the process of interface response feedback to edge sensing devices includes: The optimized parameter set is then processed according to the encryption function. Encryption is performed, and additional verification information including a parameter digest, timestamp, and server digital signature is generated. This is the data set obtained by concatenating the optimized parameter set; The matrix is ​​a pre-defined random permutation matrix; This is a dynamic offset generated based on the device's unique identifier; For random selection and with Coprime integers, , It is a large prime number; The bitwise XOR symbol; The encrypted parameter set and additional verification information are packaged into a response body and sent back to the edge sensing device via the HTTPS protocol.

[0070] In this embodiment, the optimized parameter set is a set of parameters used for camera imaging correction, such as the camera intrinsic parameter matrix, distortion coefficients, and coordinate mapping ratio, obtained after optimization by the camera calibration algorithm.

[0071] The encryption function is used to encrypt the optimized parameter set to ensure the security of the data during transmission. It combines operations such as data scrambling, dynamic offsetting, and modular exponentiation.

[0072] The parameter digest is a fixed-length data obtained by hashing the optimized parameter set. It is used to verify whether the parameter set is complete and has not been tampered with during transmission. The server digital signature is a signature generated by the server using its own private key to encrypt information such as the parameter digest and timestamp. Edge sensing devices can use the server's public key to verify the signature to confirm that the data comes from a legitimate server. For example, the server uses an RSA private key to encrypt the combination of parameter digest and timestamp data to generate an encrypted string as a digital signature.

[0073] D is a one-dimensional data group formed by sequentially concatenating the various parameters (such as intrinsic parameter matrix elements, distortion coefficients, etc.) in the optimized parameter set. This facilitates encryption operations. For example, parameters such as intrinsic parameter matrices fx=1000, fy=1000, cx=960, cy=540, distortion coefficients k1=-0.1, k2=0.02, and coordinate mapping scale s=0.001 are converted to integers (e.g., multiplied by 1000 to convert to integers) and concatenated into a data group like [1000000, 1000000, 960000, 540000, -100, 20, 1]. Specifically, this involves converting floating-point numbers and other data types in the parameter set to integers through programming, and then sequentially combining them into a list or array.

[0074] The preset random permutation matrix is ​​a pre-defined matrix with elements of 0 or 1, and each row and column containing only one 1. It is used to scramble the data set D, increasing the disorder of the data and improving encryption security. For example, for a data set D of length 7, the random permutation matrix M might be [001000001000001000000000010000000100001000000001]. Multiplying it by D can change the order of the elements in D. Multiple random permutation matrices are pre-generated and stored on the server side, and one is randomly selected for use during encryption. Matrix multiplication can be performed using the NumPy library.

[0075] The dynamic offset, generated based on the device's unique identifier, is a dynamic value used to further obfuscate the scrambled data during encryption. For example, if the MAC address of the edge device is 00:11:22:33:44:55, a hash operation is performed on it, and after converting it to an integer, a dynamic offset is generated by combining it with partial information from the current timestamp. Specifically, this involves obtaining the unique identifier of the edge device, converting it into a numerical value using a hash algorithm (such as SHA-1), and then generating a dynamic offset by combining factors such as time.

[0076] In the RSA encryption system, a randomly selected integer that is coprime to (p-1)(q-1) is a component of the public key used for encryption. It needs to be randomly selected and satisfy the condition of being coprime to (p-1)(q-1) to ensure the effectiveness and security of encryption. For example, if p=61 and q=53 (both are large prime numbers), then (p-1)(q-1)=60×52=3120. If e=17 is randomly selected, 17 and 3120 are coprime (the greatest common divisor is 1).

[0077] The response body is the data packet that the server returns to the edge sensing device. It contains encrypted parameter sets and additional verification information. For example, the encrypted parameter sets and additional verification information are organized in a specific format (such as JSON) into a response body of {encrypted_params: encrypted parameter string, param_digest: parameter digest, timestamp: timestamp, digital_signature: digital signature}. Specifically, web frameworks such as FastAPI are used to organize the data into a JSON format response body.

[0078] The HTTPS protocol is an HTTP protocol based on SSL / TLS, used for secure communication between servers and edge sensing devices to ensure the confidentiality, integrity and authenticity of data transmission. For example, SSL / TLS certificates can be configured on the server side, and a web service framework that supports HTTPS can be used (such as FastAPI combined with Uvicorn to configure SSL).

[0079] The beneficial effects of the above technical solution are as follows: by encrypting the optimized camera calibration parameter set in multiple steps and generating additional verification information containing parameter digest, timestamp and server digital signature, and then using the HTTPS protocol for transmission, the security of parameters during transmission is guaranteed, and the edge sensing device can verify the integrity, timeliness and legality of the data source, thus providing strong support for the reliable transmission of camera calibration parameters.

[0080] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.

Claims

1. A camera calibration service method for coupled edge sensing devices, characterized in that, include: Step 1: The server-side builds a camera calibration interface service based on FastAPI. The interface service includes an interface for receiving requests from edge sensing devices and adopts the POST method. The request parameters include ground control point calibration information file, image width, and image height. Step 2: The edge sensing device uploads the required calibration parameters through the service interface. After parsing the request, the server starts the camera calibration algorithm. The specific operations of the camera calibration algorithm include: Initialize the camera intrinsic parameter matrix, where the initial value of the focal length is set to the image width, and the initial value of the principal point coordinates is set to the image center. The distortion coefficients are initialized to [0,0,0,0,0], where the first three terms are radial distortion coefficients and the last two terms are tangential distortion coefficients; Extract the world coordinates (Xn, Yn, Zn) and corresponding pixel coordinates (in, jn) of at least four ground control points from the ground control point calibration information file; Based on the coordinates of the ground control points and the initial intrinsic parameter matrix, the camera rotation matrix R and translation vector t are solved to determine the camera pose. Based on the camera intrinsic parameter matrix, camera pose and distortion coefficient, calculate the ideal projected coordinates of the ground control points and the actual projected coordinates after radial distortion correction. Calculate the reprojection error and optimize the focal length based on the differential evolution algorithm. and radial distortion coefficient This minimizes the reprojection error. Based on the optimized intrinsic parameter matrix and distortion coefficients, the maximum and minimum values ​​of the corrected image coordinates and corresponding world coordinates of the ground control points in the horizontal and vertical directions are calculated to obtain the pixel-world coordinate mapping ratio. Step 3: The server sends the optimized intrinsic parameter matrix, distortion coefficients, and coordinate mapping ratio back to the edge sensing device via an interface response; Step 4: The interface service is deployed on an intranet server based on a container, supporting remote calls and parameter updates from edge sensing devices.

2. The camera calibration service method for coupled edge sensing devices according to claim 1, characterized in that, The focal length optimization range is 0.25 to 2 times the image width. The optimization range is [-0.9, 0.9]. The optimization range is [-0.5, 0.5], and the termination condition is absolute tolerance atol = 0.

002.

3. The camera calibration service method for coupled edge sensing devices according to claim 1, characterized in that, The initial form of the camera intrinsic parameter matrix for: ; in, This indicates the focal length; the initial default focal length is the image width. This represents the principal point coordinates, with the initial default principal point coordinates being the image center.

4. The camera calibration service method for coupled edge sensing devices according to claim 3, characterized in that, The actual projected coordinates after radial distortion correction are calculated using the following formula: Where (u,v) are the ideal projection coordinates; r is the coordinates from point (u,v) to the principal point. The distance; These are the projected coordinates after radial distortion correction.

5. The camera calibration service method for coupled edge sensing devices according to claim 1, characterized in that, The reprojection error is: in, This represents the pixel coordinates of the ground control points on the image. This represents the theoretical coordinates of the control points projected onto the image plane using the current camera parameters, where N represents the number of control points.

6. The camera calibration service method for coupled edge sensing devices according to claim 1, characterized in that, The response parameters of the service interface include status code, request timestamp, runtime, error code, error description, and calibration results. The calibration results include coordinate mapping ratio, intrinsic parameter matrix, and distortion coefficient.

7. The camera calibration service method for coupled edge sensing devices according to claim 1, characterized in that, Step 2 includes: Based on the preset parameter mapping table, the fields of the calibration request body are extracted, the ground control point calibration information file is converted into structured data, and the data type and range rationality of the image width and image height are verified. After parsing, a multi-level verification mechanism is initiated, including: verifying whether the number of ground control points is not less than 4 and whether the correspondence between world coordinates and pixel coordinates is unique; and verifying whether the aspect ratio of the image conforms to common resolution standards. When all verification items pass, a calibration task token containing the parsed parameters is automatically generated. The task token is bound to the unique identifier of the request through a hash algorithm. Then, the task scheduler is triggered to call the initialization function of the camera calibration algorithm and the parameter set corresponding to the token is passed to the algorithm execution environment through memory mapping. At the same time, the process monitoring thread is started to detect the algorithm initialization status in real time. If the algorithm startup success signal is not received within a preset time period, the call is automatically re-initiated and the exception log is recorded. The server-side verification of the correspondence between the world coordinates (Xn, Yn, Zn) and pixel coordinates (in, jn) of ground control points includes: The mapping confidence score between world coordinates and pixel coordinates is calculated. When the same world coordinate corresponds to multiple pixel coordinates and the mapping confidence score for each pixel coordinate exceeds the confidence score threshold, the correspondence between world coordinates and pixel coordinates is determined to be non-unique. If it is determined to be non-unique, cluster analysis is performed on the multiple pixel coordinates corresponding to the same world coordinate, the cluster center coordinates are selected as the optimal matching pixel coordinates, and the intra-cluster divergence is calculated as the ambiguity. ,in, The preset attenuation coefficient; For pixel coordinates pi1= The Euclidean distance to the center coordinates of the field of view of the edge sensing device; n1 represents the center coordinates of the corresponding cluster; n1 represents the total number of pixel coordinates in the cluster. For pixel coordinates pi1= The penalty coefficient, For the conditional function, and , The preset planar distance threshold; For pixel coordinates pi1= The corresponding three-dimensional world coordinates, AX+BY+CZ+D=0, are the fitted plane equations; If the ambiguity exceeds a preset pixel threshold, a secondary verification process is triggered, sending a request to the edge sensing device to upload a local high-resolution image of the point corresponding to the world coordinates.

8. The camera calibration service method for coupled edge sensing devices according to claim 1, characterized in that, The process of the interface response being fed back to the edge sensing device includes: The optimized parameter set is then processed according to the encryption function. Encryption is performed, and additional verification information including a parameter digest, timestamp, and server digital signature is generated. This is the data set obtained by concatenating the optimized parameter set; The matrix is ​​a pre-defined random permutation matrix; This is a dynamic offset generated based on the device's unique identifier; For random selection and with Coprime integers, , It is a large prime number; The bitwise XOR symbol; The encrypted parameter set and additional verification information are packaged into a response body and sent back to the edge sensing device via the HTTPS protocol.

Citation Information

Patent Citations

  • Method and device for positioning crowds in multiple public places, electronic equipment and medium

    CN118608611A

  • DMS camera calibration method based on computer vision

    CN121053226A