Image calibration method and device and storage medium
By using the parking lot image for linear detection and blanking point calculation in image calibration, the height mapping relationship and ground equation are constructed, and the problems of manual calibration tool arrangement and camera disturbance recalibration in the prior art are solved, and an automated and cost-reducing image calibration method is realized.
Patent Information
- Application Number
- CN202411549409.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-02-25
AI Technical Summary
The prior art requires manual arrangement of calibration tools during image calibration, which is costly and has high time and physical disturbances of the camera require recalibration and high maintenance costs.
By obtaining the car park image taken by the camera device, conducting straight lines to determine the reference straight lines in different directions, calculating the target coordinates of the blanking point, constructing a height mapping relationship and the ground equation of the parking lot, and realizing the mapping between the image coordinate system and the physical coordinate system.
No tools such as checkerboards or QR codes are required to reduce the time cost of implementation and maintenance and can automatically adapt to the tiny physical disturbances of the camera.
Smart Images

Figure CN119515993A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to an image calibration method, device and storage medium. Background Art
[0002] With the continuous development of science and technology, cameras have also developed rapidly. There are more and more types and functions of cameras, and people have also enjoyed the convenience brought by the development of science and technology. For example, people can use the camera set up in the parking lot, collect images through the camera, and then use the image detection algorithm to detect the position of the target point. In the scenario where the user uses the channel mobile map for navigation, the image detection algorithm finds that the target is in the image coordinate system. The target point in the image coordinate system needs to be projected into the world physical coordinate system. At this time, it is necessary to construct a mapping relationship between the physical coordinate system and the image coordinate system.
[0003] At present, the commonly used calibration technology requires the use of calibration tools (for example, checkerboards or QR codes, etc.). These tools have regular patterns and can be photographed by cameras at different angles, providing sufficient information for coordinate system calibration. However, during the calibration process, staff are required to arrange these tools on site, which has a high implementation time cost; and once the camera is physically disturbed, such as lens shift or camera tilt, the camera needs to be recalibrated, which has a high maintenance time cost. Summary of the invention
[0004] Based on this, it is necessary to provide an image calibration method, device and storage medium for the above technical problems, so as to solve at least one of the above technical problems.
[0005] The present invention provides an image calibration method, comprising:
[0006] Acquire the parking lot image captured by the camera device;
[0007] Performing straight line detection on the parking lot image to obtain a plurality of reference straight lines in different directions, wherein the different directions include an X direction corresponding to a long edge line of a parking space, a Z direction corresponding to a short edge line of a parking space, and a Y direction perpendicular to the ground, and a reference straight line in any direction is determined based on coordinate information of at least two position points in the direction;
[0008] Based on multiple reference straight lines in different directions, the target coordinates of the vanishing points in different directions are determined;
[0009] Based on the target coordinates of the vanishing points in different directions, a height mapping relationship and a ground equation of the parking lot are constructed, wherein the height mapping relationship represents the mapping relationship of height between the image coordinate system and the physical coordinate system, and the ground equation represents the mapping relationship of plane between the image coordinate system and the physical coordinate system.
[0010] Optionally, according to an image calibration method provided by the present invention, the step of determining target coordinates of vanishing points in different directions based on a plurality of reference straight lines in different directions includes:
[0011] For either direction;
[0012] Extending a plurality of reference straight lines in the direction to determine a coordinate value of at least one intersection point;
[0013] Determining the initial coordinates of the vanishing point in the direction based on the coordinate values of the at least one intersection point;
[0014] Based on the multiple reference straight lines in the direction, the initial coordinates of the vanishing point are optimized to obtain the target coordinates of the vanishing point in the direction.
[0015] Optionally, according to an image calibration method provided by the present invention, the initial coordinates of the vanishing point are optimized based on the multiple reference straight lines in the direction to obtain the target coordinates of the vanishing point in the direction, including:
[0016] Determine the endpoint coordinates of the two endpoints of each reference line;
[0017] Determine the midpoint coordinates of each reference straight line based on the endpoint coordinates of the two endpoints;
[0018] Based on the endpoint coordinates of the two endpoints, the midpoint coordinates and the initial coordinates of the vanishing point in the direction, a preset objective function is used to calculate the target coordinates of the vanishing point in the direction;
[0019] The objective function is a function for minimizing the projection distance between the endpoint of the reference straight line and the target straight line, and the target straight line is a straight line formed by connecting the midpoint coordinates of the reference straight line and the initial coordinates of the vanishing point.
[0020] Optionally, according to an image calibration method provided by the present invention, based on the target coordinates of the vanishing points in different directions, a ground equation of the parking lot is constructed, including:
[0021] Detecting the parking lot image to obtain parking space position information of each parking space, wherein the parking space position information includes image coordinates of corner points of each parking space;
[0022] For any parking space in the parking lot image:
[0023] Determine the physical coordinates corresponding to each of the parking space corner points;
[0024] Based on the image coordinates of each of the parking space corner points and the target coordinates of the X-direction vanishing point, a target straight line is formed, and a target intersection point where the target straight line intersects with a lane line in the parking lot is determined;
[0025] Based on the parking lot image, detecting the image coordinates corresponding to each of the target intersection points;
[0026] Based on the preset channel width and the physical coordinates of each parking space corner point, the physical coordinates of each target intersection point are calculated;
[0027] The ground equation is constructed based on the image coordinates and physical coordinates corresponding to the parking space corner point and the target intersection point respectively.
[0028] Optionally, according to an image calibration method provided by the present invention, the height mapping relationship is constructed based on the target coordinates of the vanishing points in different directions, including:
[0029] Generate a vanishing line based on the target coordinates of the vanishing point in the X direction and the target coordinates of the vanishing point in the Z direction;
[0030] Detecting image coordinates corresponding to a reference point and a target point in the parking lot image, respectively, wherein the reference point and the target point refer to any two pixel points in the parking lot image that do not belong to the ground area;
[0031] Based on the image coordinates of the reference point and the target coordinates of the Y-direction vanishing point, a first reference line is formed, and based on the image coordinates of the target point and the target coordinates of the Y-direction vanishing point, a second reference line is formed;
[0032] The height mapping relationship is constructed based on the hidden line, the first reference line, the second reference line, the reference point and the target point.
[0033] Optionally, according to an image calibration method provided by the present invention, constructing the height mapping relationship based on the hidden line, the first reference line, the second reference line, the reference point and the target point includes:
[0034] Extending the first reference line toward the ground to obtain a first foot point, and extending the second reference line toward the ground to obtain a second foot point;
[0035] Determine a first intersection point where the hidden line intersects an extended connecting line between the first foot point and the second foot point;
[0036] determining a second intersection point where the second reference line intersects a connecting line between the reference point and the first intersection point;
[0037] Using the second foot point as a foot point, determining a third reference line parallel to the first reference line;
[0038] Determine a third intersection point where an extended connecting line between the reference point and the second intersection point intersects with the third reference line;
[0039] Determine a fourth intersection point where an extended connecting line between the reference point and the target point intersects the third reference line;
[0040] The height mapping relationship is constructed based on the ratio corresponding to the length between the second foot point and the third intersection point and the length between the second foot point and the fourth intersection point.
[0041] Optionally, according to an image calibration method provided by the present invention, after constructing the height mapping relationship and the ground equation of the parking lot based on the target coordinates of the vanishing points in different directions, the method further includes:
[0042] Get the pixel coordinates of the point to be converted;
[0043] Based on the pixel coordinates and the image coordinates corresponding to the parking space corner point and the target intersection point of each of the ground equations, the distance between the position point to be converted and the parking space corner point and the target intersection point is calculated, wherein the target intersection point refers to the intersection point where the target straight line formed by the parking space corner point and the X-direction vanishing point intersects with the lane line in the parking lot;
[0044] The distances are averaged to obtain an average distance;
[0045] Comparing the average distances corresponding to the ground equations, and selecting the ground equation with the smallest average distance as the target ground equation;
[0046] Based on the pixel coordinates of the to-be-converted position point, the target ground equation and the height mapping relationship, the actual physical coordinates of the to-be-converted position point are determined.
[0047] Optionally, according to an image calibration method provided by the present invention, after determining the target coordinates of the vanishing points in different directions based on a plurality of reference lines in different directions, the method further comprises:
[0048] Determine the coordinates of a corner point of any parking space in the parking lot image;
[0049] Based on the coordinates of the parking space corner points, the target coordinates corresponding to the X-direction vanishing points, the Y-direction vanishing points, and the Z-direction vanishing points, respectively, forming an X-direction connecting line, a Y-direction connecting line, and a Z-direction connecting line;
[0050] Determine the degree of overlap between the long edge line of the parking space corresponding to the parking space and the X-direction connecting line, the degree of overlap between the short edge line of the parking space corresponding to the parking space and the Y-direction connecting line, and the degree of overlap between a straight line with the corner point coordinates as the origin and perpendicular to the ground and the Z-direction connecting line;
[0051] Based on the overlap degrees, the target coordinates of the vanishing points in different directions are verified, so as to determine whether to optimize the target coordinates of the vanishing points in different directions in combination with the verification results.
[0052] The present invention also provides an image calibration device, comprising:
[0053] An acquisition module is used to acquire the parking lot image taken by the camera device;
[0054] a detection module, configured to perform straight line detection on the parking lot image to obtain a plurality of reference straight lines in different directions, wherein the different directions include an X direction corresponding to a long edge line of a parking space, a Z direction corresponding to a short edge line of a parking space, and a Y direction perpendicular to the ground, and a reference straight line in any direction is determined based on coordinate information of at least two position points in the direction;
[0055] A determination module, used for determining target coordinates of vanishing points in different directions based on a plurality of reference straight lines in different directions;
[0056] A construction module is used to construct a height mapping relationship and a ground equation of the parking lot based on the target coordinates of the vanishing points in different directions, wherein the height mapping relationship represents the mapping relationship of the height between the image coordinate system and the physical coordinate system, and the ground equation represents the mapping relationship of the plane between the image coordinate system and the physical coordinate system.
[0057] The present invention also provides one or more readable storage media storing computer-readable instructions, and the computer-readable instructions implement the above-mentioned image calibration method when executed by a processor.
[0058] The above-mentioned image calibration method, device and storage medium include: obtaining a parking lot image taken by a camera device; performing straight line detection on the parking lot image to obtain multiple reference straight lines in different directions, wherein the different directions include the X direction corresponding to the long edge line of the parking space, the Z direction corresponding to the short edge line of the parking space, and the Y direction perpendicular to the ground, and the reference straight line in any direction is determined based on the coordinate information of at least two position points in the direction; based on the multiple reference straight lines in different directions, determining the target coordinates of the vanishing points in different directions; based on the target coordinates of the vanishing points in different directions, constructing a height mapping relationship and a ground equation of the parking lot, wherein the height mapping relationship represents the mapping relationship of the height between the image coordinate system and the physical coordinate system, and the ground equation represents the mapping relationship of the plane between the image coordinate system and the physical coordinate system. The present invention obtains the vanishing points in different directions based on the parking lot image, and then constructs the height mapping relationship and the ground equation of the parking lot based on the target coordinates of the vanishing points in different directions, without the need to deploy tools such as a chessboard or a QR code, and even if the lens is shifted or the camera is tilted, there is no need to recalibrate the camera, thereby reducing the time cost of implementation and maintenance. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0060] Figure 1 is one of the flowcharts of the image calibration method in one embodiment of the present invention;
[0061] Figure 2 This is a rendering of a parking lot image provided by an embodiment of the present invention;
[0062] Figure 3 This is an effect diagram of generating reference lines in different directions provided by an embodiment of the present invention;
[0063] Figure 4 is a target straight line effect diagram provided by an embodiment of the present invention;
[0064] Figure 5 is a schematic diagram of a height mapping relationship in a physical coordinate system provided by an embodiment of the present invention;
[0065] Figure 6 is a schematic diagram of a height mapping relationship in an image coordinate system provided by an embodiment of the present invention;
[0066] Figure 7 This is a second flow chart of an image calibration method according to an embodiment of the present invention;
[0067] Figure 8 FIG3 is a flow chart of an image calibration method according to an embodiment of the present invention;
[0068] Fig. 9 It is a scene effect diagram of constructing a ground equation provided by an embodiment of the present invention;
[0069] Fig.10 FIG4 is a fourth flow chart of an image calibration method according to an embodiment of the present invention;
[0070] Fig.11 FIG5 is a fifth flow chart of an image calibration method according to an embodiment of the present invention;
[0071] Fig.12 This is a sixth flow chart of an image calibration method according to an embodiment of the present invention;
[0072] Fig.13 is a structural schematic diagram of an image calibration device in one embodiment of the present invention;
[0073] Fig.14 is a schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0074] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0075] The terms used in one or more embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present invention. The singular forms of "a", "said" and "the" used in one or more embodiments of the present invention are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present invention refers to and includes any or all possible combinations of one or more associated listed items.
[0076] In one embodiment, if Figure 1 As shown, Figure 1 FIG. 1 is a flow chart of an image calibration method in an embodiment of the present invention. The present invention provides an image calibration method, comprising the following steps:
[0077] Step S11, obtaining a parking lot image taken by a camera device;
[0078] It should be noted that the camera equipment is installed on the passage of the parking lot and can collect the parking lot image of the passage. Figure 2 , Figure 2 This is an effect diagram of a parking lot image provided by an embodiment of the present invention.
[0079] Step S12, performing straight line detection on the parking lot image to obtain a plurality of reference straight lines in different directions;
[0080] It should be noted that, refer to Figure 2 The different directions include the X direction corresponding to the long edge line of the parking space, the Z direction corresponding to the short edge line of the parking space, and the Y direction perpendicular to the ground. Optionally, the reference straight line in any direction is determined based on the coordinate information of at least two position points in the direction.
[0081] In one embodiment, the parking lot image is detected to obtain the coordinate information of multiple position points corresponding to the short edge line and the long edge line of each parking space, and to obtain the coordinate information of multiple position points perpendicular to the ground. The coordinate information of multiple position points corresponding to each direction forms multiple reference straight lines in each direction.
[0082] In another embodiment, edge detection is performed on the parking lot image using an edge detection algorithm (such as the Canny operator), wherein edge detection can help identify straight line contours in the image; and then the Hough transform is used to detect straight lines, and the detected straight lines are classified, such as distinguishing short edge lines of parking spaces and long edge lines of parking spaces and straight lines perpendicular to the ground, thereby obtaining multiple reference straight lines in different directions. Figure 3 , Figure 3 This is an effect diagram of generating reference lines in different directions provided by an embodiment of the present invention.
[0083] Step S13, determining the target coordinates of the vanishing points in different directions based on a plurality of reference straight lines in different directions;
[0084] It should be noted that the vanishing point is a point determined based on each reference straight line. Figure 3 , the vanishing point may not belong to the pixel point in the parking lot image, where Figure 3 Vx in the figure represents the vanishing point in the X direction, Vy represents the vanishing point in the Y direction, and Vz represents the vanishing point in the Z direction.
[0085] In one embodiment, the following steps are performed for a reference line in any direction:
[0086] When there are two reference lines, extend the two reference lines to obtain an intersection point. The coordinate value of the intersection point can be calculated based on the linear equations of the two reference lines, and then the coordinate value of the intersection point is used as the target coordinate corresponding to the vanishing point in that direction. When there are more than two reference lines, extend each reference line, where any two reference lines can determine an intersection point, so that multiple intersection points can be determined, and the coordinate values corresponding to each intersection point are calculated. Furthermore, the coordinate values corresponding to all intersection points are averaged, and the average calculation result is used as the target coordinate of the vanishing point.
[0087] In another embodiment, in order to improve the accuracy of calculating the vanishing point, the above average operation result or only the coordinate value of one intersection point can be used as the initial coordinate of the vanishing point, and then the endpoint coordinates of the two end points in each reference straight line are determined. For example, the reference straight line is formed by two position points on the long edge line of the parking space, and the endpoints are the position points. Further, based on the endpoint coordinates of the two endpoints, the midpoint coordinates of each reference straight line are calculated to determine the pre-constructed objective function. It should be noted that the objective function is a function used to minimize the projection distance between the endpoints of the reference straight line and the target straight line. The target straight line is a straight line formed by connecting the midpoint coordinates of the reference straight line and the initial coordinates of the vanishing point. Figure 4 , Figure 4 is a target straight line effect diagram provided by an embodiment of the present invention, Figure 4 V in the figure represents the vanishing point, and then the endpoint coordinates of the two endpoints, the midpoint coordinates, and the initial coordinates of the vanishing point in the direction are substituted into the objective function to calculate the target coordinates of the vanishing point in the direction. For example, the least squares optimization method is used to calculate the target coordinates of the vanishing point.
[0088] Step S14, constructing a height mapping relationship and a ground equation of the parking lot based on the target coordinates of the vanishing points in different directions.
[0089] It should be noted that the height mapping relationship refers to the mapping relationship of height between the image coordinate system and the physical coordinate system, and the ground equation represents the mapping relationship of the plane between the image coordinate system and the physical coordinate system.
[0090] For the ground equation:
[0091] In one embodiment, the image coordinates corresponding to each parking space corner point in each parking space are obtained by detecting the parking lot image. For any parking space in the parking lot image: It should be noted that in the process of deploying parking spaces in the parking lot, a unique parking space identifier is assigned to each parking space, and the physical coordinates of the parking space and the parking space identifier are associated and recorded, and then the physical coordinates corresponding to each parking space corner point in the parking space corresponding to the parking space identifier can be determined in combination with the parking space identifier.
[0092] Further, refer to Figure 2 Since there will be vehicles parked on the parking spaces in the parking lot, the two corner points of the parking spaces far from the lane line will be blocked. In this embodiment, the parking corner points can be set to be two corner points close to the lane line. For any parking space: based on the image coordinates of the two parking corner points of the parking space and the target coordinates of the X-direction vanishing point, a target straight line is formed, and the target intersection points where the two target straight lines intersect with the lane line are determined respectively. Optionally, the target intersection point is the intersection point where the target straight line intersects with the lane line on the side far from the parking corner point. Further, the image coordinates corresponding to each target intersection point are detected, and the physical coordinates of each target intersection point are calculated based on the preset channel width and the physical coordinates of the parking corner point, and then the ground equation of the target area is constructed using the perspective transformation method based on the image coordinates and physical coordinates corresponding to the parking corner point and the target intersection point, wherein the target area refers to the area formed by the two parking corner points and the target intersection point of the parking space.
[0093] For height mapping relationship:
[0094] In the actual physical coordinate system, refer to Figure 5 , Figure 5 It is a schematic diagram of the height mapping relationship under the physical coordinate system provided by an embodiment of the present invention, high point B1 and high point B2, A1 is the fixed point of high point B1 projected on the ground, A2 is the fixed point of high point B2 projected on the ground, L1 is the actual height of high point B1, L2 is the actual height of high point B2, c1 is the length of high point B1 projected to another spatial coordinate system, and c2 is the length of high point B2 projected to another spatial coordinate system. For example, if the building is reduced by 100 times, the length of the spatial coordinate system corresponding to the building reduced by 100 times can be measured. B1' is the projection point of B1 perpendicular to the connecting line between B2 and A2. According to the ratio between c1 and c2, the ratio between the actual height of b1 and the actual height of b2 can be determined. Assuming that the actual height L1 of b1 is known, the actual height of b2 can be solved.
[0095] Combined with the above principle of height mapping in the actual physical coordinate system, in the image coordinate system, refer to Figure 6 , Figure 6: is a schematic diagram of the height mapping relationship under the image coordinate system provided by an embodiment of the present invention. According to the vanishing point in the Y direction, the direction perpendicular to the ground can be determined. In addition, based on the target coordinates of the vanishing point in the X direction and the target coordinates of the vanishing point in the Z direction, a vanishing line is generated; the image coordinates corresponding to the reference point and the target point in the parking lot image are detected, wherein the reference point and the target point refer to any two pixel points in the parking lot image that do not belong to the ground area; and then based on the image coordinates of the reference point and the target coordinates of the vanishing point in the Y direction, a first reference line is formed, and based on the image coordinates of the target point and the target coordinates of the vanishing point in the Y direction, a second reference line is formed. The first reference line is extended toward the ground to obtain a first foot point, and the second reference line is extended toward the ground to obtain a second foot point, and the second foot point is used as a foot point to determine a third reference line parallel to the first reference line; further, based on the first foot point, the second foot point and the hidden line, the projection point of the reference point and the target point on the third reference line is determined, and then based on the ratio between the projection point corresponding to the second foot point and the reference point and the target point, the ratio between the actual height of b1 and the actual height of b2 can be determined, and a height mapping relationship is constructed. The specific detailed construction process is specifically described in the following embodiments and will not be repeated here.
[0096] The embodiment of the present invention, through the above scheme, includes: obtaining a parking lot image taken by a camera device; performing straight line detection on the parking lot image to obtain a plurality of reference straight lines in different directions, wherein the different directions include the X direction corresponding to the long edge line of the parking space, the Z direction corresponding to the short edge line of the parking space, and the Y direction perpendicular to the ground, and the reference straight line in any direction is determined based on the coordinate information of at least two position points in the direction; based on the plurality of reference straight lines in different directions, the target coordinates of the vanishing points in different directions are determined; based on the target coordinates of the vanishing points in different directions, a height mapping relationship and a ground equation of the parking lot are constructed, wherein the height mapping relationship represents the mapping relationship of the height between the image coordinate system and the physical coordinate system, and the ground equation represents the mapping relationship of the plane between the image coordinate system and the physical coordinate system. The present invention obtains the vanishing points in different directions based on the parking lot image, and then constructs the height mapping relationship and the ground equation of the parking lot based on the target coordinates of the vanishing points in different directions, without the need to deploy tools such as a checkerboard or a QR code, and even if the lens is shifted or the camera is tilted, there is no need to recalibrate the camera, thereby reducing the time cost of implementation and maintenance.
[0097] like Figure 7 As shown, Figure 7 FIG2 is a flow chart of an image calibration method according to an embodiment of the present invention; in an embodiment of the present invention, based on a plurality of reference straight lines in different directions, the target coordinates of the vanishing points in different directions are determined, including:
[0098] Step S21, for any direction; extending multiple reference straight lines of the direction to determine the coordinate value of at least one intersection point;
[0099] Step S22, determining the initial coordinates of the vanishing point of the direction based on the coordinate value of at least one intersection point;
[0100] Step S23, based on the multiple reference straight lines of the direction, the initial coordinates of the vanishing point are optimized to obtain the target coordinates of the vanishing point of the direction.
[0101] In one embodiment, the following steps are performed for any direction: when there are only two reference lines, the two reference lines are extended to obtain an intersection point, and the coordinate value of the intersection point can be calculated according to the equations of the two reference lines, and then the coordinate value of the intersection point is used as the initial coordinate of the vanishing point in this direction. When there are more than two reference lines, in one embodiment, two reference lines can be randomly selected, and then the coordinate value of the intersection point between the two reference lines is used as the initial coordinate of the vanishing point. In other embodiments, each reference line is extended, wherein any two reference lines can determine an intersection point, and then the coordinate value corresponding to the intersection point between any two reference lines is determined, and then the coordinate value corresponding to all the intersection points is averaged, and the average calculation result is used as the initial coordinate of the vanishing point.
[0102] Furthermore, since the reference straight line is determined based on the coordinate information of at least two position points in the direction, the coordinate information of the two position points in each reference straight line is used as the endpoint coordinates of the two endpoints on the reference straight line, and then based on the endpoint coordinates of the two endpoints, the midpoint coordinates of the midpoint of each reference straight line are calculated. Further, based on the midpoint coordinates and the initial coordinates of the vanishing point, a target straight line between the midpoint and the vanishing point is formed, and then the projection distances between the two endpoints of the reference straight line to the target straight line are calculated respectively. Further, based on the projection distance, the target coordinates of the vanishing point in the direction are obtained by optimizing and calculating using a preset objective function. The objective function is a function used to minimize the projection distance between the endpoints of the reference straight line to the target straight line. Optionally, the optimization algorithm of the least squares problem can be used to cyclically calculate the target coordinates of the vanishing point.
[0103] The embodiment of the present invention adopts the above scheme to determine the initial coordinates of the vanishing point in the direction through the intersection points between multiple reference straight lines based on the direction, and optimizes the initial coordinates of the vanishing point to obtain a more accurate vanishing point.
[0104] like Figure 8 As shown, Figure 8 FIG3 is a flow chart of an image calibration method in an embodiment of the present invention; in an embodiment of the present invention, a ground equation of a parking lot is constructed based on target coordinates of vanishing points in different directions, including:
[0105] Step S31, detecting the parking lot image to obtain parking space position information of each parking space, wherein the parking space position information includes the image coordinates of each parking space corner point;
[0106] It should be noted that, refer to Fig. 9 , Fig. 9 This is a scene effect diagram of constructing a ground equation provided by an embodiment of the present invention. Since there are vehicles parked in the parking spaces in the parking lot, the two corner points of the parking spaces far away from the passage will be blocked. The parking corner points in this embodiment may be two corner points close to the lane line, for example, corner point 1 and corner point 4 in the figure. By detecting the parking lot image, the image coordinates corresponding to each parking corner point in the parking space are obtained.
[0107] Step S32, for any parking space in the parking lot image: determine the physical coordinates corresponding to the corner points of each parking space;
[0108] It should be noted that in the process of deploying parking spaces in the parking lot, a unique parking space identifier is assigned to each parking space, and the physical coordinates of the parking space and the parking space identifier are associated and recorded. Then, the parking space identifier can be combined to determine the physical coordinates of the parking space corner point in the parking space corresponding to the parking space identifier.
[0109] Step S33, based on the image coordinates of each parking space corner point and the target coordinates of the X-direction vanishing point, a target straight line is formed, and a target intersection point where the target straight line intersects with a lane line in the parking lot is determined;
[0110] In one embodiment, based on the image coordinates of each parking space corner point and the target coordinates of the X-direction vanishing point, a target straight line is formed, wherein the target straight line and the lane line have an intersection. In this embodiment, the target intersection between the parking space corner point and the lane line is used as the other two points constituting the ground equation. Fig. 9 , the target intersection point between the target straight line corresponding to corner point 1 and the opposite lane line is intersection point 2; the target intersection point between the target straight line corresponding to corner point 4 and the opposite lane line is intersection point 3. The opposite lane line refers to the lane line far away from the corner point.
[0111] Step S34, based on the parking lot image, detecting the image coordinates corresponding to each target intersection point;
[0112] Step S35, based on the preset channel width and the physical coordinates of each parking space corner point, the physical coordinates of each target intersection point are calculated;
[0113] In one embodiment, the image coordinates corresponding to each target intersection are obtained by detecting the parking lot image. In addition, the preset channel width of the parking lot is determined, and then the physical coordinates of each target intersection are calculated based on the channel width and the physical coordinates of each parking space corner point. Fig. 9, the calculation process of the physical coordinates corresponding to point 2 and point 3 is as follows:
[0114] P 2w .x=P 1w. x+W Lane
[0115] P 2w .y=P 1w. y
[0116] P 3w .x=P 4w. x+W Lane
[0117] P 3w .y=P 4w. y
[0118] Among them, P 1w. x represents the horizontal coordinate corresponding to corner point 1, P 2w .x represents the horizontal coordinate corresponding to the intersection 2, P 3w .x represents the horizontal coordinate corresponding to the intersection 3, P 4w. x represents the horizontal coordinate corresponding to corner point 4, P 1w. y represents the ordinate corresponding to corner point 1, P 2w .y represents the ordinate corresponding to intersection 2, P 3w .y represents the ordinate corresponding to intersection 3, P 4w. y represents the ordinate corresponding to corner point 4, W Lane Indicates the channel width.
[0119] Step S36, constructing a ground equation based on the image coordinates and physical coordinates corresponding to the parking space corner points and the target intersection points.
[0120] In one embodiment, based on the image coordinates and physical coordinates corresponding to the parking space corner points and the target intersection points, the ground equation corresponding to the parking space is constructed through perspective transformation. Fig. 9 , for the area formed by the corner points of each parking space and the target intersection, the ground equation corresponding to the area is constructed.
[0121] The embodiment of the present invention adopts the above scheme, determines the intersection points corresponding to the connecting lines and the lane lines according to the parking corner points of each parking space and the connecting lines between the vanishing points in the X direction, and then constructs the ground equations of the areas corresponding to the parking spaces based on the parking corner points of each parking space and the image coordinates and physical coordinates corresponding to the intersection points, without the need to deploy tools such as chessboards or QR codes. In addition, by constructing ground equations of different areas, when the image coordinates of a certain position point are subsequently converted, the ground equation closest to the position point can be determined, thereby more accurately obtaining the physical coordinates of the position point.
[0122] like Fig.10 As shown, Fig.10 FIG. 4 is a flow chart of an image calibration method in an embodiment of the present invention; in an embodiment of the present invention, a height mapping relationship is constructed based on target coordinates of vanishing points in different directions, including:
[0123] Step S41, generating a vanishing line based on the target coordinates of the vanishing point in the X direction and the target coordinates of the vanishing point in the Z direction;
[0124] Step S42, detecting the image coordinates corresponding to the reference point and the target point in the parking lot image;
[0125] Step S43, forming a first reference line based on the image coordinates of the reference point and the target coordinates of the Y-direction vanishing point, and forming a second reference line based on the image coordinates of the target point and the target coordinates of the Y-direction vanishing point;
[0126] Step S44, constructing a height mapping relationship based on the hidden line, the first reference line, the second reference line, the reference point and the target point.
[0127] It should be noted that the reference point and the target point refer to any two pixel points in the parking lot image that do not belong to the ground area. In one embodiment, based on the target coordinates of the X-direction vanishing point and the target coordinates of the Z-direction vanishing point, a vanishing line is formed, and then the parking lot image is detected to obtain the image coordinates corresponding to the reference point and the target point. Based on the image coordinates of the reference point and the target coordinates of the Y-direction vanishing point, a first reference line is formed, and based on the image coordinates of the target point and the target coordinates of the Y-direction vanishing point, a second reference line is formed. For example, Figure 6 , straight line l is the hidden line, b1 is the reference point, b2 is the target point, l1 is the first reference line, and l2 is the second reference line.
[0128] Further, the first reference line is extended toward the ground to obtain a first foot point, and the second reference line is extended toward the ground to obtain a second foot point, for example, Figure 6 The point where the extended connecting line between the first foot point and the second foot point intersects with the hidden line is taken as the first intersection point, that is, Figure 6 Further, the point where the second reference line intersects with the connecting line between the reference point and the first intersection point is taken as the second intersection point, for example, Figure 6 Using the second foot point as the foot point, determine a third reference line parallel to the first reference line, for example, Figure 6 Then determine the third intersection point where the extended connecting line between the reference point and the second intersection point intersects the third reference line, and determine the fourth intersection point where the extended connecting line between the reference point and the target point intersects the third reference line; for example, the third intersection point is Figure 6 Point b1 in the fourth intersection is Figure 6 Point b2 in the reference point. Further, the proportional relationship between the length between the second foot point and the third intersection point and the length between the second foot point and the fourth intersection point is determined, and then the proportional relationship is accumulated to construct a height mapping relationship, that is, the ratio of the actual physical height between the reference point and the target point is equal to the ratio between the length between the second foot point and the third intersection point and the length between the second foot point and the fourth intersection point. When the actual physical height of the reference point is known, the actual physical height of the target point can be obtained.
[0129] The embodiment of the present invention, through the above-mentioned scheme, constructs a height mapping relationship based on the target coordinates corresponding to the X-direction vanishing point, the Y-direction vanishing point and the Z-direction vanishing point, so that the actual physical height of the position point that does not belong to the ground can be determined in combination with the height mapping relationship.
[0130] like Fig.11 As shown, Fig.11 FIG5 is a flowchart of an image calibration method in an embodiment of the present invention; in an embodiment of the present invention, after constructing a height mapping relationship and a ground equation of a parking lot based on the target coordinates of the vanishing points in different directions, the method further includes:
[0131] Step S51, obtaining the pixel coordinates of the position point to be converted;
[0132] It should be noted that if the position point to be converted is a pixel point in the ground area of the parking lot image, the image coordinates of the position point to be converted in the parking lot image are used as the pixel coordinates. If the position point to be converted is not a pixel point in the ground area of the parking lot image, the image coordinates of the position point to be converted in the parking lot image are projected to the ground area of the parking lot image to obtain the pixel coordinates of the position point to be converted.
[0133] Step S52, based on the pixel coordinates and the image coordinates corresponding to the parking space corner point and the target intersection point of each ground equation, calculate the distance between the position point to be converted and the parking space corner point and the target intersection point;
[0134] It should be noted that the target intersection point refers to the intersection point where the target straight line formed by the parking space corner point and the X-direction vanishing point intersects the lane line in the parking lot. The calculation process of the target intersection point has been specifically described in the above embodiment and will not be repeated here.
[0135] In one embodiment, based on the pixel coordinates and the image coordinates corresponding to the parking space corner points and target intersection points of each ground equation, the distance between the position point to be converted and each parking space corner point is calculated, and the distance between the position point to be converted and each target intersection point is calculated.
[0136] Step S53, averaging the distances to obtain an average distance;
[0137] Step S54, comparing the average distances corresponding to the various ground equations to select the ground equation with the smallest average distance as the target ground equation;
[0138] Step S55, determining the actual physical coordinates of the position point to be converted based on the pixel coordinates of the position point to be converted, the target ground equation and the height mapping relationship.
[0139] In one embodiment, each distance is averaged to obtain an average distance, and then the average distances corresponding to each ground equation are compared to select the ground equation with the smallest average distance as the target ground equation. If the position point to be converted is a pixel point in the ground area of the parking lot image, the actual height of the position point to be converted is 0, and the pixel coordinates of the position point to be converted are directly substituted into the target ground equation to calculate the actual physical coordinates of the position point to be converted. If the position point to be converted is not a pixel point in the ground area of the parking lot image, it is proved that there is a height difference between the position point and the point in the ground area in the actual physical coordinate system, and then the reference point with a known actual physical height is determined, and then the actual height corresponding to the position point to be converted is calculated according to the image coordinates of the reference point in the parking lot image and the pixel coordinates of the position point to be converted according to the height mapping relationship; in addition, the pixel coordinates of the position point to be converted are substituted into the target ground equation to calculate the coordinate conversion result corresponding to the position point to be converted, and then the actual physical coordinates of the position point to be converted are determined in combination with the coordinate conversion result corresponding to the position point to be converted and the actual height.
[0140] The embodiment of the present invention obtains the pixel coordinates of the position point to be converted through the above scheme, selects the target ground equation closest to the position point to be converted from the ground equations in different areas, and then combines the target ground equation and the height mapping relationship to obtain the actual physical coordinates of the position point to be converted. The mapping between the image coordinate system and the physical coordinate system can be completed without deploying tools such as checkerboards or QR codes.
[0141] like Fig.12 As shown, Fig.12 FIG6 is a flowchart of an image calibration method according to an embodiment of the present invention; in an embodiment of the present invention, after determining the target coordinates of the vanishing points in different directions based on a plurality of reference lines in different directions, the method further includes:
[0142] Step S61, determining the corner point coordinates of any parking space in the parking lot image;
[0143] Step S62, forming an X-direction connecting line, a Y-direction connecting line and a Z-direction connecting line based on the target coordinates corresponding to the parking space corner point coordinates, the X-direction vanishing point, the Y-direction vanishing point and the Z-direction vanishing point respectively;
[0144] Step S63, determining the degree of overlap between the long edge line of the parking space corresponding to the parking space and the connecting line in the X direction, the degree of overlap between the short edge line of the parking space corresponding to the parking space and the connecting line in the Y direction, and the degree of overlap between the straight line with the corner point coordinates as the origin and perpendicular to the ground and the connecting line in the Z direction;
[0145] Step S64, based on the overlap degrees, verify the target coordinates of the vanishing points in different directions, and determine whether to optimize the target coordinates of the vanishing points in different directions in combination with the verification results.
[0146] In one embodiment, based on the parking lot image, the corner point coordinates of any parking space in the parking lot image are detected, and then the corner point coordinates of the parking space are connected with the X-direction vanishing point, the corner point coordinates of the parking space are connected with the Y-direction vanishing point, and the corner point coordinates of the parking space are connected with the Z-direction vanishing point to obtain the X-direction connecting line, the Y-direction connecting line and the Z-direction connecting line. Further, the degree of overlap between the long edge line of the parking space corresponding to the parking space and the X-direction connecting line is calculated, the degree of overlap between the short edge line of the parking space corresponding to the parking space and the Y-direction connecting line is calculated, and the degree of overlap between the straight line with the corner point coordinates as the origin and perpendicular to the ground and the Z-direction connecting line is calculated; optionally, a similarity index (such as cosine similarity) is used to quantify the degree of overlap. Based on each degree of overlap, the target coordinates of the vanishing points in different directions are verified to verify the effect of obtaining the vanishing points, so as to determine whether to optimize the target coordinates of the vanishing points in different directions. In other embodiments, the degree of overlap is compared at the position points on the object corresponding to the ground.
[0147] The embodiment of the present invention adopts the above scheme to form X-direction connecting lines, Y-direction connecting lines and Z-direction connecting lines based on the target coordinates corresponding to the parking space corner point coordinates and the X-direction vanishing points, the Y-direction vanishing points and the Z-direction vanishing points, and determines the degree of overlap between the three-direction connecting lines and the parking space, thereby verifying the effect of obtaining the vanishing points.
[0148] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0149] In one embodiment, an image calibration device is provided, which corresponds one-to-one to the image calibration method in the above embodiment. Fig.13 As shown, Fig.13 is a structural schematic diagram of an image calibration device in one embodiment of the present invention, the image calibration device comprises:
[0150] An acquisition module 71 is used to acquire a parking lot image taken by a camera device;
[0151] The detection module 72 is used to perform straight line detection on the parking lot image to obtain a plurality of reference straight lines in different directions, wherein the different directions include an X direction corresponding to the long edge line of the parking space, a Z direction corresponding to the short edge line of the parking space, and a Y direction perpendicular to the ground, and the reference straight line in any direction is determined based on the coordinate information of at least two position points in the direction;
[0152] A determination module 73, for determining target coordinates of vanishing points in different directions based on a plurality of reference straight lines in different directions;
[0153] Construction module 74 is used to construct a height mapping relationship and a ground equation of the parking lot based on the target coordinates of the vanishing points in different directions, wherein the height mapping relationship represents the mapping relationship of the height between the image coordinate system and the physical coordinate system, and the ground equation represents the mapping relationship of the plane between the image coordinate system and the physical coordinate system.
[0154] The determination module 73 is also used for:
[0155] For either direction;
[0156] Extending multiple reference straight lines of the direction to determine the coordinate value of at least one intersection point;
[0157] Determining initial coordinates of a vanishing point of the direction based on the coordinate value of at least one intersection point;
[0158] Based on multiple reference straight lines of the direction, the initial coordinates of the vanishing point are optimized to obtain the target coordinates of the vanishing point of the direction.
[0159] The determination module 73 is also used for:
[0160] Determine the endpoint coordinates of the two endpoints of each reference line;
[0161] Based on the endpoint coordinates of the two endpoints, determine the midpoint coordinates of each reference straight line;
[0162] Based on the endpoint coordinates of the two endpoints, the midpoint coordinates and the initial coordinates of the vanishing point of the direction, the target coordinates of the vanishing point of the direction are calculated using a preset objective function;
[0163] The objective function is a function used to minimize the projection distance between the endpoint of the reference straight line and the target straight line, and the target straight line is a straight line formed by connecting the midpoint coordinates of the reference straight line and the initial coordinates of the vanishing point.
[0164] The building block 74 is also used to:
[0165] Detecting the parking lot image to obtain parking space location information of each parking space, wherein the parking space location information includes the image coordinates of each parking space corner point;
[0166] For any parking space in the parking lot image:
[0167] Determine the physical coordinates corresponding to each parking space corner point;
[0168] Based on the image coordinates of each parking space corner point and the target coordinates of the X-direction vanishing point, a target straight line is formed, and a target intersection point where the target straight line intersects with the lane line in the parking lot is determined;
[0169] Based on the parking lot image, the image coordinates corresponding to each target intersection are detected;
[0170] Based on the preset channel width and the physical coordinates of each parking space corner point, the physical coordinates of each target intersection point are calculated;
[0171] Based on the image coordinates and physical coordinates corresponding to the parking space corner points and the target intersection points, the ground equation is constructed.
[0172] The building block 74 is also used to:
[0173] Generate a vanishing line based on the target coordinates of the vanishing point in the X direction and the target coordinates of the vanishing point in the Z direction;
[0174] Detect the image coordinates corresponding to the reference point and the target point in the parking lot image, where the reference point and the target point refer to any two pixel points in the parking lot image that do not belong to the ground area;
[0175] Forming a first reference line based on the image coordinates of the reference point and the target coordinates of the Y-direction vanishing point, and forming a second reference line based on the image coordinates of the target point and the target coordinates of the Y-direction vanishing point;
[0176] Based on the hidden line, the first reference line, the second reference line, the reference point and the target point, a height mapping relationship is constructed.
[0177] The building block 74 is also used to:
[0178] Extend the first reference line toward the ground to obtain a first foot point, and extend the second reference line toward the ground to obtain a second foot point;
[0179] Determine a first intersection point where the hidden line intersects the extended connecting line between the first foot point and the second foot point;
[0180] determining a second intersection point where the second reference line intersects a connecting line between the reference point and the first intersection point;
[0181] Using the second foot point as a foot point, determine a third reference line parallel to the first reference line;
[0182] Determine a third intersection point where an extended connecting line between the reference point and the second intersection point intersects a third reference line;
[0183] Determine a fourth intersection point where the extended connecting line between the reference point and the target point intersects the third reference line;
[0184] Based on the ratio corresponding to the length between the second foot point and the third intersection point and the length between the second foot point and the fourth intersection point, a height mapping relationship is constructed.
[0185] The image calibration device includes:
[0186] A pixel coordinate acquisition module is used to obtain the pixel coordinates of the position point to be converted;
[0187] A calculation module, for calculating the distance between the position point to be converted and the parking space corner point and the target intersection point based on the pixel coordinates and the image coordinates corresponding to the parking space corner point and the target intersection point of each ground equation, wherein the target intersection point refers to the intersection point where the target straight line formed by the parking space corner point and the X-direction vanishing point intersects with the lane line in the parking lot;
[0188] An average calculation module is used to average each distance to obtain an average distance;
[0189] A comparison module, used for comparing the average distances corresponding to various ground equations, so as to select the ground equation with the smallest average distance as the target ground equation;
[0190] The physical coordinate determination module is used to determine the actual physical coordinates of the position point to be converted based on the pixel coordinates of the position point to be converted, the target ground equation and the height mapping relationship.
[0191] The image calibration device includes:
[0192] A corner point coordinate determination module is used to determine the corner point coordinates of any parking space in the parking lot image;
[0193] A forming module, for forming an X-direction connecting line, a Y-direction connecting line and a Z-direction connecting line based on the target coordinates corresponding to the parking space corner point coordinates, the X-direction vanishing point, the Y-direction vanishing point and the Z-direction vanishing point respectively;
[0194] The overlap degree module is used to determine the overlap degree between the long edge line of the parking space corresponding to the parking space and the X-direction connecting line, the overlap degree between the short edge line of the parking space corresponding to the parking space and the Y-direction connecting line, and the overlap degree between the straight line with the corner point coordinates as the origin and perpendicular to the ground and the Z-direction connecting line;
[0195] The verification module is used to verify the target coordinates of the vanishing points in different directions based on the overlap degrees, so as to determine whether to optimize the target coordinates of the vanishing points in different directions in combination with the verification results.
[0196] For the specific definition of the image calibration device, please refer to the definition of the image calibration method above, which will not be repeated here. Each module in the above image calibration device can be implemented in whole or in part by software, hardware and a combination thereof. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0197] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.14 As shown, Fig.14 : is a schematic diagram of a computer device in an embodiment of the present invention. The computer device includes a processor, a memory, a network interface and a database connected by a device bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a readable storage medium and an internal memory. The readable storage medium stores an operating device, a computer-readable instruction and a database. The internal memory provides an environment for the operation of the operating device and the computer-readable instructions in the readable storage medium. The database of the computer device is used to store data involved in the image calibration method. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer-readable instruction is executed by the processor, an image calibration method is implemented. The readable storage medium provided in this embodiment includes a non-volatile readable storage medium and a volatile readable storage medium.
[0198] In one embodiment, a computer device is provided. The computer device may be a terminal device, and its internal structure diagram may be as follows: Fig.14 As shown. The computer device includes a processor, a memory, and a network interface connected through a device bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a readable storage medium. The readable storage medium stores computer-readable instructions. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer-readable instructions are executed by the processor, an image calibration method is implemented. The readable storage medium provided in this embodiment includes a non-volatile readable storage medium and a volatile readable storage medium.
[0199] In one embodiment, a computer device is provided, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, and the processor implements the steps of the above-mentioned image calibration method when executing the computer-readable instructions.
[0200] In one embodiment, a readable storage medium is provided, the readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the above-mentioned image calibration method are implemented. A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing related hardware through computer-readable instructions, and the computer-readable instructions can be stored in a non-volatile readable storage medium or a volatile readable storage medium. When the computer-readable instructions are executed, they can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0201] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0202] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.
Claims
1. An image calibration method, characterized in that: include: Acquire the parking lot image captured by the camera device; Performing straight line detection on the parking lot image to obtain a plurality of reference straight lines in different directions, wherein the different directions include an X direction corresponding to a long edge line of a parking space, a Z direction corresponding to a short edge line of a parking space, and a Y direction perpendicular to the ground, and a reference straight line in any direction is determined based on coordinate information of at least two position points in the direction; Based on multiple reference straight lines in different directions, the target coordinates of the vanishing points in different directions are determined; Based on the target coordinates of the vanishing points in different directions, a height mapping relationship and a ground equation of the parking lot are constructed, wherein the height mapping relationship represents the mapping relationship of height between the image coordinate system and the physical coordinate system, and the ground equation represents the mapping relationship of plane between the image coordinate system and the physical coordinate system.
2. The image calibration method according to claim 1, characterized in that: The method of determining target coordinates of vanishing points in different directions based on a plurality of reference straight lines in different directions includes: For either direction; Extending a plurality of reference straight lines in the direction to determine a coordinate value of at least one intersection point; Determining the initial coordinates of the vanishing point in the direction based on the coordinate values of the at least one intersection point; Based on the multiple reference straight lines in the direction, the initial coordinates of the vanishing point are optimized to obtain the target coordinates of the vanishing point in the direction.
3. The image calibration method according to claim 2, characterized in that: The step of optimizing the initial coordinates of the vanishing point based on the plurality of reference straight lines in the direction to obtain the target coordinates of the vanishing point in the direction includes: Determine the endpoint coordinates of the two endpoints of each reference line; Determine the midpoint coordinates of each reference straight line based on the endpoint coordinates of the two endpoints; Based on the endpoint coordinates of the two endpoints, the midpoint coordinates and the initial coordinates of the vanishing point in the direction, a preset objective function is used to calculate the target coordinates of the vanishing point in the direction; The objective function is a function for minimizing the projection distance between the endpoint of the reference straight line and the target straight line, and the target straight line is a straight line formed by connecting the midpoint coordinates of the reference straight line and the initial coordinates of the vanishing point.
4. The image calibration method according to claim 1, characterized in that: Based on the target coordinates of the vanishing points in different directions, the ground equation of the parking lot is constructed, including: Detecting the parking lot image to obtain parking space position information of each parking space, wherein the parking space position information includes image coordinates of corner points of each parking space; For any parking space in the parking lot image: Determine the physical coordinates corresponding to each of the parking space corner points; Based on the image coordinates of each of the parking space corner points and the target coordinates of the X-direction vanishing point, a target straight line is formed, and a target intersection point where the target straight line intersects with a lane line in the parking lot is determined; Based on the parking lot image, detecting the image coordinates corresponding to each of the target intersection points; Based on the preset channel width and the physical coordinates of each parking space corner point, the physical coordinates of each target intersection point are calculated; The ground equation is constructed based on the image coordinates and physical coordinates corresponding to the parking space corner point and the target intersection point respectively.
5. The image calibration method according to claim 1, characterized in that: The step of constructing a height mapping relationship based on the target coordinates of the vanishing points in different directions includes: Generate a vanishing line based on the target coordinates of the vanishing point in the X direction and the target coordinates of the vanishing point in the Z direction; Detecting image coordinates corresponding to a reference point and a target point in the parking lot image, respectively, wherein the reference point and the target point refer to any two pixel points in the parking lot image that do not belong to the ground area; Based on the image coordinates of the reference point and the target coordinates of the Y-direction vanishing point, a first reference line is formed, and based on the image coordinates of the target point and the target coordinates of the Y-direction vanishing point, a second reference line is formed; The height mapping relationship is constructed based on the hidden line, the first reference line, the second reference line, the reference point and the target point.
6. The image calibration method according to claim 5, characterized in that: The step of constructing the height mapping relationship based on the hidden line, the first reference line, the second reference line, the reference point and the target point includes: Extending the first reference line toward the ground to obtain a first foot point, and extending the second reference line toward the ground to obtain a second foot point; Determine a first intersection point where the hidden line intersects an extended connecting line between the first foot point and the second foot point; determining a second intersection point where the second reference line intersects a connecting line between the reference point and the first intersection point; Using the second foot point as a foot point, determining a third reference line parallel to the first reference line; Determine a third intersection point where an extended connecting line between the reference point and the second intersection point intersects with the third reference line; Determine a fourth intersection point where an extended connecting line between the reference point and the target point intersects the third reference line; The height mapping relationship is constructed based on the ratio corresponding to the length between the second foot point and the third intersection point and the length between the second foot point and the fourth intersection point.
7. The image calibration method according to claim 1, characterized in that: After constructing the height mapping relationship and the ground equation of the parking lot based on the target coordinates of the vanishing points in different directions, the method further includes: Get the pixel coordinates of the point to be converted; Based on the pixel coordinates and the image coordinates corresponding to the parking space corner point and the target intersection point of each of the ground equations, the distance between the position point to be converted and the parking space corner point and the target intersection point is calculated, wherein the target intersection point refers to the intersection point where the target straight line formed by the parking space corner point and the X-direction vanishing point intersects with the lane line in the parking lot; The distances are averaged to obtain an average distance; Comparing the average distances corresponding to the ground equations, and selecting the ground equation with the smallest average distance as the target ground equation; Based on the pixel coordinates of the to-be-converted position point, the target ground equation and the height mapping relationship, the actual physical coordinates of the to-be-converted position point are determined.
8. The image calibration method according to claim 1, characterized in that: After determining the target coordinates of the vanishing points in different directions based on the multiple reference straight lines in different directions, the method further includes: Determine the coordinates of a corner point of any parking space in the parking lot image; Based on the coordinates of the parking space corner points, the target coordinates corresponding to the X-direction vanishing points, the Y-direction vanishing points, and the Z-direction vanishing points, respectively, forming an X-direction connecting line, a Y-direction connecting line, and a Z-direction connecting line; Determine the degree of overlap between the long edge line of the parking space corresponding to the parking space and the X-direction connecting line, the degree of overlap between the short edge line of the parking space corresponding to the parking space and the Y-direction connecting line, and the degree of overlap between a straight line with the corner point coordinates as the origin and perpendicular to the ground and the Z-direction connecting line; Based on the overlap degrees, the target coordinates of the vanishing points in different directions are verified, so as to determine whether to optimize the target coordinates of the vanishing points in different directions in combination with the verification results.
9. An image calibration device, characterized in that: include: An acquisition module is used to acquire the parking lot image taken by the camera device; a detection module, configured to perform straight line detection on the parking lot image to obtain a plurality of reference straight lines in different directions, wherein the different directions include an X direction corresponding to a long edge line of a parking space, a Z direction corresponding to a short edge line of a parking space, and a Y direction perpendicular to the ground, and a reference straight line in any direction is determined based on coordinate information of at least two position points in the direction; A determination module, used for determining target coordinates of vanishing points in different directions based on a plurality of reference straight lines in different directions; A construction module is used to construct a height mapping relationship and a ground equation of the parking lot based on the target coordinates of the vanishing points in different directions, wherein the height mapping relationship represents the mapping relationship of the height between the image coordinate system and the physical coordinate system, and the ground equation represents the mapping relationship of the plane between the image coordinate system and the physical coordinate system.
10. A readable storage medium having computer readable instructions stored thereon, characterized in that: When the computer-readable instructions are executed by a processor, the image calibration method according to any one of claims 1 to 8 is implemented.