hp index calculation

Converting their head position parameters to our index.


filelist = dir;

Index =1;
AllImages = [];
AllPoseIndex = [];
AllPoseParameters = [];

for j = 3:size(filelist,1)

    if filelist(j).isdir ~= true
        % open the mat file
        fname = filelist(j).name;

        % check if the file extension is .mat
        if strcmp( fname(size(fname,2)-3:size(fname,2)) ,'.mat') == 1
            % load the mat file
            load(fname);

            n = size(all_wimgs,2);
            %Yaw of the first picture
            iniYaw = 0;
            %pitch of the first picture
            iniPitch = 0;
            for i=1:n

                diffYaw = pose_parameter(2,i) - pose_parameter(2,1);
                diffPitch = pose_parameter(1,i)- pose_parameter(1,1);

                % adjust first parameter
                labelYaw = round((-diffYaw + 65)/130*5) -1;
                if labelYaw > 4
                    labelYaw = 4;
                elseif labelYaw  6.5)
                    labelPitch = 2;
                elseif (diffPitch > -30)
                    labelPitch = 1;
                else
                    labelPitch = 0;
                end

                %save the image
                img = reshape(all_wimgs(:,i),32,32);

                % check if the folder exist?
                if(size(dir(fname(1:size(fname,2)-4)),1) == 0)
                    mkdir(fname(1:size(fname,2)-4));
                end

                imwrite(img,['./' fname(1:size(fname,2)-4) '/P' num2str(labelYaw) num2str(labelPitch) '_' num2str(i) '_Y' num2str(diffYaw) '_P' num2str(diffPitch)...
                        '.jpg'],'jpg');
                % save the index
                AllPoseIndex = [AllPoseIndex (labelYaw*10+labelPitch)];

            end % end of for i

            AllImages = [AllImages all_wimgs];
            AllPoseParameters = [AllPoseParameters pose_parameter];

            %clear all_wimgs,pose_parameter;

        end % end of if strcmp

    end % end of if isdir

end % end of for j
% save all
save AllFaces AllImages AllPoseIndex AllPoseParameters;

Advertisements

One Response to hp index calculation

  1. refly123 says:

    how to find the determinant of a non-square matrix in c++??
    i’m having trouble doing it …

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: