How user move lines that is drawed in a figure interactivly and extract the data of new location of lines ?

조회 수: 3 (최근 30일)
After executed some codes; a result will come out with 4 lines that made a rectangular and drawn in a figure (with image background). User wants to move these lines (one or more lines) of rectangular (while they be stayed rectangular) to new location interactivly. The new data of these lines is required for using. Maybe the angles of the lines be changed(no parallel). Based on the attachment picture, first location is in red lines. User wants to change the location of lines to the 2nd location by mouse (green lines). I have the points of edges (cross lines) of lines red lines. I want the points of edges (cross lines) of 2nd location (green lines).
I prefer the function be able to use Matlab coder but it's not necessary.
  댓글 수: 3
marya anderson
marya anderson 2018년 5월 31일
편집: marya anderson 2018년 6월 3일
Yes, impoly works very well. In my case, I used imrect and impoly well. Thank you so mush. It was really helpful.
marya anderson
marya anderson 2018년 6월 3일
Thank you sloppydisk for ur answer.it works perfectly. Please put ur answer in answer box, thus, I can accept your answer. I used it in following code (ex; doc impoly):
PG = impoly(gca, P); %% P comes from my defualt Points api = iptgetapi(PG); % % Set the color of the polygon to yellow. api.setColor('yellow'); %% Create the function that constrains the movement of the polygon, specifying the boundary of the image as the limits, and then set the value of the setPositionConstraintFcn property. fcn = makeConstrainToRectFcn('impoly',get(gca,'XLim'),get(gca,'YLim')); api.setPositionConstraintFcn(fcn);
%%waiting till user double click then new points be update. wait(PG); UpdatedPoints = getPosition(PG);

댓글을 달려면 로그인하십시오.

채택된 답변

sloppydisk
sloppydisk 2018년 6월 3일
Take a look at
doc impoly
or
doc imline
For example:
imshow('gantrycrane.png');
impoly

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by