简体   繁体   中英

How can i draw a slanted rectangle in a frame (or picture)?

I have a code that takes a video, split it into frames and then asks me how many rectangles would i like to draw on the frame (only the first frame, k in the code below).

I would like to be able to draw a slanted rectangles too. Is there any command that can help me?

 if k==1
    result=input('How many rectangles would you like to draw? ');
    pos=zeros(result,4); 
    for i=1:result
      handle=imrect;
      pos(i,:)=handle.getPosition;   
    end
end

In your code, imrect is responsible for drawing a rectangle.

You may use impoly to draw some polygons (here slanted rectangles).

The code

imshow('cameraman.tif')
h_poly = impoly;

will give

在此处输入图片说明

You can modify the shape by drag/dropping the selection's blue handles.

The positions of the blue handles can be known with

pos = getPosition(h_poly) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM