Camera parameter determination method and device, electronic equipment and storage medium
By screening and optimizing matching point pairs in camera images, candidate camera parameters are determined, which solves the problem of low recall rate of online camera calibration in mobile products and achieves accurate and efficient camera parameter calibration.
Patent Information
- Application Number
- CN202310226148.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-02
- Publication Date
- 2024-09-03
AI Technical Summary
Existing online camera calibration solutions have a low recall rate in mobile products, making it difficult to accurately determine camera parameters without considering the characteristics of image content.
Determine the candidate camera internal and external parameters based on multiple matching point pairs based on the camera image, filter out the matching point pairs that meet the preset conditions, select the group with the largest number of candidate matching point pairs as the initial camera parameters, and adjust them through nonlinear optimization Get target camera parameters.
Without considering the characteristics of the image content, universal calibration of camera parameters is achieved, with small error and high recall rate, and the camera internal parameters can be accurately determined.
Smart Images

Figure CN118587294A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision technology, and in particular to a method, device, electronic device and storage medium for determining camera parameters. Background Art
[0002] Camera calibration can basically be divided into two types: offline calibration and online calibration. Offline calibration usually relies on calibration reference objects to achieve camera calibration. Online calibration is when the camera captures surrounding objects and achieves camera self-calibration through digital image processing methods and related geometric calculations.
[0003] For some mobile products, camera parameters are not provided when they leave the factory. Therefore, when implementing related applications based on such mobile products, the required camera parameters need to be obtained through online calibration. However, the existing online calibration scheme requires that the images collected during calibration contain some calibration points or stable line segment features, making it difficult to guarantee the recall rate of the above online calibration scheme. Summary of the invention
[0004] According to one aspect of the present disclosure, a method for determining camera parameters is provided, comprising:
[0005] Determine candidate camera extrinsic parameters corresponding to multiple groups of candidate camera intrinsic parameters based on multiple matching point pairs of the camera image, wherein the matching point pairs include two-dimensional imaging points contained in the camera image and three-dimensional space points matching the two-dimensional imaging points;
[0006] Filtering candidate matching point pairs that meet preset conditions from the plurality of matching point pairs based on each group of candidate camera internal parameters;
[0007] A group of the candidate camera intrinsic parameters having the largest number of candidate matching point pairs and the candidate camera extrinsic parameters corresponding to the candidate camera intrinsic parameters are used as initial camera parameters, and the corresponding initial camera parameters are adjusted based on the candidate matching points corresponding to the initial camera parameters to obtain target camera parameters.
[0008] According to another aspect of the present disclosure, a device for determining camera parameters is provided, comprising:
[0009] An initialization module is used to determine candidate camera extrinsic parameters corresponding to multiple groups of candidate camera intrinsic parameters based on multiple matching point pairs of the camera image, wherein the matching point pairs include two-dimensional imaging points contained in the camera image and three-dimensional space points matching the two-dimensional imaging points; and to filter out candidate matching point pairs that meet preset conditions from the multiple matching point pairs based on each group of the candidate camera intrinsic parameters;
[0010] a parameter optimization module, configured to use a group of the candidate camera intrinsic parameters having the largest number of candidate matching point pairs and the candidate camera extrinsic parameters corresponding to the candidate camera intrinsic parameters as initial camera parameters, and adjust the corresponding initial camera parameters based on the candidate matching points corresponding to the initial camera parameters to obtain target camera parameters.
[0011] According to another aspect of the present disclosure, there is provided an electronic device, comprising:
[0012] processor; and,
[0013] A memory for storing programs;
[0014] The program includes instructions, which, when executed by the processor, cause the processor to perform the method according to the exemplary embodiment of the present disclosure.
[0015] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium is provided, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to cause the computer to execute the method according to the exemplary embodiments of the present disclosure.
[0016] One or more technical solutions provided in the embodiments of the present disclosure can determine the candidate camera extrinsic parameters corresponding to multiple groups of candidate camera intrinsic parameters based on multiple matching point pairs of the camera image, and then screen out candidate matching point pairs that meet preset conditions from multiple matching point pairs based on each group of the candidate camera intrinsic parameters, so as to eliminate matching point pairs with poor reliability from multiple matching point pairs corresponding to each group of the candidate camera intrinsic parameters. The more candidate matching point pairs corresponding to the group of candidate camera intrinsic parameters, the closer the group of candidate camera intrinsic parameters is to the real candidate camera intrinsic parameters. Therefore, the group of candidate camera intrinsic parameters with the largest number of candidate matching point pairs and the candidate camera extrinsic parameters corresponding to the group of candidate camera intrinsic parameters can be used as initial camera parameters, and the corresponding initial camera parameters can be adjusted based on the candidate matching points corresponding to the initial camera parameters to obtain target camera parameters with relatively small errors. Therefore, the exemplary embodiment method of the present disclosure can universally calibrate camera parameters without considering the characteristics of the image content, and the error of the determined camera intrinsic parameters is relatively small, with a good recall rate. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Further details, features and advantages of the present disclosure are disclosed in the following description of exemplary embodiments in conjunction with the accompanying drawings, in which:
[0018] Figure 1 A schematic diagram of a pinhole camera model is shown;
[0019] Figure 2 A flowchart showing a method of an exemplary embodiment of the present disclosure is shown;
[0020] Figure 3 A curve diagram showing a change in the number of points within a bureau corresponding to different candidate focal lengths of an exemplary embodiment of the present disclosure is shown;
[0021] Figure 4 A schematic diagram of camera intrinsic parameter results of single-frame solution of different frame camera images of an exemplary embodiment of the present disclosure is shown;
[0022] Figure 5 A schematic diagram of camera intrinsic parameter results of multi-frame solution of different frame camera images of an exemplary embodiment of the present disclosure is shown;
[0023] Figure 6 A schematic block diagram of functional modules of a device for determining camera parameters according to an exemplary embodiment of the present disclosure is shown;
[0024] Figure 7 A schematic block diagram of a chip according to an exemplary embodiment of the present disclosure is shown;
[0025] Figure 8 A structural block diagram of an exemplary electronic device that can be used to implement the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0026] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0027] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0028] The term "including" and its variations used in this document are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions of other terms will be given in the description below. It should be noted that the concepts of "first", "second", etc. mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0029] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0030] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0031] Before introducing the embodiments of the present disclosure, the following definitions are given for the relevant terms involved in the embodiments of the present disclosure:
[0032] The n-point perspective problem (Perspective-n-Point, PnP) is a method to solve the motion from a 3D point to a 2D point pair. It describes how to estimate the position of the camera when we know n 3D space points and their projection positions.
[0033] The Random Sample Consensus (RANSAC) algorithm is an algorithm that calculates the mathematical model parameters of the data based on a sample data set containing abnormal data to obtain valid sample data. When using the mathematical model to test the matching point pair, if the error of the matching point pair is within the set error threshold, the matching point pair is called an internal matching point pair, otherwise it is called an external matching point pair.
[0034] Nonlinear optimization methods are basically iterative methods: given a starting point x0, continuously iterate to generate new x1, x2, ..., and finally converge to x*.
[0035] Bundle Adjustment (BA) refers to the simultaneous adjustment of the camera posture and feature point positions so that the bundles of light rays reflected from each feature point can finally pass through the camera optical center through adjustment.
[0036] The reprojection error refers to the difference between the projection of a real three-dimensional space point on the image plane (that is, the pixel point on the image) and the reprojection (actually a virtual pixel point obtained by calculating the value).
[0037] Figure 1 A schematic diagram of the pinhole camera model is shown in FIG. Figure 1 As shown in the typical pinhole camera model, the camera is regarded as a pinhole (point O). The three-dimensional space point P in the real world passes through the optical center O of the camera and is projected onto the physical imaging plane to become a two-dimensional imaging point P'.
[0038] There are three coordinate systems in the pinhole imaging model, namely the camera coordinate system, the world coordinate system and the pixel coordinate system. For the camera coordinate system, it is located in the camera lens plane, the Zc axis points to the front of the camera, the Xc axis points to the right of the camera, and the Yc axis points to the bottom of the camera. O is the center of the camera coordinate system, that is, the optical center of the camera, which is also the pinhole in the pinhole model. For the world coordinate system, it is the coordinate system of the real world. For the pixel coordinate system, it is located in the physical imaging plane. O' is the principal point of the physical imaging plane, located in the upper left corner of the image, the X axis points to the right of the camera, parallel to the Xc axis, and the Y axis points to the bottom of the camera, parallel to the Yc axis. Suppose the coordinates of the three-dimensional space point P in the world coordinate system are [X, Y, Z] T , the coordinates of the two-dimensional imaging point P' are (X', Y', Z'), the distance between the camera optical center O and the principal point O' of the imaging plane is the focal length, and the three-dimensional space point P and the corresponding two-dimensional space point P' can realize the coordinate transformation through the camera intrinsic parameters and camera extrinsic parameters.
[0039] In related technologies, camera intrinsic parameters are related to the physical properties of the camera itself, and a calibration plate can be used to calibrate the camera intrinsic parameters to obtain an intrinsic parameter matrix. However, considering that mobile applications may not be able to obtain existing calibration results in advance, it is necessary to use the marking point or vanishing point method to estimate the intrinsic parameters online, resulting in a low recall rate for the online calibration intrinsic parameter solution.
[0040] The exemplary embodiments of the present disclosure provide a method for determining camera parameters, which can universally calibrate camera parameters without considering the characteristics of image content, and the error of the determined camera intrinsic parameters is relatively small and has a good recall rate. It should be understood that the method of the exemplary embodiments of the present disclosure can be applied to electronic devices with cameras, video cameras, or image acquisition functions.
[0041] The electronic device may be a smart phone (such as an Android phone, an iOS phone), a wearable device, an AR (augmented reality)\VR (virtual reality) device, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), a tablet computer, a PDA, a mobile internet device (MID), or other devices using flash memory devices. The electronic device is equipped with a camera, which may be a monocular camera, a binocular camera, or the like, and the image collected by the camera may be a grayscale image, a color image, a thermal image, or the like, but is not limited thereto.
[0042] The method of the exemplary embodiments of the present disclosure may be executed by an electronic device or a chip used in the electronic device. Figure 2A flow chart of a method of an exemplary embodiment of the present disclosure is shown. Figure 2 As shown, the method of the exemplary embodiment of the present disclosure may include:
[0043] Step 201: Determine candidate camera extrinsic parameters corresponding to multiple candidate camera intrinsic parameters based on multiple matching point pairs of the camera image, where the matching point pairs may include two-dimensional imaging points contained in the camera image and three-dimensional space points matched with the two-dimensional imaging points. The number of matching point pairs formed by two-dimensional imaging points and three-dimensional feature points may be multiple, which is determined according to actual needs.
[0044] In practical applications, the camera image can be a static image (i.e., a picture) or a frame in a dynamic image (i.e., a video). The camera image can be taken by a camera whose camera parameters need to be calibrated, which can be a camera carried by an electronic device, or another camera independent of the electronic device or a camera carried by another device. After acquiring the camera image, a three-dimensional reconstruction technology combined with a feature matching algorithm can be used to find the three-dimensional space point corresponding to the two-dimensional imaging point.
[0045] The camera parameters of the exemplary embodiment of the present disclosure include camera extrinsic parameters and camera intrinsic parameters. The function of the camera extrinsic parameters is to transform the coordinates from the world coordinate system to the camera coordinate system, which may include the rotation matrix R and the translation vector t. The rotation matrix R and the translation vector t can describe the camera posture, while the camera intrinsic parameters may include the camera principal point position and the camera focal length, so as to realize the coordinate conversion between the point in the camera coordinate system and the pixel coordinate system.
[0046] Exemplarily, the method of the exemplary embodiment of the present disclosure may further include: determining the candidate principal point position based on the camera image, and determining multiple groups of candidate camera intrinsic parameters based on the candidate principal point position and multiple candidate camera focal lengths. Considering that the camera's two-dimensional imaging point and three-dimensional imaging point are mainly determined by the camera intrinsic parameters, camera extrinsic parameters and distortion parameters during the matching process, the camera intrinsic parameters include the camera principal point position and the camera focal length. Among them, the coordinates of the camera principal point position are approximately located at the center of the image. It can be assumed that the candidate principal point positions contained in each group of candidate camera intrinsic parameters are the same, and the mobile terminal camera can be approximately distortion-free. It can be seen that the accuracy of the camera focal length calibration result has the greatest impact on the user experience. Therefore, when calibrating the camera parameters, it can be assumed that the camera distortion corresponding to different candidate camera intrinsic parameters is zero, and the candidate principal point positions included in different candidate camera intrinsic parameters are the same. Based on this, the candidate camera focal lengths contained in each group of candidate camera intrinsic parameters can be set to be different, and the method of the exemplary embodiment of the present disclosure can be used to find the best camera focal length, thereby reducing the amount of intrinsic parameters that need to be calibrated.
[0047] In some embodiments, after acquiring the camera image, the coordinates of the candidate principal point position can be acquired based on the width w and height h of the camera image. Considering the characteristic that the principal point coordinates are located at the center of the camera image, the horizontal coordinate Cx of the candidate principal point position is w / 2, and the vertical coordinate Cy is h / 2. Here, the units of Cx and Cy can be pixel units or actual size units.
[0048] The above-mentioned multiple candidate camera focal lengths can be sampled and determined within a certain interval range, and the interval range can be obtained based on actual experience or can be an interval determined through a large number of statistics, and a candidate camera focal length is determined at a certain sampling interval within the interval range. For example, if the interval range is 300mm to 1500mm, a candidate camera focal length can be determined every 50mm within the interval range of 300mm to 1500mm, thereby obtaining 25 candidate camera focal lengths, namely 300mm, 350mm, 400mm, 450mm, 500mm, 550mm, 600mm, 650mm, 700mm, 750mm, 800mm, 850mm, 900mm, 950mm, 1000mm, 1050mm, 1100mm, 1150mm, 1200mm, 1250mm, 1300mm, 1350mm, 1400mm, 1450mm and 1500mm.
[0049] Exemplarily, a preset image that matches the camera image features can be searched from the multi-view preset images to obtain a target preset image, and then based on the mapping relationship between the target preset image and the three-dimensional reconstruction model, the two-dimensional imaging points included in the camera image and the three-dimensional space points that match the two-dimensional imaging points are determined.
[0050] For example, a large number of various preset images of different perspectives can be collected in advance, and these preset images contain at least part of the target. The target is reconstructed in three dimensions based on multiple preset images, so as to capture the three-dimensional reconstruction model of the target. On this basis, when a camera image containing the target is acquired by a camera, various feature point detection algorithms can be used to detect feature points in the camera image and each preset image. The feature point detection algorithm here can include Laplacian detection algorithm, Difference of Gaussian (DOG) algorithm, gradient covariance matrix detection method of corner point position, etc.
[0051] After the feature points of the camera image and each preset image are detected, the Euclidean distance between the descriptors can be compared, and the feature points of the camera image and the preset image corresponding to the Euclidean distance less than the set threshold can be matched. The nearest neighbor feature points can also be searched in the feature space to determine the feature point matching relationship.
[0052] When a preset image of a certain perspective that matches each feature point of the camera image is found, the preset image is the target preset image, and then the three-dimensional space points mapped by the feature points of the target preset image in the three-dimensional reconstruction model are used as the three-dimensional space points that match the two-dimensional imaging points of the camera image, thereby obtaining each matching point pair of the camera image.
[0053] Exemplarily, the camera pose corresponding to each set of candidate camera intrinsic parameters, that is, the candidate camera extrinsic parameters corresponding to the candidate camera intrinsic parameters, can be determined by solving the PnP problem. For example, the direct linear transformation (DLT) solution can be used to solve the PnP problem, and the EPnP solution can also be used to solve the PnP problem.
[0054] Taking the DLT solution as an example, the coordinates of the two-dimensional imaging point and the coordinates of the matching three-dimensional space point can be converted through the projection matrix M. The relationship between the projection matrix M, the candidate camera extrinsic parameters and the candidate camera intrinsic parameters can be expressed as projection matrix M = candidate camera extrinsic parameters * candidate camera intrinsic parameters. Therefore, the corresponding projection matrix M can be solved first through multiple known matching point pairs. When solving the candidate camera extrinsic parameters corresponding to the candidate camera intrinsic parameters, the candidate camera intrinsic parameters can be used as known conditions, and a linear equation system with the candidate camera extrinsic parameters as unknown quantities can be constructed through the projection matrix M corresponding to multiple known matching point pairs. The candidate camera extrinsic parameters corresponding to the candidate camera intrinsic parameters are obtained by solving the linear equation system.
[0055] Step 202: Based on each group of candidate camera internal parameters, candidate matching point pairs that meet preset conditions are screened out from multiple matching point pairs. The method for screening out candidate matching point pairs that meet preset conditions may be a random sampling consistency method, and the candidate matching point pairs that meet preset conditions include matching point pairs obtained when the fitting model in the random sampling consistency method reaches a preset iteration termination condition. When the random sampling consistency method is used to screen candidate matching point pairs from multiple matching point pairs, if the fitting model reaches the iteration termination condition, the fitting model can be considered to be the optimal fitting model.
[0056] In some embodiments, assuming that the total number of matching point pairs is M, for each set of candidate camera intrinsic parameters, K first matching point pairs can be randomly selected from multiple matching point pairs, and they are assumed to be intra-local matching point pairs, and then an initial fitting model is fitted based on the K first matching point pairs and the candidate camera intrinsic parameters, and then the initial fitting model is used to test J second matching point pairs, and matching point pairs less than or equal to the set error are screened out as intra-local matching point pairs, and the intra-local matching points obtained by the screening are used to update the initially assumed intra-local matching point pairs. It should be understood that K+J=M, M is an integer greater than 3, K is an integer greater than 1, and J is an integer greater than or equal to 0.
[0057] Before using the screened intra-office matching points to update the initially assumed intra-office matching point pairs, it can be determined whether the fitted model has reached a preset iteration termination condition. If the iteration termination condition is reached, the fitting model is considered to be optimal and the iteration of the fitting model can be terminated. Otherwise, continue to update the historically determined intra-office matching point pairs based on the screened intra-office matching points.
[0058] The preset iteration termination conditions of the random sampling consistency method corresponding to the above-mentioned groups of candidate camera intrinsic parameters are the same. Based on this, when the random sampling consistency method is used to screen the candidate matching point pairs corresponding to each group of candidate camera intrinsic parameters, the iteration of the fitting model can be terminated on the basis that the fitting model reaches the same preset iteration termination condition to obtain the candidate matching point pairs. Therefore, when the preset iteration termination conditions of the random sampling consistency method corresponding to each group of candidate camera intrinsic parameters are the same, it can be ensured that when the number of candidate matching point pairs corresponding to different groups of candidate camera intrinsic parameters is compared, the preconditions (that is, when the fitting models corresponding to each group of candidate camera intrinsic parameters reach the same preset iteration termination condition, the iteration of the fitting model is stopped to obtain the candidate matching point pairs) are the same, thereby reducing the comparison error caused by different preconditions.
[0059] The preset iteration termination conditions of the exemplary embodiment of the present disclosure may include that the error rate of the fitting model is less than the preset error rate, and may also include that the number of iterations is greater than or equal to the preset number, and may also include: the number of matching point pairs within the bureau remains constant. The constant here may mean that the number of matching point pairs within the bureau is consistent within a consecutive preset number of times, or fluctuates within a certain range.
[0060] Taking the preset iteration termination condition including that the error rate of the fitting model is less than the preset error rate as an example, M matching point pairs can be substituted into the fitting model to determine the number of matching point pairs greater than the set error, and the matching point pairs greater than the set error are defined as incorrect matching point pairs. Based on the number of incorrect matching point pairs and the total number of matching point pairs, the error rate of the fitting model can be determined. When the error rate of the fitting model is less than the preset error rate, it indicates that the fitting model has met the preset iteration termination condition. When the error rate of the fitting model is less than or equal to the preset error rate, it indicates that the fitting model has not met the preset iteration termination condition.
[0061] For each set of candidate camera intrinsic parameters, when the random sampling consensus algorithm is used to find the optimal fitting model, the fitting model involved in each iteration process is not only based on the assumed local matching point pairs, but also takes the candidate camera intrinsic parameters as the known parameters of the fitting model, and solves the unknown parameters based on the known parameters and the extracted K matching points, thereby fitting the fitting model. The unknown parameters can be considered as camera extrinsics or camera postures.
[0062] Step 203: taking a group of candidate camera intrinsic parameters with the largest number of candidate matching point pairs and candidate camera extrinsic parameters corresponding to the group of candidate camera intrinsic parameters as initial camera parameters, adjusting corresponding initial camera parameters based on candidate matching points corresponding to the initial camera parameters, and obtaining target camera parameters.
[0063] The method for adjusting the above initial camera parameters can be a nonlinear optimization method, and the objective function of the nonlinear optimization method can be a reprojection error function. When the BA solution method is used to optimize the initial camera parameters, the candidate matching point pairs corresponding to the initial camera parameters and the initial camera parameters can be used for reprojection, and then the reprojection error is calculated. If the reprojection error is less than the preset error, the optimization is considered to be completed, otherwise the initial camera parameters are updated.
[0064] In practical applications, nonlinear optimization methods such as Gauss-Newton method, gradient descent method or damped least squares method can be used to update the initial camera parameters. For example, when the damped least squares method is used to optimize the initial camera parameters, the three-dimensional space point P in the candidate matching point pair can be i And the initial camera parameters calculate the projection point u of the three-dimensional space point in the pixel coordinate system, and then use each three-dimensional space point P i Matched 2D imaging point Z i The reprojection error is solved by the sum of the squares of the differences between the projection point u and the projection point u, and then whether to continue updating the initial camera parameters is determined based on the reprojection error solution.
[0065] In an optional method, the number of candidate matching point pairs corresponding to the initial camera parameters can be determined. If the number of candidate matching points corresponding to the initial camera parameters is less than or equal to a preset number threshold, the camera image can be updated, and the updated camera image can be used to redetermine the initial camera parameters in the manner of steps 201 and 202.
[0066] If the current camera image is a frame in a video image, the camera image to be updated here may be the next frame of the current camera image, or other frames, or a frame or any picture in any other video image other than the video image. It should be understood that no matter it is a video image or any other video image or any image, the image acquisition device used is the same camera.
[0067] Exemplarily, the method of the exemplary embodiment of the present disclosure may also update the camera image after obtaining the target camera parameters, and if the number of camera image updates is greater than a preset number, weighted summation is performed on the target camera parameters corresponding to the multiple camera images, and the weighted summation result is used as the final target camera parameters. When weighted summation is performed on the target camera parameters corresponding to the multiple camera images, the weights of the target camera parameters corresponding to different camera images may be the same or different.
[0068] When the weights of the target camera parameters corresponding to different camera images are the same, the essence is to add and average the target camera parameters corresponding to different camera images. When the weights of the target camera parameters corresponding to different camera images are different, the weights of the target camera parameters corresponding to different camera images are positively correlated with the number of candidate matching points corresponding to the initial camera parameters. In this case, the original method can be considered as the process of solving the target camera parameters in a single frame, and the weighted summation of the target camera parameters corresponding to multiple camera images is the process of solving the target camera parameters using multiple camera frames. The preset number of times here can be 3 to 5 times, or other times, depending on actual requirements.
[0069] It can be understood that when the number of candidate matching points corresponding to the initial camera parameters is greater, it means that the initial camera parameters are closer to the true values. Therefore, the weight of the target camera parameters corresponding to the camera image can be increased. The smaller the number of candidate matching points corresponding to the corresponding initial camera parameters, the greater the gap between the initial camera parameters and the true values. Therefore, the weight of the target camera parameters corresponding to the camera image can be reduced to ensure the accuracy of the final target camera parameters.
[0070] In an optional manner, the method of the exemplary embodiment of the present disclosure may also include: if the difference between the target camera parameters and the initial camera parameters containing the same attribute is greater than a preset difference threshold, it means that the offset characteristics of the target camera parameters and the initial camera parameters are large and have exceeded a reasonable space, and the target camera parameters may be wrong, so the camera image can be updated to re-determine the target camera parameters, and the original target camera parameters can be cleared to avoid excessive errors introduced when solving the target camera parameters in multiple frames. For example: the focal length contained in the target camera parameters can be compared with the focal length contained in the initial camera parameters. If the focal length contained in the target camera parameters is significantly different from the focal length in the initial camera parameters, the target camera parameters can be deleted to ensure that the camera focal length can be reliably calibrated.
[0071] In order to demonstrate the effectiveness of the method of the exemplary embodiment of the present disclosure, a mobile phone is used as an example to collect a large number of scene pictures online, and some of the pictures are selected to calibrate the camera focal length using the method of the exemplary embodiment of the present disclosure. The following describes the process of estimating the focal length of the target camera using pictures of a certain place collected by a mobile phone camera in conjunction with the accompanying drawings.
[0072] Figure 3 A curve diagram showing the change in the number of points in a candidate matching point pair corresponding to different candidate focal lengths of an exemplary embodiment of the present disclosure is shown, wherein: Figure 3 The horizontal axis is the candidate focal length (in millimeters), and the vertical axis is the number of candidate matching point pairs. Figure 3 As shown in Figure 1, the candidate focal length with the largest number of candidate matching point pairs is 900mm. Figure 3The candidate focal length of 900mm with the largest number of candidate matching point pairs is used as the initial focal length, and the initial principal point position abscissa Cx and the initial principal point position ordinate Cy are solved according to the width and height of a large number of scene images. Then, the above single-frame solution algorithm is used to estimate the target camera intrinsic parameters of different frame camera images. The results are as follows: Figure 4 shown.
[0073] Figure 4 A schematic diagram of camera intrinsic parameter results of single frame solution of different frame camera images of an exemplary embodiment of the present disclosure is shown, wherein: Figure 4 The vertical axis is the internal parameter value (in millimeters), and the horizontal axis is the frame number of the camera image. Figure 4 As shown, the initial focal lengths corresponding to different frames of camera images are optimized, and the obtained target camera focal length f is close to the initial focal length f0, and is relatively stably located between 800mm and 900mm.
[0074] Figure 5 A schematic diagram of camera intrinsic parameter results of multi-frame solution of different frame camera images of an exemplary embodiment of the present disclosure is shown, wherein: Figure 5 The vertical axis is the internal parameter value (in millimeters), and the horizontal axis is the frame number of the camera image. Figure 5 It can be seen that the target camera focal length corresponding to the camera image frame 1 to the camera image frame 9 is quite different from the initial focal length. This is because the number of candidate matching point pairs selected is relatively small. Therefore, the target camera intrinsic parameters corresponding to the target camera focal length corresponding to the camera image frame 1 to the camera image frame 9 can be screened out, that is, simply discarding these target camera intrinsic parameters. Alternatively, the target camera focal length can be determined based on the combination of multiple frames without discarding these target camera intrinsic parameters. It should be understood that, referring to the previous description, it can be considered that the initial principal point position contained in the initial camera intrinsic parameters is the same as the target principal point position contained in the solved camera intrinsic parameters. Therefore, Figure 4 and Figure 5 The difference between the initial principal point position and the target principal point position is not shown.
[0075] Through the above test, it was found that after three online focal length calibrations, within a short time range (2s to 3s), the calibrated camera focal length was 402.246mm, 406.33mm or 406.256mm, while the true value of the focal length was 405mm. It can be seen that the estimated target camera focal length is relatively small compared to the true value of the focal length. Therefore, the target camera focal length estimated by the method of the exemplary embodiment of the present invention is relatively accurate and has good stability, which can improve the coverage of mobile services such as the Visual Positioning Service (VPS).
[0076] One or more technical solutions provided in the embodiments of the present disclosure can determine the candidate camera extrinsic parameters corresponding to multiple groups of candidate camera intrinsic parameters based on multiple matching point pairs of the camera image, and then screen out candidate matching point pairs that meet preset conditions from multiple matching point pairs based on each group of the candidate camera intrinsic parameters, so as to eliminate matching point pairs with poor reliability from multiple matching point pairs corresponding to each group of the candidate camera intrinsic parameters. The more candidate matching point pairs corresponding to the group of candidate camera intrinsic parameters, the closer the group of candidate camera intrinsic parameters is to the real candidate camera intrinsic parameters. Therefore, the group of candidate camera intrinsic parameters with the largest number of candidate matching point pairs and the candidate camera extrinsic parameters corresponding to the group of candidate camera intrinsic parameters can be used as initial camera parameters, and the corresponding initial camera parameters can be adjusted based on the candidate matching points corresponding to the initial camera parameters to obtain target camera parameters with relatively small errors. Therefore, the exemplary embodiment method of the present disclosure can universally calibrate camera parameters without considering the characteristics of the image content, and the error of the determined camera intrinsic parameters is relatively small, with a good recall rate.
[0077] The above mainly introduces the solution provided by the embodiment of the present disclosure from the perspective of an electronic device. It is understandable that, in order to realize the above functions, the electronic device includes a hardware structure and / or software module corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present disclosure.
[0078] The disclosed embodiment can divide the electronic device into functional units according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the disclosed embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0079] In the case of dividing each functional module according to each function, an exemplary embodiment of the present disclosure provides a device for determining camera parameters, and the device for determining camera parameters may be an electronic device or a chip applied to the electronic device. Figure 6 FIG. 1 is a schematic block diagram showing the functional modules of a device for determining camera parameters according to an exemplary embodiment of the present disclosure. Figure 6 As shown, the camera parameter determination device 600 includes:
[0080] Initialization module 601, used to determine candidate camera extrinsic parameters corresponding to multiple groups of candidate camera intrinsic parameters based on multiple matching point pairs of the camera image, and screen out candidate matching point pairs that meet preset conditions from the multiple matching point pairs based on each group of the candidate camera intrinsic parameters, wherein the matching point pairs include two-dimensional imaging points contained in the camera image and three-dimensional space points matching the two-dimensional imaging points;
[0081] The parameter optimization module 602 is used to take a group of the candidate camera intrinsic parameters with the largest number of candidate matching point pairs and the candidate camera extrinsic parameters corresponding to the candidate camera intrinsic parameters as initial camera parameters, and adjust the corresponding initial camera parameters based on the candidate matching points corresponding to the initial camera parameters to obtain target camera parameters.
[0082] In a possible implementation, the candidate camera intrinsic parameters include candidate principal point positions and candidate camera focal lengths, and each of the candidate camera intrinsic parameters contains a different camera focal length; the initialization module 601 is further used to determine the candidate principal point position based on the camera image, and determine multiple candidate camera intrinsic parameters based on the candidate principal point position and multiple groups of candidate camera focal lengths.
[0083] In a possible implementation, the initialization module 601 is also used to search for a preset image that matches the camera image features from a multi-view preset image to obtain a target preset image, and based on a mapping relationship between the target preset image and a three-dimensional reconstruction model, determine the two-dimensional imaging points included in the camera image and the three-dimensional space points that match the two-dimensional imaging points.
[0084] In a possible implementation, the method for screening out candidate matching point pairs that meet preset conditions is a random sampling consistency method, and the preset conditions include that the matching point pairs obtained when the fitting model in the random sampling consistency method reaches a preset iteration termination condition include the candidate matching point pairs. In a possible implementation, the preset iteration termination conditions of the random sampling consistency method corresponding to each group of the candidate camera intrinsic parameters are the same.
[0085] In a possible implementation, the initial camera parameters are adjusted in a nonlinear optimization manner, and the objective function of the nonlinear optimization manner is a projection error function.
[0086] In a possible implementation, the parameter optimization model 602 is further configured to update the camera image if the number of the candidate matching point pairs corresponding to the initial camera parameters is less than or equal to a preset number.
[0087] In a possible implementation, the parameter optimization model 602 is further used to update the camera image. If the update times of the camera image are greater than the prediction times, a weighted sum is performed on the target camera parameters corresponding to the multiple camera images.
[0088] In a possible implementation manner, the weights of the target camera parameters corresponding to different camera images are the same; or,
[0089] The weights of the target camera parameters corresponding to the different camera images are positively correlated with the number of candidate matching points corresponding to the initial camera parameters.
[0090] In a possible implementation, the parameter optimization model 602 is further configured to update the camera image if a difference between the target camera parameters and the initial camera parameters having the same attributes is greater than a preset difference threshold.
[0091] Figure 7 Schematic block diagram of a chip according to an exemplary embodiment of the present disclosure is shown. Figure 7 As shown, the chip 700 includes one or more (including two) processors 701 and a communication interface 702. The communication interface 702 can support the electronic device to perform the data sending and receiving steps in the above method, and the processor 701 can support the electronic device to perform the data processing steps in the above method.
[0092] Optional, such as Figure 7 As shown, the chip 700 also includes a memory 703, which may include a read-only memory and a random access memory, and provides operation instructions and data to the processor. A portion of the memory may also include a non-volatile random access memory (NVRAM).
[0093] In some embodiments, Figure 7 As shown, the processor 701 performs corresponding operations by calling the operation instructions stored in the memory (the operation instructions may be stored in the operating system). The processor 701 controls the processing operations of any one of the terminal devices, and the processor may also be called a central processing unit (CPU). The memory 703 may include a read-only memory and a random access memory, and provides instructions and data to the processor 701. A portion of the memory 703 may also include NVRAM. For example, in an application, the memory, the communication interface, and the memory are coupled together through a bus system, wherein the bus system may include a power bus, a control bus, and a status signal bus in addition to a data bus. However, for the sake of clarity, in Figure 7 Various buses are labeled as bus system 804 .
[0094] The method disclosed in the above-mentioned embodiment of the present disclosure can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above-mentioned processor may be a general-purpose processor, a digital signal processor (digital signal processing, DSP), an ASIC, a field-programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present disclosure can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiment of the present disclosure can be directly embodied as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module may be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory and completes the steps of the above method in conjunction with its hardware.
[0095] The exemplary embodiment of the present disclosure also provides an electronic device, comprising: at least one processor; and a memory connected to the at least one processor in communication. The memory stores a computer program that can be executed by the at least one processor, and the computer program is used to cause the electronic device to perform the method according to the embodiment of the present disclosure when executed by the at least one processor.
[0096] The exemplary embodiments of the present disclosure also provide a non-transitory computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to perform the method according to the embodiments of the present disclosure.
[0097] The exemplary embodiments of the present disclosure further provide a computer program product, including a computer program, wherein when the computer program is executed by a processor of a computer, the computer is used to enable the computer to perform the method according to the embodiments of the present disclosure.
[0098] refer to Figure 8, a block diagram of an electronic device 800 that can be used as a server or client of the present disclosure will now be described, which is an example of a hardware device that can be applied to various aspects of the present disclosure. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0099] like Figure 8 As shown, the electronic device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0100] A plurality of components in the electronic device 800 are connected to the I / O interface 805, including: an input unit 806, an output unit 807, a storage unit 808, and a communication unit 809. The input unit 806 may be any type of device capable of inputting information to the electronic device 800, and the input unit 806 may receive input digital or character information, and generate key signal inputs related to user settings and / or function control of the electronic device. The output unit 807 may be any type of device capable of presenting information, and may include, but is not limited to, a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 808 may include, but is not limited to, a disk, an optical disk. The communication unit 809 allows the electronic device 800 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and may include, but is not limited to, a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chipset, such as a Bluetooth™ device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.
[0101] The computing unit 801 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 801 performs the various methods and processes described above. For example, in some embodiments, the method of the exemplary embodiment of the present disclosure may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 800 via the ROM 802 and / or the communication unit 809. In some embodiments, the computing unit 801 may be configured to perform the method of the exemplary embodiment of the present disclosure in any other appropriate manner (e.g., by means of firmware).
[0102] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0103] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0104] As used in this disclosure, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and / or device (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0105] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0106] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0107] A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.
[0108] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed on a computer, the process or function described in the embodiment of the present disclosure is executed in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, a terminal, a user device or other programmable device. The computer program or instruction may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer program or instruction may be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired or wireless means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server, data center, etc. that integrates one or more available media. The available medium may be a magnetic medium, for example, a floppy disk, a hard disk, a tape; it may also be an optical medium, for example, a digital video disc (DVD); it may also be a semiconductor medium, for example, a solid state drive (SSD).
[0109] Although the present disclosure has been described in conjunction with specific features and embodiments thereof, it is apparent that various modifications and combinations may be made thereto without departing from the spirit and scope of the present disclosure. Accordingly, this specification and the drawings are merely exemplary illustrations of the present disclosure as defined by the appended claims, and are deemed to have covered any and all modifications, variations, combinations or equivalents within the scope of the present disclosure. Obviously, those skilled in the art may make various modifications and variations to the present disclosure without departing from the spirit and scope of the present disclosure. Thus, if these modifications and variations of the present disclosure fall within the scope of the claims of the present disclosure and their equivalents, the present disclosure is also intended to include these modifications and variations.
Claims
1. A method for determining camera parameters, It is characterized in that include: Determine candidate camera extrinsic parameters corresponding to multiple groups of candidate camera intrinsic parameters based on multiple matching point pairs of the camera image, wherein the matching point pairs include two-dimensional imaging points contained in the camera image and three-dimensional space points matching the two-dimensional imaging points; Based on each group of candidate camera internal parameters, filter out candidate matching point pairs that meet preset conditions from the plurality of matching point pairs; A group of the candidate camera intrinsic parameters having the largest number of candidate matching point pairs and the candidate camera extrinsic parameters corresponding to the candidate camera intrinsic parameters are used as initial camera parameters, and the corresponding initial camera parameters are adjusted based on the candidate matching points corresponding to the initial camera parameters to obtain target camera parameters.
2. The method according to claim 1, It is characterized in that The candidate camera intrinsic parameters include candidate principal point positions and candidate camera focal lengths, a plurality of the candidate camera intrinsic parameters contain the same principal point positions, and each of the candidate camera intrinsic parameters contains a different camera focal length, and the method further includes: determining a candidate principal point position based on the camera image; A plurality of sets of candidate camera intrinsic parameters are determined based on the candidate principal point positions and a plurality of candidate camera focal lengths.
3. The method according to claim 1, It is characterized in that The method further comprises: Searching for a preset image matching the camera image feature from the multi-view preset images to obtain a target preset image; Based on the mapping relationship between the target preset image and the three-dimensional reconstruction model, the two-dimensional imaging points included in the camera image and the three-dimensional space points matching the two-dimensional imaging points are determined.
4. The method according to claim 1, It is characterized in that The method for screening out candidate matching point pairs that meet preset conditions is a random sampling consistency method, and the candidate matching point pairs that meet preset conditions include matching point pairs obtained when the fitting model in the random sampling consistency method reaches a preset iteration termination condition.
5. The method according to claim 4, It is characterized in that The preset iteration termination conditions of the random sampling consistency method corresponding to each group of candidate camera intrinsic parameters are the same.
6. The method according to claim 1, It is characterized in that The method of adjusting the initial camera parameters is a nonlinear optimization method, and the objective function of the nonlinear optimization method is a projection error function.
7. The method according to any one of claims 1 to 6, It is characterized in that The method further comprises: If the number of the candidate matching point pairs corresponding to the initial camera parameters is less than or equal to a preset number threshold, the camera image is updated.
8. The method according to any one of claims 1 to 6, It is characterized in that The method further comprises: updating the camera image; If the update number of the camera image is greater than the prediction number, a weighted sum is performed on the target camera parameters corresponding to the plurality of camera images.
9. The method according to claim 8, It is characterized in that The weights of the target camera parameters corresponding to the different camera images are the same; or, The weights of the target camera parameters corresponding to the different camera images are positively correlated with the number of candidate matching points corresponding to the initial camera parameters.
10. The method according to any one of claims 1 to 6, It is characterized in that The method further comprises: If the difference between the target camera parameters and the initial camera parameters in the same attribute parameter is greater than a preset difference threshold, the camera image is updated.
11. A device for determining camera parameters, It is characterized in that include: an initialization module, configured to determine candidate camera extrinsic parameters corresponding to multiple groups of candidate camera intrinsic parameters based on multiple matching point pairs of the camera image, and to screen candidate matching point pairs satisfying preset conditions from the multiple matching point pairs based on each group of the candidate camera intrinsic parameters, wherein the matching point pairs include two-dimensional imaging points contained in the camera image and three-dimensional space points matching the two-dimensional imaging points; a parameter optimization module, configured to use a group of the candidate camera intrinsic parameters having the largest number of candidate matching point pairs and the candidate camera extrinsic parameters corresponding to the candidate camera intrinsic parameters as initial camera parameters, and adjust the corresponding initial camera parameters based on the candidate matching points corresponding to the initial camera parameters to obtain target camera parameters.
12. An electronic device, It is characterized in that include: processor; as well as, A memory for storing programs; The program includes instructions, which, when executed by the processor, cause the processor to perform the method according to any one of claims 1 to 10.
13. A non-transitory computer-readable storage medium, It is characterized in that The non-transitory computer-readable storage medium stores computer instructions for causing the computer to execute the method according to any one of claims 1 to 10.
