-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcentroid_computation_office.m
More file actions
65 lines (49 loc) · 2.24 KB
/
centroid_computation_office.m
File metadata and controls
65 lines (49 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function centroid_computation_office()
%% Author: Girmaw Abebe
% Date: March, 2015
% Go through ReadMe.doc and License.doc files before using the software.
%
% Requested citation acknowledgement when using this software:
%
% Girmaw Abebe, Andrea Cavallaro and Xavier Parra, "Robust multi-dimensional motion features for first-person vision activity recognition",
% Computer Vision and Image Understanding, Vol. 149, 2016, pp. 229-248
%
% Girmaw Abebe and Andrea Cavallaro, "Hierarchical modeling for first-person vision activity recognition",
% Neurocomputing, Vol. 267, 2017, pp. 362-377
% This code extracts Horn and schunk optical flow, particularly, grid
% optical flow from video segments of office activity in the dataset
%Begin parallel computing
%matlabpool('open',4);
%clear; clc; close all;
%add videos file path
videoPath='/home/nafkote/Desktop/Matlab_practice/data/office_activities/';
addpath(videoPath)
videos= dir(strcat(videoPath,'*.MP4'));
videos={videos.name};
numVideos=length(videos)
load('gt_office.mat')
numSubjects=numVideos;
whole_data_centroid=cell(1,numSubjects);
for sub=1:numSubjects
numSegments=length(gt_office.(strcat('subject',num2str(sub))).start_time);
whole_data_centroid{sub}=cell(1,numSegments);
vidObj=VideoReader(videos{sub});
frameRate=vidObj.FrameRate;
for segm=1:numSegments
sprintf('subjet %d, segment %d',sub, segm)
startFrame=ceil(frameRate*gt_office.(strcat('subject',num2str(sub))).start_time(segm)/1000);
stopFrame=floor(frameRate*gt_office.(strcat('subject',num2str(sub))).final_time(segm)/1000);
numFrames=stopFrame-startFrame+1;
centroidsVideo=zeros(2,numFrames);
ind=1;
for frameNum=startFrame:stopFrame
videoFrame=read(vidObj,frameNum);
centroidsVideo(:,ind)=image_moments(rgb2gray(videoFrame));
ind=ind+1;
end%end of frameNum
whole_data_centroid{sub}{segm}=centroidsVideo;
end
end
% %save the cell of histVideoCell
save('whole_data_centroid.mat','whole_data_centroid');
end