CN-121619498-B - Camera focal length control method, system, equipment and medium based on target imaging
Abstract
A camera focal length control method, system, equipment and medium based on target imaging relates to the technical field of data processing. The method comprises the steps of obtaining expected imaging parameters and the current height of the unmanned aerial vehicle, determining a focal length traversing range and a stepping interval according to the expected imaging parameters and the current height of the unmanned aerial vehicle, and controlling a camera to acquire an image sequence in the range. And carrying out target detection on each frame of image, calculating imaging size and center offset of a target area, and carrying out offset correction to obtain imaging parameters under each focal length. And screening out the target focal length meeting the threshold value by calculating the deviation between the imaging parameter and the expected parameter. And then, performing definition calculation on the area corresponding to the target focal length, and compensating according to the attitude angle and the flying speed information of the unmanned aerial vehicle to obtain a final definition value. And selecting the focal length corresponding to the maximum definition as the optimal focal length, and controlling the camera to finish focusing. By implementing the technical scheme provided by the application, the accuracy of camera focal length control can be improved.
Inventors
- HUANG YU
- ZHANG LIANG
- ZHOU HAO
- HE LIJIE
Assignees
- 北京中电联达信息技术有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20260114
Claims (10)
- 1. A method for controlling a focal length of a camera based on target imaging, comprising: acquiring expected imaging parameters and the current flight altitude of the unmanned aerial vehicle; determining a focal length traversing range and a focal length stepping interval according to the current flying height, controlling a camera lens of the unmanned aerial vehicle to carry out traversing acquisition at the focal length stepping interval in the focal length traversing range, and determining an image acquisition sequence; performing target detection on each frame of image in the image acquisition sequence, determining a target area, acquiring imaging width and imaging height of the target area, and calculating offset distance between the geometric center of the target area and the image center; Correcting the imaging width and the imaging height based on the offset distance to obtain imaging size parameters under a plurality of focal lengths; Calculating the size deviation value of the imaging size parameter and the target expected imaging parameter under each focal length, and screening out the target focal length of which the size deviation value is smaller than a preset threshold value; performing image definition calculation on a tracking area corresponding to the target focal length, and determining a first image definition; acquiring attitude angle information and flight speed information of the unmanned aerial vehicle, and performing attitude compensation on the first image definition according to the attitude angle information and the flight speed information to obtain a second image definition; And taking the target focal length corresponding to the maximum definition of the second image as the focal length of the camera to be adjusted, and controlling the camera lens of the unmanned aerial vehicle to adjust to the focal length of the camera to be adjusted.
- 2. The method of claim 1, wherein the determining a focus traversal range and a focus step interval from the current fly-height comprises: Acquiring a minimum focal length value and a maximum focal length value of a camera lens of the unmanned aerial vehicle; inquiring a preset height-focal length mapping table according to the current flying height, and determining a recommended focal length central value corresponding to the current flying height; respectively expanding a preset focal length range to the directions of the minimum focal length value and the maximum focal length value by taking the recommended focal length central value as a reference to obtain the focal length traversing range; And determining the focal length stepping interval according to the ratio of the span of the focal length traversing range to the preset traversing frame number.
- 3. The method of claim 1, wherein said calculating the offset distance of the geometric center of the target region from the image center comprises: extracting boundary frame coordinates of the target area, wherein the boundary frame coordinates comprise an upper left corner coordinate and a lower right corner coordinate; calculating the geometric center coordinate of the target area according to the boundary frame coordinate, wherein the geometric center coordinate is the midpoint coordinate of the upper left corner coordinate and the lower right corner coordinate; acquiring an image center coordinate of a current image in the image acquisition sequence; calculating coordinate difference values of the geometric center coordinates and the image center coordinates in the horizontal direction and the vertical direction; and calculating the offset distance by using a Euclidean distance formula based on the coordinate difference value in the horizontal direction and the coordinate difference value in the vertical direction.
- 4. The method of claim 1, wherein said correcting said imaging width and said imaging height based on said offset distance results in imaging dimensional parameters at a plurality of focal lengths, comprising: traversing the imaging width and the imaging height according to a preset focal length scale to obtain sub-imaging widths and sub-imaging heights corresponding to a plurality of focal lengths Judging whether the target area is positioned in the central area of the image according to the offset distance for each focal length; If the target area is positioned in the image center area, taking the sub-imaging width and the sub-imaging height corresponding to the focal length as imaging size parameters under the focal length; if the target area is not located in the image center area, calculating a perspective distortion correction coefficient according to the offset distance and the distortion parameter of the camera lens; and carrying out compensation calculation on the sub-imaging width and the sub-imaging height corresponding to the focal length based on the perspective distortion correction coefficient to obtain imaging size parameters under the focal length.
- 5. The method of claim 4, wherein calculating perspective distortion correction coefficients based on the offset distance and a distortion parameter of the camera lens comprises: Acquiring a radial distortion coefficient and a tangential distortion coefficient of the camera lens; calculating radial offset and tangential offset of the target area in the image according to the offset distance; calculating a first dimensional error introduced by radial distortion based on the radial distortion coefficient and the radial offset; calculating a second size error introduced by tangential distortion based on the tangential distortion coefficient and the tangential offset; vector synthesis is carried out on the first size error and the second size error, and a distortion error value is obtained; and determining a perspective distortion correction coefficient according to the ratio of the distortion error value to the reference size value of the camera lens.
- 6. The method of claim 1, wherein the calculating the image sharpness for the tracking area corresponding to the target focal length to determine the first image sharpness includes: Extracting a target area in the image corresponding to the target focal length as a tracking area; graying treatment is carried out on the tracking area, so that a gray image is obtained; Performing edge detection on the gray level image by adopting a Sobel operator, and calculating the gradient amplitude of each pixel point in the tracking area; Counting the number of pixels with gradient amplitude values larger than a preset gradient threshold value in the tracking area to obtain the number of pixels with effective edges; calculating the average value of gradient amplitude values of all pixel points in the tracking area to obtain average gradient strength; Taking the ratio of the number of the effective edge pixels to the total number of pixels of the tracking area as an edge density coefficient; and carrying out weighted summation on the average gradient strength and the edge density coefficient to obtain the first image definition.
- 7. The method of claim 1, wherein said performing attitude compensation on said first image sharpness based on said attitude angle information and said flying speed information to obtain a second image sharpness comprises: extracting a pitch angle and a roll angle in the attitude angle information; calculating a posture deviation degree according to the pitch angle and the roll angle, wherein the posture deviation degree is the square root of the sum of the square of the pitch angle and the square of the roll angle; determining a posture compensation coefficient according to the posture deviation degree, wherein the posture compensation coefficient is positively correlated with the posture deviation degree; acquiring the horizontal flight speed and the vertical flight speed in the flight speed information; Calculating the displacement of the unmanned aerial vehicle in the image exposure time according to the horizontal flight speed and the vertical flight speed; Determining a motion blur compensation coefficient according to the displacement, wherein the motion blur compensation coefficient is positively correlated with the displacement; and carrying out product operation on the first image definition, the gesture compensation coefficient and the motion blur compensation coefficient to obtain the second image definition.
- 8. A target imaging-based camera focal length control system, the system comprising: the data acquisition module is used for acquiring expected imaging parameters and the current flight altitude of the unmanned aerial vehicle; The offset distance determining module is used for determining a focal length traversing range and a focal length stepping interval according to the current flight height, controlling a camera lens of the unmanned aerial vehicle to carry out traversing acquisition at the focal length stepping interval in the focal length traversing range and determining an image acquisition sequence; The image definition determining module is used for correcting the imaging width and the imaging height based on the offset distance to obtain imaging size parameters under a plurality of focal lengths, calculating the size deviation value of the imaging size parameters under each focal length and target expected imaging parameters, and screening out a target focal length with the size deviation value smaller than a preset threshold value; The focal length adjustment module is used for acquiring attitude angle information and flight speed information of the unmanned aerial vehicle, carrying out attitude compensation on the first image definition according to the attitude angle information and the flight speed information to obtain second image definition, taking a target focal length corresponding to the maximum second image definition as a focal length of a camera to be adjusted, and controlling a camera lens of the unmanned aerial vehicle to adjust to the focal length of the camera to be adjusted.
- 9. An electronic device comprising a processor, a memory, a user interface, and a network interface, the memory for storing instructions, the user interface and the network interface for communicating to other devices, the processor for executing the instructions stored in the memory to cause the electronic device to perform the object imaging based camera focus control method of any one of claims 1-7.
- 10. A computer readable storage medium storing instructions that, when executed, perform the object imaging-based camera focus control method of any one of claims 1-7.
Description
Camera focal length control method, system, equipment and medium based on target imaging Technical Field The application relates to the technical field of data processing, in particular to a camera focal length control method, a system, equipment and a medium based on target imaging. Background Along with the wide application of unmanned aerial vehicle technology in fields such as industry inspection, emergency rescue and survey and drawing, the imaging quality who carries on camera system has put forward higher and higher requirement. When various tasks are executed, the unmanned aerial vehicle needs to image a specific target with high quality, and ensures that the size and definition of the target in an image meet the requirements of practical application, which presents a serious challenge to the focal length control capability of the camera. At present, an unmanned aerial vehicle camera system mainly adopts an automatic focusing technology to adjust focal length, evaluates imaging quality by collecting image data in real time and analyzing image characteristics, dynamically adjusts focal distance according to evaluation results, and generates a target image meeting shooting requirements. However, in practical application, the existing focal length control method is generally used for independently analyzing and evaluating local features of a single image frame, so that influence of unmanned aerial vehicle attitude change on imaging effect in the flight process is ignored, imaging features of a target in a dynamic environment are difficult to comprehensively reflect, generated image quality is unstable, and accuracy of camera focal length control is lowered. Disclosure of Invention The application provides a camera focal length control method, a system, equipment and a medium based on target imaging, which can improve the accuracy of camera focal length control. In a first aspect, the present application provides a method for controlling a focal length of a camera based on target imaging, including: acquiring expected imaging parameters and the current flight altitude of the unmanned aerial vehicle; determining a focal length traversing range and a focal length stepping interval according to the current flying height, controlling a camera lens of the unmanned aerial vehicle to carry out traversing acquisition at the focal length stepping interval in the focal length traversing range, and determining an image acquisition sequence; performing target detection on each frame of image in the image acquisition sequence, determining a target area, acquiring imaging width and imaging height of the target area, and calculating offset distance between the geometric center of the target area and the image center; Correcting the imaging width and the imaging height based on the offset distance to obtain imaging size parameters under a plurality of focal lengths; Calculating the size deviation value of the imaging size parameter and the target expected imaging parameter under each focal length, and screening out the target focal length of which the size deviation value is smaller than a preset threshold value; performing image definition calculation on a tracking area corresponding to the target focal length, and determining a first image definition; acquiring attitude angle information and flight speed information of the unmanned aerial vehicle, and performing attitude compensation on the first image definition according to the attitude angle information and the flight speed information to obtain a second image definition; And taking the target focal length corresponding to the maximum definition of the second image as the focal length of the camera to be adjusted, and controlling the camera lens of the unmanned aerial vehicle to adjust to the focal length of the camera to be adjusted. According to the technical scheme, firstly, a focal length traversing range and a stepping interval are determined according to the current flying height of the unmanned aerial vehicle, a camera is controlled to carry out traversing acquisition within the range, target imaging features under different focal lengths can be comprehensively acquired, secondly, by carrying out target detection on each frame of image in an acquisition sequence and determining a target area, calculating the offset distance between the geometric center of the target area and the image center, correcting imaging size parameters based on the offset distance, and therefore the influence of target position offset on imaging size evaluation can be eliminated, then, by calculating the size offset value of the corrected imaging size parameters and expected imaging parameters under each focal length, and screening out target focal lengths meeting the requirement of a preset threshold value, candidate focal lengths meeting the requirement of the size can be preliminarily determined, and finally, image definition calculation and attitude compensation are carried out