Disclosure of Invention
In view of the above, the present invention provides a method, an apparatus, a device and a storage medium for measuring a distance of an object on a horizontal plane, wherein the method is simple and easy to implement, low in cost, and wide in distance measurement range, and does not require matching of corresponding points of left and right cameras. The specific scheme is as follows:
a method of range finding an object in a horizontal plane, comprising:
calibrating parameters of a monocular camera to obtain internal parameters of the monocular camera;
calibrating the rotation angle scale of the monocular camera;
acquiring an image of a target through the monocular camera, and acquiring an image coordinate of the target in the acquired image;
reading a current included angle between the optical axis of the monocular camera and a telescopic bracket for fixing the monocular camera through the calibrated rotation angle scale, and simultaneously reading the current height of the telescopic bracket;
and calculating the position of the target on the horizontal plane according to the acquired internal parameters and the image coordinates, and the read current height and the current included angle.
Preferably, in the method for measuring a distance to a target on a horizontal plane provided in the embodiment of the present invention, calibrating parameters of the monocular camera specifically includes:
and calibrating the parameters of the monocular camera by adopting a Zhangyingyou chessboard pattern calibration method.
Preferably, in the above method for ranging a target on a horizontal plane, the internal parameters include an optical center pixel coordinate of an imaging plane, and focal length in pixels in x and y directions of the imaging plane, respectively.
Preferably, in the method for measuring a distance to a target on a horizontal plane provided in the embodiment of the present invention, calibrating the rotation angle scale of the monocular camera specifically includes:
adjusting a telescopic bracket for fixing the monocular camera to the lowest height;
rotating the included angle between the optical axis of the monocular camera and the telescopic bracket to the maximum angle;
moving the position of a calibration object on a horizontal plane until the image coordinate of the calibration object is located at the optical center pixel coordinate, and measuring the distance between the calibration object and a horizontal base for fixing the telescopic bracket;
calculating the maximum angle value of the included angle according to the lowest height of the telescopic bracket and the distance obtained by measurement;
and averaging the calculated maximum angle value, and marking the angle of each scale after averaging.
Preferably, in the above method for measuring a distance to an object on a horizontal plane provided in the embodiment of the present invention, before calculating a position of the object on the horizontal plane, the method further includes:
and establishing an O-XYZ space coordinate system, taking a fixed point of the horizontal base and the telescopic support as an origin, taking the telescopic support as a Z axis, taking the horizontal plane as a plane where an X axis and a Y axis are located, and taking the optical axis of the monocular camera to pass through the X axis, wherein the position coordinate of the target on the horizontal plane is (X, Y).
Preferably, in the above method for measuring distance of an object on a horizontal plane provided by the embodiment of the present invention, the position coordinates of the object on the horizontal plane are calculated by using the following formula: :
wherein (X, Y) represents the position coordinates of the object on the horizontal plane α1Representing the current included angle between the optical axis of the monocular camera and the telescopic bracket, H representing the current height of the telescopic bracket, α2Representing the included angle between the connecting line of the projection point of the target on the X axis and the optical center and the optical axis of the monocular camera; (u, v) represents the image coordinates; (u)0,v0) Representing the optical center pixel coordinates; f. ofxRepresents the focal length in pixels in the x-direction of the imaging plane; f. ofyDenotes the focal length in pixels in the y-direction of the imaging plane.
The embodiment of the invention also provides a device for measuring the distance of the target on the horizontal plane, which comprises: the device comprises a horizontal base, a telescopic bracket which is fixed on the horizontal base and adjustable in height, and a monocular camera which is fixed at the top end of the telescopic bracket and adjustable in pitching angle and is used for acquiring an image of a target; further comprising:
the parameter calibration module is used for calibrating the parameters of the monocular camera to acquire the internal parameters of the monocular camera;
the angle calibration module is used for calibrating the rotation angle scale of the monocular camera;
the coordinate acquisition module is used for acquiring the image coordinates of the target in the acquired image;
the data reading module is used for reading the current included angle between the optical axis of the monocular camera and the telescopic bracket through the calibrated rotating angle scale and reading the current height of the telescopic bracket;
and the position calculation module is used for calculating the position of the target on a horizontal plane according to the acquired internal parameters and the image coordinates, and the read current height and the current included angle.
Preferably, in the above device for measuring a distance to a target on a horizontal plane provided in an embodiment of the present invention, the device further includes:
and the coordinate system establishing module is used for establishing an O-XYZ space coordinate system, the fixed point of the horizontal base and the telescopic support is taken as an origin, the telescopic support is a Z axis, the horizontal plane is a plane where an X axis and a Y axis are located, and the optical axis of the monocular camera passes through the X axis, so that the position coordinate of the target on the horizontal plane is (X, Y).
The embodiment of the present invention further provides an apparatus for measuring a distance to a target on a horizontal plane, which includes a processor and a memory, where the processor implements the method for measuring a distance to a target on a horizontal plane, provided by the embodiment of the present invention, when executing a computer program stored in the memory.
Embodiments of the present invention further provide a computer-readable storage medium for storing a computer program, where the computer program is executed by a processor to implement the above method for ranging a target on a horizontal plane according to an embodiment of the present invention.
It can be seen from the above technical solutions that, the method, apparatus, device and storage medium for measuring distance of an object on a horizontal plane provided by the present invention include: calibrating parameters of the monocular camera to obtain internal parameters of the monocular camera; calibrating the rotation angle scale of the monocular camera; acquiring an image of a target through a monocular camera, and acquiring an image coordinate of the target in the acquired image; reading the current included angle between the optical axis of the monocular camera and a telescopic bracket for fixing the monocular camera through the calibrated rotation angle scale, and simultaneously reading the current height of the telescopic bracket; and calculating the position of the target on the horizontal plane according to the acquired internal parameters and image coordinates, the read current height and the read current included angle.
The method provided by the application is based on the monocular camera, the internal parameters of the monocular camera are obtained through calibration, the rotation angle scale of the monocular camera is calibrated, the monocular camera is used for collecting a target image, the spatial position of the target on a horizontal plane is calculated according to the image coordinate of the target image, the height of the telescopic support and the pitching angle of the optical axis of the monocular camera can be adjusted according to the image coordinate of the target, the operation is simple and easy to implement, the cost is low, the distance measurement range is wide, the algorithm is simple, the implementation is strong, non-contact measurement is achieved, corresponding points of the left camera and the right camera are not required to be matched, and the method has.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The invention provides a method for measuring distance of a target on a horizontal plane, which comprises the following steps as shown in figure 1:
s101, calibrating parameters of the monocular camera to obtain internal parameters of the monocular camera;
it should be understood that the intrinsic parameters obtained in this step are used to provide the basis for calculating the spatial position of the target on the horizontal plane;
s102, calibrating the rotation angle scale of the monocular camera;
in the invention, the included angle between the optical axis of the monocular camera and the telescopic bracket for fixing the monocular camera (namely, the pitching angle of the optical axis of the monocular camera) can be adjusted, and the rotation angle scale of the monocular camera is calibrated and marked, so that the adjusted included angle value between the optical axis and the telescopic bracket can be conveniently read later, and a basis is provided for calculating the spatial position of a target on a horizontal plane;
s103, acquiring an image of the target through a monocular camera, and acquiring an image coordinate of the target in the acquired image;
in the process of executing the step, the height of a telescopic bracket for fixing the monocular camera and the angle between the optical axis of the monocular camera and the telescopic bracket need to be adjusted until an image of a target can be acquired;
s104, reading a current included angle between the optical axis of the monocular camera and a telescopic bracket for fixing the monocular camera through the calibrated rotation angle scale, and simultaneously reading the current height of the telescopic bracket;
and S105, calculating the position of the target on the horizontal plane according to the acquired internal parameters and image coordinates, the read current height and the read current included angle.
In the method for measuring the distance of the target on the horizontal plane provided by the embodiment of the invention, firstly, parameter calibration is carried out on a monocular camera to obtain internal parameters of the monocular camera; then calibrating the rotation angle scale of the monocular camera; then, acquiring an image of the target through a monocular camera, and acquiring an image coordinate of the target in the acquired image; then, reading the current included angle between the optical axis of the monocular camera and the telescopic bracket through the calibrated rotation angle scale, and simultaneously reading the current height of the telescopic bracket; and finally, calculating the position of the target on the horizontal plane according to the acquired internal parameters and image coordinates, the read current height and the read current included angle. The space position of the target on the horizontal plane can be obtained through the steps, the whole operation is simple and easy to implement, the cost is low, the range measurement range is wide, corresponding points of the left camera and the right camera are not required to be matched, and the method has high application value.
In a specific implementation, in the method for measuring a distance to a target on a horizontal plane provided in the embodiment of the present invention, the step S101 performs parameter calibration on the monocular camera, which may specifically include: and (5) calibrating parameters of the monocular camera by adopting a Zhangyingyou chessboard pattern calibration method. As shown in FIG. 2, the intrinsic parameter includes the optical center pixel coordinate O of the imaging plane xy1(u0,v0) And focal length f in pixels in the x-direction and y-direction of the imaging plane, respectivelyx、fy. O in FIG. 2c-XcYcZcCamera coordinate system for monocular camera, OcIs the optical center of the camera, as the origin of the camera coordinate system, P is the image coordinates of the object in the image, P is the coordinates of the object in the camera coordinate system,is targeted relative to ZcAxis in XcOZcDeclination on a plane.
In a specific implementation, in the method for measuring a distance to a target on a horizontal plane provided in the embodiment of the present invention, the step S102 may calibrate a rotation angle scale of the monocular camera, and specifically include: as shown in fig. 3, thetelescopic bracket 2 for fixing the monocular camera 1 is adjusted to the lowest height h; rotating the included angle between the optical axis of the monocular camera 1 and thetelescopic bracket 2 to the maximum angle; the position of thecalibration object 4 is moved on the horizontal plane until the image coordinates of thecalibration object 4 are located at the optical center pixel coordinates (u)0,v0) During the process, measuring the distance l between thecalibration object 4 and thehorizontal base 3 for fixing thetelescopic bracket 2; according to the minimum height h of thetelescopic bracket 2 and the measured distance l, the monocular camera 1 is calculatedThe maximum angle value of the included angle between the optical axis and thetelescopic bracket 2; and (4) averaging the calculated maximum angle value, and marking the angle of each scale after averaging.
Specifically, the following formula can be adopted to calculate the maximum angle value of the included angle between the optical axis of the monocular camera 1 and the telescopic bracket 2:
wherein α represents the biggest angle of the contained angle between monocular camera optical axis and the telescopic bracket, l represents the distance between calibration object and the horizontal base, and h represents the minimum height of telescopic bracket.
The calculated maximum angle α is divided equally into n parts, and the angle of each scale is equal to
Further, in the above method for measuring a distance to a target on a horizontal plane according to the embodiment of the present invention, in the step S103, acquiring an image of the target by using a monocular camera, and acquiring image coordinates of the target in the acquired image, specifically, as shown in fig. 4, adjusting the height of thetelescopic bracket 2 to be H, and adjusting the included angle between the optical axis of the monocular camera 1 and the telescopic bracket to α1The monocular camera 1 is enabled to capture an image of the target, and the image coordinates (u, v) of the target in the image are recognized.
Further, in practical implementation, in the above method for measuring a distance to a target on a horizontal plane provided in the embodiment of the present invention, before the step S105 is executed to calculate the position of the target on the horizontal plane, as shown in fig. 4, the method further includes:
and establishing an O-XYZ space coordinate system, wherein a fixed point of the horizontal base and the telescopic support is taken as an original point, the telescopic support is a Z axis, the horizontal plane is a plane where an X axis and a Y axis are located, and the optical axis of the monocular camera passes through the X axis, so that the position coordinate of the target on the horizontal plane is (X, Y).
Next, when step S105 is executed, the position coordinates of the object on the horizontal plane are calculated using the following formula:
wherein (X, Y) represents the position coordinates of the object on the horizontal plane α1Representing the current angle between the monocular camera's optical axis and the telescopic support, H representing the current height of the telescopic support, α2The included angle between the connecting line of the projection point of the target on the X axis and the optical center and the optical axis of the monocular camera is represented; (u, v) represents image coordinates; (u)0,v0) Representing optical center pixel coordinates; f. ofxRepresents the focal length in pixels in the x-direction of the imaging plane; f. ofyDenotes the focal length in pixels in the y-direction of the imaging plane.
It should be noted that α2The derivation of Y is as follows:
the spatial position of the target on the horizontal plane can be calculated by the formula, the algorithm is simple, the realization performance is strong, non-contact measurement is realized, and the target which cannot be reached can be measured.
Based on the same inventive concept, the embodiment of the present invention further provides a device for measuring a distance to a target on a horizontal plane, and since the principle of the device for measuring a distance to a target on a horizontal plane to solve the problem is similar to the above method for measuring a distance to a target on a horizontal plane, the implementation of the device for measuring a distance to a target on a horizontal plane can refer to the implementation of the method for measuring a distance to a target on a horizontal plane, and repeated details are omitted.
In specific implementation, the device for measuring a distance to a target on a horizontal plane according to the embodiment of the present invention, as shown in fig. 4, includes: the device comprises ahorizontal base 3, atelescopic bracket 2 which is fixed on thehorizontal base 3 and is adjustable in height, and a monocular camera 1 which is fixed at the top end of thetelescopic bracket 2 and is adjustable in pitching angle and used for collecting images of a target; further comprising:
the parameter calibration module is used for calibrating parameters of the monocular camera 1 to obtain internal parameters of the monocular camera 1;
the angle calibration module is used for calibrating the rotation angle scale of the monocular camera 1;
the coordinate acquisition module is used for acquiring image coordinates of the target in the acquired image;
the data reading module is used for reading the current included angle between the optical axis of the monocular camera 1 and thetelescopic bracket 2 through the calibrated rotating angle scale and simultaneously reading the current height of thetelescopic bracket 2;
and the position calculation module is used for calculating the position of the target on the horizontal plane according to the acquired internal parameters and image coordinates, the read current height and the read current included angle.
In the device for measuring the distance of the target on the horizontal plane provided by the embodiment of the invention, the position of the target on the horizontal plane can be calculated through the interaction of the components, and the device is simple to operate, low in cost and high in application value.
For more specific working processes of the modules, reference may be made to corresponding contents disclosed in the foregoing embodiments, and details are not repeated here.
Correspondingly, the embodiment of the invention also discloses a device for measuring the distance of the target on the horizontal plane, which comprises a processor and a memory; wherein the processor, when executing the computer program stored in the memory, implements the method for target ranging on a horizontal plane as disclosed in the foregoing embodiments.
For more specific processes of the above method, reference may be made to corresponding contents disclosed in the foregoing embodiments, and details are not repeated here.
Further, the present invention also discloses a computer readable storage medium for storing a computer program; the computer program when executed by a processor implements the method for range finding of an object in a horizontal plane as disclosed above.
For more specific processes of the above method, reference may be made to corresponding contents disclosed in the foregoing embodiments, and details are not repeated here.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. The device, the equipment and the storage medium disclosed by the embodiment correspond to the method disclosed by the embodiment, so that the description is relatively simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The embodiment of the invention provides a method, a device, equipment and a storage medium for measuring distance of a target on a horizontal plane, wherein the method comprises the following steps: calibrating parameters of the monocular camera to obtain internal parameters of the monocular camera; calibrating the rotation angle scale of the monocular camera; acquiring an image of a target through a monocular camera, and acquiring an image coordinate of the target in the acquired image; reading the current included angle between the optical axis of the monocular camera and the telescopic bracket for fixing the monocular camera through the calibrated rotation angle scale, and simultaneously reading the current height of the telescopic bracket for fixing the monocular camera; and calculating the position of the target on the horizontal plane according to the acquired internal parameters and image coordinates, the read current height and the read current included angle. The method provided by the invention has the advantages of simple and easy operation, low cost, wide range of distance measurement, simple algorithm, strong realizability, non-contact measurement, no need of matching corresponding points of a left camera and a right camera, and very high application value.
Finally, it is further noted that, herein, relational terms are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The method, apparatus, device and storage medium for measuring distance of an object on a horizontal plane provided by the present invention are described in detail above, and a specific example is applied in the present disclosure to explain the principle and the implementation of the present invention, and the description of the above embodiment is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.