Losing GPS data when I extract frames from mp4 video
Show older comments
Hi guys,
I have a mp4 video from a GOPRO with GPS data, but when I extract frames of this video with matlab I loose all the GPS data.
Does anyone already had this problem and could help me, please?
clc;
clear all;
close all;
tic;
vid=VideoReader('C:\Users\Cinthya Ruffo\Desktop\teste códigos prospecção por imagem\videovieira2.mp4');
numFrames = vid.framerate;
duration = vid.Duration;
mkdir('teste');
Folder = ('C:\Users\Cinthya Ruffo\Desktop\teste códigos prospecção por imagem\teste');
for iFrame = 1:duration
frames = read(vid, iFrame);
imwrite(frames, fullfile(Folder, sprintf('%06d.jpeg', iFrame)));
end
FileList = dir(fullfile(Folder, '*.jpeg'));
for iFile = 1:length(FileList)
aFile = fullfile(Folder, FileList(iFile).name);
img = imread(aFile);
end
cd('C:\Users\Cinthya Ruffo\Desktop\teste códigos prospecção por imagem\teste' );
list = dir('*.jpeg');
[m n]= size(list);
sz = [m 3];
varTypes = { 'string','string','string'};
varNames = {'ImageName','Lat','Lng'};
T = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
for i = 1:m
disp(list(i).name);
imgName = list(i).name;
info = imfinfo(imgName);
if isfield(info.GPSInfo)
lat = info.GPSInfo.GPSLatitude;
lng = info.GPSInfo.GPSLongitude;
strLat = lat(1) + "," + lat(2)+ "," + lat(3);
strLng = lng(1) + "," + lng(2)+ "," + lng(3);
T(i,:) = {imgName, strLat,strLng};
else
lat = [0 0 0];
lng = [0 0 0];
strLat = lat(1) + "," + lat(1)+ "," + lat(3);
strLng = lng(1) + "," + lng(1)+ "," + lng(3);
T(i,:) = {imgName, strLat,strLng};
end
end
Answers (0)
Categories
Find more on Video Formats and Interfaces in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!