Skip to content

Commit

Permalink
Minro changes
Browse files Browse the repository at this point in the history
+ Added video rotation in VideoReader2
. FFT function does zero padding of data make the length a multiple of 2
  • Loading branch information
umartechboy committed Sep 10, 2018
1 parent 31f23f2 commit ea751d5
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 6 deletions.
6 changes: 5 additions & 1 deletion Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
v2.3 (20170907)
v2.4 (20180910)
+ Added video rotation in VideoReader2
. FFT function does zero padding of data make the length a multiple of 2

v2.3 (20180907)
.+ Added functionality to allow the user to re-select the object if the tracking is lost in KLT. The tracker is re-initialized with new eigen shapes on the last successfully tracked frame. This give a new set of object coordinates. The offset of these coordinates is kept for all the further tracked points. This way, the first newly tracked point coincides with the last tarcked and the track is rebuilt. Note that the length of validity map and track point records may change after selecting a new object. The length of the existing and new data are padded for the matching.
+ Added "Show Last position" button in objectSelector. This way, the user can view the location of the object on the last tracked frame which can be tool as a reference while selecting a new object.
+ Added script for analyzing Wilberforce pendulum
Expand Down
6 changes: 6 additions & 0 deletions Source Code/+PhysTrack/FFT.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
if nargin <=3
dataUnits = 'the data';
end
nearestPower = log2(length(data));
if nearestPower - floor(nearestPower) ~= 0
nearestPower = uint16(floor(nearestPower) + 1);
lengthReq = 2^nearestPower
data(lengthReq) = 0;
end
meanData = data(:,1)-mean(data(:,1));
dataFFT = abs((fft(meanData))); %take the fourier transform of the position data
dataFFT = dataFFT * 1/length(data);
Expand Down
2 changes: 1 addition & 1 deletion Source Code/+PhysTrack/VideoReader2.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
forceFPS = round(vro.FrameRate);
end
fps = PhysTrack.askValue('Enter the number of frames shot per second by the camera: ', forceFPS, 'Video Frame rate', 'uint16');
vro2Obj = struct('obj', vro, 'PreMag', preMag, 'FPS', fps, 'CropRect', [0,0, vro.Width * preMag, vro.height * preMag], 'ifi', 1, 'ofi', vro.NumberOfFrames, 'TotalFrames', vro.NumberOfFrames, 'BinaryThreshold', [], 'BinaryBackgroundIsLight', false );
vro2Obj = struct('obj', vro, 'PreMag', preMag, 'FPS', fps, 'CropRect', [0,0, vro.Width * preMag, vro.height * preMag], 'ifi', 1, 'ofi', vro.NumberOfFrames, 'TotalFrames', vro.NumberOfFrames, 'BinaryThreshold', [], 'BinaryBackgroundIsLight', false , 'Rotation', 0);
if (forceCropTrim)
if strcmp(questdlg('Do you want to Crop and Trim the video?', '', 'Yes', 'No', 'Yes'), 'Yes')
vro2Obj = PhysTrack.TrimVideo(vro2Obj, true);
Expand Down
4 changes: 4 additions & 0 deletions Source Code/+PhysTrack/read2.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function I = read2(vro, frameNumber, indIsAbsolute, forceRGB, cropPreviewOnly)

% READ2 This function has mnay working modes and depending upon the kind
% and types of arguments, can give differnet result. Basically, it is used
% to read an image frame from a PHYSTRACK.VIDEOREADER2 object. It will use
Expand Down Expand Up @@ -126,4 +127,7 @@
end
end
end
if vro.Rotation ~= 0
I = imrotate(I, vro.Rotation);
end
end
6 changes: 4 additions & 2 deletions Source Code/GUIs/ShowImWithRef.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ function ShowImWithRef( vr2o, ind, rwRCS, forceRGB, ppmLine)
else
rwRCS_ = rwRCS;
end
I = insertText(PhysTrack.read2(vr2o, ind, false, forceRGB), rwRCS_(2,:), 'X', 'BoxOpacity', 0.2, 'BoxColor', [255,255,255]);
I = insertText(I, rwRCS_(3,:), 'Y', 'BoxOpacity', 0.2, 'BoxColor', [255,255,255]);
I = PhysTrack.read2(vr2o, ind, false, forceRGB);
ts = uint16(round(min(size(I, 1), size(I, 2))/20));
I = insertText(I, rwRCS_(2,:), 'X', 'BoxOpacity', 0.5, 'BoxColor', [255,255,255], 'FontSize', ts);
I = insertText(I, rwRCS_(3,:), 'Y', 'BoxOpacity', 0.5, 'BoxColor', [255,255,255], 'FontSize', ts);
if ~isempty(ppmLine)
I = insertShape(I, 'Line', ppmLine, 'Color', PhysTrack.GetColor('Pink'), 'LineWidth',3);
end
Expand Down
Binary file modified Source Code/GUIs/vidTrimTool.fig
Binary file not shown.
70 changes: 69 additions & 1 deletion Source Code/GUIs/vidTrimTool.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

% Edit the above text to modify the response to help vidTrimTool

% Last Modified by GUIDE v2.5 17-Nov-2016 11:08:49
% Last Modified by GUIDE v2.5 10-Sep-2018 13:33:00

% Begin initialization code - DO NOT EDIT
addpath(fileparts(pwd));
Expand Down Expand Up @@ -461,3 +461,71 @@ function forceRGB_Callback(hObject, eventdata, handles)
% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of forceRGB


% --- Executes on button press in rotate0RB.
function rotate0RB_Callback(hObject, eventdata, handles)
% hObject handle to rotate0RB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

global vtt_vr2o_00
if get(hObject, 'Value') == 1
vtt_vr2o_00.Rotation = 0;
set(handles.rotate90RB, 'Value', 0);
set(handles.rotate180RB, 'Value', 0);
set(handles.rotate270RB, 'Value', 0);
end
imshow(PhysTrack.read2(vtt_vr2o_00, vtt_vr2o_00.ifi, true, get(handles.forceRGB, 'Value'), true));
% Hint: get(hObject,'Value') returns toggle state of rotate0RB


% --- Executes on button press in rotate90RB.
function rotate90RB_Callback(hObject, eventdata, handles)
% hObject handle to rotate90RB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

global vtt_vr2o_00
if get(hObject, 'Value') == 1
vtt_vr2o_00.Rotation = 90;
set(handles.rotate0RB, 'Value', 0);
set(handles.rotate180RB, 'Value', 0);
set(handles.rotate270RB, 'Value', 0);
end
imshow(PhysTrack.read2(vtt_vr2o_00, vtt_vr2o_00.ifi, true, get(handles.forceRGB, 'Value'), true));
% Hint: get(hObject,'Value') returns toggle state of rotate90RB


% --- Executes on button press in rotate180RB.
function rotate180RB_Callback(hObject, eventdata, handles)
% hObject handle to rotate180RB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

global vtt_vr2o_00
if get(hObject, 'Value') == 1
vtt_vr2o_00.Rotation = 180;
set(handles.rotate90RB, 'Value', 0);
set(handles.rotate0RB, 'Value', 0);
set(handles.rotate270RB, 'Value', 0);
end
imshow(PhysTrack.read2(vtt_vr2o_00, vtt_vr2o_00.ifi, true, get(handles.forceRGB, 'Value'), true));
% Hint: get(hObject,'Value') returns toggle state of rotate180RB


% --- Executes on button press in rotate270RB.
function rotate270RB_Callback(hObject, eventdata, handles)
% hObject handle to rotate270RB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

global vtt_vr2o_00
if get(hObject, 'Value') == 1
vtt_vr2o_00.Rotation = 270;
set(handles.rotate90RB, 'Value', 0);
set(handles.rotate180RB, 'Value', 0);
set(handles.rotate0RB, 'Value', 0);
end
imshow(PhysTrack.read2(vtt_vr2o_00, vtt_vr2o_00.ifi, true, get(handles.forceRGB, 'Value'), true));
% Hint: get(hObject,'Value') returns toggle state of rotate270RB
Binary file modified Source Code/GUIs/vidTrimToolOld.fig
Binary file not shown.
38 changes: 37 additions & 1 deletion Source Code/GUIs/vidTrimToolOld.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

% Edit the above text to modify the response to help vidTrimToolOld

% Last Modified by GUIDE v2.5 18-Dec-2016 11:04:01
% Last Modified by GUIDE v2.5 10-Sep-2018 13:25:59

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
Expand Down Expand Up @@ -204,3 +204,39 @@ function framex_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in rotate0RB.
function rotate0RB_Callback(hObject, eventdata, handles)
% hObject handle to rotate0RB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of rotate0RB


% --- Executes on button press in rotate90RB.
function rotate90RB_Callback(hObject, eventdata, handles)
% hObject handle to rotate90RB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of rotate90RB


% --- Executes on button press in rotate180RB.
function rotate180RB_Callback(hObject, eventdata, handles)
% hObject handle to rotate180RB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of rotate180RB


% --- Executes on button press in rotate270RB.
function rotate270RB_Callback(hObject, eventdata, handles)
% hObject handle to rotate270RB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of rotate270RB

0 comments on commit ea751d5

Please sign in to comment.