Prespectrive transform for Lane detection project

7 ビュー (過去 30 日間)
Eduardo Lacerda
Eduardo Lacerda 2020 年 1 月 4 日
コメント済み: Eduardo Lacerda 2020 年 1 月 26 日
hello , any ideas on how to get the transformation matrix for this projection :
my goal is to obtain this :
question1.PNG
from this :
question.PNG
i have tried this :
im = imread('test1.jpg');
initial_points=[580,475; 740,475; 300,650; 1050,650]
final_points= [250,0 ; 1100,0; 0,720; 1200,720]
tform = fitgeotrans(final_points,initial_points,'projective');
out = imwarp(im,tform);
and allways get something like this :
question3.PNG
with open.cv in python i can do it with :
#4-points on the initial iamge
initial_points=np.float32([(580,475),(740,475),(300,650),(1050,650)])
#same 4 points in the porjected image
final_points=np.float32([(250,0),(1100,0),(250,720),(1100,720)])
Transformation_Matrix = cv2.getPerspectiveTransform(initial_points, final_points)
warped = cv2.warpPerspective(image, Transformation_Matrix,(1280,720)) #equivalent to imwarp
and i get this :
Test_gray.jpg
  2 件のコメント
Qu Cao
Qu Cao 2020 年 1 月 7 日
Can you attach 'test1.jpg' here?
Eduardo Lacerda
Eduardo Lacerda 2020 年 1 月 7 日
here you have

サインインしてコメントする。

回答 (2 件)

Eduardo Lacerda
Eduardo Lacerda 2020 年 1 月 7 日
here it is
thanks!

Prabhan Purwar
Prabhan Purwar 2020 年 1 月 23 日
Hi,
Following code may help
clc
close all
clear
oim = imread('test1.jpg');
im=oim(475:650,300:1050,:);
initial_points=[580,475; 740,475; 300,650; 1050,650];
final_points=[575,0; 720,0; 310,720; 1000,720];
initial_points(:,1) = initial_points(:,1)-475;
initial_points(:,2) = initial_points(:,2)-300;
tform = fitgeotrans(final_points,initial_points,'projective');
invtform = invert(tform);
out = imwarp(im,invtform);
subplot(1,2,1)
imshow(out);
subplot(1,2,2)
imshow(im);
Output:
pic.jpg
For more information refer to the following link:
  1 件のコメント
Eduardo Lacerda
Eduardo Lacerda 2020 年 1 月 26 日
thanks a lot for you help ,any ideas on how can i change your code to get a complete bird eye view of my lane like i present in the 1st images ? i also have to keep the original image size
thanks again

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeC4ISR についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by