WO2023273108A1 - Monocular distance measurement method and apparatus, and intelligent apparatus - Google Patents

Monocular distance measurement method and apparatus, and intelligent apparatus Download PDF

Info

Publication number
WO2023273108A1
WO2023273108A1 PCT/CN2021/131460 CN2021131460W WO2023273108A1 WO 2023273108 A1 WO2023273108 A1 WO 2023273108A1 CN 2021131460 W CN2021131460 W CN 2021131460W WO 2023273108 A1 WO2023273108 A1 WO 2023273108A1
Authority
WO
WIPO (PCT)
Prior art keywords
coordinates
pixel
reference point
monocular camera
pixel coordinates
Prior art date
Application number
PCT/CN2021/131460
Other languages
French (fr)
Chinese (zh)
Inventor
李奕润
程骏
庞建新
Original Assignee
深圳市优必选科技股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市优必选科技股份有限公司 filed Critical 深圳市优必选科技股份有限公司
Publication of WO2023273108A1 publication Critical patent/WO2023273108A1/en

Links

Images

Classifications

    • GPHYSICS
    • G01MEASURING; TESTING
    • G01CMEASURING DISTANCES, LEVELS OR BEARINGS; SURVEYING; NAVIGATION; GYROSCOPIC INSTRUMENTS; PHOTOGRAMMETRY OR VIDEOGRAMMETRY
    • G01C3/00Measuring distances in line of sight; Optical rangefinders
    • G01C3/26Measuring distances in line of sight; Optical rangefinders using a parallactic triangle with fixed angles and a base of variable length, at, near, or formed by the object
    • G01C3/28Measuring distances in line of sight; Optical rangefinders using a parallactic triangle with fixed angles and a base of variable length, at, near, or formed by the object with provision for reduction of the distance into the horizontal plane
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01CMEASURING DISTANCES, LEVELS OR BEARINGS; SURVEYING; NAVIGATION; GYROSCOPIC INSTRUMENTS; PHOTOGRAMMETRY OR VIDEOGRAMMETRY
    • G01C11/00Photogrammetry or videogrammetry, e.g. stereogrammetry; Photographic surveying
    • G01C11/04Interpretation of pictures
    • G01C11/06Interpretation of pictures by comparison of two or more pictures of the same area
    • G01C11/08Interpretation of pictures by comparison of two or more pictures of the same area the pictures not being supported in the same relative position as when they were taken
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01CMEASURING DISTANCES, LEVELS OR BEARINGS; SURVEYING; NAVIGATION; GYROSCOPIC INSTRUMENTS; PHOTOGRAMMETRY OR VIDEOGRAMMETRY
    • G01C11/00Photogrammetry or videogrammetry, e.g. stereogrammetry; Photographic surveying
    • G01C11/04Interpretation of pictures
    • G01C11/30Interpretation of pictures by triangulation

Definitions

  • the present application relates to the technical field of image processing, in particular to a monocular ranging method, device and intelligent device.
  • a monocular camera takes a photo, it is essentially a projection left by the shooting scene on the imaging plane of the monocular camera.
  • the photo reflects the three-dimensional world in a two-dimensional form.
  • the depth information of the shooting scene is lost during the shooting process.
  • the embodiments of the present application provide a monocular ranging method, device and smart device.
  • the embodiment of the present application provides a monocular ranging method, the method comprising:
  • a plane view is taken by a monocular camera, the ground visible area of the monocular camera includes a rectangular area, and the plane view includes a first area image corresponding to the rectangular area;
  • the reverse perspective coordinates of the target determine the target object and the monocular camera.
  • the distance between the cameras determine the target object and the monocular camera.
  • the determining the homography matrix for inverse perspective transformation of the plane view into the top view according to the pixel coordinates of the top corner of the first region image includes:
  • the homography matrix is determined according to the vertex pixel coordinates of the first area image and the reverse perspective vertex pixel coordinates.
  • the obtaining the coordinates of the reverse perspective reference point corresponding to the pixel coordinates of the reference point includes:
  • the reverse perspective coordinates of the pixel coordinates of the reference point are set according to the size of the top view.
  • the acquiring the apex pixel coordinates of the first region image and their corresponding inverse perspective apex pixel coordinates includes:
  • the pixel coordinates of the reverse perspective corner are determined according to the reverse perspective coordinates of the pixel coordinates of the reference point, the corresponding relationship between the physical scale and the pixel scale, and the side length of the rectangular area.
  • the method also includes:
  • the plane view is corrected to obtain the corrected plane view, including:
  • the plane view is corrected according to the internal reference and the distortion parameter to obtain the corrected plane view.
  • the reverse perspective coordinates of the pixel coordinates of the reference point include the pixel coordinates of the reference point in the first direction and the pixel coordinates of the reference point in the second direction, and the second direction is perpendicular to the first direction;
  • determining the pixel coordinates of the inverse perspective corners includes:
  • the pixel coordinates of the reference point in the first direction the pixel coordinates of the reference point in the second direction, the side length of the rectangular area, the corresponding relationship between the physical scale and the pixel scale, the pixel coordinates of the reverse perspective vertex and the The positional relationship of the reference point coordinates of the reverse perspective is determined, and the coordinates of the first direction and the second direction of the pixel coordinates of the reverse perspective corner are determined.
  • the target inverse perspective coordinates determines the The distance between the target object and the monocular camera, including:
  • the embodiment of the present application provides a monocular ranging device, and the monocular ranging device includes:
  • a photographing module configured to photograph a plane view through a monocular camera, the ground visible area of the monocular camera includes a rectangular area, and the plane view includes a first area image corresponding to the rectangular area;
  • a first determination module configured to determine a homography matrix for inverse perspective transformation of the plane view into a top view according to the top corner pixel coordinates of the first area image
  • An acquisition module configured to determine a reference point from the bottom of the rectangular area, and acquire a distance between the reference point and the monocular camera
  • the first processing module is configured to determine the pixel coordinates of the reference point corresponding to the reference point in the first region image, and acquire the reverse perspective reference point coordinates corresponding to the pixel coordinates of the reference point;
  • the second processing module is configured to perform target object detection on other flat views captured by the monocular camera to obtain a target object bounding box, and coordinate any pixel point on the bottom edge of the target object bounding box according to the homography matrix Perform inverse perspective transformation to obtain the target inverse perspective coordinates corresponding to the coordinates of any pixel point on the bottom edge;
  • the second determination module is configured to determine the inverse perspective reference point coordinates, the target inverse perspective coordinates, the corresponding relationship between physical scale and pixel scale, and the distance between the reference point and the monocular camera. The distance between the target object and the monocular camera.
  • the first determining module is further configured to acquire the pixel coordinates of the top corner of the first area image and the corresponding pixel coordinates of the top corner of the reverse perspective;
  • the homography matrix is determined according to the vertex pixel coordinates of the first area image and the reverse perspective vertex pixel coordinates.
  • the first determining module is further configured to set reverse perspective coordinates of pixel coordinates of the reference point according to the size of the top view.
  • the first determination module is further configured to correct the plan view to obtain a corrected plan view, the corrected plan view includes a second area image, and the vertex angle of the second area image
  • the pixel coordinates are used as the apex pixel coordinates of the first region image
  • the pixel coordinates of the reverse perspective corner are determined according to the reverse perspective coordinates of the pixel coordinates of the reference point, the corresponding relationship between the physical scale and the pixel scale, and the side length of the rectangular area.
  • the monocular distance measuring device also includes:
  • a rectification module that takes a checkerboard image through the monocular camera, and acquires internal references and distortion parameters of the monocular camera according to the checkerboard image;
  • the first determining module is further configured to correct the plane view according to the internal reference and distortion parameters to obtain the corrected plane view.
  • the reverse perspective coordinates of the pixel coordinates of the reference point include the pixel coordinates of the reference point in the first direction and the pixel coordinates of the reference point in the second direction, and the second direction is perpendicular to the first direction;
  • the first determination module is further configured to: according to the pixel coordinates of the reference point in the first direction, the pixel coordinates of the reference point in the second direction, the side length of the rectangular area, the correspondence between the physical scale and the pixel scale, The positional relationship between the reverse perspective vertex corner pixel coordinates and the reverse perspective reference point coordinates determines the first direction coordinate and the second direction coordinate of the reverse perspective vertex corner pixel coordinates.
  • the second determination module is further configured to subtract the pixel coordinates of the first direction reference point from the first direction coordinates of the target reverse perspective coordinates to obtain a first pixel difference value; The value is multiplied by the corresponding relationship between the physical scale and the pixel scale to obtain the first product; the first product is used as the first direction distance between the target object and the monocular camera; and/or,
  • an embodiment of the present application provides an intelligent device, including a monocular camera, a memory, and a processor, the memory stores a computer program, and the computer program executes the method provided in the first aspect when the processor runs. Monocular ranging method.
  • an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and the computer program executes the monocular ranging method provided in the first aspect when running on a processor.
  • the flat view is taken by a monocular camera; the pixel coordinates of the top corner of the first area image are used to determine the reverse perspective transformation of the flat view into a top view.
  • Homography matrix determine the reference point from the bottom edge of the rectangular area, and obtain the distance between the reference point and the monocular camera; determine the reference point pixel corresponding to the reference point in the first region image Coordinates, obtain the coordinates of the reverse perspective reference point corresponding to the pixel coordinates of the reference point; perform target object detection on other flat views taken by the monocular camera, obtain the target object bounding box, and calculate the target object according to the homography matrix Perform inverse perspective transformation on the coordinates of any pixel point on the bottom edge of the bounding box, and obtain the target inverse perspective coordinates corresponding to the coordinates of any pixel point on the bottom edge; according to the coordinates of the inverse perspective reference point, the target inverse perspective coordinates, and the physical scale
  • the corresponding relationship with the pixel scale and the distance between the reference point and the monocular camera determine the distance between the target object and the monocular camera. In this way, the distance of the target object can be measured through the monocular camera, without excessive data requirements, and the ranging of irregular target objects can be realized
  • Fig. 1 shows a schematic flow chart of the monocular ranging method provided by the embodiment of the present application
  • Fig. 2 shows a schematic plan view provided by the embodiment of the present application
  • Fig. 3 shows another schematic plan view provided by the embodiment of the present application.
  • Fig. 4 shows a schematic flow diagram of a rectified plane view provided by the embodiment of the present application
  • Fig. 5 shows a schematic diagram of a reverse perspective view provided by the embodiment of the present application.
  • Fig. 6 shows a schematic diagram of a physical coordinate system provided by the embodiment of the present application.
  • FIG. 7 shows a schematic structural diagram of a monocular ranging device provided by an embodiment of the present application.
  • An embodiment of the present disclosure provides a monocular ranging method.
  • the monocular ranging method includes
  • Step S101 taking a plan view with a monocular camera.
  • the ground viewable area of the monocular camera includes a rectangular area
  • the plane view includes a first area image corresponding to the rectangular area
  • tiles with a rectangular pattern can be laid on the ground, and a plurality of tiles with a rectangular pattern can form a rectangular area, and the corresponding first area image can be determined by performing image detection on a plan view.
  • a rectangular area may be set on the ground, and the rectangular area is set in the ground visible area of the monocular camera.
  • the monocular camera 201 is set on the ground 202, and the ground 202 is laid with the ceramic tile of rectangular pattern, and the ceramic tile of a plurality of rectangular patterns can form a rectangular area, for example, the ceramic tile of 4 rectangular patterns forms a rectangular area 203, by pairing The image detection is performed on the plane view, and the corresponding first area image 203 can be determined.
  • Step S102 determining a homography matrix for inverse perspective transformation of the plane view into a top view according to the pixel coordinates of the top corner of the first area image.
  • the pixel coordinate system can be established by taking the upper left corner of FIG. 2 as the origin, the left vertical side as the y-axis, and the top as the x-axis. , C, D pixel coordinates.
  • the homography matrix can be calculated according to the pixel coordinates of the top corner of the first region image and the inverse perspective coordinates of the pixel coordinates of the top corner of the first region image in the previous stage.
  • step S103 a reference point is determined from the bottom of the rectangular area, and a distance between the reference point and the monocular camera is acquired.
  • the reference point may be any point on the bottom of the rectangular area.
  • the midpoint of the bottom of the rectangular area may be used as the reference point.
  • the distance between the reference point and the monocular camera can be obtained by measuring the distance between the reference point and the monocular camera by the user, or according to the distance between the reference point and the monocular camera.
  • the number of tiles in the rectangular pattern at intervals is obtained through image analysis and processing, and is not limited here.
  • Step S104 determining the pixel coordinates of the reference point corresponding to the reference point in the first region image, and obtaining the coordinates of the reverse perspective reference point corresponding to the pixel coordinates of the reference point.
  • the rectangular area is located in the ground visible area of the monocular camera, and the image of the first area in the plane view includes all sides of the rectangular area.
  • the pixel coordinate of the reference point corresponding to the reference point in the first area image 203 is the pixel point E.
  • Step S105 Perform target object detection on other flat views captured by the monocular camera to obtain the target object bounding box, and perform inverse perspective transformation on the coordinates of any pixel point on the bottom edge of the target object bounding box according to the homography matrix , to obtain the target inverse perspective coordinates corresponding to the coordinates of any pixel point on the bottom edge.
  • the height and clamping angle of the monocular camera are kept unchanged, and other planar views are captured by the monocular camera.
  • the main purpose of target object detection is to frame the outline of the object to be detected using a rectangular frame. It can be seen from this that the bottom edge of the target object framed by the Bounding Box of the target detection is in the calibrated two-dimensional plane.
  • the first plane view 300 includes a target object 302 and a target object bounding box 301
  • the target object bounding box 301 includes a bottom edge 3013 , a top edge 3011 , a left vertical edge 3012 , and a right vertical edge 3013 .
  • the inverse perspective transformation is performed on the coordinates of the midpoint of the base 3013 according to the homography matrix, and the reverse perspective coordinates of the target corresponding to the coordinates of the midpoint of the base 3013 are obtained.
  • the pixel point coordinates of the bottom midpoint of the bounding box of the target object are subjected to inverse perspective transformation, and the target reverse perspective coordinates corresponding to the pixel point coordinates of the bottom midpoint are obtained .
  • (u, v) represent the pixel coordinates of the midpoint of the bottom edge of the bounding box of the target object
  • (x, y) are the reverse perspective coordinates of the target corresponding to the pixel coordinates of the midpoint of the bottom edge
  • Z represents the depth value
  • Step S106 according to the inverse perspective reference point coordinates, the target inverse perspective coordinates, the corresponding relationship between physical scale and pixel scale, and the distance between the reference point and the monocular camera, determine the distance between the target object and the The distance between the monocular cameras.
  • each pixel corresponds to the length of the real world.
  • 1 pixel corresponds to s meters in the real world.
  • step S102 includes:
  • the homography matrix is determined according to the vertex pixel coordinates of the first area image and the reverse perspective vertex pixel coordinates.
  • the apex pixel coordinates of the first region image are respectively p1 (u1, v1), p2 (u2, v2), p3 (u3, v3), p4 (u4, v4), and the corresponding inverse
  • the perspective pixel coordinates are q1(x1, y1), q2(x2, y2), q3(x3, y3), q4(x4, y4).
  • step S104 the acquiring the coordinates of the reverse perspective reference point corresponding to the pixel coordinates of the reference point includes:
  • the reverse perspective coordinates of the pixel coordinates of the reference point are set according to the size of the top view.
  • the size of the top view obtained by inverse perspective transformation of the plan view can be set.
  • Half of the width of the top view can be set as the pixel coordinate in the first direction of the reverse perspective coordinates of the pixel coordinates of the reference point, and three quarters of the height of the top view can be set as the first direction of the reverse perspective coordinates of the pixel coordinates of the reference point Pixel coordinates in two directions.
  • the height of the top view may also be set as the pixel coordinates in the second direction of the reverse perspective coordinates of the pixel coordinates of the reference point. There is no limitation here.
  • the obtaining the apex pixel coordinates of the first region image and their corresponding inverse perspective apex pixel coordinates includes:
  • the pixel coordinates of the reverse perspective corner are determined according to the reverse perspective coordinates of the pixel coordinates of the reference point, the corresponding relationship between the physical scale and the pixel scale, and the side length of the rectangular area.
  • the pixel coordinates of the top corners of the second area image 401 in the plane view after correction are the pixel coordinates of pixel points F, G, H, and I, and the second area image 401 is larger than the first area image 203 before correction.
  • the edge of the second region image 401 is relatively straight, which reduces the distortion effect.
  • the method also includes:
  • the plane view is corrected to obtain the corrected plane view, including:
  • the plane view is corrected according to the internal reference and the distortion parameter to obtain the corrected plane view.
  • a geometric model of camera imaging in order to determine the relationship between the three-dimensional geometric position of a certain point on the surface of the space object and its corresponding point in the image, a geometric model of camera imaging must be established, and these geometric model parameters are camera parameters. Under most conditions, these parameters must be obtained through experiments and calculations.
  • This process of solving internal parameters, external parameters, and distortion parameters is called camera calibration. Converting from the image coordinate system to the camera coordinate system can give formula 1, where the 3 ⁇ 4 matrix on the right side of the equation is called the internal reference matrix of the camera, where fx and fy are the focal lengths of the x-axis and y-axis respectively, u0 and v0 is the optical center coordinate of the camera, and D is the physical scale parameter.
  • Distortion simply means that due to the lens of the monocular camera, a straight line projected onto the picture cannot be kept as a straight line, resulting in optical distortion.
  • Camera distortion is mainly divided into two types, radial distortion and tangential distortion.
  • the internal reference and distortion parameters of the monocular camera are obtained by using a monocular camera to capture a checkerboard image. According to the calibrated camera internal parameters and distortion parameters, the distortion correction is performed on the flat view captured by the monocular camera.
  • the reverse perspective coordinates of the pixel coordinates of the reference point include the pixel coordinates of the reference point in the first direction and the pixel coordinates of the reference point in the second direction, and the second direction is perpendicular to the first direction;
  • determining the pixel coordinates of the inverse perspective corners includes:
  • the pixel coordinates of the reference point in the first direction the pixel coordinates of the reference point in the second direction, the side length of the rectangular area, the corresponding relationship between the physical scale and the pixel scale, the pixel coordinates of the reverse perspective vertex and the The positional relationship of the reference point coordinates of the reverse perspective is determined, and the coordinates of the first direction and the second direction of the pixel coordinates of the reverse perspective corner are determined.
  • the reference point is the midpoint of the bottom of the rectangular area
  • half of the width of the top view is set as the pixel coordinate in the first direction of the reverse perspective coordinate of the pixel coordinates of the reference point
  • the height of the top view is divided into four
  • the third is set as the pixel coordinates in the second direction of the reverse perspective coordinates of the pixel coordinates of the reference point, and set the reverse perspective coordinates of the pixel coordinates of the reference point to (x, y). Since the reference point is the middle point of the bottom of the rectangular area, according to the positional relationship between the pixel coordinates of the reverse perspective corner and the coordinates of the reverse perspective reference point, the coordinates of the pixel coordinates of the reverse perspective corner can be deduced.
  • the inverse perspective coordinates of the pixel coordinates of the reference point are the coordinates of the pixel point N in Figure 5, which is set to (x, y), then the inverse perspective pixel coordinates of the top corner Corresponding to the coordinates of pixel points J, K, L, M, if the length of the bottom side of the rectangular area is W meters, and the length of the vertical side perpendicular to the bottom side is L meters, each pixel corresponds to s in the physical world m, it can be obtained that the bottom edge is W/s pixels in the inverse perspective transformation diagram, and the vertical edge is L/s pixels in the inverse perspective transformation diagram.
  • the coordinates of pixel points J, K, L, and M are q1(x-W/2s, y-L/s), q2(x+W/2s, y-L/s), q3(x-W/2s, y), q4(x +W/2s,y).
  • Equation 4 Equation 4:
  • p1(u1, v1), p2(u2, v2), p3(u3, v3), p4(u4, v4) can be read directly from the flat view, and the corresponding reverse perspective pixel coordinates q1(x1, y1) , q2(x2, y2), q3(x3, y3), q4(x4, y4), with q1(x-W/2s, y-L/s), q2(x+W/2s, y-L/s), q3(x-W /2s, y), q4(x+W/2s, y) is replaced, brought into Formula 8-Formula 15, and the homography matrix H is calculated.
  • step S106 includes:
  • the origin of the physical coordinate system needs to be determined.
  • set the projection point of the monocular camera on the road as the origin of the physical coordinate system take the road as the 2D plane, the line of sight parallel to the camera as the positive direction of the y-axis, and the right side perpendicular to the y-axis as the x-axis Positive direction.
  • the reference point of the rectangular area is the midpoint of the base, and the distance in the y direction between the origin of the coordinate system and the midpoint of the base is L1 meters .
  • the target inverse perspective coordinates (a, b) of any pixel point on the bottom edge of the bounding box of the target object in other flat views are in the physical coordinate system
  • the coordinates of are ((a-x)s, (b-y)s+L1).
  • (a-x)s and (b-y)s+L1 represent the real physical distance between the target object and the monocular camera in the x-axis direction and y-axis direction, respectively, in meters.
  • the coordinates of the target anti-perspective coordinates (a1, b1) of the midpoint coordinates of the bottom edge of the target object's bounding box in other flat views in the physical coordinate system are ((a1-x)s, (b1-y) s+L1).
  • (a1-x)s and (b1-y)s+L11 represent the real physical distance of the midpoint of the bottom edge of the bounding box of the target object in the x-axis direction and the y-axis direction, respectively, in meters.
  • a flat view is taken by a monocular camera; a homography matrix for inverse perspective transformation of the flat view into a top view is determined according to the apex pixel coordinates of the first region image; from The bottom edge of the rectangular area determines a reference point, and obtains the distance between the reference point and the monocular camera; determines the reference point pixel coordinates corresponding to the reference point in the first area image, and obtains the The coordinates of the reverse perspective reference point corresponding to the pixel coordinates of the reference point; the target object detection is performed on other flat views captured by the monocular camera to obtain the target object bounding box, and the bottom edge of the target object bounding box is obtained according to the homography matrix Perform inverse perspective transformation on the coordinates of any pixel point, and obtain the target inverse perspective coordinates corresponding to any pixel point coordinates of the bottom edge; relationship, and the distance between the reference point and the monocular camera, determine the distance between the target object and the monocular camera.
  • an embodiment of the present disclosure provides a monocular ranging device.
  • the monocular ranging device may be a smart device such as a smart car or a robot.
  • the monocular ranging device 700 includes:
  • the photographing module 701 is configured to photograph a plane view through a monocular camera, the ground visible area of the monocular camera includes a rectangular area, and the plane view includes a first area image corresponding to the rectangular area;
  • the first determination module 702 is configured to determine a homography matrix used for inverse perspective transformation of the plane view into a top view according to the top corner pixel coordinates of the first area image;
  • An acquisition module 703 configured to determine a reference point from the bottom of the rectangular area, and acquire the distance between the reference point and the monocular camera;
  • the first processing module 704 is configured to determine the pixel coordinates of the reference point corresponding to the reference point in the first region image, and obtain the reverse perspective reference point coordinates corresponding to the pixel coordinates of the reference point;
  • the second processing module 705 is configured to perform target object detection on other plane views captured by the monocular camera to obtain a bounding box of the target object, and perform any pixel point on the bottom edge of the bounding box of the target object according to the homography matrix
  • the coordinates are subjected to inverse perspective transformation, and the target inverse perspective coordinates corresponding to the coordinates of any pixel point on the bottom edge are obtained;
  • the second determination module 706 is configured to determine according to the inverse perspective reference point coordinates, the target inverse perspective coordinates, the corresponding relationship between physical scale and pixel scale, and the distance between the reference point and the monocular camera The distance between the target object and the monocular camera.
  • the first determining module 702 is further configured to obtain the pixel coordinates of the top corner of the first area image and the corresponding pixel coordinates of the top corner of the reverse perspective;
  • the homography matrix is determined according to the vertex pixel coordinates of the first area image and the reverse perspective vertex pixel coordinates.
  • the first determination module 702 is further configured to set reverse perspective coordinates of pixel coordinates of the reference point according to the size of the top view.
  • the first determination module 702 is further configured to correct the plane view to obtain a corrected plane view, the corrected plane view includes a second area image, and the top of the second area image The corner pixel coordinates are used as the top corner pixel coordinates of the first region image;
  • the pixel coordinates of the reverse perspective corner are determined according to the reverse perspective coordinates of the pixel coordinates of the reference point, the corresponding relationship between the physical scale and the pixel scale, and the side length of the rectangular area.
  • the monocular ranging device 700 also includes:
  • a rectification module that takes a checkerboard image through the monocular camera, and acquires internal references and distortion parameters of the monocular camera according to the checkerboard image;
  • the first determination module 702 is further configured to correct the plane view according to the internal reference and distortion parameters to obtain the corrected plane view.
  • the reverse perspective coordinates of the pixel coordinates of the reference point include the pixel coordinates of the reference point in the first direction and the pixel coordinates of the reference point in the second direction, and the second direction is perpendicular to the first direction;
  • the first determination module 702 is further configured to: according to the pixel coordinates of the reference point in the first direction, the pixel coordinates of the reference point in the second direction, the side length of the rectangular area, and the corresponding relationship between the physical scale and the pixel scale .
  • the second determination module 706 is further configured to subtract the pixel coordinates of the reference point in the first direction from the coordinates in the first direction of the reverse perspective coordinates of the target to obtain a first pixel difference; The difference is multiplied by the corresponding relationship between the physical scale and the pixel scale to obtain a first product; the first product is used as the first direction distance between the target object and the monocular camera; and/or,
  • the monocular ranging device 700 provided in this embodiment can implement the monocular ranging method shown in Embodiment 1, and details are not repeated here to avoid repetition.
  • the monocular distance measuring device uses a monocular camera to take a plane view; determines a homography matrix for inverse perspective transformation of the plane view into a top view according to the apex pixel coordinates of the first region image; The bottom edge of the rectangular area determines a reference point, and obtains the distance between the reference point and the monocular camera; determines the reference point pixel coordinates corresponding to the reference point in the first area image, and obtains the The coordinates of the reverse perspective reference point corresponding to the pixel coordinates of the reference point; the target object detection is performed on other flat views captured by the monocular camera to obtain the target object bounding box, and the bottom edge of the target object bounding box is obtained according to the homography matrix Perform inverse perspective transformation on the coordinates of any pixel point, and obtain the target inverse perspective coordinates corresponding to any pixel point coordinates of the bottom edge; relationship, and the distance between the reference point and the monocular camera, determine the distance between the target object and the monocular camera. In this way, the distance of the distance of the
  • an embodiment of the present disclosure provides an intelligent device, including a monocular camera, a memory, and a processor, the memory stores a computer program, and when the computer program runs on the processor, it executes the above method described in Embodiment 1. Provided monocular ranging method.
  • the smart device may be smart devices such as smart cars and robots.
  • the processor is configured to: take a plane view through a monocular camera, the ground visible area of the monocular camera includes a rectangular area, and the plane view includes a first area image corresponding to the rectangular area;
  • the reverse perspective coordinates of the target determine the target object and the monocular camera.
  • the distance between the cameras determine the target object and the monocular camera.
  • the processor is further configured to: obtain the pixel coordinates of the top corner of the image of the first region and the corresponding pixel coordinates of the top corner of the image in reverse perspective;
  • the homography matrix is determined according to the vertex pixel coordinates of the first area image and the reverse perspective vertex pixel coordinates.
  • the processor is further configured to: set reverse perspective coordinates of pixel coordinates of the reference point according to the size of the top view.
  • the processor is further configured to: correct the plane view to obtain a corrected plane view, the corrected plane view includes a second area image, and use the apex pixel coordinates of the second area image as The pixel coordinates of the top corner of the first area image;
  • the pixel coordinates of the reverse perspective corner are determined according to the reverse perspective coordinates of the pixel coordinates of the reference point, the corresponding relationship between the physical scale and the pixel scale, and the side length of the rectangular area.
  • the processor is further configured to: take a checkerboard image through the monocular camera, and acquire internal references and distortion parameters of the monocular camera according to the checkerboard image;
  • the plane view is corrected according to the internal reference and the distortion parameter to obtain the corrected plane view.
  • the reverse perspective coordinates of the pixel coordinates of the reference point include the pixel coordinates of the reference point in the first direction and the pixel coordinates of the reference point in the second direction, and the second direction is perpendicular to the first direction;
  • the processor is further configured to: according to the pixel coordinates of the reference point in the first direction, the pixel coordinates of the reference point in the second direction, the side length of the rectangular area, the corresponding relationship between the physical scale and the pixel scale, the inverse The positional relationship between the perspective pixel coordinates and the reverse perspective reference point coordinates determines the first direction coordinates and the second direction coordinates of the reverse perspective pixel coordinates.
  • the processor is further configured to: subtract the pixel coordinates of the first direction reference point from the first direction coordinates of the target reverse perspective coordinates to obtain a first pixel difference; Multiplying the corresponding relationship between the physical scale and the pixel scale to obtain a first product; using the first product as the distance in the first direction between the target object and the monocular camera; and/or,
  • the smart device provided in this embodiment can implement the monocular ranging method shown in Embodiment 1, and to avoid repetition, details are not repeated here.
  • the smart device uses a monocular camera to take a plane view; determines a homography matrix for reverse perspective transformation of the plane view into a top view according to the pixel coordinates of the top corner of the first region image; The bottom edge of the area determines the reference point, and obtains the distance between the reference point and the monocular camera; determines the reference point pixel coordinates corresponding to the reference point in the first area image, and obtains the reference point pixel The coordinates of the inverse perspective reference point corresponding to the coordinates; the target object detection is performed on other flat views captured by the monocular camera to obtain the bounding box of the target object, and any pixel of the bottom edge of the bounding box of the target object is obtained according to the homography matrix Perform inverse perspective transformation on the point coordinates to obtain the target inverse perspective coordinates corresponding to any pixel point coordinates of the bottom edge; according to the inverse perspective reference point coordinates, the target inverse perspective coordinates, the corresponding relationship between the physical scale and the pixel scale, and The distance between the reference point
  • the present application also provides a computer-readable storage medium, on which a computer program is stored, and a plane view is taken by a monocular camera, the visible area of the ground of the monocular camera includes a rectangular area, and the plane view including a first area image corresponding to the rectangular area;
  • the reverse perspective coordinates of the target determine the target object and the monocular camera.
  • the distance between the cameras determine the target object and the monocular camera.
  • the homography matrix is determined according to the vertex pixel coordinates of the first area image and the reverse perspective vertex pixel coordinates.
  • the reverse perspective coordinates of the pixel coordinates of the reference point are set according to the size of the top view.
  • the pixel coordinates of the reverse perspective corner are determined according to the reverse perspective coordinates of the pixel coordinates of the reference point, the corresponding relationship between the physical scale and the pixel scale, and the side length of the rectangular area.
  • the plane view is corrected according to the internal reference and the distortion parameter to obtain the corrected plane view.
  • the reverse perspective coordinates of the pixel coordinates of the reference point include the pixel coordinates of the reference point in the first direction and the pixel coordinates of the reference point in the second direction, and the second direction is perpendicular to the first direction;
  • the pixel coordinates of the reference point in the first direction the pixel coordinates of the reference point in the second direction, the side length of the rectangular area, the corresponding relationship between the physical scale and the pixel scale, the pixel coordinates of the reverse perspective vertex and the The positional relationship of the reference point coordinates of the reverse perspective is determined, and the coordinates of the first direction and the second direction of the pixel coordinates of the reverse perspective corner are determined.
  • the computer-readable storage medium may be a read-only memory (Read-Only Memory, ROM for short), a random access memory (Random Access Memory, RAM for short), a magnetic disk or an optical disk, and the like.
  • ROM Read-Only Memory
  • RAM Random Access Memory
  • the computer-readable storage medium provided in this embodiment can implement the monocular ranging method shown in Embodiment 1, and to avoid repetition, details are not repeated here.
  • the methods of the above embodiments can be implemented by means of software plus a necessary general-purpose hardware platform, and of course also by hardware, but in many cases the former is better implementation.
  • the technical solution of the present application can be embodied in the form of a software product in essence or the part that contributes to the prior art, and the computer software product is stored in a storage medium (such as ROM/RAM, disk, CD) contains several instructions to enable a terminal (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in various embodiments of the present application.
  • a terminal which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Radar, Positioning & Navigation (AREA)
  • Remote Sensing (AREA)
  • Multimedia (AREA)
  • Electromagnetism (AREA)
  • Length Measuring Devices By Optical Means (AREA)

Abstract

A monocular distance measurement method and apparatus, and an intelligent apparatus. The method comprises: capturing a head-up view by means of a monocular camera (201); determining a homography matrix according to the vertex angle pixel coordinates of a first area image (203); determining a reference point from a bottom edge of a rectangular area, and acquiring the distance between the reference point and the monocular camera (201); determining the reference point pixel coordinates in the first area image (203) that correspond to the reference point, and acquiring the inverse perspective reference point coordinates corresponding to the reference point pixel coordinates; performing target object (302) detection on another head-up view captured by the monocular camera (201), so as to obtain a target object bounding box (301), and according to the homography matrix, performing inverse perspective transformation on any pixel point coordinates of a bottom edge (3013) of the target object bounding box (301), so as to acquire the target inverse perspective coordinates corresponding to the any pixel point coordinates of the bottom edge; and determining the distance between a target object (302) and the monocular camera (201) according to the acquired relevant parameters. In this way, the distance to a target object (302) can be measured by means of a monocular camera (201), thereby lowering a distance measurement condition, and improving the distance measurement efficiency.

Description

单目测距方法、装置及智能装置Monocular ranging method, device and intelligent device
相关申请的交叉引用Cross References to Related Applications
本申请要求于2021年06月30日提交中国专利局的申请号为202110738325X、名称为“单目测距方法、装置及智能装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application with the application number 202110738325X and titled "Monocular distance measuring method, device and intelligent device" submitted to the China Patent Office on June 30, 2021, the entire contents of which are incorporated herein by reference. Applying.
技术领域technical field
本申请涉及图像处理技术域,尤其涉及一种单目测距方法、装置及智能装置。The present application relates to the technical field of image processing, in particular to a monocular ranging method, device and intelligent device.
背景技术Background technique
目前单目相机在拍摄照片时,实质上市拍摄场景在单目相机的成像平面上留下的一个投影,照片以二维的形式反映了三维的世界。显然,拍摄过程中丢掉了拍摄场景的深度信息。在单目相机中,无法通过单个图片来计算场景中物体离单目相机的距离。At present, when a monocular camera takes a photo, it is essentially a projection left by the shooting scene on the imaging plane of the monocular camera. The photo reflects the three-dimensional world in a two-dimensional form. Obviously, the depth information of the shooting scene is lost during the shooting process. In a monocular camera, it is impossible to calculate the distance of an object in the scene from a single image through a single image.
随着近年来人工智能的不断发展,基于人工智能的自动驾驶技术也受到了广泛的关注,也相继提出一些基于深度学习的单目相机的测距算法,但是这些算法多数是通过已知物体在摄像头中的成像大小和姿态通过神经网络计算物体的距离,这样的算法对于不规则的物体则需要采集每个姿态下的物体距离,对于数据的要求十分苛刻,导致现有单目相机的测距技术存在测距条件比较难满足的问题。With the continuous development of artificial intelligence in recent years, automatic driving technology based on artificial intelligence has also received extensive attention, and some ranging algorithms based on deep learning monocular cameras have also been proposed, but most of these algorithms are based on known objects in the distance. The image size and attitude in the camera calculate the distance of the object through the neural network. For irregular objects, this algorithm needs to collect the object distance under each attitude. The technology has the problem that the ranging conditions are difficult to meet.
申请内容application content
为了解决上述技术问题,本申请实施例提供了一种单目测距方法、装置及智能装置。In order to solve the above technical problems, the embodiments of the present application provide a monocular ranging method, device and smart device.
第一方面,本申请实施例提供了一种单目测距方法,所述方法包括:In the first aspect, the embodiment of the present application provides a monocular ranging method, the method comprising:
通过单目相机拍摄平视图,所述单目相机的地面可视区域包括矩形区域,所述平视图包括所述矩形区域对应的第一区域图像;A plane view is taken by a monocular camera, the ground visible area of the monocular camera includes a rectangular area, and the plane view includes a first area image corresponding to the rectangular area;
根据所述第一区域图像的顶角像素坐标确定用于将所述平视图逆透视变换为俯视图的单应矩阵;determining a homography matrix for inverse perspective transforming the plane view into a top view according to the apex pixel coordinates of the first region image;
从所述矩形区域的底边确定基准点,获取所述基准点与所述单目相机之间的距离;Determining a reference point from the bottom edge of the rectangular area, and obtaining the distance between the reference point and the monocular camera;
确定所述基准点在所述第一区域图像中对应的基准点像素坐标,获取所述基准点像素坐标对应的逆透视基准点坐标;Determining the pixel coordinates of the reference point corresponding to the reference point in the first region image, and obtaining the coordinates of the reverse perspective reference point corresponding to the pixel coordinates of the reference point;
对所述单目相机拍摄的其他平视图进行目标物体检测,得到目标物体边界框,根据所述单应矩阵对所述目标物体边界框的底边任一像素点坐标进行逆透视变换,获取所述底边任一像素点坐标对应的目标逆透视坐标;Perform target object detection on other planar views captured by the monocular camera to obtain the target object bounding box, perform inverse perspective transformation on the coordinates of any pixel point on the bottom edge of the target object bounding box according to the homography matrix, and obtain the target object bounding box. The target inverse perspective coordinate corresponding to any pixel coordinate of the bottom edge;
根据所述逆透视基准点坐标、所述目标逆透视坐标、物理尺度与像素尺度的对应关系、及所述基准点与所述单目相机之间的距离,确定所述目标物体与所述单目相机之间的距离。According to the coordinates of the reverse perspective reference point, the reverse perspective coordinates of the target, the corresponding relationship between the physical scale and the pixel scale, and the distance between the reference point and the monocular camera, determine the target object and the monocular camera. The distance between the cameras.
可选的,所述根据所述第一区域图像的顶角像素坐标确定用于将所述平视图逆透视变换为俯视图的单应矩阵,包括:Optionally, the determining the homography matrix for inverse perspective transformation of the plane view into the top view according to the pixel coordinates of the top corner of the first region image includes:
获取所述第一区域图像的顶角像素坐标及其对应的逆透视顶角像素坐标;Acquiring the pixel coordinates of the top corner of the first area image and the corresponding pixel coordinates of the top corner of the reverse perspective image;
根据所述第一区域图像的顶角像素坐标、所述逆透视顶角像素坐标确定所述单应矩阵。The homography matrix is determined according to the vertex pixel coordinates of the first area image and the reverse perspective vertex pixel coordinates.
可选的,所述获取所述基准点像素坐标对应的逆透视基准点坐标,包括:Optionally, the obtaining the coordinates of the reverse perspective reference point corresponding to the pixel coordinates of the reference point includes:
根据所述俯视图的大小设置所述基准点像素坐标的逆透视坐标。The reverse perspective coordinates of the pixel coordinates of the reference point are set according to the size of the top view.
可选的,所述获取所述第一区域图像的顶角像素坐标及其对应的逆透视顶角像素坐标,包括:Optionally, the acquiring the apex pixel coordinates of the first region image and their corresponding inverse perspective apex pixel coordinates includes:
对所述平视图进行矫正,得到矫正后平视图,所述矫正后平视图包括第二区域图像,将所述第二区域图像的顶角像素坐标作为所述第一区域图像的顶角像素坐标;Correcting the plan view to obtain a corrected plan view, the corrected plan view including a second area image, using the apex pixel coordinates of the second area image as the apex pixel coordinates of the first area image ;
根据所述基准点像素坐标的逆透视坐标、所述物理尺度与像素尺度的对应关系、所述矩形区域的边长,确定所述逆透视顶角像素坐标。The pixel coordinates of the reverse perspective corner are determined according to the reverse perspective coordinates of the pixel coordinates of the reference point, the corresponding relationship between the physical scale and the pixel scale, and the side length of the rectangular area.
可选的,所述方法还包括:Optionally, the method also includes:
通过所述单目相机拍摄棋盘格图像,根据所述棋盘格图像获取所述单目相机的内参及畸变参数;Taking a checkerboard image through the monocular camera, and obtaining internal reference and distortion parameters of the monocular camera according to the checkerboard image;
所述对所述平视图进行矫正,得到矫正后平视图,包括:The plane view is corrected to obtain the corrected plane view, including:
根据所述内参及畸变参数对所述平视图进行矫正,得到所述矫正后平视图。The plane view is corrected according to the internal reference and the distortion parameter to obtain the corrected plane view.
可选的,所述基准点像素坐标的逆透视坐标包括第一方向基准点像素坐标及第二方向基准点像素坐标,所述第二方向垂直于所述第一方向;Optionally, the reverse perspective coordinates of the pixel coordinates of the reference point include the pixel coordinates of the reference point in the first direction and the pixel coordinates of the reference point in the second direction, and the second direction is perpendicular to the first direction;
所述根据所述基准点像素坐标的逆透视坐标、所述物理尺度与像素尺度的对应关系、所述矩形区域的边长,确定所述逆透视顶角像素坐标,包括:According to the inverse perspective coordinates of the pixel coordinates of the reference point, the corresponding relationship between the physical scale and the pixel scale, and the side length of the rectangular area, determining the pixel coordinates of the inverse perspective corners includes:
根据所述第一方向基准点像素坐标、所述第二方向基准点像素坐标、所述矩形区域的边长、所述物理尺度与像素尺度的对应关系、所述逆透视顶角像素坐标与所述逆透视基准点坐标的位置关系,确定所述逆透视顶角像素坐标的第一方向坐标及第二方向坐标。According to the pixel coordinates of the reference point in the first direction, the pixel coordinates of the reference point in the second direction, the side length of the rectangular area, the corresponding relationship between the physical scale and the pixel scale, the pixel coordinates of the reverse perspective vertex and the The positional relationship of the reference point coordinates of the reverse perspective is determined, and the coordinates of the first direction and the second direction of the pixel coordinates of the reverse perspective corner are determined.
可选的,所述根据所述逆透视基准点坐标、所述目标逆透视坐标、物理尺度与像素尺度的对应关系、及所述基准点与所述单目相机之间的距离,确定所述目标物体与所述单目相机之间的距离,包括:Optionally, according to the inverse perspective reference point coordinates, the target inverse perspective coordinates, the corresponding relationship between physical scale and pixel scale, and the distance between the reference point and the monocular camera, determine the The distance between the target object and the monocular camera, including:
将所述目标逆透视坐标的第一方向坐标减去所述第一方向基准点像素坐标,得到第一像素差值;将所述第一像素差值乘以物理尺度与像素尺度的对应关系,得到第一乘积;将所述第一乘积作为所述目标物体与所述单目相机之间的第一方向距离;和/或,Subtracting the pixel coordinates of the reference point in the first direction from the coordinates in the first direction of the reverse perspective coordinates of the target to obtain a first pixel difference; multiplying the first pixel difference by the corresponding relationship between the physical scale and the pixel scale, Obtain a first product; use the first product as a first direction distance between the target object and the monocular camera; and/or,
将所述目标逆透视坐标的第二方向坐标减去所述第二方向基准点像素坐标,得到第二像素差值;将所述第二像素差值乘以物理尺度与像素尺度的对应关系,得到第二乘积;将所述第二乘积作加上所述基准点与所述单目相机之间的第二方向距离之和,作为所述目标物体与所述单目相机之间的第二方向距离。Subtracting the pixel coordinates of the reference point in the second direction from the second direction coordinates of the target reverse perspective coordinates to obtain a second pixel difference; multiplying the second pixel difference by the corresponding relationship between the physical scale and the pixel scale, Obtain the second product; add the second product to the sum of the distance in the second direction between the reference point and the monocular camera, as the second distance between the target object and the monocular camera direction distance.
第二方面,本申请实施例提供了一种单目测距装置,所述单目测距装置包括:In the second aspect, the embodiment of the present application provides a monocular ranging device, and the monocular ranging device includes:
拍摄模块,用于通过单目相机拍摄平视图,所述单目相机的地面可视区域包括矩形区域,所述平视图包括所述矩形区域对应的第一区域图像;A photographing module, configured to photograph a plane view through a monocular camera, the ground visible area of the monocular camera includes a rectangular area, and the plane view includes a first area image corresponding to the rectangular area;
第一确定模块,用于根据所述第一区域图像的顶角像素坐标确定用于将所述平视图逆透视变换为俯视图的单应矩阵;A first determination module, configured to determine a homography matrix for inverse perspective transformation of the plane view into a top view according to the top corner pixel coordinates of the first area image;
获取模块,用于从所述矩形区域的底边确定基准点,获取所述基准点与所述单目相机之间的所述基准点与所述单目相机之间的距离;An acquisition module, configured to determine a reference point from the bottom of the rectangular area, and acquire a distance between the reference point and the monocular camera;
第一处理模块,用于确定所述基准点在所述第一区域图像中对应的基准点像素坐标,获取所述基准点像素坐标对应的逆透视基准点坐标;The first processing module is configured to determine the pixel coordinates of the reference point corresponding to the reference point in the first region image, and acquire the reverse perspective reference point coordinates corresponding to the pixel coordinates of the reference point;
第二处理模块,用于对所述单目相机拍摄的其他平视图进行目标物体检测,得到目标物体边界框,根据所述单应矩阵对所述目标物体边界框的底边任一像素点坐标进行逆透视变换,获取所述底边任一像素点坐标对应的目标逆透视坐标;The second processing module is configured to perform target object detection on other flat views captured by the monocular camera to obtain a target object bounding box, and coordinate any pixel point on the bottom edge of the target object bounding box according to the homography matrix Perform inverse perspective transformation to obtain the target inverse perspective coordinates corresponding to the coordinates of any pixel point on the bottom edge;
第二确定模块,用于根据所述逆透视基准点坐标、所述目标逆透视坐标、物理尺度与像素尺度的对应关系、及所述基准点与所述单目相机之间的距离,确定所述目标物体与所述单目相机之间的距离。The second determination module is configured to determine the inverse perspective reference point coordinates, the target inverse perspective coordinates, the corresponding relationship between physical scale and pixel scale, and the distance between the reference point and the monocular camera. The distance between the target object and the monocular camera.
可选的,所述第一确定模块,还用于获取所述第一区域图像的顶角像素坐标及其对应的逆透视顶角像素坐标;Optionally, the first determining module is further configured to acquire the pixel coordinates of the top corner of the first area image and the corresponding pixel coordinates of the top corner of the reverse perspective;
根据所述第一区域图像的顶角像素坐标、所述逆透视顶角像素坐标确定所述单应矩阵。The homography matrix is determined according to the vertex pixel coordinates of the first area image and the reverse perspective vertex pixel coordinates.
可选的,所述第一确定模块,还用于根据所述俯视图的大小设置所述基准点像素坐标的逆透视坐标。Optionally, the first determining module is further configured to set reverse perspective coordinates of pixel coordinates of the reference point according to the size of the top view.
可选的,所述第一确定模块,还用于对所述平视图进行矫正,得到矫正后平视图,所述矫正后平视图包括第二区域图像,将所述第二区域图像的顶角像素坐标作为所述第一区域图像的顶角像素坐标;Optionally, the first determination module is further configured to correct the plan view to obtain a corrected plan view, the corrected plan view includes a second area image, and the vertex angle of the second area image The pixel coordinates are used as the apex pixel coordinates of the first region image;
根据所述基准点像素坐标的逆透视坐标、所述物理尺度与像素尺度的对应关系、所述矩形区域的边长,确定所述逆透视顶角像素坐标。The pixel coordinates of the reverse perspective corner are determined according to the reverse perspective coordinates of the pixel coordinates of the reference point, the corresponding relationship between the physical scale and the pixel scale, and the side length of the rectangular area.
可选的,所述单目测距装置还包括:Optionally, the monocular distance measuring device also includes:
矫正模块,通过所述单目相机拍摄棋盘格图像,根据所述棋盘格图像获取所述单目相机的内参及畸变参数;A rectification module that takes a checkerboard image through the monocular camera, and acquires internal references and distortion parameters of the monocular camera according to the checkerboard image;
所述第一确定模块,还用于根据所述内参及畸变参数对所述平视图进行矫正,得到 所述矫正后平视图。The first determining module is further configured to correct the plane view according to the internal reference and distortion parameters to obtain the corrected plane view.
可选的,所述基准点像素坐标的逆透视坐标包括第一方向基准点像素坐标及第二方向基准点像素坐标,所述第二方向垂直于所述第一方向;Optionally, the reverse perspective coordinates of the pixel coordinates of the reference point include the pixel coordinates of the reference point in the first direction and the pixel coordinates of the reference point in the second direction, and the second direction is perpendicular to the first direction;
所述第一确定模块,还用于根据所述第一方向基准点像素坐标、所述第二方向基准点像素坐标、所述矩形区域的边长、所述物理尺度与像素尺度的对应关系、所述逆透视顶角像素坐标与所述逆透视基准点坐标的位置关系,确定所述逆透视顶角像素坐标的第一方向坐标及第二方向坐标。The first determination module is further configured to: according to the pixel coordinates of the reference point in the first direction, the pixel coordinates of the reference point in the second direction, the side length of the rectangular area, the correspondence between the physical scale and the pixel scale, The positional relationship between the reverse perspective vertex corner pixel coordinates and the reverse perspective reference point coordinates determines the first direction coordinate and the second direction coordinate of the reverse perspective vertex corner pixel coordinates.
可选的,第二确定模块,还用于将所述目标逆透视坐标的第一方向坐标减去所述第一方向基准点像素坐标,得到第一像素差值;将所述第一像素差值乘以物理尺度与像素尺度的对应关系,得到第一乘积;将所述第一乘积作为所述目标物体与所述单目相机之间的第一方向距离;和/或,Optionally, the second determination module is further configured to subtract the pixel coordinates of the first direction reference point from the first direction coordinates of the target reverse perspective coordinates to obtain a first pixel difference value; The value is multiplied by the corresponding relationship between the physical scale and the pixel scale to obtain the first product; the first product is used as the first direction distance between the target object and the monocular camera; and/or,
将所述目标逆透视坐标的第二方向坐标减去所述第二方向基准点像素坐标,得到第二像素差值;将所述第二像素差值乘以物理尺度与像素尺度的对应关系,得到第二乘积;将所述第二乘积作加上所述基准点与所述单目相机之间的第二方向距离之和,作为所述目标物体与所述单目相机之间的第二方向距离。Subtracting the pixel coordinates of the reference point in the second direction from the second direction coordinates of the target reverse perspective coordinates to obtain a second pixel difference; multiplying the second pixel difference by the corresponding relationship between the physical scale and the pixel scale, Obtain the second product; add the second product to the sum of the distance in the second direction between the reference point and the monocular camera, as the second distance between the target object and the monocular camera direction distance.
第三方面,本申请实施例提供了一种智能装置,包括单目相机、存储器以及处理器,所述存储器存储有计算机程序,所述计算机程序在所述处理器运行时执行第一方面提供的单目测距方法。In a third aspect, an embodiment of the present application provides an intelligent device, including a monocular camera, a memory, and a processor, the memory stores a computer program, and the computer program executes the method provided in the first aspect when the processor runs. Monocular ranging method.
第四方面,本申请实施例提供了一种计算机可读存储介质,其存储有计算机程序,所述计算机程序在处理器上运行时执行第一方面提供的单目测距方法。In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and the computer program executes the monocular ranging method provided in the first aspect when running on a processor.
上述本申请提供的单目测距方法、装置及智能装置,通过单目相机拍摄平视图;根据所述第一区域图像的顶角像素坐标确定用于将所述平视图逆透视变换为俯视图的单应矩阵;从所述矩形区域的底边确定基准点,获取所述基准点与所述单目相机之间的距离;确定所述基准点在所述第一区域图像中对应的基准点像素坐标,获取所述基准点像素坐标对应的逆透视基准点坐标;对所述单目相机拍摄的其他平视图进行目标物体检测,得到目标物体边界框,根据所述单应矩阵对所述目标物体边界框的底边任一像素点坐标进行逆透视变换,获取所述底边任一像素点坐标对应的目标逆透视坐标;根据所述逆透视基准点坐标、所述目标逆透视坐标、物理尺度与像素尺度的对应关系、及所述基准点与所述单目相机之间的距离,确定所述目标物体与所述单目相机之间的距离。这样,可以通过单目相机测量目标物体的距离,没有过多的数据要求,能实现对不规则的目标物体的测距,降低测距条件,提高测距效率。In the monocular distance measuring method, device and smart device provided by the above-mentioned application, the flat view is taken by a monocular camera; the pixel coordinates of the top corner of the first area image are used to determine the reverse perspective transformation of the flat view into a top view. Homography matrix; determine the reference point from the bottom edge of the rectangular area, and obtain the distance between the reference point and the monocular camera; determine the reference point pixel corresponding to the reference point in the first region image Coordinates, obtain the coordinates of the reverse perspective reference point corresponding to the pixel coordinates of the reference point; perform target object detection on other flat views taken by the monocular camera, obtain the target object bounding box, and calculate the target object according to the homography matrix Perform inverse perspective transformation on the coordinates of any pixel point on the bottom edge of the bounding box, and obtain the target inverse perspective coordinates corresponding to the coordinates of any pixel point on the bottom edge; according to the coordinates of the inverse perspective reference point, the target inverse perspective coordinates, and the physical scale The corresponding relationship with the pixel scale and the distance between the reference point and the monocular camera determine the distance between the target object and the monocular camera. In this way, the distance of the target object can be measured through the monocular camera, without excessive data requirements, and the ranging of irregular target objects can be realized, the ranging condition is reduced, and the ranging efficiency is improved.
附图说明Description of drawings
为了更清楚地说明本申请的技术方案,下面将对实施例中所需要使用的附图作简单 地介绍,应当理解,以下附图仅示出了本申请的某些实施例,因此不应被看作是对本申请保护范围的限定。在各个附图中,类似的构成部分采用类似的编号。In order to illustrate the technical solution of the present application more clearly, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the application, and therefore should not be regarded It is regarded as a limitation on the scope of protection of the present application. In the respective drawings, similar components are given similar reference numerals.
图1示出了本申请实施例提供的单目测距方法的一流程示意图;Fig. 1 shows a schematic flow chart of the monocular ranging method provided by the embodiment of the present application;
图2示出了本申请实施例提供的一平视图示意图;Fig. 2 shows a schematic plan view provided by the embodiment of the present application;
图3示出了本申请实施例提供的另一平视图示意图;Fig. 3 shows another schematic plan view provided by the embodiment of the present application;
图4示出了本申请实施例提供的一矫正后平视图流程示意图;Fig. 4 shows a schematic flow diagram of a rectified plane view provided by the embodiment of the present application;
图5示出了本申请实施例提供的一逆透视图示意图;Fig. 5 shows a schematic diagram of a reverse perspective view provided by the embodiment of the present application;
图6示出了本申请实施例提供的一物理坐标系统示意图;Fig. 6 shows a schematic diagram of a physical coordinate system provided by the embodiment of the present application;
图7示出了本申请实施例提供的单目测距装置的一结构示意图。FIG. 7 shows a schematic structural diagram of a monocular ranging device provided by an embodiment of the present application.
具体实施方式detailed description
下面将结合本申请实施例中附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, not all of them.
通常在此处附图中描述和示出的本申请实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本申请的实施例的详细描述并非旨在限制要求保护的本申请的范围,而是仅仅表示本申请的选定实施例。基于本申请的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本申请保护的范围。The components of the embodiments of the application generally described and illustrated in the figures herein may be arranged and designed in a variety of different configurations. Accordingly, the following detailed description of the embodiments of the application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of the application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative efforts belong to the scope of protection of the present application.
在下文中,可在本申请的各种实施例中使用的术语“包括”、“具有”及其同源词仅意在表示特定特征、数字、步骤、操作、元件、组件或前述项的组合,并且不应被理解为首先排除一个或更多个其它特征、数字、步骤、操作、元件、组件或前述项的组合的存在或增加一个或更多个特征、数字、步骤、操作、元件、组件或前述项的组合的可能性。Hereinafter, the terms "comprising", "having" and their cognates that may be used in various embodiments of the present application are only intended to represent specific features, numbers, steps, operations, elements, components or combinations of the foregoing, And it should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing or adding one or more features, numbers, steps, operations, elements, components or a combination of the foregoing possibilities.
此外,术语“第一”、“第二”、“第三”等仅用于区分描述,而不能理解为指示或暗示相对重要性。In addition, the terms "first", "second", "third", etc. are only used for distinguishing descriptions, and should not be construed as indicating or implying relative importance.
除非另有限定,否则在这里使用的所有术语(包括技术术语和科学术语)具有与本申请的各种实施例所属领域普通技术人员通常理解的含义相同的含义。所述术语(诸如在一般使用的词典中限定的术语)将被解释为具有与在相关技术领域中的语境含义相同的含义并且将不被解释为具有理想化的含义或过于正式的含义,除非在本申请的各种实施例中被清楚地限定。Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which various embodiments of the application belong. The terms (such as those defined in commonly used dictionaries) will be interpreted as having the same meaning as the contextual meaning in the relevant technical field and will not be interpreted as having an idealized meaning or an overly formal meaning, Unless clearly defined in the various embodiments of the present application.
实施例1Example 1
本公开实施例提供了一种单目测距方法。An embodiment of the present disclosure provides a monocular ranging method.
具体的,如图1所示,单目测距方法包括Specifically, as shown in Figure 1, the monocular ranging method includes
步骤S101,通过单目相机拍摄平视图。Step S101, taking a plan view with a monocular camera.
在本实施例中,所述单目相机的地面可视区域包括矩形区域,所述平视图包括所述 矩形区域对应的第一区域图像。In this embodiment, the ground viewable area of the monocular camera includes a rectangular area, and the plane view includes a first area image corresponding to the rectangular area.
需要补充说明的是,地面可以铺设有矩形图案的瓷砖,多个矩形图案的瓷砖可以组成矩形区域,通过对平视图进行图像检测,可以确定相应的第一区域图像。此外,在其他实现方式中,在地面没有瓷砖等矩形图案时,可以在地面设置矩形区域,该矩形区域设置在单目相机的地面可视区域。It should be added that tiles with a rectangular pattern can be laid on the ground, and a plurality of tiles with a rectangular pattern can form a rectangular area, and the corresponding first area image can be determined by performing image detection on a plan view. In addition, in other implementation manners, when there is no rectangular pattern such as tiles on the ground, a rectangular area may be set on the ground, and the rectangular area is set in the ground visible area of the monocular camera.
请参阅图2,单目相机201设置在地面202上,地面202铺设有矩形图案的瓷砖,多个矩形图案的瓷砖可以组成矩形区域,例如,4个矩形图案的瓷砖组成矩形区域203,通过对平视图进行图像检测,可以确定相应的第一区域图像203。Please refer to Fig. 2, the monocular camera 201 is set on the ground 202, and the ground 202 is laid with the ceramic tile of rectangular pattern, and the ceramic tile of a plurality of rectangular patterns can form a rectangular area, for example, the ceramic tile of 4 rectangular patterns forms a rectangular area 203, by pairing The image detection is performed on the plane view, and the corresponding first area image 203 can be determined.
步骤S102,根据所述第一区域图像的顶角像素坐标确定用于将所述平视图逆透视变换为俯视图的单应矩阵。Step S102, determining a homography matrix for inverse perspective transformation of the plane view into a top view according to the pixel coordinates of the top corner of the first area image.
请参阅图2,可以将图2的左上角作为原点、以左竖边为y轴、顶部为x轴,建立像素坐标系,第一区域图像203的顶角像素坐标,即像素点A、B、C、D的像素坐标。Please refer to FIG. 2, the pixel coordinate system can be established by taking the upper left corner of FIG. 2 as the origin, the left vertical side as the y-axis, and the top as the x-axis. , C, D pixel coordinates.
在本实施例中,可以根据第一区域图像的顶角像素坐标、预先后期的第一区域图像的顶角像素坐标的逆透视坐标计算单应矩阵。In this embodiment, the homography matrix can be calculated according to the pixel coordinates of the top corner of the first region image and the inverse perspective coordinates of the pixel coordinates of the top corner of the first region image in the previous stage.
步骤S103,从所述矩形区域的底边确定基准点,获取所述基准点与所述单目相机之间的所述基准点与所述单目相机之间的距离。In step S103, a reference point is determined from the bottom of the rectangular area, and a distance between the reference point and the monocular camera is acquired.
在本实施例中,所述基准点可以是所述矩形区域的底边的任一点。例如,举例来说,可以将矩形区域的底边中点作为基准点。In this embodiment, the reference point may be any point on the bottom of the rectangular area. For example, for example, the midpoint of the bottom of the rectangular area may be used as the reference point.
在本实施例中,获取所述基准点与所述单目相机之间的距离,可以通过用户测量基准点与单目相机之间的距离,也可以根据基准点与所述单目相机之间间隔的矩形图案的瓷砖个数,进行图像分析处理得到,在此不做限制。In this embodiment, the distance between the reference point and the monocular camera can be obtained by measuring the distance between the reference point and the monocular camera by the user, or according to the distance between the reference point and the monocular camera. The number of tiles in the rectangular pattern at intervals is obtained through image analysis and processing, and is not limited here.
步骤S104,确定所述基准点在所述第一区域图像中对应的基准点像素坐标,获取所述基准点像素坐标对应的逆透视基准点坐标。Step S104, determining the pixel coordinates of the reference point corresponding to the reference point in the first region image, and obtaining the coordinates of the reverse perspective reference point corresponding to the pixel coordinates of the reference point.
在本实施例中,矩形区域位于单目相机的地面可视区域,平视图中的第一区域图像包括矩形区域的所有边。在将矩形区域的底边中点作为基准点时,如图2中所示,基准点在所述第一区域图像203中对应的基准点像素坐标为像素点E。In this embodiment, the rectangular area is located in the ground visible area of the monocular camera, and the image of the first area in the plane view includes all sides of the rectangular area. When the midpoint of the bottom of the rectangular area is used as the reference point, as shown in FIG. 2 , the pixel coordinate of the reference point corresponding to the reference point in the first area image 203 is the pixel point E.
步骤S105,对所述单目相机拍摄的其他平视图进行目标物体检测,得到目标物体边界框,根据所述单应矩阵对所述目标物体边界框的底边任一像素点坐标进行逆透视变换,获取所述底边任一像素点坐标对应的目标逆透视坐标。Step S105: Perform target object detection on other flat views captured by the monocular camera to obtain the target object bounding box, and perform inverse perspective transformation on the coordinates of any pixel point on the bottom edge of the target object bounding box according to the homography matrix , to obtain the target inverse perspective coordinates corresponding to the coordinates of any pixel point on the bottom edge.
在本实施例中,保持单目相机的高度及夹持角度不变,通过单目相机拍摄其他平视图。可以选择Yolo V5、Fast-RCNN等目标检测费算法进行目标物体检测。目标物体检测的主要目的就是将需要检测的物体的轮廓使用矩形框框出轮廓。由此可知,目标检测的Bounding Box所框出的目标物体底边处在所标定的二维平面。In this embodiment, the height and clamping angle of the monocular camera are kept unchanged, and other planar views are captured by the monocular camera. You can choose Yolo V5, Fast-RCNN and other target detection algorithms for target object detection. The main purpose of target object detection is to frame the outline of the object to be detected using a rectangular frame. It can be seen from this that the bottom edge of the target object framed by the Bounding Box of the target detection is in the calibrated two-dimensional plane.
请参阅图3,第一平视图300包括目标物体302及目标物体边界框301,目标物体 边界框301包括底边3013、顶边3011、左竖边3012、右竖边3013。根据单应矩阵对底边3013任一像素点坐标进行逆透视变换,获取底边3013任一像素点坐标对应的目标逆透视坐标。举例来说,根据单应矩阵对底边3013中点坐标进行逆透视变换,获取底边3013中点坐标对应的目标逆透视坐标。Referring to FIG. 3 , the first plane view 300 includes a target object 302 and a target object bounding box 301 , and the target object bounding box 301 includes a bottom edge 3013 , a top edge 3011 , a left vertical edge 3012 , and a right vertical edge 3013 . Perform inverse perspective transformation on the coordinates of any pixel point of the bottom edge 3013 according to the homography matrix, and obtain the target inverse perspective coordinates corresponding to the coordinates of any pixel point point of the bottom edge 3013. For example, the inverse perspective transformation is performed on the coordinates of the midpoint of the base 3013 according to the homography matrix, and the reverse perspective coordinates of the target corresponding to the coordinates of the midpoint of the base 3013 are obtained.
在本实施例中,根据所述单应矩阵对所述目标物体边界框的底边中点的像素点坐标进行逆透视变换,获取所述底边中点的像素点坐标对应的目标逆透视坐标。In this embodiment, according to the homography matrix, the pixel point coordinates of the bottom midpoint of the bounding box of the target object are subjected to inverse perspective transformation, and the target reverse perspective coordinates corresponding to the pixel point coordinates of the bottom midpoint are obtained .
在本实施例中,根据公式1,对所述目标物体边界框的底边中点的像素点坐标进行逆透视变换,获取所述底边中点的像素点坐标对应的目标逆透视坐标。In this embodiment, according to Formula 1, reverse perspective transformation is performed on the pixel point coordinates of the bottom midpoint of the bounding box of the target object, and the target reverse perspective coordinates corresponding to the pixel point coordinates of the bottom midpoint are obtained.
公式1:
Figure PCTCN2021131460-appb-000001
Formula 1:
Figure PCTCN2021131460-appb-000001
其中,(u,v)表示目标物体边界框的底边中点的像素点坐标,(x,y)为底边中点的像素点坐标对应的目标逆透视坐标。Z表示深度值。Among them, (u, v) represent the pixel coordinates of the midpoint of the bottom edge of the bounding box of the target object, and (x, y) are the reverse perspective coordinates of the target corresponding to the pixel coordinates of the midpoint of the bottom edge. Z represents the depth value.
步骤S106,根据所述逆透视基准点坐标、所述目标逆透视坐标、物理尺度与像素尺度的对应关系、及所述基准点与所述单目相机之间的距离,确定所述目标物体与所述单目相机之间的距离。Step S106, according to the inverse perspective reference point coordinates, the target inverse perspective coordinates, the corresponding relationship between physical scale and pixel scale, and the distance between the reference point and the monocular camera, determine the distance between the target object and the The distance between the monocular cameras.
在本实施例中,为了将像素坐标与真实物理坐标对应,预先设定像素尺度与物理尺度的对应关系,即每个像素对应现实世界的长度。例如,1个像素对应现实世界的s米。In this embodiment, in order to correspond the pixel coordinates to the real physical coordinates, the corresponding relationship between the pixel scale and the physical scale is preset, that is, each pixel corresponds to the length of the real world. For example, 1 pixel corresponds to s meters in the real world.
可选的,步骤S102包括:Optionally, step S102 includes:
获取所述第一区域图像的顶角像素坐标及其对应的逆透视顶角像素坐标;Acquiring the pixel coordinates of the top corner of the first area image and the corresponding pixel coordinates of the top corner of the reverse perspective image;
根据所述第一区域图像的顶角像素坐标、所述逆透视顶角像素坐标确定所述单应矩阵。The homography matrix is determined according to the vertex pixel coordinates of the first area image and the reverse perspective vertex pixel coordinates.
在本实施例中,所述第一区域图像的顶角像素坐标分别为p1(u1,v1),p2(u2,v2),p3(u3,v3),p4(u4,v4),对应的逆透视顶角像素坐标分别为q1(x1,y1),q2(x2,y2),q3(x3,y3),q4(x4,y4)。根据p1(u1,v1),p2(u2,v2),p3(u3,v3),p4(u4,v4),q1(x1,y1),q2(x2,y2),q3(x3,y3),q4(x4,y4)计算单应矩阵。In this embodiment, the apex pixel coordinates of the first region image are respectively p1 (u1, v1), p2 (u2, v2), p3 (u3, v3), p4 (u4, v4), and the corresponding inverse The perspective pixel coordinates are q1(x1, y1), q2(x2, y2), q3(x3, y3), q4(x4, y4). According to p1(u1, v1), p2(u2, v2), p3(u3, v3), p4(u4, v4), q1(x1, y1), q2(x2, y2), q3(x3, y3), q4(x4, y4) computes the homography matrix.
可选的,步骤S104中,所述获取所述基准点像素坐标对应的逆透视基准点坐标,包括:Optionally, in step S104, the acquiring the coordinates of the reverse perspective reference point corresponding to the pixel coordinates of the reference point includes:
根据所述俯视图的大小设置所述基准点像素坐标的逆透视坐标。The reverse perspective coordinates of the pixel coordinates of the reference point are set according to the size of the top view.
在本实施例中,平视图进行逆透视变换得到的俯视图的大小是可以进行设置的。可以将俯视图的宽度的一半设置为所述基准点像素坐标的逆透视坐标的第一方向像素坐标,可以将俯视图的高度的四分之三设置为所述基准点像素坐标的逆透视坐标的第二方向像素坐标。在其他实施方式中,还可以将俯视图的高度设置为所述基准点像素坐标的逆透视坐标的第二方向像素坐标。在此不做限制。In this embodiment, the size of the top view obtained by inverse perspective transformation of the plan view can be set. Half of the width of the top view can be set as the pixel coordinate in the first direction of the reverse perspective coordinates of the pixel coordinates of the reference point, and three quarters of the height of the top view can be set as the first direction of the reverse perspective coordinates of the pixel coordinates of the reference point Pixel coordinates in two directions. In other implementation manners, the height of the top view may also be set as the pixel coordinates in the second direction of the reverse perspective coordinates of the pixel coordinates of the reference point. There is no limitation here.
可选的,所述获取所述第一区域图像的顶角像素坐标及其对应的逆透视顶角像素 坐标,包括:Optionally, the obtaining the apex pixel coordinates of the first region image and their corresponding inverse perspective apex pixel coordinates includes:
对所述平视图进行矫正,得到矫正后平视图,所述矫正后平视图包括第二区域图像,将所述第二区域图像的顶角像素坐标作为所述第一区域图像的顶角像素坐标;Correcting the plan view to obtain a corrected plan view, the corrected plan view including a second area image, using the apex pixel coordinates of the second area image as the apex pixel coordinates of the first area image ;
根据所述基准点像素坐标的逆透视坐标、所述物理尺度与像素尺度的对应关系、所述矩形区域的边长,确定所述逆透视顶角像素坐标。The pixel coordinates of the reverse perspective corner are determined according to the reverse perspective coordinates of the pixel coordinates of the reference point, the corresponding relationship between the physical scale and the pixel scale, and the side length of the rectangular area.
请参阅图4,矫正后平视图中第二区域图像401的顶角像素坐标为像素点F、G、H、I的像素坐标,第二区域图像401相比矫正之前的第一区域图像203而言,第二区域图像401的边线比较直,降低了畸变效果。Please refer to FIG. 4 , the pixel coordinates of the top corners of the second area image 401 in the plane view after correction are the pixel coordinates of pixel points F, G, H, and I, and the second area image 401 is larger than the first area image 203 before correction. In other words, the edge of the second region image 401 is relatively straight, which reduces the distortion effect.
可选的,所述方法还包括:Optionally, the method also includes:
通过所述单目相机拍摄棋盘格图像,根据所述棋盘格图像获取所述单目相机的内参及畸变参数;Taking a checkerboard image through the monocular camera, and obtaining internal reference and distortion parameters of the monocular camera according to the checkerboard image;
所述对所述平视图进行矫正,得到矫正后平视图,包括:The plane view is corrected to obtain the corrected plane view, including:
根据所述内参及畸变参数对所述平视图进行矫正,得到所述矫正后平视图。The plane view is corrected according to the internal reference and the distortion parameter to obtain the corrected plane view.
在本实施例中,为确定空间物体表面某点的三维几何位置与其在图像中对应点之间的相互关系,必须建立相机成像的几何模型,这些几何模型参数就是相机参数。在大多数条件下这些参数必须通过实验与计算才能得到,这个求解内参、外参、畸变参数的过程就称之为相机标定。由图像坐标系转换为相机坐标系可得式公式1,其中等式右侧的3×4的矩阵称为相机的内参矩阵,其中fx和fy分别为x轴和y轴的焦距,u0和v0为相机的光心坐标,D为物理尺度参数。In this embodiment, in order to determine the relationship between the three-dimensional geometric position of a certain point on the surface of the space object and its corresponding point in the image, a geometric model of camera imaging must be established, and these geometric model parameters are camera parameters. Under most conditions, these parameters must be obtained through experiments and calculations. This process of solving internal parameters, external parameters, and distortion parameters is called camera calibration. Converting from the image coordinate system to the camera coordinate system can give formula 1, where the 3×4 matrix on the right side of the equation is called the internal reference matrix of the camera, where fx and fy are the focal lengths of the x-axis and y-axis respectively, u0 and v0 is the optical center coordinate of the camera, and D is the physical scale parameter.
公式2:
Figure PCTCN2021131460-appb-000002
Formula 2:
Figure PCTCN2021131460-appb-000002
在本实施例中,除标定单目相机内参外,还需要标定单目相机的畸变参数。畸变简单来说,就是可能由于单目相机镜头的原因,一条直线投影到图片上不能保持为一条直线,产生了光学畸变。相机畸变主要分为两种,径向畸变与切向畸变。In this embodiment, in addition to calibrating the internal parameters of the monocular camera, it is also necessary to calibrate the distortion parameters of the monocular camera. Distortion simply means that due to the lens of the monocular camera, a straight line projected onto the picture cannot be kept as a straight line, resulting in optical distortion. Camera distortion is mainly divided into two types, radial distortion and tangential distortion.
在本实施例中,使用单目相机拍摄棋盘格图像的方式,获取单目相机的内参以及畸变参数。根据标定后的相机内参以及畸变参数,对单目相机拍摄的平视图进行畸变矫正。In this embodiment, the internal reference and distortion parameters of the monocular camera are obtained by using a monocular camera to capture a checkerboard image. According to the calibrated camera internal parameters and distortion parameters, the distortion correction is performed on the flat view captured by the monocular camera.
可选的,所述基准点像素坐标的逆透视坐标包括第一方向基准点像素坐标及第二方向基准点像素坐标,所述第二方向垂直于所述第一方向;Optionally, the reverse perspective coordinates of the pixel coordinates of the reference point include the pixel coordinates of the reference point in the first direction and the pixel coordinates of the reference point in the second direction, and the second direction is perpendicular to the first direction;
所述根据所述基准点像素坐标的逆透视坐标、所述物理尺度与像素尺度的对应关系、所述矩形区域的边长,确定所述逆透视顶角像素坐标,包括:According to the inverse perspective coordinates of the pixel coordinates of the reference point, the corresponding relationship between the physical scale and the pixel scale, and the side length of the rectangular area, determining the pixel coordinates of the inverse perspective corners includes:
根据所述第一方向基准点像素坐标、所述第二方向基准点像素坐标、所述矩形区域的边长、所述物理尺度与像素尺度的对应关系、所述逆透视顶角像素坐标与所述逆 透视基准点坐标的位置关系,确定所述逆透视顶角像素坐标的第一方向坐标及第二方向坐标。According to the pixel coordinates of the reference point in the first direction, the pixel coordinates of the reference point in the second direction, the side length of the rectangular area, the corresponding relationship between the physical scale and the pixel scale, the pixel coordinates of the reverse perspective vertex and the The positional relationship of the reference point coordinates of the reverse perspective is determined, and the coordinates of the first direction and the second direction of the pixel coordinates of the reverse perspective corner are determined.
在本实施例中,若基准点为矩形区域的底边中点,将俯视图的宽度的一半设置为所述基准点像素坐标的逆透视坐标的第一方向像素坐标,将俯视图的高度的四分之三设置为所述基准点像素坐标的逆透视坐标的第二方向像素坐标,设置所述基准点像素坐标的逆透视坐标为(x,y)。由于基准点为矩形区域的底边中点,根据逆透视顶角像素坐标与所述逆透视基准点坐标的位置关系,可以推导出逆透视顶角像素坐标。In this embodiment, if the reference point is the midpoint of the bottom of the rectangular area, half of the width of the top view is set as the pixel coordinate in the first direction of the reverse perspective coordinate of the pixel coordinates of the reference point, and the height of the top view is divided into four The third is set as the pixel coordinates in the second direction of the reverse perspective coordinates of the pixel coordinates of the reference point, and set the reverse perspective coordinates of the pixel coordinates of the reference point to (x, y). Since the reference point is the middle point of the bottom of the rectangular area, according to the positional relationship between the pixel coordinates of the reverse perspective corner and the coordinates of the reverse perspective reference point, the coordinates of the pixel coordinates of the reverse perspective corner can be deduced.
请参阅图5,若基准点为矩形区域的底边中点,基准点像素坐标的逆透视坐标为图5中像素点N的坐标,设为(x,y),则逆透视顶角像素坐标对应为像素点J、K、L、M的坐标,若所述矩形区域的底边边长为W米,垂直于底边的竖边边长为L米,每一像素点对应物理世界的s米,可以求得底边在逆透视变换图为W/s像素,竖边在逆透视变换图为L/s像素。像素点J、K、L、M的坐标,分别为q1(x-W/2s,y-L/s),q2(x+W/2s,y-L/s),q3(x-W/2s,y),q4(x+W/2s,y)。Please refer to Figure 5, if the reference point is the midpoint of the bottom of the rectangular area, the inverse perspective coordinates of the pixel coordinates of the reference point are the coordinates of the pixel point N in Figure 5, which is set to (x, y), then the inverse perspective pixel coordinates of the top corner Corresponding to the coordinates of pixel points J, K, L, M, if the length of the bottom side of the rectangular area is W meters, and the length of the vertical side perpendicular to the bottom side is L meters, each pixel corresponds to s in the physical world m, it can be obtained that the bottom edge is W/s pixels in the inverse perspective transformation diagram, and the vertical edge is L/s pixels in the inverse perspective transformation diagram. The coordinates of pixel points J, K, L, and M are q1(x-W/2s, y-L/s), q2(x+W/2s, y-L/s), q3(x-W/2s, y), q4(x +W/2s,y).
进一步补充说明的是,按照公式3设置逆透视变换的单应矩阵:It is further added that the homography matrix of inverse perspective transformation is set according to formula 3:
公式3:
Figure PCTCN2021131460-appb-000003
Formula 3:
Figure PCTCN2021131460-appb-000003
由p1逆透视转换得到q1,以p1和q1的对应关系为例,首先将p1和q1坐标变换为其次坐标(u1,v1,1)和(x1,y1,1),二者可以通过单应矩阵得到公式4:q1 is obtained by inverse perspective transformation of p1. Taking the corresponding relationship between p1 and q1 as an example, the coordinates of p1 and q1 are first transformed into the second coordinates (u1, v1, 1) and (x1, y1, 1), and the two can be obtained through the homography The matrix yields Equation 4:
Figure PCTCN2021131460-appb-000004
Figure PCTCN2021131460-appb-000004
将方程展开可以得到公式5-公式7:Expand the equation to get Equation 5-Equation 7:
公式5:h 1u 1+h 2v 1+h 3=x 1Formula 5: h 1 u 1 +h 2 v 1 +h 3 = x 1 ;
公式6:h 4u 1+h 5v 1+h 6=y 1Formula 6: h 4 u 1 +h 5 v 1 +h 6 =y 1 ;
公式7:h 7u 1+h 8v 1+h 9=1; Formula 7: h 7 u 1 +h 8 v 1 +h 9 =1;
由于单应矩阵存在尺度不变形,因此可以令h9=1,此时h 7u 1+h 8v 1=0,代入可得公式8-公式9; Since the scale of the homography matrix is not deformed, h9=1 can be set. At this time, h 7 u 1 +h 8 v 1 =0 can be substituted into Formula 8-Formula 9;
公式8:h 1u 1+h 2v 1+h 3-h 7u 1x 1-h 8v 1y 1=x 1Formula 8: h 1 u 1 +h 2 v 1 +h 3 -h 7 u 1 x 1 -h 8 v 1 y 1 = x 1 ;
公式9:h 4u 1+h 5v 1+h 6-h 7u 1x 1-h 8v 1y 1=y 1Formula 9: h 4 u 1 +h 5 v 1 +h 6 -h 7 u 1 x 1 -h 8 v 1 y 1 =y 1 ;
以p2和q2的对应关系,可以推出公式10-公式11:Based on the corresponding relationship between p2 and q2, Formula 10-Formula 11 can be deduced:
公式10:h 1u 2+h 2v 2+h 3-h 7u 2x 2-h 8v 2y 2=x 2Formula 10: h 1 u 2 +h 2 v 2 +h 3 -h 7 u 2 x 2 -h 8 v 2 y 2 = x 2 ;
公式11:h 4u 2+h 5v 2+h 6-h 7u 2x 2-h 8v 2y 2=y 2Formula 11: h 4 u 2 +h 5 v 2 +h 6 -h 7 u 2 x 2 -h 8 v 2 y 2 =y 2 ;
以p2和q2的对应关系,可以推出公式12-公式13:Based on the corresponding relationship between p2 and q2, Formula 12-Formula 13 can be deduced:
公式12:h 1u 3+h 2v 3+h 3-h 7u 3x 3-h 8v 3y 3=x 3Formula 12: h 1 u 3 +h 2 v 3 +h 3 -h 7 u 3 x 3 -h 8 v 3 y 3 = x 3 ;
公式13:h 4u 3+h 5v 3+h 6-h 7u 3x 3-h 8v 3y 3=y 3Formula 13: h 4 u 3 +h 5 v 3 +h 6 -h 7 u 3 x 3 -h 8 v 3 y 3 =y 3 ;
以p3和q3的对应关系,可以推出公式14-公式15:Based on the correspondence between p3 and q3, Formula 14-Formula 15 can be deduced:
公式14:h 1u 4+h 2v 4+h 3-h 7u 4x 4-h 8v 4y 4=x 4Formula 14: h 1 u 4 +h 2 v 4 +h 3 -h 7 u 4 x 4 -h 8 v 4 y 4 = x 4 ;
公式15:h 4u 4+h 5v 3+h 6-h 7u 44-h 8v 4y 4=y 4Formula 15: h 4 u 4 +h 5 v 3 +h 6 -h 7 u 4 4-h 8 v 4 y 4 =y 4 ;
p1(u1,v1),p2(u2,v2),p3(u3,v3),p4(u4,v4)可以从平视图中直接读取,对应的逆透视顶角像素坐标q1(x1,y1),q2(x2,y2),q3(x3,y3),q4(x4,y4),用q1(x-W/2s,y-L/s),q2(x+W/2s,y-L/s),q3(x-W/2s,y),q4(x+W/2s,y)替换,带入公式8-公式15,计算得到单应矩阵H。p1(u1, v1), p2(u2, v2), p3(u3, v3), p4(u4, v4) can be read directly from the flat view, and the corresponding reverse perspective pixel coordinates q1(x1, y1) , q2(x2, y2), q3(x3, y3), q4(x4, y4), with q1(x-W/2s, y-L/s), q2(x+W/2s, y-L/s), q3(x-W /2s, y), q4(x+W/2s, y) is replaced, brought into Formula 8-Formula 15, and the homography matrix H is calculated.
可选的,步骤S106包括:Optionally, step S106 includes:
将所述目标逆透视坐标的第一方向坐标减去所述第一方向基准点像素坐标,得到第一像素差值;将所述第一像素差值乘以物理尺度与像素尺度的对应关系,得到第一乘积;将所述第一乘积作为所述目标物体与所述单目相机之间的第一方向距离;和/或,Subtracting the pixel coordinates of the reference point in the first direction from the coordinates in the first direction of the reverse perspective coordinates of the target to obtain a first pixel difference; multiplying the first pixel difference by the corresponding relationship between the physical scale and the pixel scale, Obtain a first product; use the first product as a first direction distance between the target object and the monocular camera; and/or,
将所述目标逆透视坐标的第二方向坐标减去所述第二方向基准点像素坐标,得到第二像素差值;将所述第二像素差值乘以物理尺度与像素尺度的对应关系,得到第二乘积;将所述第二乘积作加上所述基准点与所述单目相机之间的第二方向距离之和,作为所述目标物体与所述单目相机之间的第二方向距离。Subtracting the pixel coordinates of the reference point in the second direction from the second direction coordinates of the target reverse perspective coordinates to obtain a second pixel difference; multiplying the second pixel difference by the corresponding relationship between the physical scale and the pixel scale, Obtain the second product; add the second product to the sum of the distance in the second direction between the reference point and the monocular camera, as the second distance between the target object and the monocular camera direction distance.
在本实施例中,为了计算其他平视图中路面像素点的物理坐标,需要确定物理坐标系的原点。如图6所示,将单目相机在路面的投影点设为物理坐标系的原点,以路面作为2D平面,平行于摄像头的视线作为y轴正方向,垂直于y轴的右侧为x轴正方向。测量坐标系原点与矩形区域的基准点之间的距离,具体的,在本实施例中,矩形区域的基准点为底边中点,测量坐标系原点与底边中点的y方向距离L1米。由于矩形底边中点的图像坐标为(x,y),由此可知,其他平视图中目标物体边界框底边的任一像素点的目标逆透视坐标(a,b)在物理坐标系中的坐标为((a-x)s,(b-y)s+L1)。其中(a-x)s与(b-y)s+L1分别表示x轴方向上、y轴方向上目标物体与单目相机的真实的物理距离,单位为米。In this embodiment, in order to calculate the physical coordinates of road pixel points in other plan views, the origin of the physical coordinate system needs to be determined. As shown in Figure 6, set the projection point of the monocular camera on the road as the origin of the physical coordinate system, take the road as the 2D plane, the line of sight parallel to the camera as the positive direction of the y-axis, and the right side perpendicular to the y-axis as the x-axis Positive direction. Measure the distance between the origin of the coordinate system and the reference point of the rectangular area. Specifically, in this embodiment, the reference point of the rectangular area is the midpoint of the base, and the distance in the y direction between the origin of the coordinate system and the midpoint of the base is L1 meters . Since the image coordinates of the midpoint of the bottom edge of the rectangle are (x, y), it can be seen that the target inverse perspective coordinates (a, b) of any pixel point on the bottom edge of the bounding box of the target object in other flat views are in the physical coordinate system The coordinates of are ((a-x)s, (b-y)s+L1). Among them, (a-x)s and (b-y)s+L1 represent the real physical distance between the target object and the monocular camera in the x-axis direction and y-axis direction, respectively, in meters.
补充说明的是,其他平视图中目标物体边界框底边的中点坐标的目标逆透视坐标(a1,b1)在物理坐标系中的坐标为((a1-x)s,(b1-y)s+L1)。其中(a1-x)s与(b1-y)s+L11分别表示x轴方向上、y轴方向上目标物体边界框底边的中点真实的物理距离,单位为米。It is supplemented that the coordinates of the target anti-perspective coordinates (a1, b1) of the midpoint coordinates of the bottom edge of the target object's bounding box in other flat views in the physical coordinate system are ((a1-x)s, (b1-y) s+L1). Among them, (a1-x)s and (b1-y)s+L11 represent the real physical distance of the midpoint of the bottom edge of the bounding box of the target object in the x-axis direction and the y-axis direction, respectively, in meters.
本实施例提供的单目测距方法,通过单目相机拍摄平视图;根据所述第一区域图像的顶角像素坐标确定用于将所述平视图逆透视变换为俯视图的单应矩阵;从所述矩形区域的底边确定基准点,获取所述基准点与所述单目相机之间的距离;确定所述基准点在所述第一区域图像中对应的基准点像素坐标,获取所述基准点像素坐标对应的 逆透视基准点坐标;对所述单目相机拍摄的其他平视图进行目标物体检测,得到目标物体边界框,根据所述单应矩阵对所述目标物体边界框的底边任一像素点坐标进行逆透视变换,获取所述底边任一像素点坐标对应的目标逆透视坐标;根据所述逆透视基准点坐标、所述目标逆透视坐标、物理尺度与像素尺度的对应关系、及所述基准点与所述单目相机之间的距离,确定所述目标物体与所述单目相机之间的距离。这样,可以通过单目相机测量目标物体的距离,没有过多的数据要求,能实现对不规则的目标物体的测距,降低测距条件,提高测距效率。In the monocular ranging method provided in this embodiment, a flat view is taken by a monocular camera; a homography matrix for inverse perspective transformation of the flat view into a top view is determined according to the apex pixel coordinates of the first region image; from The bottom edge of the rectangular area determines a reference point, and obtains the distance between the reference point and the monocular camera; determines the reference point pixel coordinates corresponding to the reference point in the first area image, and obtains the The coordinates of the reverse perspective reference point corresponding to the pixel coordinates of the reference point; the target object detection is performed on other flat views captured by the monocular camera to obtain the target object bounding box, and the bottom edge of the target object bounding box is obtained according to the homography matrix Perform inverse perspective transformation on the coordinates of any pixel point, and obtain the target inverse perspective coordinates corresponding to any pixel point coordinates of the bottom edge; relationship, and the distance between the reference point and the monocular camera, determine the distance between the target object and the monocular camera. In this way, the distance of the target object can be measured through the monocular camera, without excessive data requirements, and the ranging of irregular target objects can be realized, the ranging condition is reduced, and the ranging efficiency is improved.
实施例2Example 2
此外,本公开实施例提供了一种单目测距装置。In addition, an embodiment of the present disclosure provides a monocular ranging device.
在本实施例中,单目测距装置可以是智能车、机器人等智能设备。In this embodiment, the monocular ranging device may be a smart device such as a smart car or a robot.
具体的,如图7所示,单目测距装置700包括:Specifically, as shown in Figure 7, the monocular ranging device 700 includes:
拍摄模块701,用于通过单目相机拍摄平视图,所述单目相机的地面可视区域包括矩形区域,所述平视图包括所述矩形区域对应的第一区域图像;The photographing module 701 is configured to photograph a plane view through a monocular camera, the ground visible area of the monocular camera includes a rectangular area, and the plane view includes a first area image corresponding to the rectangular area;
第一确定模块702,用于根据所述第一区域图像的顶角像素坐标确定用于将所述平视图逆透视变换为俯视图的单应矩阵;The first determination module 702 is configured to determine a homography matrix used for inverse perspective transformation of the plane view into a top view according to the top corner pixel coordinates of the first area image;
获取模块703,用于从所述矩形区域的底边确定基准点,获取所述基准点与所述单目相机之间的所述基准点与所述单目相机之间的距离;An acquisition module 703, configured to determine a reference point from the bottom of the rectangular area, and acquire the distance between the reference point and the monocular camera;
第一处理模块704,用于确定所述基准点在所述第一区域图像中对应的基准点像素坐标,获取所述基准点像素坐标对应的逆透视基准点坐标;The first processing module 704 is configured to determine the pixel coordinates of the reference point corresponding to the reference point in the first region image, and obtain the reverse perspective reference point coordinates corresponding to the pixel coordinates of the reference point;
第二处理模块705,用于对所述单目相机拍摄的其他平视图进行目标物体检测,得到目标物体边界框,根据所述单应矩阵对所述目标物体边界框的底边任一像素点坐标进行逆透视变换,获取所述底边任一像素点坐标对应的目标逆透视坐标;The second processing module 705 is configured to perform target object detection on other plane views captured by the monocular camera to obtain a bounding box of the target object, and perform any pixel point on the bottom edge of the bounding box of the target object according to the homography matrix The coordinates are subjected to inverse perspective transformation, and the target inverse perspective coordinates corresponding to the coordinates of any pixel point on the bottom edge are obtained;
第二确定模块706,用于根据所述逆透视基准点坐标、所述目标逆透视坐标、物理尺度与像素尺度的对应关系、及所述基准点与所述单目相机之间的距离,确定所述目标物体与所述单目相机之间的距离。The second determination module 706 is configured to determine according to the inverse perspective reference point coordinates, the target inverse perspective coordinates, the corresponding relationship between physical scale and pixel scale, and the distance between the reference point and the monocular camera The distance between the target object and the monocular camera.
可选的,所述第一确定模块702,还用于获取所述第一区域图像的顶角像素坐标及其对应的逆透视顶角像素坐标;Optionally, the first determining module 702 is further configured to obtain the pixel coordinates of the top corner of the first area image and the corresponding pixel coordinates of the top corner of the reverse perspective;
根据所述第一区域图像的顶角像素坐标、所述逆透视顶角像素坐标确定所述单应矩阵。The homography matrix is determined according to the vertex pixel coordinates of the first area image and the reverse perspective vertex pixel coordinates.
可选的,所述第一确定模块702,还用于根据所述俯视图的大小设置所述基准点像素坐标的逆透视坐标。Optionally, the first determination module 702 is further configured to set reverse perspective coordinates of pixel coordinates of the reference point according to the size of the top view.
可选的,所述第一确定模块702,还用于对所述平视图进行矫正,得到矫正后平视图,所述矫正后平视图包括第二区域图像,将所述第二区域图像的顶角像素坐标作为所述第一区域图像的顶角像素坐标;Optionally, the first determination module 702 is further configured to correct the plane view to obtain a corrected plane view, the corrected plane view includes a second area image, and the top of the second area image The corner pixel coordinates are used as the top corner pixel coordinates of the first region image;
根据所述基准点像素坐标的逆透视坐标、所述物理尺度与像素尺度的对应关系、所述矩形区域的边长,确定所述逆透视顶角像素坐标。The pixel coordinates of the reverse perspective corner are determined according to the reverse perspective coordinates of the pixel coordinates of the reference point, the corresponding relationship between the physical scale and the pixel scale, and the side length of the rectangular area.
可选的,所述单目测距装置700还包括:Optionally, the monocular ranging device 700 also includes:
矫正模块,通过所述单目相机拍摄棋盘格图像,根据所述棋盘格图像获取所述单目相机的内参及畸变参数;A rectification module that takes a checkerboard image through the monocular camera, and acquires internal references and distortion parameters of the monocular camera according to the checkerboard image;
所述第一确定模块702,还用于根据所述内参及畸变参数对所述平视图进行矫正,得到所述矫正后平视图。The first determination module 702 is further configured to correct the plane view according to the internal reference and distortion parameters to obtain the corrected plane view.
可选的,所述基准点像素坐标的逆透视坐标包括第一方向基准点像素坐标及第二方向基准点像素坐标,所述第二方向垂直于所述第一方向;Optionally, the reverse perspective coordinates of the pixel coordinates of the reference point include the pixel coordinates of the reference point in the first direction and the pixel coordinates of the reference point in the second direction, and the second direction is perpendicular to the first direction;
所述第一确定模块702,还用于根据所述第一方向基准点像素坐标、所述第二方向基准点像素坐标、所述矩形区域的边长、所述物理尺度与像素尺度的对应关系、所述逆透视顶角像素坐标与所述逆透视基准点坐标的位置关系,确定所述逆透视顶角像素坐标的第一方向坐标及第二方向坐标。The first determination module 702 is further configured to: according to the pixel coordinates of the reference point in the first direction, the pixel coordinates of the reference point in the second direction, the side length of the rectangular area, and the corresponding relationship between the physical scale and the pixel scale . The positional relationship between the reverse perspective vertex corner pixel coordinates and the reverse perspective reference point coordinates, determining the first direction coordinate and the second direction coordinate of the reverse perspective vertex corner pixel coordinates.
可选的,第二确定模块706,还用于将所述目标逆透视坐标的第一方向坐标减去所述第一方向基准点像素坐标,得到第一像素差值;将所述第一像素差值乘以物理尺度与像素尺度的对应关系,得到第一乘积;将所述第一乘积作为所述目标物体与所述单目相机之间的第一方向距离;和/或,Optionally, the second determination module 706 is further configured to subtract the pixel coordinates of the reference point in the first direction from the coordinates in the first direction of the reverse perspective coordinates of the target to obtain a first pixel difference; The difference is multiplied by the corresponding relationship between the physical scale and the pixel scale to obtain a first product; the first product is used as the first direction distance between the target object and the monocular camera; and/or,
将所述目标逆透视坐标的第二方向坐标减去所述第二方向基准点像素坐标,得到第二像素差值;将所述第二像素差值乘以物理尺度与像素尺度的对应关系,得到第二乘积;将所述第二乘积作加上所述基准点与所述单目相机之间的第二方向距离之和,作为所述目标物体与所述单目相机之间的第二方向距离。Subtracting the pixel coordinates of the reference point in the second direction from the second direction coordinates of the target reverse perspective coordinates to obtain a second pixel difference; multiplying the second pixel difference by the corresponding relationship between the physical scale and the pixel scale, Obtain the second product; add the second product to the sum of the distance in the second direction between the reference point and the monocular camera, as the second distance between the target object and the monocular camera direction distance.
本实施例提供的单目测距装置700可以实现实施例1所示单目测距方法,为避免重复,在此不再赘述。The monocular ranging device 700 provided in this embodiment can implement the monocular ranging method shown in Embodiment 1, and details are not repeated here to avoid repetition.
本实施例提供的单目测距装置,通过单目相机拍摄平视图;根据所述第一区域图像的顶角像素坐标确定用于将所述平视图逆透视变换为俯视图的单应矩阵;从所述矩形区域的底边确定基准点,获取所述基准点与所述单目相机之间的距离;确定所述基准点在所述第一区域图像中对应的基准点像素坐标,获取所述基准点像素坐标对应的逆透视基准点坐标;对所述单目相机拍摄的其他平视图进行目标物体检测,得到目标物体边界框,根据所述单应矩阵对所述目标物体边界框的底边任一像素点坐标进行逆透视变换,获取所述底边任一像素点坐标对应的目标逆透视坐标;根据所述逆透视基准点坐标、所述目标逆透视坐标、物理尺度与像素尺度的对应关系、及所述基准点与所述单目相机之间的距离,确定所述目标物体与所述单目相机之间的距离。这样,可以通过单目相机测量目标物体的距离,没有过多的数据要求,能实现对不规则的目标物体的测距,降低测距条件,提高测距效率。The monocular distance measuring device provided in this embodiment uses a monocular camera to take a plane view; determines a homography matrix for inverse perspective transformation of the plane view into a top view according to the apex pixel coordinates of the first region image; The bottom edge of the rectangular area determines a reference point, and obtains the distance between the reference point and the monocular camera; determines the reference point pixel coordinates corresponding to the reference point in the first area image, and obtains the The coordinates of the reverse perspective reference point corresponding to the pixel coordinates of the reference point; the target object detection is performed on other flat views captured by the monocular camera to obtain the target object bounding box, and the bottom edge of the target object bounding box is obtained according to the homography matrix Perform inverse perspective transformation on the coordinates of any pixel point, and obtain the target inverse perspective coordinates corresponding to any pixel point coordinates of the bottom edge; relationship, and the distance between the reference point and the monocular camera, determine the distance between the target object and the monocular camera. In this way, the distance of the target object can be measured through the monocular camera, without excessive data requirements, and the ranging of irregular target objects can be realized, the ranging condition is reduced, and the ranging efficiency is improved.
实施例3Example 3
此外,本公开实施例提供了一种智能装置,包括单目相机、存储器以及处理器,所述存储器存储有计算机程序,所述计算机程序在所述处理器上运行时执行上述方法实施例1所提供的单目测距方法。In addition, an embodiment of the present disclosure provides an intelligent device, including a monocular camera, a memory, and a processor, the memory stores a computer program, and when the computer program runs on the processor, it executes the above method described in Embodiment 1. Provided monocular ranging method.
在本实施例中,智能装置可以为智能车、机器人等智能设备。In this embodiment, the smart device may be smart devices such as smart cars and robots.
其中,处理器,用于:通过单目相机拍摄平视图,所述单目相机的地面可视区域包括矩形区域,所述平视图包括所述矩形区域对应的第一区域图像;Wherein, the processor is configured to: take a plane view through a monocular camera, the ground visible area of the monocular camera includes a rectangular area, and the plane view includes a first area image corresponding to the rectangular area;
根据所述第一区域图像的顶角像素坐标确定用于将所述平视图逆透视变换为俯视图的单应矩阵;determining a homography matrix for inverse perspective transforming the plane view into a top view according to the apex pixel coordinates of the first region image;
从所述矩形区域的底边确定基准点,获取所述基准点与所述单目相机之间的距离;Determining a reference point from the bottom edge of the rectangular area, and obtaining the distance between the reference point and the monocular camera;
确定所述基准点在所述第一区域图像中对应的基准点像素坐标,获取所述基准点像素坐标对应的逆透视基准点坐标;Determining the pixel coordinates of the reference point corresponding to the reference point in the first region image, and obtaining the coordinates of the reverse perspective reference point corresponding to the pixel coordinates of the reference point;
对所述单目相机拍摄的其他平视图进行目标物体检测,得到目标物体边界框,根据所述单应矩阵对所述目标物体边界框的底边任一像素点坐标进行逆透视变换,获取所述底边任一像素点坐标对应的目标逆透视坐标;Perform target object detection on other planar views captured by the monocular camera to obtain the target object bounding box, perform inverse perspective transformation on the coordinates of any pixel point on the bottom edge of the target object bounding box according to the homography matrix, and obtain the target object bounding box. The target inverse perspective coordinate corresponding to any pixel coordinate of the bottom edge;
根据所述逆透视基准点坐标、所述目标逆透视坐标、物理尺度与像素尺度的对应关系、及所述基准点与所述单目相机之间的距离,确定所述目标物体与所述单目相机之间的距离。According to the coordinates of the reverse perspective reference point, the reverse perspective coordinates of the target, the corresponding relationship between the physical scale and the pixel scale, and the distance between the reference point and the monocular camera, determine the target object and the monocular camera. The distance between the cameras.
可选的,处理器,还用于:获取所述第一区域图像的顶角像素坐标及其对应的逆透视顶角像素坐标;Optionally, the processor is further configured to: obtain the pixel coordinates of the top corner of the image of the first region and the corresponding pixel coordinates of the top corner of the image in reverse perspective;
根据所述第一区域图像的顶角像素坐标、所述逆透视顶角像素坐标确定所述单应矩阵。The homography matrix is determined according to the vertex pixel coordinates of the first area image and the reverse perspective vertex pixel coordinates.
可选的,处理器,还用于:根据所述俯视图的大小设置所述基准点像素坐标的逆透视坐标。Optionally, the processor is further configured to: set reverse perspective coordinates of pixel coordinates of the reference point according to the size of the top view.
可选的,处理器,还用于:对所述平视图进行矫正,得到矫正后平视图,所述矫正后平视图包括第二区域图像,将所述第二区域图像的顶角像素坐标作为所述第一区域图像的顶角像素坐标;Optionally, the processor is further configured to: correct the plane view to obtain a corrected plane view, the corrected plane view includes a second area image, and use the apex pixel coordinates of the second area image as The pixel coordinates of the top corner of the first area image;
根据所述基准点像素坐标的逆透视坐标、所述物理尺度与像素尺度的对应关系、所述矩形区域的边长,确定所述逆透视顶角像素坐标。The pixel coordinates of the reverse perspective corner are determined according to the reverse perspective coordinates of the pixel coordinates of the reference point, the corresponding relationship between the physical scale and the pixel scale, and the side length of the rectangular area.
可选的,处理器,还用于:通过所述单目相机拍摄棋盘格图像,根据所述棋盘格图像获取所述单目相机的内参及畸变参数;Optionally, the processor is further configured to: take a checkerboard image through the monocular camera, and acquire internal references and distortion parameters of the monocular camera according to the checkerboard image;
根据所述内参及畸变参数对所述平视图进行矫正,得到所述矫正后平视图。The plane view is corrected according to the internal reference and the distortion parameter to obtain the corrected plane view.
可选的,所述基准点像素坐标的逆透视坐标包括第一方向基准点像素坐标及第二方向基准点像素坐标,所述第二方向垂直于所述第一方向;Optionally, the reverse perspective coordinates of the pixel coordinates of the reference point include the pixel coordinates of the reference point in the first direction and the pixel coordinates of the reference point in the second direction, and the second direction is perpendicular to the first direction;
处理器,还用于:根据所述第一方向基准点像素坐标、所述第二方向基准点像素坐标、所述矩形区域的边长、所述物理尺度与像素尺度的对应关系、所述逆透视顶角像素坐标与所述逆透视基准点坐标的位置关系,确定所述逆透视顶角像素坐标的第一方向坐标及第二方向坐标。The processor is further configured to: according to the pixel coordinates of the reference point in the first direction, the pixel coordinates of the reference point in the second direction, the side length of the rectangular area, the corresponding relationship between the physical scale and the pixel scale, the inverse The positional relationship between the perspective pixel coordinates and the reverse perspective reference point coordinates determines the first direction coordinates and the second direction coordinates of the reverse perspective pixel coordinates.
可选的,处理器,还用于:将所述目标逆透视坐标的第一方向坐标减去所述第一方向基准点像素坐标,得到第一像素差值;将所述第一像素差值乘以物理尺度与像素尺度的对应关系,得到第一乘积;将所述第一乘积作为所述目标物体与所述单目相机之间的第一方向距离;和/或,Optionally, the processor is further configured to: subtract the pixel coordinates of the first direction reference point from the first direction coordinates of the target reverse perspective coordinates to obtain a first pixel difference; Multiplying the corresponding relationship between the physical scale and the pixel scale to obtain a first product; using the first product as the distance in the first direction between the target object and the monocular camera; and/or,
将所述目标逆透视坐标的第二方向坐标减去所述第二方向基准点像素坐标,得到第二像素差值;将所述第二像素差值乘以物理尺度与像素尺度的对应关系,得到第二乘积;将所述第二乘积作加上所述基准点与所述单目相机之间的第二方向距离之和,作为所述目标物体与所述单目相机之间的第二方向距离。Subtracting the pixel coordinates of the reference point in the second direction from the second direction coordinates of the target reverse perspective coordinates to obtain a second pixel difference; multiplying the second pixel difference by the corresponding relationship between the physical scale and the pixel scale, Obtain the second product; add the second product to the sum of the distance in the second direction between the reference point and the monocular camera, as the second distance between the target object and the monocular camera direction distance.
本实施例提供的智能装置可以实现实施例1所示单目测距方法,为避免重复,在此不再赘述。The smart device provided in this embodiment can implement the monocular ranging method shown in Embodiment 1, and to avoid repetition, details are not repeated here.
本实施例提供的智能装置,通过单目相机拍摄平视图;根据所述第一区域图像的顶角像素坐标确定用于将所述平视图逆透视变换为俯视图的单应矩阵;从所述矩形区域的底边确定基准点,获取所述基准点与所述单目相机之间的距离;确定所述基准点在所述第一区域图像中对应的基准点像素坐标,获取所述基准点像素坐标对应的逆透视基准点坐标;对所述单目相机拍摄的其他平视图进行目标物体检测,得到目标物体边界框,根据所述单应矩阵对所述目标物体边界框的底边任一像素点坐标进行逆透视变换,获取所述底边任一像素点坐标对应的目标逆透视坐标;根据所述逆透视基准点坐标、所述目标逆透视坐标、物理尺度与像素尺度的对应关系、及所述基准点与所述单目相机之间的距离,确定所述目标物体与所述单目相机之间的距离。这样,可以通过单目相机测量目标物体的距离,没有过多的数据要求,能实现对不规则的目标物体的测距,降低测距条件,提高测距效率。The smart device provided in this embodiment uses a monocular camera to take a plane view; determines a homography matrix for reverse perspective transformation of the plane view into a top view according to the pixel coordinates of the top corner of the first region image; The bottom edge of the area determines the reference point, and obtains the distance between the reference point and the monocular camera; determines the reference point pixel coordinates corresponding to the reference point in the first area image, and obtains the reference point pixel The coordinates of the inverse perspective reference point corresponding to the coordinates; the target object detection is performed on other flat views captured by the monocular camera to obtain the bounding box of the target object, and any pixel of the bottom edge of the bounding box of the target object is obtained according to the homography matrix Perform inverse perspective transformation on the point coordinates to obtain the target inverse perspective coordinates corresponding to any pixel point coordinates of the bottom edge; according to the inverse perspective reference point coordinates, the target inverse perspective coordinates, the corresponding relationship between the physical scale and the pixel scale, and The distance between the reference point and the monocular camera determines the distance between the target object and the monocular camera. In this way, the distance of the target object can be measured through the monocular camera, without excessive data requirements, and the ranging of irregular target objects can be realized, the ranging condition is reduced, and the ranging efficiency is improved.
实施例4Example 4
本申请还提供一种计算机可读存储介质,所述计算机可读存储介质上存储计算机程序,通过单目相机拍摄平视图,所述单目相机的地面可视区域包括矩形区域,所述平视图包括所述矩形区域对应的第一区域图像;The present application also provides a computer-readable storage medium, on which a computer program is stored, and a plane view is taken by a monocular camera, the visible area of the ground of the monocular camera includes a rectangular area, and the plane view including a first area image corresponding to the rectangular area;
根据所述第一区域图像的顶角像素坐标确定用于将所述平视图逆透视变换为俯视图的单应矩阵;determining a homography matrix for inverse perspective transforming the plane view into a top view according to the apex pixel coordinates of the first region image;
从所述矩形区域的底边确定基准点,获取所述基准点与所述单目相机之间的距离;Determining a reference point from the bottom edge of the rectangular area, and obtaining the distance between the reference point and the monocular camera;
确定所述基准点在所述第一区域图像中对应的基准点像素坐标,获取所述基准点像素坐标对应的逆透视基准点坐标;Determining the pixel coordinates of the reference point corresponding to the reference point in the first region image, and obtaining the coordinates of the reverse perspective reference point corresponding to the pixel coordinates of the reference point;
对所述单目相机拍摄的其他平视图进行目标物体检测,得到目标物体边界框,根据所述单应矩阵对所述目标物体边界框的底边任一像素点坐标进行逆透视变换,获取所述底边任一像素点坐标对应的目标逆透视坐标;Perform target object detection on other planar views captured by the monocular camera to obtain the target object bounding box, perform inverse perspective transformation on the coordinates of any pixel point on the bottom edge of the target object bounding box according to the homography matrix, and obtain the target object bounding box. The target inverse perspective coordinate corresponding to any pixel coordinate of the bottom edge;
根据所述逆透视基准点坐标、所述目标逆透视坐标、物理尺度与像素尺度的对应关系、及所述基准点与所述单目相机之间的距离,确定所述目标物体与所述单目相机之间的距离。According to the coordinates of the reverse perspective reference point, the reverse perspective coordinates of the target, the corresponding relationship between the physical scale and the pixel scale, and the distance between the reference point and the monocular camera, determine the target object and the monocular camera. The distance between the cameras.
所述计算机程序被处理器执行时实现如下步骤:When the computer program is executed by the processor, the following steps are implemented:
获取所述第一区域图像的顶角像素坐标及其对应的逆透视顶角像素坐标;Acquiring the pixel coordinates of the top corner of the first area image and the corresponding pixel coordinates of the top corner of the reverse perspective image;
根据所述第一区域图像的顶角像素坐标、所述逆透视顶角像素坐标确定所述单应矩阵。The homography matrix is determined according to the vertex pixel coordinates of the first area image and the reverse perspective vertex pixel coordinates.
可选的,所述计算机程序被处理器执行时还实现如下步骤:Optionally, when the computer program is executed by the processor, the following steps are also implemented:
根据所述俯视图的大小设置所述基准点像素坐标的逆透视坐标。The reverse perspective coordinates of the pixel coordinates of the reference point are set according to the size of the top view.
可选的,所述计算机程序被处理器执行时还实现如下步骤:Optionally, when the computer program is executed by the processor, the following steps are also implemented:
对所述平视图进行矫正,得到矫正后平视图,所述矫正后平视图包括第二区域图像,将所述第二区域图像的顶角像素坐标作为所述第一区域图像的顶角像素坐标;Correcting the plan view to obtain a corrected plan view, the corrected plan view including a second area image, using the apex pixel coordinates of the second area image as the apex pixel coordinates of the first area image ;
根据所述基准点像素坐标的逆透视坐标、所述物理尺度与像素尺度的对应关系、所述矩形区域的边长,确定所述逆透视顶角像素坐标。The pixel coordinates of the reverse perspective corner are determined according to the reverse perspective coordinates of the pixel coordinates of the reference point, the corresponding relationship between the physical scale and the pixel scale, and the side length of the rectangular area.
可选的,所述计算机程序被处理器执行时还实现如下步骤:Optionally, when the computer program is executed by the processor, the following steps are also implemented:
通过所述单目相机拍摄棋盘格图像,根据所述棋盘格图像获取所述单目相机的内参及畸变参数;Taking a checkerboard image through the monocular camera, and obtaining internal reference and distortion parameters of the monocular camera according to the checkerboard image;
根据所述内参及畸变参数对所述平视图进行矫正,得到所述矫正后平视图。The plane view is corrected according to the internal reference and the distortion parameter to obtain the corrected plane view.
可选的,所述基准点像素坐标的逆透视坐标包括第一方向基准点像素坐标及第二方向基准点像素坐标,所述第二方向垂直于所述第一方向;Optionally, the reverse perspective coordinates of the pixel coordinates of the reference point include the pixel coordinates of the reference point in the first direction and the pixel coordinates of the reference point in the second direction, and the second direction is perpendicular to the first direction;
所述计算机程序被处理器执行时还实现如下步骤:When the computer program is executed by the processor, the following steps are also implemented:
根据所述第一方向基准点像素坐标、所述第二方向基准点像素坐标、所述矩形区域的边长、所述物理尺度与像素尺度的对应关系、所述逆透视顶角像素坐标与所述逆透视基准点坐标的位置关系,确定所述逆透视顶角像素坐标的第一方向坐标及第二方向坐标。According to the pixel coordinates of the reference point in the first direction, the pixel coordinates of the reference point in the second direction, the side length of the rectangular area, the corresponding relationship between the physical scale and the pixel scale, the pixel coordinates of the reverse perspective vertex and the The positional relationship of the reference point coordinates of the reverse perspective is determined, and the coordinates of the first direction and the second direction of the pixel coordinates of the reverse perspective corner are determined.
可选的,所述计算机程序被处理器执行时还实现如下步骤:Optionally, when the computer program is executed by the processor, the following steps are also implemented:
将所述目标逆透视坐标的第一方向坐标减去所述第一方向基准点像素坐标,得到第一像素差值;将所述第一像素差值乘以物理尺度与像素尺度的对应关系,得到第一乘积;将所述第一乘积作为所述目标物体与所述单目相机之间的第一方向距离;和/或,Subtracting the pixel coordinates of the reference point in the first direction from the coordinates in the first direction of the reverse perspective coordinates of the target to obtain a first pixel difference; multiplying the first pixel difference by the corresponding relationship between the physical scale and the pixel scale, Obtain a first product; use the first product as a first direction distance between the target object and the monocular camera; and/or,
将所述目标逆透视坐标的第二方向坐标减去所述第二方向基准点像素坐标,得到 第二像素差值;将所述第二像素差值乘以物理尺度与像素尺度的对应关系,得到第二乘积;将所述第二乘积作加上所述基准点与所述单目相机之间的第二方向距离之和,作为所述目标物体与所述单目相机之间的第二方向距离。Subtracting the pixel coordinates of the reference point in the second direction from the second direction coordinates of the target reverse perspective coordinates to obtain a second pixel difference; multiplying the second pixel difference by the corresponding relationship between the physical scale and the pixel scale, Obtain the second product; add the second product to the sum of the distance in the second direction between the reference point and the monocular camera, as the second distance between the target object and the monocular camera direction distance.
在本实施例中,计算机可读存储介质可以为只读存储器(Read-Only Memory,简称ROM)、随机存取存储器(Random Access Memory,简称RAM)、磁碟或者光盘等。In this embodiment, the computer-readable storage medium may be a read-only memory (Read-Only Memory, ROM for short), a random access memory (Random Access Memory, RAM for short), a magnetic disk or an optical disk, and the like.
本实施例提供的计算机可读存储介质可以实现实施例1所示单目测距方法,为避免重复,在此不再赘述。The computer-readable storage medium provided in this embodiment can implement the monocular ranging method shown in Embodiment 1, and to avoid repetition, details are not repeated here.
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者终端不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者终端所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者终端中还存在另外的相同要素。It should be noted that, in this document, the term "comprising", "comprising" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article or terminal comprising a set of elements includes not only those elements, It also includes other elements not expressly listed, or elements inherent in the process, method, article, or terminal. Without further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of additional identical elements in the process, method, article or terminal comprising the element.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus a necessary general-purpose hardware platform, and of course also by hardware, but in many cases the former is better implementation. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product in essence or the part that contributes to the prior art, and the computer software product is stored in a storage medium (such as ROM/RAM, disk, CD) contains several instructions to enable a terminal (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in various embodiments of the present application.
上面结合附图对本申请的实施例进行了描述,但是本申请并不局限于上述的具体实施方式,上述的具体实施方式仅仅是示意性的,而不是限制性的,本领域的普通技术人员在本申请的启示下,在不脱离本申请宗旨和权利要求所保护的范围情况下,还可做出很多形式,均属于本申请的保护之内。The embodiments of the present application have been described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementations. The above-mentioned specific implementations are only illustrative and not restrictive. Those of ordinary skill in the art will Under the inspiration of this application, without departing from the purpose of this application and the scope of protection of the claims, many forms can also be made, all of which belong to the protection of this application.

Claims (10)

  1. 一种单目测距方法,其特征在于,所述方法包括:A monocular ranging method, characterized in that the method comprises:
    通过单目相机拍摄平视图,所述单目相机的地面可视区域包括矩形区域,所述平视图包括所述矩形区域对应的第一区域图像;A plane view is taken by a monocular camera, the ground visible area of the monocular camera includes a rectangular area, and the plane view includes a first area image corresponding to the rectangular area;
    根据所述第一区域图像的顶角像素坐标确定用于将所述平视图逆透视变换为俯视图的单应矩阵;determining a homography matrix for inverse perspective transforming the plane view into a top view according to the apex pixel coordinates of the first region image;
    从所述矩形区域的底边确定基准点,获取所述基准点与所述单目相机之间的距离;Determining a reference point from the bottom edge of the rectangular area, and obtaining the distance between the reference point and the monocular camera;
    确定所述基准点在所述第一区域图像中对应的基准点像素坐标,获取所述基准点像素坐标对应的逆透视基准点坐标;Determining the pixel coordinates of the reference point corresponding to the reference point in the first region image, and obtaining the coordinates of the reverse perspective reference point corresponding to the pixel coordinates of the reference point;
    对所述单目相机拍摄的其他平视图进行目标物体检测,得到目标物体边界框,根据所述单应矩阵对所述目标物体边界框的底边任一像素点坐标进行逆透视变换,获取所述底边任一像素点坐标对应的目标逆透视坐标;Perform target object detection on other planar views captured by the monocular camera to obtain the target object bounding box, perform inverse perspective transformation on the coordinates of any pixel point on the bottom edge of the target object bounding box according to the homography matrix, and obtain the target object bounding box. The target inverse perspective coordinate corresponding to any pixel coordinate of the bottom edge;
    根据所述逆透视基准点坐标、所述目标逆透视坐标、物理尺度与像素尺度的对应关系、及所述基准点与所述单目相机之间的距离,确定所述目标物体与所述单目相机之间的距离。According to the coordinates of the reverse perspective reference point, the reverse perspective coordinates of the target, the corresponding relationship between the physical scale and the pixel scale, and the distance between the reference point and the monocular camera, determine the target object and the monocular camera. The distance between the cameras.
  2. 根据权利要求1所述的方法,其特征在于,所述根据所述第一区域图像的顶角像素坐标确定用于将所述平视图逆透视变换为俯视图的单应矩阵,包括:The method according to claim 1, wherein the determining a homography matrix for inverse perspective transformation of the plane view into a top view according to the apex pixel coordinates of the first region image comprises:
    获取所述第一区域图像的顶角像素坐标及其对应的逆透视顶角像素坐标;Acquiring the pixel coordinates of the top corner of the first area image and the corresponding pixel coordinates of the top corner of the reverse perspective image;
    根据所述第一区域图像的顶角像素坐标、所述逆透视顶角像素坐标确定所述单应矩阵。The homography matrix is determined according to the vertex pixel coordinates of the first area image and the reverse perspective vertex pixel coordinates.
  3. 根据权利要求2所述的方法,其特征在于,所述获取所述基准点像素坐标对应的逆透视基准点坐标,包括:The method according to claim 2, wherein said obtaining the coordinates of the reverse perspective reference point corresponding to the pixel coordinates of the reference point comprises:
    根据所述俯视图的大小设置所述基准点像素坐标的逆透视坐标。The reverse perspective coordinates of the pixel coordinates of the reference point are set according to the size of the top view.
  4. 根据权利要求3所述的方法,其特征在于,所述获取所述第一区域图像的顶角像素坐标及其对应的逆透视顶角像素坐标,包括:The method according to claim 3, wherein the acquiring the pixel coordinates of the top corners of the image of the first region and the corresponding pixel coordinates of the top corners of the reverse perspective comprises:
    对所述平视图进行矫正,得到矫正后平视图,所述矫正后平视图包括第二区域图像,将所述第二区域图像的顶角像素坐标作为所述第一区域图像的顶角像素坐标;Correcting the plan view to obtain a corrected plan view, the corrected plan view including a second area image, using the apex pixel coordinates of the second area image as the apex pixel coordinates of the first area image ;
    根据所述基准点像素坐标的逆透视坐标、所述物理尺度与像素尺度的对应关系、所述矩形区域的边长,确定所述逆透视顶角像素坐标。The pixel coordinates of the reverse perspective corner are determined according to the reverse perspective coordinates of the pixel coordinates of the reference point, the corresponding relationship between the physical scale and the pixel scale, and the side length of the rectangular area.
  5. 根据权利要求4所述的方法,其特征在于,所述方法还包括:The method according to claim 4, characterized in that the method further comprises:
    通过所述单目相机拍摄棋盘格图像,根据所述棋盘格图像获取所述单目相机的内参及畸变参数;Taking a checkerboard image through the monocular camera, and obtaining internal reference and distortion parameters of the monocular camera according to the checkerboard image;
    所述对所述平视图进行矫正,得到矫正后平视图,包括:The plane view is corrected to obtain the corrected plane view, including:
    根据所述内参及畸变参数对所述平视图进行矫正,得到所述矫正后平视图。The plane view is corrected according to the internal reference and the distortion parameter to obtain the corrected plane view.
  6. 根据权利要求4所述的单目测距方法,其特征在于,所述基准点像素坐标的逆透视坐标包括第一方向基准点像素坐标及第二方向基准点像素坐标,所述第二方向垂直于所述第一方向;The monocular ranging method according to claim 4, wherein the reverse perspective coordinates of the pixel coordinates of the reference point include the pixel coordinates of the reference point in the first direction and the pixel coordinates of the reference point in the second direction, and the second direction is perpendicular to in said first direction;
    所述根据所述基准点像素坐标的逆透视坐标、所述物理尺度与像素尺度的对应关系、所述矩形区域的边长,确定所述逆透视顶角像素坐标,包括:According to the inverse perspective coordinates of the pixel coordinates of the reference point, the corresponding relationship between the physical scale and the pixel scale, and the side length of the rectangular area, determining the pixel coordinates of the inverse perspective corners includes:
    根据所述第一方向基准点像素坐标、所述第二方向基准点像素坐标、所述矩形区域的边长、所述物理尺度与像素尺度的对应关系、所述逆透视顶角像素坐标与所述逆透视基准点坐标的位置关系,确定所述逆透视顶角像素坐标的第一方向坐标及第二方向坐标。According to the pixel coordinates of the reference point in the first direction, the pixel coordinates of the reference point in the second direction, the side length of the rectangular area, the corresponding relationship between the physical scale and the pixel scale, the pixel coordinates of the reverse perspective vertex and the The positional relationship of the reference point coordinates of the reverse perspective is determined, and the coordinates of the first direction and the second direction of the pixel coordinates of the reverse perspective corner are determined.
  7. 根据权利要求6所述的单目测距方法,其特征在于,所述根据所述逆透视基准点坐标、所述目标逆透视坐标、物理尺度与像素尺度的对应关系、及所述基准点与所述单目相机之间的距离,确定所述目标物体与所述单目相机之间的距离,包括:The monocular ranging method according to claim 6, wherein, according to the coordinates of the inverse perspective reference point, the coordinates of the target inverse perspective, the corresponding relationship between the physical scale and the pixel scale, and the relationship between the reference point and the pixel scale The distance between the monocular cameras, determining the distance between the target object and the monocular cameras, includes:
    将所述目标逆透视坐标的第一方向坐标减去所述第一方向基准点像素坐标,得到第一像素差值;将所述第一像素差值乘以物理尺度与像素尺度的对应关系,得到第一乘积;将所述第一乘积作为所述目标物体与所述单目相机之间的第一方向距离;和/或,Subtracting the pixel coordinates of the reference point in the first direction from the coordinates in the first direction of the reverse perspective coordinates of the target to obtain a first pixel difference; multiplying the first pixel difference by the corresponding relationship between the physical scale and the pixel scale, Obtain a first product; use the first product as a first direction distance between the target object and the monocular camera; and/or,
    将所述目标逆透视坐标的第二方向坐标减去所述第二方向基准点像素坐标,得到第二像素差值;将所述第二像素差值乘以物理尺度与像素尺度的对应关系,得到第二乘积;将所述第二乘积作加上所述基准点与所述单目相机之间的第二方向距离之和,作为所述目标物体与所述单目相机之间的第二方向距离。Subtracting the pixel coordinates of the reference point in the second direction from the second direction coordinates of the target reverse perspective coordinates to obtain a second pixel difference; multiplying the second pixel difference by the corresponding relationship between the physical scale and the pixel scale, Obtain the second product; add the second product to the sum of the distance in the second direction between the reference point and the monocular camera, as the second distance between the target object and the monocular camera direction distance.
  8. 一种单目测距装置,其特征在于,所述装置包括:A monocular ranging device, characterized in that the device comprises:
    拍摄模块,用于通过单目相机拍摄平视图,所述单目相机的地面可视区域包括矩形区域,所述平视图包括所述矩形区域对应的第一区域图像;A photographing module, configured to photograph a plane view through a monocular camera, the ground visible area of the monocular camera includes a rectangular area, and the plane view includes a first area image corresponding to the rectangular area;
    第一确定模块,用于根据所述第一区域图像的顶角像素坐标确定用于将所述平视图逆透视变换为俯视图的单应矩阵;A first determination module, configured to determine a homography matrix for inverse perspective transformation of the plane view into a top view according to the top corner pixel coordinates of the first area image;
    获取模块,用于从所述矩形区域的底边确定基准点,获取所述基准点与所述单目相机之间的所述基准点与所述单目相机之间的距离;An acquisition module, configured to determine a reference point from the bottom of the rectangular area, and acquire a distance between the reference point and the monocular camera;
    第一处理模块,用于确定所述基准点在所述第一区域图像中对应的基准点像素坐标,获取所述基准点像素坐标对应的逆透视基准点坐标;The first processing module is configured to determine the pixel coordinates of the reference point corresponding to the reference point in the first region image, and acquire the reverse perspective reference point coordinates corresponding to the pixel coordinates of the reference point;
    第二处理模块,用于对所述单目相机拍摄的其他平视图进行目标物体检测,得到目标物体边界框,根据所述单应矩阵对所述目标物体边界框的底边任一像素点坐标进行逆透视变换,获取所述底边任一像素点坐标对应的目标逆透视坐标;The second processing module is configured to perform target object detection on other flat views captured by the monocular camera to obtain a target object bounding box, and coordinate any pixel point on the bottom edge of the target object bounding box according to the homography matrix Perform inverse perspective transformation to obtain the target inverse perspective coordinates corresponding to the coordinates of any pixel point on the bottom edge;
    第二确定模块,用于根据所述逆透视基准点坐标、所述目标逆透视坐标、物理尺度与像素尺度的对应关系、及所述基准点与所述单目相机之间的距离,确定所述目标物体与所述单目相机之间的距离。The second determination module is configured to determine the inverse perspective reference point coordinates, the target inverse perspective coordinates, the corresponding relationship between physical scale and pixel scale, and the distance between the reference point and the monocular camera. The distance between the target object and the monocular camera.
  9. 一种智能装置,其特征在于,包括单目相机、存储器以及处理器,所述存储器存储有计算机程序,所述计算机程序在所述处理器运行时执行权利要求1至7中任一项所述的单目测距方法。An intelligent device, characterized in that it comprises a monocular camera, a memory and a processor, the memory stores a computer program, and the computer program executes any one of claims 1 to 7 when the processor runs. monocular ranging method.
  10. 一种计算机可读存储介质,其特征在于,其存储有计算机程序,所述计算机程序在处理器上运行时执行权利要求1至7中任一项所述的单目测距方法。A computer-readable storage medium, characterized in that it stores a computer program, and the computer program executes the monocular ranging method according to any one of claims 1 to 7 when running on a processor.
PCT/CN2021/131460 2021-06-30 2021-11-18 Monocular distance measurement method and apparatus, and intelligent apparatus WO2023273108A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110738325.XA CN113465573A (en) 2021-06-30 2021-06-30 Monocular distance measuring method and device and intelligent device
CN202110738325.X 2021-06-30

Publications (1)

Publication Number Publication Date
WO2023273108A1 true WO2023273108A1 (en) 2023-01-05

Family

ID=77876665

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/131460 WO2023273108A1 (en) 2021-06-30 2021-11-18 Monocular distance measurement method and apparatus, and intelligent apparatus

Country Status (2)

Country Link
CN (1) CN113465573A (en)
WO (1) WO2023273108A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117782030A (en) * 2023-11-24 2024-03-29 北京天数智芯半导体科技有限公司 Distance measurement method and device, storage medium and electronic equipment

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113465573A (en) * 2021-06-30 2021-10-01 深圳市优必选科技股份有限公司 Monocular distance measuring method and device and intelligent device
CN114049394B (en) * 2021-11-23 2022-06-21 智道网联科技(北京)有限公司 Monocular distance measuring method, device, equipment and storage medium
CN116681778B (en) * 2023-06-06 2024-01-09 固安信通信号技术股份有限公司 Distance measurement method based on monocular camera

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160288711A1 (en) * 2015-04-01 2016-10-06 Robert Bosch Gmbh Distance and direction estimation of a target point from a vehicle using monocular video camera
KR20170133756A (en) * 2016-05-26 2017-12-06 현대자동차주식회사 System and Method for Recognizing Cut-in Vehicle on the basis of Monocular Image
CN109343041A (en) * 2018-09-11 2019-02-15 昆山星际舟智能科技有限公司 The monocular distance measuring method driven for high-grade intelligent auxiliary
CN110031829A (en) * 2019-04-18 2019-07-19 北京联合大学 A kind of targeting accuracy distance measuring method based on monocular vision
CN110542895A (en) * 2018-05-28 2019-12-06 北京京东尚科信息技术有限公司 monocular-based freespace distance measurement method
CN111380503A (en) * 2020-05-29 2020-07-07 电子科技大学 Monocular camera ranging method adopting laser-assisted calibration
CN112927306A (en) * 2021-02-24 2021-06-08 深圳市优必选科技股份有限公司 Calibration method and device of shooting device and terminal equipment
CN113465573A (en) * 2021-06-30 2021-10-01 深圳市优必选科技股份有限公司 Monocular distance measuring method and device and intelligent device

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104504680A (en) * 2014-11-23 2015-04-08 北京联合大学 Inverse perspective calibration method used for intelligent vehicle
CN110322513B (en) * 2018-03-30 2022-03-04 杭州海康威视数字技术股份有限公司 Camera external parameter calibration method and device and electronic equipment
CN111521117B (en) * 2019-08-21 2022-01-28 毫末智行科技有限公司 Monocular vision distance measuring method, storage medium and monocular camera
CN110599548A (en) * 2019-09-02 2019-12-20 Oppo广东移动通信有限公司 Camera calibration method and device, camera and computer readable storage medium
CN111047536B (en) * 2019-12-18 2023-11-14 深圳市汉森软件股份有限公司 CCD image correction method, device, equipment and storage medium
CN111474519A (en) * 2020-04-28 2020-07-31 广东博智林机器人有限公司 Positioning method, device, equipment and storage medium
CN112665577A (en) * 2020-12-29 2021-04-16 北京电子工程总体研究所 Monocular vision target positioning method and system based on inverse perspective transformation matrix
CN112669382A (en) * 2020-12-30 2021-04-16 联想未来通信科技(重庆)有限公司 Image-based distance determination method and device

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160288711A1 (en) * 2015-04-01 2016-10-06 Robert Bosch Gmbh Distance and direction estimation of a target point from a vehicle using monocular video camera
KR20170133756A (en) * 2016-05-26 2017-12-06 현대자동차주식회사 System and Method for Recognizing Cut-in Vehicle on the basis of Monocular Image
CN110542895A (en) * 2018-05-28 2019-12-06 北京京东尚科信息技术有限公司 monocular-based freespace distance measurement method
CN109343041A (en) * 2018-09-11 2019-02-15 昆山星际舟智能科技有限公司 The monocular distance measuring method driven for high-grade intelligent auxiliary
CN110031829A (en) * 2019-04-18 2019-07-19 北京联合大学 A kind of targeting accuracy distance measuring method based on monocular vision
CN111380503A (en) * 2020-05-29 2020-07-07 电子科技大学 Monocular camera ranging method adopting laser-assisted calibration
CN112927306A (en) * 2021-02-24 2021-06-08 深圳市优必选科技股份有限公司 Calibration method and device of shooting device and terminal equipment
CN113465573A (en) * 2021-06-30 2021-10-01 深圳市优必选科技股份有限公司 Monocular distance measuring method and device and intelligent device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
ZHAO XUAN: "Forward Vehicle Detection,tracking and Ranging Based on Monocular Vision", ENGINEERING SCIENCE & TECHNOLOGY II, CHINA MASTER’S THESES FULL-TEXT DATABASE, 15 July 2018 (2018-07-15), XP093018984 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117782030A (en) * 2023-11-24 2024-03-29 北京天数智芯半导体科技有限公司 Distance measurement method and device, storage medium and electronic equipment

Also Published As

Publication number Publication date
CN113465573A (en) 2021-10-01

Similar Documents

Publication Publication Date Title
WO2023273108A1 (en) Monocular distance measurement method and apparatus, and intelligent apparatus
JP6859442B2 (en) Calibration equipment, calibration system, and calibration method
CN110809786B (en) Calibration device, calibration chart, chart pattern generation device, and calibration method
WO2019200837A1 (en) Method and system for measuring volume of parcel, and storage medium and mobile terminal
CN106846409B (en) Calibration method and device of fisheye camera
CN112686877B (en) Binocular camera-based three-dimensional house damage model construction and measurement method and system
JP2007036482A (en) Information projection display and program
KR101589167B1 (en) System and Method for Correcting Perspective Distortion Image Using Depth Information
WO2018102990A1 (en) System and method for rectifying a wide-angle image
CN109920004A (en) Image processing method, device, the combination of calibration object, terminal device and calibration system
WO2020232971A1 (en) Fisheye camera calibration system, method and apparatus, and electronic device and storage medium
CN111681186A (en) Image processing method and device, electronic equipment and readable storage medium
CN115457147A (en) Camera calibration method, electronic device and storage medium
CN111383264A (en) Positioning method, positioning device, terminal and computer storage medium
JP2011155412A (en) Projection system and distortion correction method in the same
CN111131801B (en) Projector correction system and method and projector
CN114998447A (en) Multi-view vision calibration method and system
CN111601093A (en) Method and device for acquiring projection standard brightness and readable storage medium
CN113658279B (en) Camera internal reference and external reference estimation method, device, computer equipment and storage medium
JP6178127B2 (en) Building measuring apparatus and measuring method
JP2014178141A (en) Calibration system and calibration method
CN107527323B (en) Calibration method and device for lens distortion
CN112446926A (en) Method and device for calibrating relative position of laser radar and multi-eye fisheye camera
KR101996226B1 (en) Apparatus for measuring three-dimensional position of subject and method thereof
JP2004212142A (en) Method of measuring dimension of image

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21948034

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE