Image and Trajectory Perspective Projection
5 views (last 30 days)
Show older comments
I am trying to apply perspective projection on an image and a trajectory from visual tracking. ( Trajectory points (x,y) ar actually the meadian values of x,y coordinates of the bootom side of a person bounding box.
My goal is to have the top down view for the image and trajectory. However, I am getting a wrong results, I cannot figure out the reason.
Here is my code:
close all
clear
im1 = imread('Outdoor.png');
load('Trajectory1.mat')
inpX = [290.462825278810;380.276951672862;432.618959107807;264.291821561338];
inpY = [181.615241635688;181.020446096654;305.927509293680;307.117100371747];
OutX = [290.462825278810;381.466542750929;381.466542750929;290.462825278810];
OutY = [181.020446096654;181.020446096654;307.117100371747;307.117100371747];
T = fitgeotrans([inpX inpY],[OutX OutY],'projective');
newimg = imwarp(im1, T);
[TranformedTrajectoryX,TranformedTrajectoryY] = transformPointsInverse(T,Trajectory(:,1),Trajectory(:,2));
figure
imshow(im1)
hold on
plot(inpX,inpY,'xr','LineWidth',2)
hold on
plot(OutX,OutY,'xb','LineWidth',2)
legend({'Input Control Points','Output Control Points'})
hold off
figure
imshow(im1)
hold on
scatter(Trajectory(:,1),Trajectory(:,2),'filled','r')
title('Trajectory Points (Original)')
axis ij
axis tight
xlabel('X')
ylabel('Y')
hold off
figure
imshow(newimg);
hold on
scatter( TranformedTrajectoryX, TranformedTrajectoryY,'filled')
title('Trajectory Points (Perspective Transformation)')
xlabel('X')
ylabel('Y')
axis ij
axis tight
hold off
The original image and trajectory:

After applying transformation functions:

My control points are shown in this figure:

Can anybody help me understanding what is actually causing this error and how to fix it.
I have attached the original image and trajectory points.
Thank you
5 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!