Closed GustavoStahl closed 4 years ago
I solved the problem modifying the getFrameAndCrop.m
file and running aside in MatLab. With the following code i could extract the images, it's just necessary to change the paths that were used and also create folders for the frames. In this case the path for them was named "Imagesdata/cam(number)". Note: The images were saved each 5 frames, for any changes it can be modified here: if rem(count, 5) == 0
function [subImage, image] = getFrameAndCrop(testCamera, frame, bb)
declareGlobalVariables,
video_file_numbers = [2, 17, 18, 19, 40, 50, 53, 54, 56, 57, 58, 59, 60];
for file_number = 1:length(video_file_numbers)
%Set up image reading stuff
seqFilesDirectory = [hdaRootDirectory '/hda_image_sequences_matlab'];
seqName = sprintf('%s/camera%02d.seq',seqFilesDirectory, video_file_numbers(file_number)); %MATTEO TODO CHANGE CAM TO CAMERA
seqReader = seqIo( seqName, 'reader'); % Open the input image sequence
%Read the image
for count = 0:10000
stop = seqReader.seek(count);
if stop == 0
break
end
if rem(count, 5) == 0
seqReader.seek(count);
image = seqReader.getframe();
frame_string = int2str(count);
image_folder_name = ['cam_', int2str(video_file_numbers(file_number)), '/'];
save_path = ['/home/gustavostahl/LabVisao/PeopleDetector/data/HDA_Dataset_V1.3/Images_data/', image_folder_name, 'frame_',frame_string , '.png'];
imwrite(image, save_path);
end
end
seqReader.close();
end
if exist('bb','var')
% and crop
[nRows,nCols,nPags] = size(image);
x1 = max(round(bb(1)),1);
y1 = max(round(bb(2)),1);
x2 = min(round(bb(1)+bb(3)),nCols);
y2 = min(round(bb(2)+bb(4)),nRows);
subImage=image( y1:y2, x1:x2, : );
else
subImage = [];
end
I read Nurungyi issue on how to extract the image files, but it still confuses me, since i'm not familiar with MATLAB. I am trying to get the frames (.jpg, .png) and bounding boxes(.csv, or other txt readable format) from each video. I tried to modify the file getFrameAndCrop.m and run it aside from RunToVisualize.m, but some errors were presented. Are there any suggestions on how to proceed? Thanks in advance