Image and Trajectory Perspective Projection

11 Ansichten (letzte 30 Tage)
Aalali
Aalali am 1 Nov. 2020
Kommentiert: Aalali am 8 Nov. 2020
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 Kommentare
Aalali
Aalali am 6 Nov. 2020
.
Aalali
Aalali am 8 Nov. 2020
.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Produkte


Version

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by