Filter löschen
Filter löschen

How can I map a specific location in MATLAB using the drone images with corresponding gps data latitude and longitude?

31 Ansichten (letzte 30 Tage)
I have a tabulated data on matlab of the images I took using the drone with their latitude and longitude and I want to make a map like the image below to visualize the location of each image. How can I achieve this using MATLAB. Does anybody knows how to do it? Thank you for helping.
  2 Kommentare
KSSV am 27 Feb. 2022
What data you have? You have (lat,lon) and images? Do you have the geographic reference of images?
Cristel Esmerna
Cristel Esmerna am 27 Feb. 2022
Yes I have the images with their gps info the latitude and longitude tabulated in matlab like this.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

AndresVar am 27 Feb. 2022
Bearbeitet: AndresVar am 27 Feb. 2022
You can ignore geolimits first, get a nice a view, query the limits and then set it.
lats = [34.07293; 34.08];
longs = [-118.44867; -118.45];
id_str = {'1';'2'}; % maybe use the file name instead or some timedate format
data = table(id_str,lats,longs)
data = 2×3 table
id_str lats longs ______ ______ _______ {'1'} 34.073 -118.45 {'2'} 34.08 -118.45
geolimits([34.0452 34.0978],[-118.4800 -118.4])
geobasemap streets
  3 Kommentare
Cristel Esmerna
Cristel Esmerna am 27 Feb. 2022
I tried to add your code on the code I used to tabulate the coordinates of the images but it shows a different location and only one image location appears. Here is my full code
% go to the directory that contains all the images
%2 -get the list of all images in the directory above
list = dir('*.JPG');
%3 - get the number of the images in the directory
[m,n] = size(list);
%create a size for the table that will contain information about the% images
sz = [m 4];
%create a table that contains information about the images
varTypes = {'string', 'string', 'string', 'string'};
varNames = {'ImageName', 'Latitude', 'Longitude', 'DateTime'};
T = table('Size', sz, 'VariableTypes',varTypes, 'VariableNames', varNames);
%Loop through the images and retrieve gps information
for i = 1:m
imgName = list(i).name;
info = imfinfo(imgName);
latitude = info.GPSInfo.GPSLatitude;
longitude = info.GPSInfo.GPSLongitude;
dateTime = info.DateTime;
strLatitude = latitude(1) + ";" + latitude(2) + ";" + latitude(3);
strLongitude = longitude(1) + ";" + longitude(2) + ";" + longitude(3);
DateTime = dateTime(1);
T(i,:) = {imgName, strLatitude, strLongitude, dateTime};
geolimits([13.5 13.65],[121.3 121.5])
geobasemap streets
AndresVar am 1 Mär. 2022
@Cristel Esmerna parse and collect the data in the loop but plot outside the loop otherwise you might need to use hold on
I don't know why it would show wrong location. Geoplot worked well with a location I got off googlemaps. Verify you lat and lon for just 1 photo on google maps.

Melden Sie sich an, um zu kommentieren.

William Rose
William Rose am 27 Feb. 2022
My interpretation of your question is that you would like to show shapes on a basemap that will indicate the area covered by each drone image. In general, each rectangular drone image will map to a curvy quadrilateral on the basemap. You know the lat and long of the corners your basemap image, and therefore you can easily compute the lat and long of any point in the basemap, by simple linear interpolation from the corner points.
Approach 1. For a start, let's assume the ground covered by the basemap is all at the same altitude. Then you need to known the lat and long of the drone, which you said you have. You also need to know its altitude above the ground and the 3D orientation of the camera (which is described by 3 parameters, or by the 3x3 rotation matrix, which only has 3 independent parameters, even though it has 9 elements). You need to know the camera projection properties, which is a non-trivial thing. If you have all that information, then you can compute the lat and long of the edge points of your image, and you can draw a shape on th basemap with those points.
If you do not know the camera orientation and camera projection properties, then you need to identify several fiducial points, also known as reference points, on the base map, and associate them with corresponding points in the drone image. Then you use the associated points to solve for the constants in the projection equations that relate the drone image to the base map. Depending on the equations you choose for the projection, you may end up with an over-determined set of equations to solve. This will happen if you have M constants to solve for in the projection equations, and you have more than M/2 fiducial points - because you get 2 identities from every fiducial point If the system is overdetermined, then you take a least-squares approach to estimate the constants.
Example: Assume the camera projection is affine, which means that straight lines on the ground get mapped to straight lines in the camera image. Each point on the base map has a latitude ϕand longitude λ. The points in the drone image are described by the pixel coordinates: row i, i=1:M, and column j, j=1:N. The affine projection equations can be written as
With 3 non-co-linear fiducial points, you can solve for the unknowns a11,...,a23. If you have more than 3 fiducial points, you use singular value decomposition to find the values of the six constants that minimize the errors between the actual and predicted basemap coordinates of the fiducial points. Once you have the six unknowns, you use the projection equations to determine the latitudes and longitudes of the corners of the image, and you draw straight lines betweeen those points on the basemap.
  7 Kommentare
William Rose
William Rose am 21 Mär. 2022
I am not sure I have correctly undesrstood what you want to do.
I assume you would like to turn your drone image into a map-like image. There are nice ways to do it, with imwarp(). imwarp warps the image and with the right inputs, it can take a drone image and warp it into what the image would look like if it were taken from very high straight overhead, i.e. warp it into a map projection. But imwarp() has to know a bunch of stuff to do it. The fiducial points are one way to calculate what imwarp needs to know.
You have a lat and long and altitude. Is that for the drone when it took the photo, or for a place on the image?
Please post yor question as a whole new question. It deserves its own thread. Include an image and the lat-long-alt info if you are able share, or, if you cannot share it, make up a simulated problem analgous to yours, perhaps using google maps and 3D view, like I did for you. There are people on this forum who know a lot more than me about this, who can give better help, although I will try. Include @William Rose, in the posting, so that I get an email about it, because I have not been chekcing Matlab ansers regularly for the last couple of weeks. Or we can take it off line if you prefer to share an email.
Beth Carreon
Beth Carreon am 22 Mär. 2022
@William Rose the GPS info is for the drone when it took the photo. I will post a question regarding this. Thank you for your help.

Melden Sie sich an, um zu kommentieren.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by