Starburst- based eye tracking algorithm on single images

조회 수: 3 (최근 30일)
Beatrice Pazzucconi
Beatrice Pazzucconi 2017년 10월 24일
댓글: Beatrice Pazzucconi 2018년 4월 10일
Hi everybody, I'm trying to process some eye images for eye tracking and I am trying currently with Starburst algorithm. Since the algorithm originally takes videos while I'd like to process single images, I must break down the single functions to do what I want. I am going through the single functions to do so. I am not familiar with the file handling, so this bit of code for me turns out very hard to understand:
[sfname, spname] = uigetfile('*.mp4','Scene movie file');
sf = strcat(spname, sfname);
[efname, epname] = uigetfile('*.mp4','Eye movie file', spname);
ef = strcat(epname, efname);
eval(sprintf('!mkdir %s/Scene', spname));
eval(sprintf('!mkdir %s/Eye', epname));
eval(sprintf('!ffmpeg -i %s -img jpeg %sScene/Scene_%%5d.jpg', sf, spname));
eval(sprintf('!ffmpeg -i %s -img jpeg %sEye/Eye_%%5d.jpg', ef, epname));
Supposedly breaks the video into single images (which would be my starting point). However, the !ffmpeg command doesn't seem to be working, as it raise and error:
The syntax of the command is incorrect.
'ffmpeg' is not recognized as an internal or external command,
operable program or batch file.
Can anybody help me out with understanding what this snippet will actually do (I understand what 'eval' and 'sprintf' do but what it's inside there remains obscure) and why it raises and error?
Thank you very much!

채택된 답변

Walter Roberson
Walter Roberson 2017년 10월 24일
ffmpeg = '/usr/local/bin/ffmpeg'; %full path to executable
[sfname, spname] = uigetfile('*.mp4','Scene movie file');
sf = fullfile(spname, sfname);
[efname, epname] = uigetfile('*.mp4','Eye movie file', spname);
ef = fullfile(epname, efname);
mkdir( fullfile(spnane, 'Scene') );
mkdir( fullfile(epnae, 'Eye') );
cmd1 = sprintf('''%s'' -i ''%s'' -img jpeg ''%s/Scene/Scene_%%5d.jpg''', ffmpeg, sf, spname);
cmd2 = sprintf('''%s'' -i ''%s'' -img jpeg ''%s/Eye/Eye_%%5d.jpg''', ffmpeg, ef, epname);
system(cmd1)
system(cmd2)
  댓글 수: 8
Mohy Faid
Mohy Faid 2018년 4월 9일
편집: Mohy Faid 2018년 4월 9일
Beatrice Pazzucconi , Do you solve this problem ?
Beatrice Pazzucconi
Beatrice Pazzucconi 2018년 4월 10일
Actually in the end I did not use it, because I did not need to break into frames a video. I just used the part relative to file handling
dir_name = uigetdir(pwd,'Select working folder, must be the same
for algorithm and Eye folder');
mkdir(fullfile(dir_name, 'Results'))
res_name = strcat(dir_name, '/Results/');
eye_file_name = sprintf('%s/Eye/Eye_', dir_name);
results_data_name = sprintf('%s/Results.mat', res_name);
% some image processing happens [...]
% save image (inside for loop, with image handle open and then closed)
save_image(res_name, frame_index);
frame_index = frame_index + 1;
% save results (out of for loop)
save(results_data_name, 'first_frame', 'last_frame', 'CR_matrix', 'Ellipse_matrix', 'Diff_vector_matrix')
The parameters I save are the variables I get from image processing. I create a folder with the results.mat file in which I save those and the image I processed with some markers applied on to decide if the processing went right. The frame index goes from the first image index found to the last and increase with each cycle. I attach here the save_image function:
function save_image(res_name, frame_index)
% image must be existsing already, so that one can choose if it will be
% visible or not
F = getframe ;
res_filename = strcat(res_name, sprintf('Eye_res_%5.5d.jpg', frame_index));
imwrite(F.cdata, res_filename)
return

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by