Oil pumping unit geometric dimension measuring method and measuring system based on double-video correction
Through the method based on dual video correction and multi-step optimization algorithm, the error and safety hazards in the geometric dimension measurement of the gaze beam pump are solved, high-precision, non-contact geometric dimension measurement is achieved, and the quality of the counterweight block is measured.
Patent Information
- Application Number
- CN202411538347.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-02-28
AI Technical Summary
The prior art has calculation errors, safety risks, difficulty in measuring the distance between the swimming beam and the crank plane, and lack of means of measuring the weight mass when measuring the geometric dimensions of the swimming beam and the weight pump.
Using a method based on dual video correction, the crank outer paramembrane and the swimming beam outer paramembrane are optimized in multiple steps by obtaining dual-angle working videos, combining genetic algorithms and differential evolution algorithms, accurately measuring the geometric dimensions of the oil pump, and measuring the quality of the counterweight blocks through deep learning semantic segmentation algorithm.
It improves the accuracy and consistency of geometric dimension measurement, avoids safety hazards and errors of contact measurement, realizes non-contact measurement throughout the whole process, and enhances the reliability of measurement data.
Smart Images

Figure CN119533274A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a method and a system for measuring the geometric dimensions of an oil pumping unit based on dual video correction, and belongs to the technical field of oil pumping unit dimension measurement. Background Art
[0002] The walking beam pump is an important equipment in oilfield production, and its geometric dimensions are crucial to the generation of the electric parameter indicator diagram. The indicator diagram is deduced by high-speed sampling of the torque and speed of the motor, but this deduction relies on accurate equipment size data, such as the length of the connecting rod, the length of the front and rear arms of the walking beam, the distance from the walking beam balance weight to the support center, and the size of the right triangle between the walking beam support center and the crank rotation center, including horizontal, vertical and hypotenuse distances. In the face of the current situation where the walking beam pump equipment is old or data is missing, a safe, fast and non-contact geometric dimension measurement method is needed. However, the existing visual measurement methods have the following problems:
[0003] 1. The feature point trajectory used in the external parameter measurement is difficult to verify, which may lead to calculation errors.
[0004] 2. The measurement of the distance between the walking beam and the crank plane is difficult and poses a safety hazard. The error in this distance affects the calculation of external parameters, which in turn affects the accuracy of dimensional measurement.
[0005] 3. The measurement of connecting rod length depends on the connection point, which is outside the crank plane. Using the external parameters of the crank plane for conversion will introduce errors.
[0006] 4. The existing methods lack the means to measure the mass of the counterweight of the oil pump. Summary of the invention
[0007] The purpose of the present invention is to overcome the deficiencies in the prior art and provide a method and system for measuring the geometric dimensions of an oil pumping unit based on dual video correction. By introducing dual-angle working videos and a variety of external parameter optimization algorithms, the geometric dimensions of the oil pumping unit equipment can be measured more accurately.
[0008] To achieve the above object, the present invention is implemented by adopting the following technical solutions:
[0009] On the one hand, the present invention discloses a method for measuring the geometric dimensions of an oil pumping unit based on dual video correction, the method comprising the following steps:
[0010] Obtaining a first-angle working video and a second-angle working video of the oil pumping unit;
[0011] According to the first angle working video, a pre-constructed crank extrinsic parameter objective function is solved based on a genetic algorithm to obtain a first crank extrinsic parameter;
[0012] According to the first angle working video and the second angle working video, a pre-constructed plane distance objective function is solved based on a differential evolution algorithm to obtain a plane distance between a crank plane and a beam plane;
[0013] Obtaining a first walking beam external parameter according to the plane distance and the first crank external parameter;
[0014] According to the first crank external parameter, the first walking beam external parameter, and the first internal parameter obtained in advance by calibration, the size measurement of the part to be measured is achieved by converting the coordinates of the size point of any part to be measured of the pumping unit in the first angle working video in the image coordinate system into the coordinates in the world coordinate system.
[0015] Furthermore, the steps for obtaining the first angle working video and the second angle working video are as follows:
[0016] Placing the first camera at a preset first position and the second camera at a preset second position, wherein the distance between the first position and the second position is 2-5 meters;
[0017] The first camera and the second camera are both provided with an inertial measurement unit, and the pitch angle and the rotation angle are adjusted by the inertial measurement unit so that the first camera or the second camera is parallel to the plane where the pumping unit is located and maintains a shooting state of zero rotation angle;
[0018] The first camera is used to capture a first-angle working video of the oil pump; the second camera is used to capture a second-angle working video of the oil pump.
[0019] Furthermore, a characteristic point is provided at the end of any crank rotating shaft of the oil pumping unit to be tested; and obtaining the first crank external parameter comprises the following steps:
[0020] Extracting a first feature point set according to each frame image of the first angle working video;
[0021] For any feature point in the first feature point set, perform center point extraction and remove noise by excluding static points and outliers to obtain the first feature point trajectory , , represents the number of feature points in the first feature point trajectory;
[0022] According to the first characteristic point trajectory, solving the pre-constructed crank extrinsic parameter objective function based on the genetic algorithm until the crank extrinsic parameter objective function is minimized to obtain the optimal first crank extrinsic parameter;
[0023] Among them, the optimization target of the crank extrinsic parameter objective function is that the trajectory of the first feature point in the camera coordinate system falls on a preset circular trajectory after being converted to the world coordinate system through the first crank extrinsic parameter, and the crank rotation center in the camera coordinate system coincides with the origin of the world coordinate system.
[0024] Furthermore, the expression of the crank extrinsic parameter objective function is as follows:
[0025] ;
[0026] In the formula, represents the crank extrinsic objective function; Represents the first crank external parameter; represents the weight coefficient; represents the number of feature points in the first feature point trajectory; Represents the nth feature point transformed from the camera coordinate system to the world coordinate system; represents the origin (0,0,0) of the world coordinate system corresponding to the center of rotation of the crank; Indicates the crank radius; The point representing the conversion of the crank's rotation center from the camera coordinate system to the world coordinate system.
[0027] Furthermore, obtaining the first beam external parameter comprises the following steps:
[0028] According to the first angle working video, calculate the first coordinate of the beam fixing point in the world coordinate system;
[0029] According to the second angle working video, calculate the second coordinate of the beam fixing point in the world coordinate system;
[0030] According to the first coordinate and the second coordinate of the beam fixed point in the world coordinate system, a differential evolution algorithm is used to solve the pre-constructed plane distance objective function until the plane distance objective function is minimized, and the optimal plane distance between the crank plane and the beam plane is obtained, thereby obtaining the first beam extrinsic parameter;
[0031] The optimization objective of the plane distance objective function is to minimize the point distance between the first coordinate and the second coordinate of the walking beam fixed point in the world coordinate system.
[0032] Furthermore, the objective function of the plane distance objective function is as follows:
[0033] ;
[0034] In the formula, represents the second objective function; It represents the plane distance between the crank plane and the beam plane;
[0035] Indicates the distance between the included planes The first coordinate of the variable beam fixed point in the world coordinate system is expressed as follows:
[0036] ;
[0037] In the formula, Represents the coordinates of the beam fixing point in the first camera coordinate system; Indicates the distance between the included planes The first beam rotation matrix in the first beam extrinsic parameter of the variable; Indicates the distance between the included planes The first beam translation vector in the first beam extrinsic parameter of the variable;
[0038] Indicates the distance between the included planes The second coordinate of the variable beam fixed point in the world coordinate system is expressed as follows:
[0039] ;
[0040] In the formula, represents the coordinates of the beam fixing point in the second camera coordinate system; Indicates the distance between the included planes The second beam rotation matrix in the second beam extrinsic parameters of the variables; Indicates the distance between the included planes The second beam translation vector in the second beam extrinsic parameter of the variable.
[0041] Furthermore, the first beam extrinsic parameters include a first beam rotation matrix and a first beam translation vector, which are expressed as follows:
[0042] ;
[0043] In the formula, represents the first beam rotation matrix; represents the first beam translation vector; represents the first crank rotation matrix in the first crank external parameter; represents the first crank translation vector in the first crank extrinsic parameter; It represents the translation vector of the beam coordinate system relative to the crank coordinate system, and the expression is as follows:
[0044] ;
[0045] In the formula, Indicates the plane distance between the crank plane and the beam plane.
[0046] Furthermore, the size measurement of the part to be measured comprises the following steps:
[0047] The part to be measured of the oil pumping unit includes a first dimension point and a second dimension point;
[0048] According to the first angle working video, the coordinates of the first size point and the second size point in the image coordinate system are respectively extracted;
[0049] If the first dimension point and the second dimension point are both located on the crank plane, the coordinates of the first dimension point and the second dimension point in the world coordinate system are obtained according to the first internal parameter, the first crank external parameter, and the coordinates of the first dimension point and the second dimension point in the image coordinate system, and then the size of the part to be measured is calculated; wherein the distance between the first dimension point and the second dimension point in the world coordinate system represents the size of the part to be measured;
[0050] If the first dimension point and the second dimension point are both located in the beam plane, the coordinates of the first dimension point and the second dimension point in the world coordinate system are obtained according to the first internal parameter, the first beam external parameter, and the coordinates of the first dimension point and the second dimension point in the image coordinate system, and then the size of the part to be measured is calculated;
[0051] If the first dimension point is located in the crank plane and the second dimension point is located in the rocker plane, the coordinates of the first dimension point in the world coordinate system are obtained according to the first internal parameter, the first crank external parameter, and the coordinates of the first dimension point in the image coordinate system; the coordinates of the second dimension point in the world coordinate system are obtained according to the first internal parameter, the first rocker external parameter, and the coordinates of the second dimension point in the image coordinate system; the size of the part to be measured is calculated according to the coordinates of the first dimension point and the second dimension point in the world coordinate system.
[0052] Furthermore, the measuring method further comprises the following steps:
[0053] Obtain the thickness and density of the counterweight of the pumping unit;
[0054] Based on a semantic segmentation algorithm of deep learning, contour segmentation is performed on the counterweight block in the first angle working video or the second angle working video to obtain multiple segmentation masks; and the segmentation mask with the highest confidence is taken as the final mask data;
[0055] Extracting inner and outer contour points of the mask data to obtain a contour set;
[0056] Convert each contour point in the contour set to the world coordinate system, and then calculate the area difference between the inner and outer contours to obtain the actual area of the counterweight;
[0057] Calculate the mass of the counterweight block according to the actual area, thickness and density of the counterweight block;
[0058] According to the first crank external parameter, the first walking beam external parameter, and the first internal parameter of the first camera obtained in advance through calibration, the dimension points of any measured part of the pumping unit in the first angle working video in the image coordinate system are converted into dimension points in the world coordinate system, so as to achieve the dimension measurement of the measured part.
[0059] On the other hand, the present invention discloses a pumping unit geometric dimension measurement system based on dual video correction, which is applicable to the above-mentioned pumping unit geometric dimension measurement method based on dual video correction, and comprises:
[0060] A data acquisition module, used to acquire a first-angle working video and a second-angle working video of the oil pump;
[0061] A first crank extrinsic parameter module, used for solving a pre-constructed crank extrinsic parameter objective function based on a genetic algorithm according to the first angle working video to obtain a first crank extrinsic parameter;
[0062] A plane distance module is used to solve a pre-constructed plane distance objective function based on the differential evolution algorithm according to the first angle working video and the second angle working video, so as to obtain the plane distance between the crank plane and the walking beam plane;
[0063] A first walking beam extrinsic parameter module, used for obtaining a first walking beam extrinsic parameter according to the plane distance and a first crank extrinsic parameter;
[0064] The dimension measurement module is used to measure the dimension of any part to be measured of the oil pump in the first angle working video by converting the coordinates of the dimension point of the part to be measured in the image coordinate system into the coordinates in the world coordinate system based on the first crank external parameter, the first walking beam external parameter, and the first internal parameter obtained in advance.
[0065] Compared with the prior art, the present invention has the following beneficial effects:
[0066] The pumping unit geometric dimension measurement method and measurement system based on dual video correction of the present invention, firstly, can enrich spatial information by acquiring dual-angle working videos, avoiding occlusion and projection errors that may be introduced by a single perspective. The spatial correlation between the two perspectives is used for geometric correction to effectively improve the accuracy of external parameter calculation. Secondly, based on genetic algorithms and differential evolution algorithms, the camera external parameters are optimized in multiple steps. Accurate external parameter derivation is performed between the crank plane and the walking beam plane to ensure the reliability and consistency of the measurement data. Finally, compared with the traditional contact measurement method, the present invention realizes non-contact geometric dimension measurement throughout the process through video analysis, avoiding secondary damage and safety hazards of old equipment. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Figure 1is a flow chart of a method for measuring geometric dimensions of an oil pumping unit based on dual video correction provided in Example 1;
[0068] Figure 2 is a schematic diagram of the planar structure of the oil pump provided in Example 1;
[0069] Figure 3 is a schematic diagram of the three-dimensional structure of the oil pumping unit provided in Example 1;
[0070] In the figure: 1. Crank plane; 2. Rocker plane; 3. Characteristic point; 4. Rocker fixed point; 5. Crank rotation center. DETAILED DESCRIPTION
[0071] The present invention will be further described below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the protection scope of the present invention.
[0072] Example 1
[0073] This embodiment 1 provides a method for measuring the geometric dimensions of an oil pump based on dual video correction, such as Figure 1 As shown, the measurement method includes the following steps:
[0074] Obtaining a first-angle working video and a second-angle working video of the oil pumping unit;
[0075] According to the first angle working video, a pre-constructed crank extrinsic parameter objective function is solved based on a genetic algorithm to obtain a first crank extrinsic parameter;
[0076] According to the first angle working video and the second angle working video, the pre-constructed plane distance objective function is solved based on the differential evolution algorithm to obtain the plane distance between the crank plane 1 and the beam plane 2;
[0077] According to the plane distance and the first crank external parameter, the first walking beam external parameter is obtained;
[0078] According to the first crank external parameter, the first walking beam external parameter, and the first internal parameter obtained in advance, the size measurement of the part to be measured is achieved by converting the coordinates of the size point of any part to be measured of the pumping unit in the first angle working video in the image coordinate system into the coordinates in the world coordinate system.
[0079] The technical concept of the present invention is as follows: First, by acquiring dual-angle working videos, it is possible to enrich spatial information and avoid occlusion and projection errors that may be introduced by a single perspective. The spatial correlation between the two perspectives is used for geometric correction to effectively improve the accuracy of extrinsic parameter calculation. Secondly, based on genetic algorithms and differential evolution algorithms, the camera extrinsic parameters are optimized in multiple steps. Accurate external parameter derivation is performed between the crank plane 1 and the walking beam plane 2 to ensure the reliability and consistency of the measurement data. Finally, compared with traditional contact measurement methods, the present invention realizes non-contact geometric dimension measurement throughout the process through video analysis, avoiding secondary damage and safety hazards to old equipment.
[0080] The specific steps are as follows:
[0081] Step 1: Collect work videos.
[0082] 1.1, such as Figure 2 and Figure 3 As shown, a feature point 3 is set at the end of any crank rotation axis of the pumping unit to ensure that its position is close to the crank center line so that the subsequent image coordinate system and the world coordinate system can accurately correspond. The distance from the feature point to the crank rotation center 5 is measured to obtain the crank radius .
[0083] In this embodiment, the feature points are fixed by magnetic attraction.
[0084] 1.2. The steps for obtaining the first angle working video and the second angle working video are as follows:
[0085] The first camera is placed at a preset first position, and the second camera is placed at a preset second position, wherein the distance between the first position and the second position is 2-5 meters;
[0086] The first camera and the second camera are both provided with an inertial measurement unit, and the pitch angle and the rotation angle are adjusted by the inertial measurement unit so that the first camera or the second camera is parallel to the plane where the pumping unit is located and maintains a shooting state of zero rotation angle;
[0087] The first camera is used to capture a first-angle working video of the oil pump; the second camera is used to capture a second-angle working video of the oil pump.
[0088] The first camera and the second camera used in this embodiment are both mobile phones with built-in inertial measurement units. Other cameras with built-in inertial measurement units can also be used. The mobile phone is mounted on a tripod, and the pitch angle and rotation angle are adjusted through the built-in inertial measurement unit of the mobile phone to make the mobile phone parallel to the plane where the pumping unit is located and maintain a zero rotation angle. Two videos are shot separately, and the two video positions are 2 to 5 meters apart to ensure that the complete motion trajectory of the feature point is captured.
[0089] Step 2: Get the parameter matrix.
[0090] 2.1. Calibrate the first camera using an existing calibration method to obtain a first intrinsic parameter and a first distortion parameter corresponding to the first camera. This embodiment does not limit the existing calibration method.
[0091] The first internal reference is used to convert the coordinates of the image coordinate system in the first angle working video into the coordinates of the camera coordinate system in three-dimensional space, which is the basis for accurate measurement. The specific formula is as follows:
[0092] ;
[0093] ;
[0094] In the formula, Indicates the first internal reference; Indicates the horizontal focal length corresponding to the first camera; Indicates the vertical focal length of the first camera; Indicates the principal point coordinates in the horizontal direction; Indicates the coordinates of the principal point in the vertical direction;
[0095] represents the first distortion parameter; represents the first radial distortion coefficient; represents the second radial distortion coefficient; represents the first tangential distortion coefficient; represents the second tangential distortion coefficient; Represents the third radial distortion coefficient.
[0096] It should be noted that before extracting feature points, the video needs to be dedistorted, that is, the first working video needs to be dedistorted according to the first distortion parameter.
[0097] 2.2. Feature point extraction.
[0098] like Figure 2 and Figure 3 As shown, a characteristic point 3 is provided at the end of a crank rotating shaft of the oil pumping unit. In this embodiment, the characteristic point extraction of the crank plane 1 is mainly divided into the following steps: characteristic point selection, characteristic point tracking, characteristic point center extraction and denoising. The specific steps are as follows:
[0099] Determine the initial feature point in the first frame image of the first angle working video, and establish a rectangular frame as the tracking target based on the initial feature point as the center;
[0100] The CSRT tracker is used to track the target frame by frame to obtain the first feature point set; multiple feature channels such as color and gradient are analyzed during the tracking process to improve stability.
[0101] For any feature point in the first feature point set, the center point is extracted according to the color threshold of the feature point to ignore the influence of illumination changes and enhance the extraction accuracy. The first feature point trajectory is obtained by removing noise by excluding static points and outliers. , , Indicates the number of feature points in the first feature point trajectory.
[0102] 2.3. According to the trajectory of the first characteristic point, the pre-constructed crank extrinsic parameter objective function is solved based on the genetic algorithm until the crank extrinsic parameter objective function is minimized to obtain the optimal first crank extrinsic parameter.
[0103] In order to calculate the first crank extrinsic parameter of crank plane 1 relative to the first camera, we first need to know the corresponding mapping relationship between crank plane 1 in the image coordinate system and the world coordinate system. In the previous step, the dense feature point trajectory was extracted. ,The existing method establishes a correspondence between this trajectory and the circular trajectory in the world coordinate system.
[0104] In this stage, the first crank extrinsic parameters of crank plane 1 relative to the first camera are calculated by the PnP (Perspective-n-Point) genetic algorithm. This process uses the vertices of the ellipse in the image coordinate system to the vertices of the circle in the world coordinate system for preliminary matching. However, due to the deformation error caused by perspective projection, the vertices of the ellipse in the image coordinate system do not completely correspond to the vertices of the circle in the world coordinate system.
[0105] Under perspective projection, a circular object may be deformed into an ellipse in the image due to the distance between the object and the camera and the change in the shooting angle. This is specifically manifested in pitch angle, yaw angle and rotation angle. Specifically, the pitch angle can cause the upper and lower parts of the circular object in the image to be asymmetric. The yaw angle can cause the left and right sides of the circular object to be asymmetric in the image. Although the rotation angle will not directly cause the circular object to become an ellipse, it will change the direction of the ellipse in the image.
[0106] The superposition of the above angles makes it impossible to accurately obtain the first crank extrinsic parameters simply by trajectory vertex matching, so the first crank extrinsic parameters need to be further optimized.
[0107] First crank external reference Contains the first crank rotation matrix and the first crank translation vector The first crank rotation matrix By yaw angle , Pitch angle and rotation angle Multiplying the corresponding rotation matrices gives:
[0108] ;
[0109] In the formula, Indicates rotation around the Z axis The rotation matrix of the angle; Indicates rotation around the Y axis The rotation matrix of the angle; Indicates rotation around the X axis The rotation matrix of the angle.
[0110] First crank translation vector Used to describe the first camera in The axis offset is expressed as follows:
[0111] ;
[0112] In the formula, Indicates the offset in the x-axis direction; Indicates the offset in the y-axis direction; Indicates the offset in the z-axis direction.
[0113] First crank external reference It can be expressed as combining the first crank rotation matrix and the first crank translation vector The 4x4 homogeneous transformation matrix:
[0114] ;
[0115] in, Represents the world coordinate system The axis in the camera coordinate system Through the first crank external reference The point in the world coordinate system can be Point transformed into the first camera coordinate system , .
[0116] The specific solution steps are as follows:
[0117] According to the trajectory of the first characteristic point, the pre-constructed crank extrinsic parameter objective function is solved based on the genetic algorithm until the crank extrinsic parameter objective function is minimized to obtain the optimal first crank extrinsic parameter.
[0118] Among them, the optimization goal of the crank extrinsic parameter objective function is that the trajectory of the first feature point in the camera coordinate system is converted to the world coordinate system through the first crank extrinsic parameter and falls on a preset circular trajectory, and the crank rotation center 5 in the camera coordinate system coincides with the origin of the world coordinate system.
[0119] Furthermore, the expression of the crank extrinsic objective function is as follows:
[0120]
[0121] In the formula, represents the crank extrinsic objective function; Represents the first crank external parameter; represents the weight coefficient; represents the number of feature points in the first feature point trajectory; Represents the nth feature point transformed from the camera coordinate system to the world coordinate system; represents the origin (0,0,0) of the world coordinate system corresponding to the crank rotation center 5; Indicates the crank radius; It represents the point where the crank rotation center 5 is converted from the camera coordinate system to the world coordinate system.
[0122] The genetic algorithm in this embodiment gradually optimizes the solution of the problem by simulating the operations of selection, crossover and mutation in the biological evolution process, and is applicable to complex multi-dimensional optimization problems. In the specific implementation, the external parameters obtained by preliminary calculation will be used as the initial population of the genetic algorithm. The objective function is defined and applied to the algorithm, and the optimal crank external parameters are finally obtained through multiple iterations to ensure that the trajectory of the feature points is accurately consistent with the circular trajectory in the world coordinate system. This optimization process not only improves the accuracy of the external parameters, but also enhances the accuracy and reliability of the entire measurement system.
[0123] 2.4. According to the first angle working video and the second angle working video, the pre-constructed plane distance objective function is solved based on the differential evolution algorithm to obtain the plane distance between the crank plane 1 and the walking beam plane 2.
[0124] For the existing method, the distance between the crank plane 1 and the beam plane 2 An indirect measurement method was adopted: the distance between the two crank planes 1 was measured on site , method setting However, the distance between the crank plane 1 and the beam plane 2 obtained in this way ignores the thickness of the beam and the thickness of the crank. This will cause errors in the calculation of the external parameters of the beam plane 2. The present invention designs an algorithm for calculating the distance between the planes using dual video. The specific steps are as follows:
[0125] Assume that the origin of the world coordinate system is set to the crank rotation center 5, and the world coordinate of the walking beam fixed point 4 remains unchanged.
[0126] (1) Based on the first angle working video, the coordinates of the beam fixing point 4 in the first camera coordinate system are extracted, based on the plane distance The first external parameter of the variable is used to calculate the first coordinate of the fixed point 4 of the beam in the world coordinate system. The expression is as follows:
[0127] ;
[0128] In the formula, Indicates the distance between the included planes The first coordinate of the variable beam fixed point 4 in the world coordinate system; represents the coordinates of the beam fixing point 4 in the first camera coordinate system; Indicates the distance between the included planes The first beam rotation matrix in the first beam extrinsic parameter of the variable; Indicates the distance between the included planes The first beam translation vector in the first beam extrinsic parameter of the variable.
[0129] (2) Based on the second angle working video, the coordinates of the beam fixing point 4 in the second camera coordinate system are extracted and the plane distance is included. The second external parameter of the variable is used to calculate the second coordinate of the fixed point 4 of the beam in the world coordinate system. The expression is as follows:
[0130] ;
[0131] In the formula, Indicates the distance between the included planes The second coordinate of the variable beam fixed point 4 in the world coordinate system; represents the coordinates of the beam fixing point 4 in the second camera coordinate system; Indicates the distance between the included planes The second beam rotation matrix in the second beam extrinsic parameters of the variables; Indicates the distance between the included planes The second beam translation vector in the second beam extrinsic parameter of the variable.
[0132] (3) According to the first coordinate and the second coordinate of the beam fixed point 4 in the world coordinate system, the pre-constructed plane distance objective function is solved by using the differential evolution algorithm until the plane distance objective function is minimized, and the optimal plane distance between the crank plane 1 and the beam plane 2 is obtained, thereby obtaining the first beam extrinsic parameter;
[0133] The optimization goal of the plane distance objective function is to minimize the point distance between the first coordinate and the second coordinate of the walking beam fixed point 4 in the world coordinate system.
[0134] Furthermore, the objective function of the plane distance objective function is as follows:
[0135]
[0136] In the formula, represents the second objective function; It represents the plane distance between the crank plane 1 and the beam plane 2; Indicates the distance between the included planes The first coordinate of the variable beam fixed point 4 in the world coordinate system; Indicates the distance between the included planes The second coordinate of the variable walking beam fixed point 4 in the world coordinate system.
[0137] In this embodiment, the differential evolution algorithm is used to optimize the second objective function. The differential evolution algorithm can handle complex multi-dimensional optimization problems and is suitable for adjusting the plane distance between the crank plane 1 and the walking beam plane 2 to minimize the objective function value.
[0138] 2.5. According to the plane distance and the first crank external parameter, the first walking beam external parameter is obtained.
[0139] The first walking beam external parameters include the first walking beam rotation matrix and the first walking beam translation vector, and the expression is as follows:
[0140] ;
[0141] In the formula, represents the first beam rotation matrix; represents the first beam translation vector; represents the first crank rotation matrix in the first crank external parameter; represents the first crank translation vector in the first crank extrinsic parameter; It represents the translation vector of the beam coordinate system relative to the crank coordinate system, and the expression is as follows:
[0142] ;
[0143] In the formula, Indicates the plane distance between the crank plane 1 and the beam plane 2.
[0144] It should be noted that since the connection point between the connecting rod and the crank protrudes from the crank plane 1, the external parameter of the connecting rod plane can be calculated by measuring the protruding distance of the connecting rod on site. and , improve the accuracy of connecting rod length measurement.
[0145] Step 3: Measure geometric dimensions.
[0146] Knowing the first crank external parameter, the first walking beam external parameter, and the first internal parameter obtained in advance by calibration, the coordinates of the size point of any measured part of the pumping unit in the first angle working video in the image coordinate system can be converted into coordinates in the world coordinate system, thereby realizing the size measurement of the measured part.
[0147] Assuming that the part to be measured of the pumping unit includes the first dimension point and the second dimension point, the specific steps are as follows:
[0148] According to the first angle working video, the coordinates of the first size point and the second size point in the image coordinate system are respectively extracted;
[0149] If the first dimension point and the second dimension point are both located on the crank plane 1, the coordinates of the first dimension point and the second dimension point in the world coordinate system are obtained according to the first internal parameter, the first crank external parameter, and the coordinates of the first dimension point and the second dimension point in the image coordinate system, and then the size of the part to be measured is calculated; wherein the distance between the first dimension point and the second dimension point in the world coordinate system represents the size of the part to be measured;
[0150] If the first dimension point and the second dimension point are both located on the beam plane 2, the coordinates of the first dimension point and the second dimension point in the world coordinate system are obtained according to the first internal parameter, the first beam external parameter, and the coordinates of the first dimension point and the second dimension point in the image coordinate system, and then the size of the part to be measured is calculated;
[0151] If the first dimension point is located on the crank plane 1 and the second dimension point is located on the rocker plane 2, the coordinates of the first dimension point in the world coordinate system are obtained according to the first internal parameter, the first crank external parameter, and the coordinates of the first dimension point in the image coordinate system; the coordinates of the second dimension point in the world coordinate system are obtained according to the first internal parameter, the first rocker external parameter, and the coordinates of the second dimension point in the image coordinate system; the size of the part to be measured is further calculated according to the coordinates of the first dimension point and the second dimension point in the world coordinate system.
[0152] When the first crank extrinsic parameter, the first walking beam extrinsic parameter, and the first intrinsic parameter are known, any point in the image coordinate system of the first angle working video can find the corresponding point in the world coordinate system. Assuming that the coordinates of the size point in the image coordinate system are (u, v), the expanded homogeneous coordinates are .
[0153] Assume that the dimension point (u, v) is on crank plane 1 and transforms it to the coordinates in the world coordinate system for:
[0154] ;
[0155] In the formula, Represents the coordinates of the size point (u, v) on crank plane 1 in the first camera coordinate system after rotation. The expression is as follows:
[0156] ;
[0157] In the formula, Indicates the first internal reference; represents the first crank rotation matrix in the first crank external parameter;
[0158] It represents the depth of the dimension point (u,v) on the crank plane 1, and the expression is as follows:
[0159] ;
[0160] In the formula, represents the z component of the first crank translation vector in the first crank extrinsic parameter; Representing coordinates The z component of
[0161] Represents the first crank translation vector in the first crank extrinsic parameter.
[0162] Assume that the dimension point (u, v) is on the beam plane 2 and transform it to the coordinates in the world coordinate system for:
[0163] ;
[0164] In the formula, Represents the coordinates of the size point (u, v) on the beam plane 2 in the first camera coordinate system after rotation. The expression is as follows:
[0165] ;
[0166] In the formula, Indicates the first internal reference; represents the first beam rotation matrix in the first beam extrinsic parameters;
[0167] It represents the depth of the dimension point (u,v) on the beam plane 2, and the expression is as follows:
[0168] ;
[0169] In the formula, represents the z component of the first beam translation vector in the first beam extrinsic parameter; Representing coordinates The z component of
[0170] Represents the first beam translation vector in the first beam extrinsic parameter.
[0171] Step 4: Calculate the mass of the counterweight.
[0172] In the influence of the geometric dimensions of the pumping unit on the physical modeling and the power diagram of the electrical parameter conversion, the accurate calculation of the area of the counterweight is a key step. This calculation can realize the dynamic load analysis and torque balance calculation, thereby predicting the power diagram shape under different working conditions. To this end, the following method is designed to calculate the actual area of the counterweight:
[0173] 4.1. Obtain the thickness and density of the counterweight of the oil pump.
[0174] 4.2. Based on the semantic segmentation algorithm of deep learning, the contour of the counterweight block in the first-angle working video or the second-angle working video is segmented to obtain multiple segmentation masks; the segmentation mask with the highest confidence is taken as the final mask data.
[0175] Specifically, in the video frame of the pumping unit, a rectangular box is used to select the area containing the complete crank block. Some key points are marked to indicate the area that needs to be included in the segmentation, which helps to improve the segmentation accuracy and remove the holes on the crank block.
[0176] The semantic segmentation model returns multiple segmentation masks and the corresponding confidence score . Select the mask data with the highest confidence As the outline of the counterweight.
[0177] 4.3. Extract the inner and outer contour points of the mask data to obtain a contour set.
[0178] Specifically, for the selected mask data Use the findContours() function to extract the inner and outer contours and obtain a contour set ,in Represents the outer contour, Represents the inner contour.
[0179] 4.4. Convert each contour point in the contour set to the world coordinate system, and then calculate the area difference between the inner and outer contours to obtain the actual area of the counterweight.
[0180] 4.5. According to the actual area of the counterweight ,thickness and density , calculate the mass of the counterweight , .
[0181] Through the above method, the area of the counterweight can be accurately calculated and its mass can be derived, thus realizing a comprehensive analysis of the dynamic load of the pumping unit. For the first time, deep learning technology is introduced to derive the three-dimensional contour of the counterweight using the characteristic point external parameters, so as to accurately estimate its mass. This innovation breaks through the limitation that the existing method cannot measure the mass of the counterweight. It not only improves the measurement accuracy, but also provides more reliable data support for the simulation results of the electrical parameter conversion power diagram.
[0182] In summary, the present invention not only improves the measurement accuracy of the geometric dimensions of the beam pumping unit, but also significantly improves the safety and efficiency of the measurement, and solves multiple problems in the prior art.
[0183] Example 2
[0184] This embodiment 2 provides a pumping unit geometric dimension measurement system based on dual video correction, which is applicable to the above-mentioned pumping unit geometric dimension measurement method based on dual video correction, including:
[0185] A data acquisition module, used to acquire a first-angle working video and a second-angle working video of the oil pump;
[0186] A first crank extrinsic parameter module is used to solve a pre-constructed crank extrinsic parameter objective function based on a genetic algorithm according to the first angle working video to obtain a first crank extrinsic parameter;
[0187] A plane distance module is used to solve a pre-constructed plane distance objective function based on a differential evolution algorithm according to the first angle working video and the second angle working video, and obtain the plane distance between the crank plane 1 and the walking beam plane 2;
[0188] A first walking beam extrinsic parameter module, used for obtaining the first walking beam extrinsic parameter according to the plane distance and the first crank extrinsic parameter;
[0189] The dimension measurement module is used to measure the dimension of the part to be measured by converting the coordinates of the dimension point of any part to be measured of the pumping unit in the first angle working video in the image coordinate system into the coordinates in the world coordinate system based on the first crank external parameter, the first walking beam external parameter, and the first internal parameter obtained in advance.
[0190] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0191] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0192] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0193] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0194] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for measuring the geometric dimensions of an oil pump based on dual video correction, characterized in that: The measuring method comprises the following steps: Obtaining a first-angle working video and a second-angle working video of the oil pumping unit; According to the first angle working video, a pre-constructed crank extrinsic parameter objective function is solved based on a genetic algorithm to obtain a first crank extrinsic parameter; According to the first angle working video and the second angle working video, a pre-constructed plane distance objective function is solved based on a differential evolution algorithm to obtain a plane distance between a crank plane and a beam plane; Obtaining a first walking beam external parameter according to the plane distance and the first crank external parameter; According to the first crank external parameter, the first walking beam external parameter, and the first internal parameter obtained in advance by calibration, the size measurement of the part to be measured is achieved by converting the coordinates of the size point of any part to be measured of the pumping unit in the first angle working video in the image coordinate system into the coordinates in the world coordinate system.
2. The method for measuring geometric dimensions of an oil pumping unit based on dual video correction according to claim 1 is characterized in that: The steps for obtaining the first angle working video and the second angle working video are as follows: Placing the first camera at a preset first position and the second camera at a preset second position, wherein the distance between the first position and the second position is 2-5 meters; The first camera and the second camera are both provided with an inertial measurement unit, and the pitch angle and the rotation angle are adjusted by the inertial measurement unit so that the first camera or the second camera is parallel to the plane where the pumping unit is located and maintains a shooting state of zero rotation angle; The first camera is used to capture a first-angle working video of the oil pump; the second camera is used to capture a second-angle working video of the oil pump.
3. The method for measuring geometric dimensions of an oil pumping unit based on dual video correction according to claim 1 is characterized in that: A characteristic point is set at the end of any crank rotating shaft of the pumping unit to be tested; the step of obtaining the first crank external parameter comprises the following steps: Extracting a first feature point set according to each frame image of the first angle working video; For any feature point in the first feature point set, perform center point extraction and remove noise by excluding static points and outliers to obtain the first feature point trajectory , , represents the number of feature points in the first feature point trajectory; According to the first characteristic point trajectory, solving the pre-constructed crank extrinsic parameter objective function based on the genetic algorithm until the crank extrinsic parameter objective function is minimized to obtain the optimal first crank extrinsic parameter; Among them, the optimization target of the crank extrinsic parameter objective function is that the trajectory of the first feature point in the camera coordinate system falls on a preset circular trajectory after being converted to the world coordinate system through the first crank extrinsic parameter, and the crank rotation center in the camera coordinate system coincides with the origin of the world coordinate system.
4. The method for measuring geometric dimensions of an oil pumping unit based on dual video correction according to claim 3 is characterized in that: The expression of the crank extrinsic parameter objective function is as follows: ; In the formula, represents the crank extrinsic objective function; Represents the first crank external parameter; represents the weight coefficient; N1 represents the number of feature points in the first feature point trajectory; Represents the nth feature point transformed from the camera coordinate system to the world coordinate system; represents the origin (0,0,0) of the world coordinate system corresponding to the rotation center of the crank; r represents the radius of the crank; The point representing the crank's rotation center transformed from the camera coordinate system to the world coordinate system.
5. The method for measuring geometric dimensions of an oil pumping unit based on dual video correction according to claim 1 is characterized in that: The step of obtaining the first beam external parameter comprises the following steps: According to the first angle working video, calculate the first coordinate of the beam fixing point in the world coordinate system; According to the second angle working video, calculate the second coordinate of the beam fixing point in the world coordinate system; According to the first coordinate and the second coordinate of the beam fixed point in the world coordinate system, a differential evolution algorithm is used to solve the pre-constructed plane distance objective function until the plane distance objective function is minimized, and the optimal plane distance between the crank plane and the beam plane is obtained, thereby obtaining the first beam extrinsic parameter; The optimization objective of the plane distance objective function is to minimize the point distance between the first coordinate and the second coordinate of the walking beam fixed point in the world coordinate system.
6. The method for measuring geometric dimensions of an oil pumping unit based on dual video correction according to claim 5 is characterized in that: The objective function of the plane distance objective function is as follows: ; In the formula, represents the second objective function; It represents the plane distance between the crank plane and the beam plane; Indicates the distance between the included planes The first coordinate of the variable beam fixed point in the world coordinate system is expressed as follows: ; In the formula, Represents the coordinates of the beam fixing point in the first camera coordinate system; Indicates the distance between the included planes The first beam rotation matrix in the first beam extrinsic parameter of the variable; Indicates the distance between the included planes The first beam translation vector in the first beam extrinsic parameter of the variable; Indicates the distance between the included planes The second coordinate of the variable beam fixed point in the world coordinate system is expressed as follows: ; In the formula, represents the coordinates of the beam fixing point in the second camera coordinate system; Indicates the distance between the included planes The second beam rotation matrix in the second beam extrinsic parameters of the variables; Indicates the distance between the included planes The second walking beam translation vector in the second walking beam extrinsic parameter of the variable.
7. The method for measuring geometric dimensions of an oil pumping unit based on dual video correction according to claim 1 is characterized in that: The first beam extrinsic parameters include the first beam rotation matrix and the first beam translation vector, which are expressed as follows: ; In the formula, represents the first beam rotation matrix; represents the first beam translation vector; represents the first crank rotation matrix in the first crank external parameter; represents the first crank translation vector in the first crank extrinsic parameter; It represents the translation vector of the beam coordinate system relative to the crank coordinate system, and the expression is as follows: ; In the formula, Indicates the plane distance between the crank plane and the beam plane.
8. The method for measuring geometric dimensions of an oil pumping unit based on dual video correction according to claim 1 is characterized in that: The dimension measurement of the part to be measured comprises the following steps: The part to be measured of the oil pumping unit includes a first dimension point and a second dimension point; According to the first angle working video, the coordinates of the first size point and the second size point in the image coordinate system are respectively extracted; If the first dimension point and the second dimension point are both located on the crank plane, the coordinates of the first dimension point and the second dimension point in the world coordinate system are obtained according to the first internal parameter, the first crank external parameter, and the coordinates of the first dimension point and the second dimension point in the image coordinate system, and then the size of the part to be measured is calculated; wherein the distance between the first dimension point and the second dimension point in the world coordinate system represents the size of the part to be measured; If the first dimension point and the second dimension point are both located in the beam plane, the coordinates of the first dimension point and the second dimension point in the world coordinate system are obtained according to the first internal parameter, the first beam external parameter, and the coordinates of the first dimension point and the second dimension point in the image coordinate system, and then the size of the part to be measured is calculated; If the first dimension point is located in the crank plane and the second dimension point is located in the rocker plane, the coordinates of the first dimension point in the world coordinate system are obtained according to the first internal parameter, the first crank external parameter, and the coordinates of the first dimension point in the image coordinate system; the coordinates of the second dimension point in the world coordinate system are obtained according to the first internal parameter, the first rocker external parameter, and the coordinates of the second dimension point in the image coordinate system; the size of the part to be measured is calculated according to the coordinates of the first dimension point and the second dimension point in the world coordinate system.
9. The method for measuring geometric dimensions of an oil pumping unit based on dual video correction according to claim 1 is characterized in that: The measuring method further comprises the following steps: Obtain the thickness and density of the counterweight of the pumping unit; Based on a semantic segmentation algorithm of deep learning, contour segmentation is performed on the counterweight block in the first angle working video or the second angle working video to obtain multiple segmentation masks; and the segmentation mask with the highest confidence is taken as the final mask data; Extracting inner and outer contour points of the mask data to obtain a contour set; Convert each contour point in the contour set to the world coordinate system, and then calculate the area difference between the inner and outer contours to obtain the actual area of the counterweight; Calculate the mass of the counterweight block according to the actual area, thickness and density of the counterweight block; According to the first crank external parameter, the first walking beam external parameter, and the first internal parameter of the first camera obtained in advance through calibration, the dimension points of any measured part of the pumping unit in the first angle working video in the image coordinate system are converted into dimension points in the world coordinate system, so as to achieve the dimension measurement of the measured part.
10. A pumping unit geometric dimension measurement system based on dual video correction, applicable to a pumping unit geometric dimension measurement method based on dual video correction as claimed in any one of claims 1 to 9, characterized in that: include: A data acquisition module, used to acquire a first-angle working video and a second-angle working video of the oil pump; A first crank extrinsic parameter module, configured to solve a pre-constructed crank extrinsic parameter objective function based on a genetic algorithm according to the first angle working video to obtain a first crank extrinsic parameter; A plane distance module is used to solve a pre-constructed plane distance objective function based on the differential evolution algorithm according to the first angle working video and the second angle working video, so as to obtain the plane distance between the crank plane and the walking beam plane; A first walking beam extrinsic parameter module, used for obtaining a first walking beam extrinsic parameter according to the plane distance and a first crank extrinsic parameter; The dimension measurement module is used to measure the dimension of any part to be measured in the first angle working video by converting the coordinates of the dimension point of the part to be measured of the pumping unit in the image coordinate system into the coordinates in the world coordinate system based on the first crank external parameter, the first walking beam external parameter, and the first internal parameter obtained in advance.