An encoding positioning method for a battery replacement scene
By using an coded positioning method, translation and rotation vectors are calculated using physical coordinates and pixel coordinates, solving the accuracy problem of drone battery swapping when it is not in the human field of vision, and realizing high-precision and low-cost drone battery swapping operation.
Patent Information
- Application Number
- CN202111500268.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-09
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2041-12-09
AI Technical Summary
When drones are out of human sight, the accuracy of battery swapping operations cannot be guaranteed, and there is a risk of battery swapping errors.
The coding positioning method is adopted. By obtaining the physical coordinate values of the positioning code and the pixel coordinate values of the digital image, the translation vector and rotation vector are calculated using formulas to determine the pose of the shooting device relative to the positioning code. Combined with the Rodrigues formula, the robotic arm can be operated precisely.
At low cost, high-precision positioning for drone battery swapping was achieved, ensuring that the robotic arm accurately performs battery removal, battery placement, and battery charging operations with a time delay of less than 0.1 seconds.
Smart Images

Figure CN114119756B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The patent relates to the field of computer picture recognition processing, coding marks and visual guidance. Specifically, it relates to a coding positioning method for a battery replacement scene. BACKGROUND
[0002] With the increasing popularity of the use of unmanned aerial vehicles, the problem of battery replacement for unmanned aerial vehicles needs to be solved. When the unmanned aerial vehicle is in flight and the battery is low, it may cause the unmanned aerial vehicle to crash and cause losses. Therefore, the research on battery replacement for unmanned aerial vehicles is of great significance.
[0003] In the prior art, the battery replacement of the unmanned aerial vehicle is usually controlled by a person using a remote control device. When the unmanned aerial vehicle is within the person's field of view, the battery replacement of the unmanned aerial vehicle can be accurately performed.
[0004] However, when the unmanned aerial vehicle is not within the person's field of view, although it can be observed in real time through the camera of the unmanned aerial vehicle, the accuracy cannot be guaranteed, and there is a risk of battery replacement failure at any time. Therefore, a solution is needed to improve the accuracy of battery replacement for unmanned aerial vehicles. SUMMARY
[0005] The patent is proposed based on the above-mentioned needs of the prior art. The technical problem to be solved by the patent is to provide a coding positioning method for a battery replacement scene.
[0006] To solve the above problems, the patent is implemented by adopting the following technical solutions:
[0007] A coding positioning method for a battery replacement scene, the method comprising:
[0008] Obtaining physical coordinate values of vertices of a positioning code, the physical coordinate values being determined according to a physical image of the positioning code arranged on a target device;
[0009] Obtaining a digital image corresponding to the physical image collected by a shooting device;
[0010] Determining pixel coordinate values of the vertices of the positioning code in the digital image;
[0011] Inputting the physical coordinate values and the pixel coordinate values into a formula
[0012]
[0013] Operation, to obtain a translation vector and a rotation vector of the shooting device;
[0014] In the formula, represents the translation vector and the rotation vector, r 11 -r 33 represents a constant element of the translation vector, tx represents the distance between the shooting device and the positioning code yoz plane, t y represents the distance between the shooting device and the positioning code xoz plane, t z represents the distance between the shooting device and the xoy plane; represents the intrinsic parameter of the shooting device, f x and f y represents the two focal lengths of the shooting device, c x and c y represents the principal point coordinate of the shooting device relative to the imaging plane; u i and v i represents the pixel coordinate value of the i-th vertex; x i , y i and z i represents the physical coordinate value of the i-th vertex;
[0015] The pose of the shooting device relative to the positioning code is determined according to the Rodrigues formula by the translation vector and the rotation vector.
[0016] Optionally, the physical image includes a first area and a second area, the first area has a first size, the second area is located in the first area and has a second size, and the positioning code is located in the second area; the physical coordinate value is determined according to the first size and the second size.
[0017] Optionally, acquiring the digital image corresponding to the physical image collected by the shooting device includes:
[0018] acquiring a first image photographed by the shooting device;
[0019] segmenting the first image to obtain a plurality of block regions;
[0020] calculating the maximum and minimum gray values of the block regions, and then performing 3-neighbor maximum and minimum filtering processing on the maximum and minimum gray values calculated by all blocks;
[0021] the filtered maximum and minimum mean values are taken as the threshold values of the block regions to obtain a binary image.
[0022] Optionally, acquiring the digital image corresponding to the physical image collected by the shooting device includes, processing the binary image to obtain a positioning code image contour, and performing straight line fitting on the positioning code image contour to obtain the digital image including a fitted quadrilateral.
[0023] Optionally, the physical coordinate value is determined according to the positioning code physical image arranged on the target device, including:
[0024] Taking any point in the physical image of the positioning code as the origin of the world coordinate system; and determining the physical coordinate value based on the physical distance between the physical image of the positioning code and the origin.
[0025] Optionally, the physical image comprises a printed image printed based on a digital image of a predetermined size.
[0026] Optionally, the method further comprises a calibration step, which comprises:
[0027] acquiring real-time acquisition images based on the frame rate of the shooting device under different positions and rotation angles;
[0028] selecting N frames of images in the real-time acquisition images, and performing calibration operation on each frame of image to obtain a calibration result of the frame of image, wherein N is a predetermined number;
[0029] evaluating the calibration results of the frames of images, and selecting the calibration result as the calibration parameter of the shooting device when the error between N frames of images is lower than a predetermined value.
[0030] Compared with the prior art, the present patent does not use a calibration board in the calibration process, but uses a printed image on ordinary paper, which greatly reduces the calibration cost; by introducing the physical coordinate value and the pixel coordinate value, the translation vector and the rotation vector of the shooting device are more accurate; thereby ensuring that the mechanical arm accurately performs the operations of taking out the battery from the unmanned aerial vehicle, placing the battery, and charging the battery; further, the actual physical position relationship of the shooting device relative to the positioning code obtained from the translation vector can more accurately set the speed and time of the mechanical arm operation. BRIEF DESCRIPTION OF DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present specification or the prior art, the drawings needed to be used in the embodiments or prior art description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments described in the present specification, and other drawings can also be obtained by those skilled in the art based on these drawings.
[0032] Figure 1 is a flowchart of an encoding positioning method for a battery replacement scene provided by the specific embodiment of the present patent;
[0033] Figure 2 is a physical image of a positioning code of an encoding positioning method for a battery replacement scene provided by the specific embodiment of the present patent.
[0034] Reference signs:
[0035] D: peripheral size; Di: internal size. DETAILED DESCRIPTION
[0036] In order to make the objects, technical solutions and advantages of the patent embodiments clearer, the following will clearly and completely describe the technical solutions in the patent embodiments with reference to the drawings in the patent embodiments. Obviously, the described embodiments are some but not all of the embodiments of the patent. Based on the embodiments in the patent, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of the patent.
[0037] In order to make the objects, technical solutions and advantages of the patent embodiments clearer, the following will clearly and completely describe the technical solutions in the patent embodiments with reference to the drawings in the patent embodiments. Obviously, the described embodiments are some but not all of the embodiments of the patent. Based on the embodiments in the patent, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of the patent.
[0038] The patent embodiments provide an encoding positioning method for a battery replacement scene. The method is specifically applied to the scene of replacing a battery of a UAV. Since the operations of taking out a battery, placing a battery and charging a battery of a UAV have higher accuracy requirements than other scenes, and there is a problem of high cost of a calibration board in the process of calibrating a shooting device, in order to accurately calibrate the position of a UAV positioning object at low cost, achieve high-precision positioning, and time delay cannot exceed 0.1 seconds, the patent embodiments provide a solution, and embodiments are used for specific description.
[0039] The positioning code mentioned in the patent embodiments refers to a code with a specific mark stored in a visual reference library, which is similar to a two-dimensional code, but has reduced complexity and can meet the real-time requirements, and has the characteristics of quickly detecting a mark and calculating a relative position.
[0040] Before performing the specific implementation, a specific one or more two-dimensional positioning codes are needed on a battery, a UAV, a robot arm and a charging slot. The positioning in the patent embodiments refers to obtaining 3D relative position and attitude information of a camera and a positioning code through identification, decoding and conversion of the positioning code, and further guiding a robot arm to perform operations such as taking out a battery, placing a battery and charging a battery. The camera is installed on the robot arm.
[0041] The device related to the patent embodiments includes a UAV body, a robot arm, a battery, a charging slot and a camera. The robot arm is below the UAV body, the camera is installed on the robot arm, is used for shooting a positioning code pasted on the battery, the UAV and the charging slot in real time, and a charging interface of the battery is connected with a charging interface of the charging slot.
[0042] The prior art determines the relationship between the mechanical arm and the unmanned aerial vehicle by using a magnetic encoder, which is relatively high in cost and complex in equipment, and is not suitable for small devices such as unmanned aerial vehicles. Therefore, a positioning code mode is considered for positioning. However, the positioning code positioning has difficulties in that the collected images are prone to distortion and the positioning is not accurate. In addition, the cost is relatively high. In order to overcome the above defects, the following specific embodiments are used for specific description.
[0043] In the patent embodiment, a domestic industrial brand USB camera is selected as the shooting device. The camera has simple structure and low cost, and a variety of focal length distortion-free cameras can be selected. After testing a plurality of focal lengths, the 3.6mm camera has relatively excellent performance. At a height of 60cm, the height direction positioning error is 2mm, and the horizontal direction positioning error is less than 5mm.
[0044] The embodiment provides a coding positioning method for a battery replacement scene, and a flowchart of the method is shown in Figure 1 Specifically, the method comprises the following steps:
[0045] S1: Obtain the physical coordinate value of the vertex of the positioning code, wherein the physical coordinate value is determined according to the physical image of the positioning code arranged on the target device.
[0046] In the patent embodiment, the specific way of obtaining the physical coordinate value of the vertex of the positioning code is to take any point in the physical image of the positioning code as the origin of the world coordinate system, and to determine the physical distance between the physical image of the positioning code and the origin as the physical coordinate value. The physical image comprises a first region and a second region, the first region has a first size, the second region is located in the first region and has a second size, and the positioning code is located in the second region; the physical coordinate value is determined according to the first size and the second size.
[0047] In order to more intuitively reflect the size corresponding relationship, the patent embodiment provides a physical image of the positioning code, as shown in Figure 2 The first size corresponds to the peripheral size D of the positioning code, and the image area included in D is the first region. The second size corresponds to the internal size Di of the positioning code, and the image area included in Di is the second region.
[0048] In addition, the physical image further comprises a printed image printed based on a pre-determined size. Before performing the S1 step, the printed image needs to be calibrated by using a shooting device. The calibration step comprises:
[0049] Step one: based on different positions and rotation angles, real-time shooting of the printed image according to the frame rate of the shooting device to obtain real-time collected images.
[0050] Step two: select N frames of images in the real-time collected images, and perform calibration operation on each frame of image to obtain the calibration result of the frame of image, wherein N is a pre-set number.
[0051] Step three: evaluate the calibration result of the frame of image, and when the error between the N frames of images is lower than 0.045, select the calibration result as the calibration parameter of the shooting device.
[0052] The calibration result includes the intrinsic parameter and the distortion parameter of the shooting device.
[0053] In the calibration process of the patent embodiment, no calibration board is used, but a normal paper is used to print images, which greatly reduces the calibration cost, and there is no need to worry about the problem of large quantity, and the precision fully meets the requirements of actual application.
[0054] S2: Obtain a digital image corresponding to a physical image collected by a shooting device.
[0055] Obtaining a digital image corresponding to a physical image collected by a calibrated shooting device can specifically include S20-S24:
[0056] S20: Obtain a first image photographed by a shooting device.
[0057] S21: Segment the first image to obtain a plurality of block regions.
[0058] Before performing this step, the first image needs to be converted into a gray-scale image, so that each pixel point of the first image only retains one gray-scale value.
[0059] The patent embodiment divides the first image into 4x4 pixel blocks to obtain a plurality of block regions. Segmenting the first image is beneficial to increase robustness, and the features of the regions are more stable than single pixels, which can reduce the interference of random noise and improve the calculation efficiency.
[0060] S22: Calculate the maximum and minimum gray-scale values of the block regions, and then perform 3-neighbor maximum and minimum filtering processing on the maximum and minimum gray-scale values calculated by all blocks.
[0061] S23: Take the filtered maximum and minimum mean values as the threshold values of the block regions to obtain a binary image.
[0062] S24: Process the binary image to obtain a positioning code image contour, and perform straight line fitting on the positioning code image contour to obtain a digital image including a fitted quadrilateral.
[0063] In actual application, the positioning code image obtained by processing still retains more noise. In order to make the contour of the extracted positioning code image more clear and smooth, the embodiment of the patent first processes the binary image by using a joint search algorithm to obtain a connected domain, and then processes the binary image by using an edge detection algorithm on the connected domain.
[0064] Processing the boundary of the binary image by using the joint search algorithm to obtain the connected domain specifically includes:
[0065] The joint search algorithm is used to process the binary image to obtain the connected domain, and the internal region of the positioning code is obtained. However, the contour of the obtained region is not clear and is mixed with various noises, so the region contour needs to be further processed.
[0066] The specific steps of processing the binary image by using the edge detection algorithm are as follows:
[0067] Step 1: The binary image is denoised by using a Gaussian filtering method.
[0068] In the embodiment of the patent, a two-dimensional zero-mean discrete Gaussian function is used as a smoothing filter to process the binary image. The Gaussian function value on the discrete point is used as the weight value, and the weighted average of each pixel point in the collected gray matrix in a certain range of neighborhood is calculated to achieve the purpose of reducing Gaussian noise.
[0069] The specific process is to traverse each pixel in the positioning code image by using a convolution kernel with a size of (2k+1)×(2k+1) pixels, calculate the weighted average gray value of the pixels in the neighborhood determined by the convolution kernel, and replace the gray value of the center pixel point in the convolution kernel field with the weighted average gray value.
[0070] Step 2: The positioning code image after denoising is processed by using a gradient algorithm to obtain a first edge set of the positioning code image.
[0071] Since the image has the characteristics that the change is sharp at the edge and the change is smooth at the non-edge, the gradient algorithm can be used on the positioning code image after denoising to obtain the edge with sharp change, i.e., the first edge set.
[0072] However, the first edge set obtained by the gradient calculation still includes some parts with obvious gray change in the internal region of the positioning code image, so further processing is needed to remove the irrelevant parts in the internal region.
[0073] Step 3: The first edge set is processed by non-maximum suppression to obtain a second edge set.
[0074] By using the non-maximum suppression method, the redundant pixel values on the edge are removed, and only the pixel points with the maximum gray change are retained to achieve the purpose of thinning the edge.
[0075] Step four: double threshold screening processing is performed on the second edge set to obtain the positioning code image contour.
[0076] After non-maximum suppression, there are still many irrelevant image contour points in the second edge set, so further double threshold screening processing is needed.
[0077] The specific process is to set a double threshold, i.e., a high threshold and a low threshold, set the pixels with a gray scale change greater than the high threshold as strong edge pixels, eliminate the pixels with a gray scale change lower than the low threshold, and set the pixels between the high threshold and the low threshold as weak edges; further judgment is made, if there is a strong edge pixel in its field, it is retained, otherwise, the pixel point is eliminated.
[0078] Only strong edge pixels are retained because weak edge pixels are needed to supplement the part of the contour that is not closed, so that the contour edge is as closed as possible.
[0079] In summary, using the edge detection algorithm reduces the noise points in the image and obtains a clear and smooth image contour.
[0080] After obtaining the positioning code image contour, straight line fitting is needed for the positioning code image contour to obtain a fitted quadrilateral, and the specific execution steps are as follows:
[0081] The unordered label image contour points are sorted according to the angle of the center of gravity, and further points within a certain range from the center point are selected according to the order for straight line fitting, the index is iterated constantly, and the total error sum of each straight line is calculated; a low-pass filter is applied to the total error sum to make the system more robust, and the index of the corner point corresponding to the four straight lines with the largest total error sum is selected as the corner point of the quadrilateral. Finally, appropriate points between the corner points are selected for straight line fitting. The corner points of the four straight lines obtained are selected as the vertices of the label.
[0082] S3: Determine the pixel coordinate value of the vertex of the positioning code in the digital image.
[0083] Establish a pixel coordinate system to determine the pixel coordinate value of the four vertices of the fitted quadrilateral in the pixel coordinate system of the image.
[0084] S4: Input the physical coordinate value and the pixel coordinate value into the formula
[0085]
[0086] Operation, to obtain the translation vector and the rotation vector of the shooting device.
[0087] In the formula, represents the translation vector and the rotation vector, r 11 -r 33 represents the element constant of the translation vector, tx representing the distance between the shooting device and the positioning code yoz plane, t y representing the distance between the shooting device and the positioning code xoz plane, t z representing the distance between the shooting device and the xoy plane; representing the intrinsic parameter of the shooting device, f x and f y representing the two focal lengths of the shooting device, c x and c y representing the principal point coordinates of the shooting device relative to the imaging plane; u i and v i representing the pixel coordinate value of the i-th vertex; x i , y i and z i representing the physical coordinate value of the i-th vertex.
[0088] Taking any point in the physical image of the positioning code as the origin of the world coordinate system, the physical coordinate values of the four vertices are obtained to construct a physical coordinate matrix For example, when taking the top-left vertex of the physical image of the positioning code as the origin of the world coordinate system, the physical coordinate values of the four vertices are Figure 1 corresponding to wherein the order of the four vertices has no precedence, and for the sake of expression standard, the order here is in the counterclockwise direction from the top-left corner.
[0089] The intrinsic parameter and distortion parameter of the shooting device are obtained by calibration, and an intrinsic matrix of the shooting device is constructed according to the intrinsic parameter and a distortion matrix [k1 k2 k3 p1 p2] of the shooting device is constructed according to the distortion parameter.
[0090] The pixel coordinate values obtained by taking the center of the image in the pixel coordinate system as the origin are processed by the distortion parameter matrix of the shooting device to construct a pixel matrix The subscript value of the pixel matrix needs to be consistent with the combination order of the vertices in the physical coordinate matrix of the four vertices.
[0091] The physical coordinate matrix, the intrinsic matrix and the pixel matrix are input into the formula
[0092]
[0093] The translation vector and the rotation vector of the shooting device are obtained by performing operation, wherein the translation vector is wherein r 11 -r 33 representing the element constant in the matrix, used for solving the angle; and the rotation vector is wherein t x representing the distance between the shooting device and the positioning code yoz plane, t yrepresents the distance between the shooting device and the positioning code xoz,t z represents the distance between the shooting device and the xoy plane.
[0094] In the embodiment of the patent, when the three-dimensional structure of the scene is known, the absolute pose relationship between the shooting device coordinate system and the world coordinate system representing the three-dimensional scene structure, including the absolute translation vector and the rotation matrix, can be solved by using the coordinates of the multiple control points in the three-dimensional scene and their perspective projection coordinates in the image. This type of solving method is collectively referred to as N-point perspective pose solving.
[0095] By introducing the physical coordinate value and the pixel coordinate value, the translation vector and the rotation vector of the shooting device are more accurate, thereby ensuring that the mechanical arm is more accurate in performing operations such as taking out the battery from the unmanned aerial vehicle, placing the battery, and charging the battery.
[0096] S5: determining the pose of the shooting device relative to the positioning code according to the translation vector and the rotation vector based on the Rodrigues formula.
[0097] Position solving: obtaining the actual physical position relationship of the shooting device relative to the positioning code according to the translation vector.
[0098] Attitude solving: obtaining the relative angle relationship of the three dimensions of the shooting device relative to the world coordinate system established with an arbitrary point in the physical image of the positioning code as the origin according to the Rodrigues rotation formula and the rotation vector.
[0099] The actual physical position relationship can be used to more accurately set the speed and time of the operation of the mechanical arm.
[0100] The above specific embodiments further detail the purpose, technical solutions, and beneficial effects of the patent. It should be understood that the above description is only a specific embodiment of the patent and is not intended to limit the protection scope of the patent. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the patent should be included in the protection scope of the patent.
Claims
1. A coding and positioning method for battery swapping scenarios, characterized in that, The method comprises: acquiring physical coordinate values of vertices of a positioning code, the physical coordinate values being determined according to a physical image of the positioning code arranged on a target device; acquiring a digital image corresponding to the physical image collected by a shooting device, comprising: acquiring a first image shot by the shooting device; segmenting the first image to obtain a plurality of segmented regions; calculating the maximum and minimum gray values of the segmented regions, and then performing 3-neighbor maximum and minimum filtering processing on the maximum and minimum gray values calculated for all the segments; taking the filtered maximum and minimum mean values as the threshold values of the segmented regions to obtain a binary image; processing the binary image to obtain a positioning code image contour, and performing straight line fitting on the positioning code image contour to obtain the digital image including a fitted quadrilateral; determining pixel coordinate values of vertices of the positioning code in the digital image; inputting the physical coordinate values and the pixel coordinate values into a formula to obtain a translation vector and a rotation vector of the shooting device; In the formula, represents the translation vector and the rotation vector, r11-r33 represents the element constant of the translation vector, tx represents the distance between the shooting device and the positioning code yoz plane, ty represents the distance between the shooting device and the positioning code xoz plane, and tz represents the distance between the shooting device and the xoy plane; represents the intrinsic parameter of the shooting device, fx and fy represent the two focal lengths of the shooting device, cx and cy represent the principal point coordinates of the shooting device relative to the imaging plane; ui and vi represent the pixel coordinate values of the i-th vertex; xi, yi and zi represent the physical coordinate values of the i-th vertex; determining the pose of the shooting device relative to the positioning code according to the Rodrigues formula based on the translation vector and the rotation vector; the physical coordinate values being determined according to the physical image of the positioning code arranged on the target device comprises: taking any point in the physical image of the positioning code as the origin of a world coordinate system; and determining the physical coordinate values according to the physical distance between the physical image of the positioning code and the origin; the physical image comprises a first region and a second region, the first region has a first size, the second region is located in the first region and has a second size, and the positioning code is located in the second region; the physical coordinate values are determined according to the first size and the second size; and the physical image comprises a printed image output by printing a digital image based on a predetermined size; The encoding positioning method further comprises a calibration step, specifically comprising: acquiring real-time acquisition images by shooting the printed image in real time according to the frame rate of the shooting device at different positions and rotation angles; selecting N frames of images from the real-time acquisition images, and performing calibration operation on each of the frames of images to obtain calibration results of the frames of images, wherein N is a predetermined number; evaluating the calibration results of the frames of images, and selecting the calibration results as the calibration parameters of the shooting device when the errors between the N frames of images are lower than a predetermined value.
Citation Information
Patent Citations
Unmanned aerial vehicle positioning method based on a cooperative two-dimensional code of a virtual simulation environment
CN109658461A