The three-dimensional amount measuring method of geographic position of target object and height based on Streetscape picture
Technical field
The present invention relates to streetscape map, electronically graphics, photogrammetric, GIS, Web service, computer graphics etc. are led
Domain, the purpose is on the basis of existing streetscape map resource, object actual geographic position is direct in realization streetscape map
It measures.More particularly to Http request, the contents such as the space line under polar coordinate system is determining, front crosses.
Background technique
Streetscape map is a kind of live-action map service.Level side is provided for what user provided city, street or other environment
To 360 ° and 180 ° of vertical direction of street panorama, allow user that can inspect street different location and its two on selected urban ground
Other scenery.It is it is a kind of with multichannel video camera to real scene carry out multi-angle look around Image Acquisition and then using count
Calculation machine carries out later period fusion treatment, and loads playing program a kind of three-dimensional display technique for completing.
In recent years, with the rapid development of Internet technology, three-dimensional panorama, virtual tours etc. are various with panorama image information
Based on application service, be increasingly entering daily life.Streetscape map realizes two-dimentional three-dimensional and combines
Virtual reality scenario, perception on the spot in person can be brought to user.
Currently, external Google company, the information technologies such as domestic Baidu, Tencent and Internet company, are proposed
Map Services towards city streetscape.But these streetscape maps are mainly used for display and demonstration, in serious waste street view image
The bulk information contained.Compared with traditional two-dimensional map, streetscape map cannot achieve the positioning to atural object in street view image, amount
It surveys, significantly limits the extensive use of panoramic technique.
It can only be used to the deficiency of display and demonstration for current streetscape map, the present invention proposes three based on existing streetscape map
Dimension measures algorithm, realizes to the actual geographic coordinate of atural object in street view image and the quick obtaining of height.
Summary of the invention
Present invention seek to address that existing streetscape map cannot achieve to the actual geographic position of object, height in Streetscape picture
The problem of acquisition of information such as degree.Streetscape map for user provide more true and accurate, more rich in the Map Services of picture detail
On the basis of, the measurement of object actual geographic position, height in streetscape map may be implemented according to Streetscape picture by the present invention, make
Distinctive abundant information is utilized in streetscape map, expands the application of streetscape in actual production and life.
To realize the above-mentioned technical purpose, the present invention adopts the following technical scheme:
A kind of three-dimensional amount measuring method of geographic position of target object and height based on Streetscape picture, includes the following steps:
Step 1: in streetscape map, selecting the viewpoint in two angulars field of view comprising object to be measured;
Step 2: obtaining the longitude and latitude of selected two viewpoints;
Step 3: obtaining the Streetscape picture of three different perspectivess, respectively Streetscape picture 1, streetscape figure respectively under two viewpoints
Piece 2 and Streetscape picture 3, wherein Streetscape picture 1 is benchmark picture, and Streetscape picture 2 is different from 1 horizontal angle of Streetscape picture, pitch angle
Identical, Streetscape picture 3 is identical as 1 horizontal angle of Streetscape picture, and pitch angle is different;
Step 4: calculating the visual angle of certain point in two viewpoints to object bottom, including horizontal angle and pitch angle;
Step 5: according in step 4 two viewpoints and object bottom on certain point construct two space lines, front hand over
Remittance finds out the longitude and latitude of intersection point, i.e. the actual geographic position of object;
Step 6: calculate any viewpoint in selected two viewpoints to object distance, in conjunction with the viewpoint to object bottom
The pitch angle of certain point finds out the relative altitude of object bottom, top and viewpoint in portion, top;
Step 7: the actual height of object is obtained by the relative altitude of object bottom, top and viewpoint.
Method of the present invention, the viewpoint refer to, camera geographic location when shooting the street view image, with longitude and latitude
Degree indicates.The geographical location of camera is different when different points of view refers to shooting Streetscape picture.In the step 1, when viewpoint selection, lead to
Rotation streetscape map is crossed, object is adjusted to the suitable position of streetscape map, determines suitable viewpoint;Specifically, a certain
Under viewpoint, streetscape image is adjusted by rotation, so that object is located substantially at center Screen, and object is integrally clearly located at
Within sweep of the eye, clear is blocked, then selects the viewpoint.
In the step 2, viewpoint longitude and latitude is obtained according to the acquisition parameters of viewpoint.
In the step 3, viewpoint longitude and latitude is obtained to obtain according to step 2, obtains three different perspectivess respectively under two viewpoints
Streetscape picture, Streetscape picture 1 be used as reference map, pitch angle 0, the horizontal angle of Streetscape picture 2 and 1 is different, and pitch angle is identical, street
The horizontal angle of scape picture 3 and 1 is identical, and pitch angle is different;
When visual angle selects, streetscape image is adjusted by rotation, so that object is located at the suitable position of screen, zooms in or out
Image is also unlikely to excessive and exceeds screen ranges so that object is unlikely to too small and does not see.
In the step 4, the viewpoint is calculated to mesh according to the corresponding Streetscape picture 1 and 2 of the viewpoint under each viewpoint
The horizontal angle for marking certain point on object bottom, calculates the viewpoint bowing to object according to the corresponding Streetscape picture 1 and 3 of the viewpoint
The elevation angle.Certain point selection target object bottom centre or angle point on the object bottom;The horizontal angle, pitch angle are visual angles
Parameter, the azimuth information of camera when for indicating that video camera shoots street view image.
The horizontal angle refers to the compass heading of the camera of shooting camera.The range of acceptable value is 0 to 360 ° (two
Value all indicates the north, 90 ° of expression east, 180 ° of expression south).
The pitch angle refers to upward or downward angle of the camera of shooting camera relative to Street View vehicle.
Positive value indicates that camera is in upper angle (90 ° indicate vertically upward);And negative value indicates camera in downward angle (- 90 ° of expressions
Vertically downward).
The viewpoint is to object horizontal angle solution procedure:
Marked in Streetscape picture 1 first Streetscape picture 2 central point and object bottom on certain point in Streetscape picture 1
In location of pixels;The central point X1 of Streetscape picture 1, the central point X2 of Streetscape picture 2 and object bottom T are projected into viewpoint
O institute is in the horizontal plane.It crosses viewpoint O and makees straight line OO1 along the direction that horizontal angle is 0, cross the vertical line that point X2 makees OO1, intersection point O ',
In, O ' X2 and OX1, OT intersection point are respectively X1 ', T ';
The horizontal angle that object is calculated in the viewpoint calculates ∠ O ' OT, is set as ht, Streetscape picture 1, the horizontal angle at 2 centers
It is known that i.e. ∠ O ' OX1, ∠ O ' OX2, with h1, h2 expression.
By (formula 2)-(formula 1), (formula 3)-(formula 1) obtains (formula 4) respectively, (formula 5):
(formula 6) is obtained by (formula 4)/(formula 5):
It can be obtained by (formula 6):
Practical to calculate, ∠ X1OX2 is between 10 ° to 15 °, pixel distance between X1X2, compared to point O and point X1 it
Between actual range be fairly small.Therefore in △ OX1X2 and △ 0X1 ' X2,Approximately it is equivalent to
WhereinIt can be obtained by the location of pixels of each point in image, therefore water of the object bottom under the viewpoint can be found out
The straight angle:
Ht=Arctan ht
The viewpoint is to object pitch angle solution procedure:
It is marked in Streetscape picture 1 at the top of the central point and object of Streetscape picture 3 first, bottom is in Streetscape picture 1
Location of pixels;By Tt, object bottom at the top of the central point Y1 of Streetscape picture 1, the central point Y3 of Streetscape picture 3 and object
Where Tb projects to viewpoint O on vertical plane.
The horizontal angle that object bottom and top are calculated in the viewpoint calculates ∠ TtOY1, and ∠ TbOY1 is set as pt, pb,
The pitch angle of known 1 central point of Streetscape picture is 0 °, and the pitch angle of 3 central point of Streetscape picture is p3.
WhereinIt can be calculated according to the distance of picture pixels point, this makes it possible to obtain object bottom, tops to exist
Pitch angle under current view point.
In the step 5, according to two viewpoints and viewpoint to the horizontal angle of object bottom, two are constructed under polar coordinate system
Space line, front cross, and find out two straight-line intersections, the as longitude and latitude of object.
In the step 6, the relative altitude calculation method of object bottom, top and viewpoint specifically: by any viewpoint
Longitude and latitude and the longitude and latitude of object bottom find out viewpoint and object bottom in the horizontal plane at a distance from;According to the viewpoint to mesh
The pitch angle for marking object bottom and top, finds out the relative altitude of object bottom and top away from viewpoint respectively.It is excellent to be conveniently adjusted
Choosing, angle point/central point of certain point selection target object bottom or top in the viewpoint to object bottom, top;Mesh
The mark more selected line in object bottom and top is a vertical line.
In the step 7, the actual height circular of object are as follows: the relative altitude away from viewpoint at the top of object
Relative altitude of the object bottom away from viewpoint is subtracted to get the actual height of object is arrived.
Algorithm of the invention may be summarized to be: in streetscape map, selecting an object first, is selected according to object
Two suitable viewpoints obtain viewpoint longitude and latitude according to the acquisition parameters of viewpoint;Obtain three different views respectively under two viewpoints
The Streetscape picture at angle, picture 1 are used as reference map, and pitch angle 0, picture 2 is different from 1 horizontal angle of picture, and pitch angle is identical, picture
3 is identical as 1 horizontal angle of picture, and pitch angle is different;It is calculated according to the corresponding picture 1 of the viewpoint with picture 2 under each viewpoint
The viewpoint calculates the pitch angle of object according to picture 1 under the viewpoint and picture 3 to the horizontal angle of object;According to view
The visual angle of point longitude and latitude and viewpoint to object bottom determines two space lines, and front crosses, and finds out the intersection point of two straight lines, should
Intersection point is the longitude and latitude in the actual geographic space of object;It is found out by viewpoint longitude and latitude and the longitude and latitude of obtained object
The distance of viewpoint and object in the horizontal plane finds out viewpoint and mesh further according to the pitch angle of viewpoint to object top and bottom
It marks at the top of object, the relative altitude of bottom, two relative height differentials are the actual height of object.
Existing streetscape resource is effectively utilized in the present invention, and the ground of atural object in streetscape map is realized based on Streetscape picture
Reason position directly acquire and the measurement of the actual height of atural object, be conducive to existing streetscape resource smart city, intelligence hand over
Logical etc. further applies.
Detailed description of the invention
Fig. 1 is the flow chart of the embodiment of the present invention 1;
Fig. 2 a is 1 horizontal angle solution procedure viewpoint of the embodiment of the present invention, Streetscape picture central point and the signal of target object location
Figure;
Fig. 2 b is 1 horizontal angle solution procedure viewpoint of the embodiment of the present invention, Streetscape picture central point and the projection of target object location
Horizontal plane result figure where to viewpoint;
Fig. 3 a is 1 pitch angle solution procedure viewpoint of the embodiment of the present invention, Streetscape picture central point and the signal of target object location
Figure;
Fig. 3 b is 1 pitch angle solution procedure viewpoint of the embodiment of the present invention, Streetscape picture central point and the projection of target object location
Vertical plane result figure where to viewpoint;
Fig. 4 is that 1 geographic position of target object of the embodiment of the present invention solves schematic diagram;
Fig. 5 is that 1 object actual height of the embodiment of the present invention solves schematic diagram.
Specific embodiment
It is described in further detail with reference to the accompanying drawings and examples.
Embodiment 1
The present embodiment is by taking the streetscape map of Google company as an example, and the technical scheme of the present invention will be further described.Such as
Shown in Fig. 1, process of the invention includes the following steps:
Step 1: in streetscape map, selecting the viewpoint in two angulars field of view comprising object to be measured;
Step 2: obtaining the longitude and latitude of selected two viewpoints;
Step 3: obtaining the Streetscape picture of three different perspectivess, respectively Streetscape picture 1, streetscape figure respectively under two viewpoints
Piece 2 and Streetscape picture 3, wherein Streetscape picture 1 is benchmark picture, and Streetscape picture 2 is different from 1 horizontal angle of Streetscape picture, pitch angle
Identical, Streetscape picture 3 is identical as 1 horizontal angle of Streetscape picture, and pitch angle is different;
Step 4: calculating the visual angle of certain point in two viewpoints to object bottom, including horizontal angle and pitch angle;It is described
Certain point selection target object bottom centre or angle point on object bottom;
Step 5: according in step 4 two viewpoints and object bottom on certain point construct two space lines, front hand over
Remittance finds out the longitude and latitude of intersection point, i.e. the actual geographic position of object;
Step 6: calculate any viewpoint in selected two viewpoints to object distance, in conjunction with the viewpoint to object bottom
The pitch angle of certain point finds out the relative altitude of object bottom, top and viewpoint in portion, top;The viewpoint is to object bottom
Angle point/central point of certain point selection target object bottom or top in portion, top;Object bottom and top selected one
Point line is a vertical line;
Step 7: the actual height of object is obtained by the relative altitude of object bottom, top and viewpoint.
Specific implementation step is as follows:
Step 1 selects a specific object first, selects two different suitable views in Google streetscape map
Point;
The viewpoint refers to that camera geographic location, is indicated when shooting the street view image with longitude and latitude.Different points of view is
The geographical location of camera is different when referring to shooting Streetscape picture.Suitable viewpoint refers to, camera captured streetscape shadow in the position
Picture is adjusted by rotation, it can be clearly seen that object is whole, and clear is blocked.
Step 2 obtains the longitude and latitude of two streetscape viewpoints according to the related service of Google streetscape map respectively;Streetscape map
Acquisition parameters in i.e. comprising viewpoint latitude and longitude information, other streetscape maps can be used corresponding manner obtain viewpoint longitude and latitude
Information.
The longitude and latitude of viewpoint can be obtained according to Google Street ViewAPI, and specific code is as follows:
The longitude and latitude of // acquisition viewpoint
Var lat=panorama.getPosition () .lat ();
Var lng=panorama.getPosition () .lng ();
Wherein, lat is the latitude of viewpoint, and lng is the longitude of viewpoint;
Step 3 obtains to obtain viewpoint longitude and latitude according to step 2, Google Street View Image API is based on, two
The Streetscape picture of three different perspectivess is obtained under viewpoint respectively, Streetscape picture 1 is used as reference map, pitch angle 0, Streetscape picture 2
Different from 1 horizontal angle, pitch angle is identical, and the horizontal angle of Streetscape picture 3 and 1 is identical, and pitch angle is different;
The selection at the visual angle, which refers to, adjusts streetscape image by rotation, so that object is located at the suitable position of screen, puts
Big or diminution image is also unlikely to excessive and exceeds screen ranges so that object is unlikely to too small and does not see.
The horizontal angle, pitch angle are the parameters at visual angle, the side of camera when for indicating that video camera shoots street view image
Position information.
The horizontal angle refers to the compass heading of the camera of shooting camera.The range of acceptable value is 0 to 360 ° (two
Value all indicates the north, 90 ° of expression east, 180 ° of expression south).
The pitch angle refers to upward or downward angle of the camera of shooting camera relative to Street View vehicle.
Positive value indicates that camera is in upper angle (90 ° indicate vertically upward);And negative value indicates camera in downward angle (- 90 ° of expressions
Vertically downward).
In the present embodiment, the acquisition request of the Streetscape picture is a HTTPURL, and format is as follows:
Https: //maps.googleapis.com/maps/api/streetview? parameters
Corresponding manner can be used for other streetscape maps and obtain corresponding Streetscape picture;
In the present embodiment, the Streetscape picture parameter of acquisition specifically includes: location (can be text-string (such as
Chagrin Falls, OH) or lat/lon value (40.457375, -80.009353), size (the defeated of image is indicated with pixel
Size out), heading (horizontal angle indicates the compass heading of camera), pitch (pitch angle, specify camera relative to
The angle upward or downward of Street View vehicle);
Step 4 under each viewpoint according to the corresponding Streetscape picture 1 and 2 of the viewpoint calculate the viewpoint to object water
The straight angle calculates the pitch angle of object according to Streetscape picture 1 and 3 under the viewpoint;
As shown in Fig. 2 a, Fig. 2 b, the viewpoint is to object horizontal angle solution procedure:
The central point and pixel of the object bottom in Streetscape picture 1 of Streetscape picture 2 are marked in Streetscape picture 1 first
Position;Water where the central point X1 of Streetscape picture 1, the central point X2 of Streetscape picture 2 and object bottom T are projected to viewpoint O
In plane.It crosses viewpoint O and makees straight line OO1 along the direction that horizontal angle is 0, cross the vertical line that point X2 makees OO1, intersection point O ', wherein O ' X2
It is respectively X1 ', T ' with OX1, OT intersection point;
The horizontal angle that object is calculated in the viewpoint calculates ∠ O ' OT, is set as ht, Streetscape picture 1, the horizontal angle at 2 centers
It is known that i.e. ∠ O ' OX1, ∠ O ' OX2, with h1, h2 expression.
(formula 4) distinguished by (formula 2)-(formula 1), (formula 3)-(formula 1), (formula 5):
(formula 6) is obtained by (formula 4)/(formula 5):
It can be obtained by (formula 6):
Practical to calculate, ∠ X1OX2 is between 10 ° to 15 °, pixel distance between X1X2, compared to point O and point X1 it
Between actual range be fairly small.Therefore in △ OX1X2 and △ 0X1 ' X2,Approximately it is equal to
WhereinIt can be obtained by the location of pixels of each point in image, therefore water of the object bottom under the viewpoint can be found out
The straight angle:
Ht=Arctan ht
Such as Fig. 3 a, shown in Fig. 3 b, the viewpoint is to object pitch angle solution procedure:
It is marked in Streetscape picture 1 at the top of the central point and object of Streetscape picture 3 first, bottom is in Streetscape picture 1
Location of pixels;The central point Y1 of Streetscape picture 1, the central point Y3 of Streetscape picture 3 and target top Tt, object bottom Tb are projected
Onto the place viewpoint O vertical plane.
The horizontal angle that object bottom and top are calculated in the viewpoint calculates ∠ TtOY1, and ∠ TbOY1 is set as pt, pb,
The pitch angle of known 1 central point of Streetscape picture is 0 °, and the pitch angle of 3 central point of Streetscape picture is p3.
WhereinIt can be calculated according to the distance of picture pixels point, this makes it possible to obtain object bottom, tops to exist
Pitch angle under current view point.
Step 5: the longitude and latitude of known viewpoint and the horizontal angle of viewpoint to object bottom can be true according to polar coordinate system
Make a space line.As shown in figure 4, two different viewpoints then construct two different space lines, front crosses,
Determine object actual geographic position.Specific code is as follows:
//k1, k2 are respectively the slope of two space lines
Vark1=1/Math.Tan (rad (angleT1));
Var k2=1/Math.Tan (rad (angleT2));
//b1, b2 are respectively the intercept of two space lines
Var b1=lat1-k1*lng1;
Var b2=lat2-k2*lng2;
// target longitude and latitude
Var tlng=(b2-b1)/(k1-k2);
Var tlat=tlng*k1+b1;
Wherein tlng is target point longitude, and tlat is target point latitude;
Step 6: as shown in figure 3, finding out viewpoint and object bottom by the longitude and latitude of viewpoint longitude and latitude and object bottom
Distance in the horizontal plane.According to viewpoint to the pitch angle of object bottom and top, object bottom and top are found out respectively
Relative altitude away from viewpoint, as shown in Figure 5.Specific code is as follows:
Wherein, z1 is relative altitude of the object bottom away from viewpoint, and z2 is the relative altitude away from viewpoint at the top of object;
Step 7: the relative altitude away from viewpoint subtracts object bottom and obtains mesh away from the relative altitude of viewpoint at the top of object
Mark the actual height of object.Specific code is as follows:
The relative altitude for subtracting object bottom and viewpoint at the top of // object with the relative altitude of viewpoint, obtains object
Actual height
Var height=z2-z1;
Calculate the actual height that gained height is object.