How to dra two lines on the image according to the points we receive from the user?

1 回表示 (過去 30 日間)
Feyza Zehra Asik
Feyza Zehra Asik 2021 年 12 月 26 日
コメント済み: Image Analyst 2021 年 12 月 26 日
What i wanna do is,user to mark the last player of the defending team closest to the goal and the player closest to the goal line of the attacking team and draw two lines on the image according to the points we receive from the user for offside detection. I have this code here but it's connecting the lines. I need two seperate lines like in the pic.
f=figure;
imshow('resim1.jpg');
[x, y] = getpts(f);
line (x,y,'Color', 'black', 'LineWidth', 6);
F = getframe(gcf);
I = frame2im(F);
close all;

回答 (2 件)

Voss
Voss 2021 年 12 月 26 日
編集済み: Voss 2021 年 12 月 26 日
Maybe call getpts() two times, once for each line? Otherwise you will need to know which points belong to which line.

Burhan Burak AKMAN
Burhan Burak AKMAN 2021 年 12 月 26 日
Can you try that code? Maybe it will work. If you want angled lines, I think you need some reference points for perspective.
f=figure;
imshow('resim1.jpg');
[x, y] = getpts(f);
line (x(1)*ones(2,1),[-1000,1000],'Color', 'black', 'LineWidth', 6);
line (x(2)*ones(2,1),[-1000,1000],'Color', 'black', 'LineWidth', 6);
F = getframe(gcf);
I = frame2im(F);
close all;
  2 件のコメント
Feyza Zehra Asik
Feyza Zehra Asik 2021 年 12 月 26 日
yeah it's working thank you so much
Image Analyst
Image Analyst 2021 年 12 月 26 日
@Feyza Zehra Asik if it's working and completely solved then please click the "Accept this answer" link to award @Burhan Burak AKMAN "reputation points."

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by