当前位置: 首页>>代码示例>>Python>>正文


Python cv2.arrowedLine方法代码示例

本文整理汇总了Python中cv2.arrowedLine方法的典型用法代码示例。如果您正苦于以下问题:Python cv2.arrowedLine方法的具体用法?Python cv2.arrowedLine怎么用?Python cv2.arrowedLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cv2的用法示例。


在下文中一共展示了cv2.arrowedLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: write_arrow

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import arrowedLine [as 别名]
def write_arrow(self, arrow_type, scale_factor=1):
    assert (arrow_type in self._arrow_types)
    thickness = 1
    arrow_offsets = {
        'top': (12, 0, 12, -16),
        'top_right': (16, -4, 4, -16),
        'right': (0, -10, 20, -10),
        'bottom_right': (4, -16, 16, -4),
        'bottom': (10, -16, 10, 0),
        'bottom_left': (12, -12, 0, 0),
        'left': (20, -10, 0, -10),
        'top_left': (16, -4, 4, -16)
    }
    (s_x, s_y, e_x,
     e_y) = tuple(int(v * scale_factor) for v in arrow_offsets[arrow_type])
    start_point = (self._pos_x + s_x, self._pos_y + s_y)
    end_point = (self._pos_x + e_x, self._pos_y + e_y)
    image = cv2.arrowedLine(self._frame, start_point, end_point, self._color,
                            thickness) 
开发者ID:google-research,项目名称:football,代码行数:21,代码来源:observation_processor.py

示例2: draw_arrows

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import arrowedLine [as 别名]
def draw_arrows(self, frame):
        """Show the direction vector output in the cv2 window"""
        #cv2.putText(frame,"Color:", (0, 35), cv2.FONT_HERSHEY_SIMPLEX, 1, 255, thickness=2)
        cv2.arrowedLine(frame, (self.midx, self.midy),
                        (self.midx + self.xoffset, self.midy - self.yoffset),
                        (0, 0, 255), 5)
        return frame 
开发者ID:Ubotica,项目名称:telloCV,代码行数:9,代码来源:tracker.py

示例3: vis_ex

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import arrowedLine [as 别名]
def vis_ex(img, extreme_points, col, border_thick=2):
    """Visualizes a single binary mask."""

    img = img.astype(np.uint8)
    COL = (col).astype(np.uint8).tolist()
    # print('col', COL)
    ex = np.array(extreme_points).reshape(4, 2).astype(np.int32)
    
    L = 10
    T = 0.7
    cv2.arrowedLine(img, (ex[0][0], ex[0][1] + L), (ex[0][0], ex[0][1]), COL, border_thick, tipLength=T)
    cv2.arrowedLine(img, (ex[1][0] + L, ex[1][1]), (ex[1][0], ex[1][1]), COL, border_thick, tipLength=T)
    cv2.arrowedLine(img, (ex[2][0], ex[2][1] - L), (ex[2][0], ex[2][1]), COL, border_thick, tipLength=T)
    cv2.arrowedLine(img, (ex[3][0] - L, ex[3][1]), (ex[3][0], ex[3][1]), COL, border_thick, tipLength=T)
    
    '''
    R = 6
    cv2.circle(img, (ex[0][0], ex[0][1]), R, COL, -1)
    cv2.circle(img, (ex[1][0], ex[1][1]), R, COL, -1)
    cv2.circle(img, (ex[2][0], ex[2][1]), R, COL, -1)
    cv2.circle(img, (ex[3][0], ex[3][1]), R, COL, -1)

    cv2.circle(img, (ex[0][0], ex[0][1]), R, _WHITE, 2)
    cv2.circle(img, (ex[1][0], ex[1][1]), R, _WHITE, 2)
    cv2.circle(img, (ex[2][0], ex[2][1]), R, _WHITE, 2)
    cv2.circle(img, (ex[3][0], ex[3][1]), R, _WHITE, 2)
    '''
    return img.astype(np.uint8) 
开发者ID:xingyizhou,项目名称:ExtremeNet,代码行数:30,代码来源:visualize.py

示例4: create_plus

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import arrowedLine [as 别名]
def create_plus(drawing_area, start_x, start_y, end_x, end_y):
    center_x = (start_x + end_x) // 2
    center_y = (start_y + end_y) // 2
    cv2.arrowedLine(drawing_area, (center_x, center_y - 10), (center_x, center_y + 10), COLOR_PLUS, 2, tipLength=0.2)
    cv2.arrowedLine(drawing_area, (center_x - 10, center_y), (center_x + 10, center_y), COLOR_PLUS, 2, tipLength=0.2)
    cv2.arrowedLine(drawing_area, (center_x, center_y + 10), (center_x, center_y - 10), COLOR_PLUS, 2, tipLength=0.2)
    cv2.arrowedLine(drawing_area, (center_x + 10, center_y), (center_x - 10, center_y), COLOR_PLUS, 2, tipLength=0.2) 
开发者ID:marco-c,项目名称:autowebcompat,代码行数:9,代码来源:label.py

示例5: create_change_shape

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import arrowedLine [as 别名]
def create_change_shape(drawing_area, start_x, start_y, end_x, end_y):
    cv2.arrowedLine(drawing_area, (end_x - 12, end_y - 12), (end_x - 2, end_y - 2), COLOR_CHANGE_SHAPE, 2, tipLength=0.3)
    cv2.arrowedLine(drawing_area, (end_x - 2, end_y - 2), (end_x - 12, end_y - 12), COLOR_CHANGE_SHAPE, 2, tipLength=0.3) 
开发者ID:marco-c,项目名称:autowebcompat,代码行数:5,代码来源:label.py

示例6: draw_arrows

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import arrowedLine [as 别名]
def draw_arrows(img, pt1 , pt2):
    imgSz = img.shape[0]
    pt1 = ((pt1.data.cpu().numpy()+1.)/2.) * imgSz
    pt2 = ((pt2.data.cpu().numpy()[0,::]+1.)/2.) * imgSz
    for i in xrange(0,pt1.shape[1],2):
        for j in xrange(0,pt1.shape[2],2):
            if np.abs(pt1[0,i,j]-pt2[0,i,j]) > 2. or  np.abs(pt1[1,i,j]-pt2[1,i,j]) > 2. :
                img = cv2.arrowedLine(img.astype(np.uint8), tuple(pt1[:,i,j]), tuple(pt2[:,i,j]), color=(0,0,255), line_type=cv2.LINE_AA, thickness=1, tipLength = 0.4)
    return img 
开发者ID:rakshithShetty,项目名称:adversarial-object-removal,代码行数:11,代码来源:generate_boxreconst_samples.py

示例7: draw

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import arrowedLine [as 别名]
def draw(img, target, fname):
	img_temp = img.copy()
	
	color_close = (255, 0, 0)	# close is blue
	color_far = (0, 255, 0)		# far is green
	for i in range(target.shape[1]):
		x1 = int(target[1, i]); y1 = int(target[0, i]);
		x2 = int(target[3, i]); y2 = int(target[2, i]);
		
		cv2.circle(img_temp,(x1, y1),2,color_far,-1)
		cv2.circle(img_temp,(x2, y2),2,color_close,-1)
		cv2.arrowedLine(img_temp, (x2, y2), (x1, y1), (0, 255, 255), 1)
	
	cv2.imwrite(fname, img_temp)
	print "Done writing to %s" % fname 
开发者ID:princeton-vl,项目名称:YouTube3D,代码行数:17,代码来源:ReDWebDataset.py

示例8: draw_arrow

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import arrowedLine [as 别名]
def draw_arrow(img, x, y, multiply=25):
        h, w, c = img.shape
        arrow = cv2.arrowedLine(img, (int(w / 2), int(h / 2)), (int(w / 2 + x * multiply), int(h / 2 + y * multiply)),
                                color=(0, 255, 255), thickness=15)
        return arrow 
开发者ID:YoongiKim,项目名称:Walk-Assistant,代码行数:7,代码来源:opt_flow.py

示例9: visualize_paf

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import arrowedLine [as 别名]
def visualize_paf(img, pafs,name='pafs'):
    img = img.copy()
    for i in range(pafs.shape[0]):
        paf_x = pafs[i,0,:,:]
        paf_y = pafs[i,1,:,:]
        len_paf = np.sqrt(paf_x**2 + paf_y**2)
        for x in range(0,img.shape[0],8):
            for y in range(0, img.shape[1], 8):
                if len_paf[x,y]>0.25:
                    img = cv2.arrowedLine(img, (y,x), (int(y + 6*paf_x[x,y]), int(x + 6*paf_y[x,y])), colors[i], 1)
    cv2.imshow(name, img)
    cv2.waitKey() 
开发者ID:NiteshBharadwaj,项目名称:part-affinity,代码行数:14,代码来源:visualize.py

示例10: draw_arrow

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import arrowedLine [as 别名]
def draw_arrow(img, angle1, angle2, angle3):
    pt1 = (img.shape[1] / 2, img.shape[0])
    pt2_angle1 = (int(img.shape[1] / 2 - img.shape[0] / 3 * math.sin(angle1)),
                  int(img.shape[0] - img.shape[0] / 3 * math.cos(angle1)))
    pt2_angle2 = (int(img.shape[1] / 2 - img.shape[0] / 3 * math.sin(angle2)),
                  int(img.shape[0] - img.shape[0] / 3 * math.cos(angle2)))
    pt2_angle3 = (int(img.shape[1] / 2 - img.shape[0] / 3 * math.sin(angle3)),
                  int(img.shape[0] - img.shape[0] / 3 * math.cos(angle3)))
    img = cv2.arrowedLine(img, pt1, pt2_angle1, (0, 0, 255), 1)
    img = cv2.arrowedLine(img, pt1, pt2_angle2, (0, 255, 0), 1)
    img = cv2.arrowedLine(img, pt1, pt2_angle3, (255, 0, 0), 1)
    return img 
开发者ID:peikexin9,项目名称:deepxplore,代码行数:14,代码来源:utils.py

示例11: plot_trajs

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import arrowedLine [as 别名]
def plot_trajs(img, trajs, color, show_person_id=False):
  """Plot traj on img with the person_id text."""
  # color is bgr tuple
  for person_id_, traj in trajs:
    traj = [(int(p1), int(p2)) for p1, p2 in traj]
    points = zip(traj[:-1], traj[1:])
    for p1, p2 in points:
      img = cv2.arrowedLine(img, tuple(p1), tuple(p2), color=color, thickness=2,
                            line_type=cv2.LINE_AA, tipLength=0.3)
    # show the person_id
    if show_person_id:
      img = cv2.putText(img, "#%s" % person_id_, tuple(traj[0]),
                        cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255),
                        lineType=cv2.LINE_AA)
  return img 
开发者ID:JunweiLiang,项目名称:Multiverse,代码行数:17,代码来源:visualize_real_data.py

示例12: visualize_node_arrows

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import arrowedLine [as 别名]
def visualize_node_arrows(self, img, node_id, size=3, color=(255,0,255)):
        l, r, t, b = self.adjacency[node_id]
        srcX, srcY = self.node_coordinates[node_id]
        for direction, r in enumerate((l,r,t,b)):
            if r == -1: continue
            targetX, targetY = self.node_coordinates[r]
            # Use constant arrow head size. As arrowedLine() takes a fraction of the length, we need to reverse that
            length = np.hypot(targetX - srcX, targetY - srcY)
            arrowHeadSizeWant = 15  #px
            arrowHeadSize = arrowHeadSizeWant / length
            print("Drawing <{3}> arrow from #{0} to #{1}  of length {2}".format(
                    r, node_id, length, {0: "left", 1: "right", 2:"top", 3:"bottom"}[direction]))
            cv2.arrowedLine(img, (int(targetX), int(targetY)), (int(srcX), int(srcY)),
                            color=color, thickness=3, tipLength=arrowHeadSize, line_type=cv2.LINE_AA) 
开发者ID:ulikoehler,项目名称:OTR,代码行数:16,代码来源:TableRecognition.py

示例13: arrow

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import arrowedLine [as 别名]
def arrow(self, start, end):
        """Draw arrow from start to end.

        Parameters
        ----------
        start : array_like
            Vector of length 2 which contains the arrow starting position.
        end : array_like
            Vector of length 2 which contains the arrow end position.

        """
        start = tuple(int(x) for x in start)
        end = tuple(int(x) for x in end)
        cv2.arrowedLine(self.image, start, end, self.color, self.thickness) 
开发者ID:nwojke,项目名称:pymotutils,代码行数:16,代码来源:opencv.py

示例14: draw_gaze

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import arrowedLine [as 别名]
def draw_gaze(image_in, eye_pos, pitchyaw, length=40.0, thickness=2, color=(0, 0, 255)):
    """Draw gaze angle on given image with a given eye positions."""
    image_out = image_in
    if len(image_out.shape) == 2 or image_out.shape[2] == 1:
        image_out = cv.cvtColor(image_out, cv.COLOR_GRAY2BGR)
    dx = -length * np.sin(pitchyaw[1])
    dy = -length * np.sin(pitchyaw[0])
    cv.arrowedLine(image_out, tuple(np.round(eye_pos).astype(np.int32)),
                   tuple(np.round([eye_pos[0] + dx, eye_pos[1] + dy]).astype(int)), color,
                   thickness, cv.LINE_AA, tipLength=0.2)
    return image_out 
开发者ID:swook,项目名称:GazeML,代码行数:13,代码来源:gaze.py

示例15: dispOpticalFlow

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import arrowedLine [as 别名]
def dispOpticalFlow (Image, Flow, Divisor, name ):
    """
    
    Display image with a visualisation of a flow over the top. 
    A divisor controls the density of the quiver plot.
    
    Arguments:
        Image:      Image on which to display flow lines
        Flow :      Flow vectors x and y
        Divisor:    Spacing between the arrow nodes
        name:       Name of the window
    """
    PictureShape = np.shape (Image)
    # determine number of quiver points there will be
    Imax = int (PictureShape[0] / Divisor)
    Jmax = int (PictureShape[1] / Divisor)
    # create a blank mask,   on which lines will be drawn.
    mask = np.zeros_like (Image)
    panel = np.zeros_like (Image)

    for i in range (1, Imax):
        for j in range (1, Jmax):
            X1 = (i) * Divisor
            Y1 = (j) * Divisor

            X2 = int (X1 + Flow[X1, Y1, 1])
            Y2 = int (Y1 + Flow[X1, Y1, 0])
            X2 = np.clip (X2, 0, PictureShape[0])
            Y2 = np.clip (Y2, 0, PictureShape[1])
            # add all the lines to the mask

            mask = cv2.arrowedLine (mask, (Y1, X1), (Y2, X2), [255, 255, 255], 1)
            # To show only arrows in the image
            # cv2.namedWindow("Panel", 0)
            # panel = panel+mask
            # cv2.imshow("Panel", panel)
    # superpose lines onto image

    img = cv2.add (Image, mask)
    # print image
    cv2.startWindowThread ()
    cv2.namedWindow (name, 0)
    cv2.imshow (name, img)

    return [] 
开发者ID:nabulago,项目名称:anomaly-event-detection,代码行数:47,代码来源:mylib.py


注:本文中的cv2.arrowedLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。