Upload tools of visualization
Browse files
Images/tools/demo_visualize.m
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
im_root = '../images/';
|
| 3 |
+
bbox_file = '../anno_bbox.mat';
|
| 4 |
+
|
| 5 |
+
ld = load(bbox_file);
|
| 6 |
+
bbox_train = ld.bbox_train;
|
| 7 |
+
bbox_test = ld.bbox_test;
|
| 8 |
+
list_action = ld.list_action;
|
| 9 |
+
|
| 10 |
+
% change this
|
| 11 |
+
i = 100; % image index
|
| 12 |
+
j = 1; % hoi index
|
| 13 |
+
|
| 14 |
+
% read image
|
| 15 |
+
im_file = [im_root 'train2015/' bbox_train(i).filename];
|
| 16 |
+
im = imread(im_file);
|
| 17 |
+
|
| 18 |
+
% display image
|
| 19 |
+
figure(1);
|
| 20 |
+
imshow(im); hold on;
|
| 21 |
+
|
| 22 |
+
% display hoi
|
| 23 |
+
hoi_id = bbox_train(i).hoi(j).id;
|
| 24 |
+
aname = [list_action(hoi_id).vname_ing ' ' list_action(hoi_id).nname];
|
| 25 |
+
aname = strrep(aname,'_',' ');
|
| 26 |
+
title(aname);
|
| 27 |
+
|
| 28 |
+
% display bbox
|
| 29 |
+
if bbox_train(i).hoi(j).invis
|
| 30 |
+
fprintf('hoi not visible\n');
|
| 31 |
+
else
|
| 32 |
+
bboxhuman = bbox_train(i).hoi(j).bboxhuman;
|
| 33 |
+
bboxobject = bbox_train(i).hoi(j).bboxobject;
|
| 34 |
+
connection = bbox_train(i).hoi(j).connection;
|
| 35 |
+
visualize_box_conn_one(bboxhuman, bboxobject, connection, 'b','g');
|
| 36 |
+
end
|
| 37 |
+
|
Images/tools/visualize_box_conn_one.m
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function [ ] = visualize_box_conn_one( box_1, box_2, conn, clr_1, clr_2 )
|
| 2 |
+
|
| 3 |
+
if nargin < 4
|
| 4 |
+
clr_1 = 'b';
|
| 5 |
+
end
|
| 6 |
+
|
| 7 |
+
if nargin < 5
|
| 8 |
+
clr_2 = 'g';
|
| 9 |
+
end
|
| 10 |
+
|
| 11 |
+
for r = 1:numel(box_1)
|
| 12 |
+
rt = [box_1(r).x1, ...
|
| 13 |
+
box_1(r).y1, ...
|
| 14 |
+
box_1(r).x2-box_1(r).x1+1, ...
|
| 15 |
+
box_1(r).y2-box_1(r).y1+1];
|
| 16 |
+
rectangle('Position', rt, 'LineWidth', 3, 'EdgeColor', clr_1);
|
| 17 |
+
end
|
| 18 |
+
for r = 1:numel(box_2)
|
| 19 |
+
rt = [box_2(r).x1, ...
|
| 20 |
+
box_2(r).y1, ...
|
| 21 |
+
box_2(r).x2-box_2(r).x1+1, ...
|
| 22 |
+
box_2(r).y2-box_2(r).y1+1];
|
| 23 |
+
rectangle('Position', rt, 'LineWidth', 3, 'EdgeColor', clr_2);
|
| 24 |
+
end
|
| 25 |
+
for c = 1:size(conn,1)
|
| 26 |
+
rt1 = box_1(conn(c,1));
|
| 27 |
+
rt2 = box_2(conn(c,2));
|
| 28 |
+
ct1 = [(rt1.x1+rt1.x2)/2, (rt1.y1+rt1.y2)/2];
|
| 29 |
+
ct2 = [(rt2.x1+rt2.x2)/2, (rt2.y1+rt2.y2)/2];
|
| 30 |
+
|
| 31 |
+
line( ...
|
| 32 |
+
'XData', [ct1(1); ct2(1)], ...
|
| 33 |
+
'YData', [ct1(2); ct2(2)], ...
|
| 34 |
+
'Color', 'r', ...
|
| 35 |
+
'LineStyle', '-', ...
|
| 36 |
+
'LineWidth', 3 ...
|
| 37 |
+
);
|
| 38 |
+
plot(gca, ct1(1), ct1(2), 'ro', 'LineWidth', 2, 'MarkerFaceColor', 'red');
|
| 39 |
+
plot(gca, ct2(1), ct2(2), 'ro', 'LineWidth', 2, 'MarkerFaceColor', 'red');
|
| 40 |
+
end
|
| 41 |
+
|
| 42 |
+
end
|
| 43 |
+
|