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


Python cv2.line方法代码示例

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


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

示例1: __init__

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import line [as 别名]
def __init__(self, line):
        data = line.split(' ')
        data[1:] = [float(x) for x in data[1:]]
        self.classname = data[0]
        self.xmin = data[1] 
        self.ymin = data[2]
        self.xmax = data[1]+data[3]
        self.ymax = data[2]+data[4]
        self.box2d = np.array([self.xmin,self.ymin,self.xmax,self.ymax])
        self.centroid = np.array([data[5],data[6],data[7]])
        self.unused_dimension = np.array([data[8],data[9],data[10]])
        self.w = data[8]
        self.l = data[9]
        self.h = data[10]
        self.orientation = np.zeros((3,))
        self.orientation[0] = data[11]
        self.orientation[1] = data[12]
        self.heading_angle = -1 * np.arctan2(self.orientation[1], self.orientation[0]) 
开发者ID:zaiweizhang,项目名称:H3DNet,代码行数:20,代码来源:sunrgbd_utils.py

示例2: draw_projected_box3d

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import line [as 别名]
def draw_projected_box3d(image, qs, color=(255,255,255), thickness=2):
    ''' Draw 3d bounding box in image
        qs: (8,2) array of vertices for the 3d box in following order:
            1 -------- 0
           /|         /|
          2 -------- 3 .
          | |        | |
          . 5 -------- 4
          |/         |/
          6 -------- 7
    '''
    qs = qs.astype(np.int32)
    for k in range(0,4):
       #http://docs.enthought.com/mayavi/mayavi/auto/mlab_helper_functions.html
       i,j=k,(k+1)%4
       cv2.line(image, (qs[i,0],qs[i,1]), (qs[j,0],qs[j,1]), color, thickness, cv2.CV_AA) # use LINE_AA for opencv3

       i,j=k+4,(k+1)%4 + 4
       cv2.line(image, (qs[i,0],qs[i,1]), (qs[j,0],qs[j,1]), color, thickness, cv2.CV_AA)

       i,j=k,k+4
       cv2.line(image, (qs[i,0],qs[i,1]), (qs[j,0],qs[j,1]), color, thickness, cv2.CV_AA)
    return image 
开发者ID:zaiweizhang,项目名称:H3DNet,代码行数:25,代码来源:sunrgbd_utils.py

示例3: get_curve

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import line [as 别名]
def get_curve(self):
        L = 200
        canvas = np.ones((L, L, 3)) * 0.851
        curve_step = 16
        xs = np.linspace(0.0, 1.0, curve_step + 1)[:, None, None]
        xs = np.concatenate([xs] * 3, axis=2)
        ys = self.apply(xs.copy())
        ys = np.clip(ys, 0.01, 1.0)
        for i in range(curve_step):
            for j in range(3):
                x, y = xs[i, 0, j], ys[i, 0, j]
                xx, yy = xs[i + 1, 0, j], ys[i + 1, 0, j]
                color = [0, 0, 0]
                color[j] = 0.7
                color = tuple(color)
                cv2.line(canvas, (int(L * x), int(L - L * y)), (int(L * xx), int(L - L * yy)), color, 1)
        return canvas 
开发者ID:yuanming-hu,项目名称:exposure,代码行数:19,代码来源:filters.py

示例4: visualize_filter

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import line [as 别名]
def visualize_filter(self, debug_info, canvas):
    curve = debug_info['filter_parameters']
    height, width = canvas.shape[:2]
    for i in range(self.channels):
      values = np.array([0] + list(curve[0][0][i]))
      values /= sum(values) + 1e-30
      scale = 1
      values *= scale
      for j in range(0, self.cfg.curve_steps):
        values[j + 1] += values[j]
      for j in range(self.cfg.curve_steps):
        p1 = tuple(
            map(int, (width / self.cfg.curve_steps * j, height - 1 -
                      values[j] * height)))
        p2 = tuple(
            map(int, (width / self.cfg.curve_steps * (j + 1), height - 1 -
                      values[j + 1] * height)))
        color = []
        for t in range(self.channels):
          color.append(1 if t == i else 0)
        cv2.line(canvas, p1, p2, tuple(color), thickness=1) 
开发者ID:yuanming-hu,项目名称:exposure,代码行数:23,代码来源:filters.py

示例5: update

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import line [as 别名]
def update(self, radarData):
        self.img = np.zeros((self.height, self.width, self.channels), np.uint8)
        cv2.line(self.img, (10, 0), (self.width/2 - 5, self.height), (100, 255, 255))
        cv2.line(self.img, (self.width - 10, 0), (self.width/2 + 5, self.height), (100, 255, 255))

        for track_number in range(1, 65):
            if str(track_number)+'_track_range' in radarData:
                track_range = radarData[str(track_number)+'_track_range']
                track_angle = (float(radarData[str(track_number)+'_track_angle'])+90.0)*math.pi/180

                x_pos = math.cos(track_angle)*track_range*4
                y_pos = math.sin(track_angle)*track_range*4

                cv2.circle(self.img, (self.width/2 + int(x_pos), self.height - int(y_pos) - 10), 5, (255, 255, 255))
                #cv2.putText(self.img, str(track_number), 
                #    (self.width/2 + int(x_pos)-2, self.height - int(y_pos) - 10), self.font, 1, (255,255,255), 2)

        cv2.imshow("Radar", self.img)
        cv2.waitKey(2) 
开发者ID:diyjac,项目名称:Udacity-SDC-Radar-Driver-Micro-Challenge,代码行数:21,代码来源:esr_visualizer.py

示例6: func1

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import line [as 别名]
def func1(k=None):
    if not k:
        k=randint(0, 20)
    print('image is',k)
    for i, (img, heatmap,vecmap,depthmap,kpt_3d) in enumerate(train_loader):
        if i==k:
#            test_heatmaps(heatmap,img,i)
#            test_vecmaps(vecmap,img,i)
#            edges = [[0, 1], [1, 2], [2, 6], [6, 3], [3, 4], [4, 5], [10, 11], [11, 12], [12, 8], [8, 13], [13, 14], [14, 15], [6, 8], [8, 9]]
#            ppl=kpt_3d.shape[0]
#            for i in range(ppl):
#                for edge in edges:
#                    cv2.line(img,(int(kpt_3d[i][edge[0]][0]),int(kpt_3d[i][edge[0]][1])),(int(kpt_3d[i][edge[1]][0]),int(kpt_3d[i][edge[1]][1])),(0,255,0))
#            cv2.imwrite('outside3dfinal.png',img)
       
            return img,heatmap,vecmap,depthmap,kpt_3d 
开发者ID:Naman-ntc,项目名称:3D-HourGlass-Network,代码行数:18,代码来源:my.py

示例7: draw_humans

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import line [as 别名]
def draw_humans(npimg, humans, imgcopy=False):
        if imgcopy:
            npimg = np.copy(npimg)
        image_h, image_w = npimg.shape[:2]
        centers = {}
        for human in humans:
            # draw point
            for i in range(common.CocoPart.Background.value):
                if i not in human.body_parts.keys():
                    continue

                body_part = human.body_parts[i]
                center = (int(body_part.x * image_w + 0.5), int(body_part.y * image_h + 0.5))
                centers[i] = center
                cv2.circle(npimg, center, 3, common.CocoColors[i], thickness=3, lineType=8, shift=0)

            # draw line
            for pair_order, pair in enumerate(common.CocoPairsRender):
                if pair[0] not in human.body_parts.keys() or pair[1] not in human.body_parts.keys():
                    continue

                npimg = cv2.line(npimg, centers[pair[0]], centers[pair[1]], common.CocoColors[pair_order], 3)

        return npimg 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:26,代码来源:estimator.py

示例8: draw_limbs

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import line [as 别名]
def draw_limbs(image, pose_2d, visible):
    """Draw the 2D pose without the occluded/not visible joints."""

    _COLORS = [
        [0, 0, 255], [0, 170, 255], [0, 255, 170], [0, 255, 0],
        [170, 255, 0], [255, 170, 0], [255, 0, 0], [255, 0, 170],
        [170, 0, 255]
    ]
    _LIMBS = np.array([0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9,
                       9, 10, 11, 12, 12, 13]).reshape((-1, 2))

    _NORMALISATION_FACTOR = int(math.floor(math.sqrt(image.shape[0] * image.shape[1] / NORMALISATION_COEFFICIENT)))

    for oid in range(pose_2d.shape[0]):
        for lid, (p0, p1) in enumerate(_LIMBS):
            if not (visible[oid][p0] and visible[oid][p1]):
                continue
            y0, x0 = pose_2d[oid][p0]
            y1, x1 = pose_2d[oid][p1]
            cv2.circle(image, (x0, y0), JOINT_DRAW_SIZE *_NORMALISATION_FACTOR , _COLORS[lid], -1)
            cv2.circle(image, (x1, y1), JOINT_DRAW_SIZE*_NORMALISATION_FACTOR , _COLORS[lid], -1)
            cv2.line(image, (x0, y0), (x1, y1),
                     _COLORS[lid], LIMB_DRAW_SIZE*_NORMALISATION_FACTOR , 16) 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:25,代码来源:draw.py

示例9: on_mouse

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import line [as 别名]
def on_mouse(self, event, x, y, flags, param):
        pt = (x, y)
        if event == cv2.EVENT_LBUTTONDOWN:
            self.prev_pt = pt
        elif event == cv2.EVENT_LBUTTONUP:
            self.prev_pt = None

        if self.prev_pt and flags & cv2.EVENT_FLAG_LBUTTON:
            for dst, color in zip(self.dests, self.colors_func()):
                cv2.line(dst, self.prev_pt, pt, color, 5)
            self.dirty = True
            self.prev_pt = pt
            self.show()


# palette data from matplotlib/_cm.py 
开发者ID:makelove,项目名称:OpenCV-Python-Tutorial,代码行数:18,代码来源:common.py

示例10: drawMatch

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import line [as 别名]
def drawMatch(img0,img1,src,tgt,color='b'):
    if len(img0.shape)==2:
      img0=np.expand_dims(img0,2)
    if len(img1.shape)==2:
      img1=np.expand_dims(img1,2)
    h,w = img0.shape[0],img0.shape[1]
    img = np.zeros([2*h,w,3])
    img[:h,:,:] = img0
    img[h:,:,:] = img1
    n = len(src)
    if color == 'b':
        color=(255,0,0)
    else:
        color=(0,255,0)
    for i in range(n):
      cv2.circle(img, (int(src[i,0]), int(src[i,1])), 3,color,-1)
      cv2.circle(img, (int(tgt[i,0]), int(tgt[i,1])+h), 3,color,-1)
      cv2.line(img, (int(src[i,0]),int(src[i,1])),(int(tgt[i,0]),int(tgt[i,1])+h),color,1)
    return img 
开发者ID:zhenpeiyang,项目名称:RelativePose,代码行数:21,代码来源:rputil.py

示例11: visualize_joints

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import line [as 别名]
def visualize_joints(bone_list, focus):
    m = np.zeros((424, 600, 3))
    m.astype(np.uint8)
    for bone in bone_list:
        p1x = bone[0][0]
        p1y = bone[0][1]
        p1z = bone[0][2] + 400
        p2x = bone[1][0]
        p2y = bone[1][1]
        p2z = bone[1][2] + 400
        p1 = (
         int(p1x * focus / p1z + 300.0), int(-p1y * focus / p1z + 204.0))
        p2 = (int(p2x * focus / p2z + 300.0), int(-p2y * focus / p2z + 204.0))
        if inside_image(p1[0], p1[1]) and inside_image(p2[0], p2[1]):
            cv.line(m, p1, p2, (255, 0, 0), 2)
            cv.circle(m, p1, 2, (0, 255, 255), -1)
            cv.circle(m, p2, 2, (0, 255, 255), -1)

    return m 
开发者ID:papagina,项目名称:Auto_Conditioned_RNN_motion,代码行数:21,代码来源:rotation2xyz.py

示例12: visualize_joints2

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import line [as 别名]
def visualize_joints2(bone_list, focus):
    m = np.zeros((424, 600, 3))
    m.astype(np.uint8)
    for bone in bone_list:
        p1x = bone[0][0]
        p1y = bone[0][1]
        p1z = bone[0][2] + 400
        p2x = bone[1][0]
        p2y = bone[1][1]
        p2z = bone[1][2] + 400
        p1 = (
         int(p1x * focus / p1z + 300.0), int(-p1y * focus / p1z + 204.0))
        p2 = (int(p2x * focus / p2z + 300.0), int(-p2y * focus / p2z + 204.0))
        if inside_image(p1[0], p1[1]) and inside_image(p2[0], p2[1]):
            cv.line(m, p1, p2, (255, 0, 0), 2)
            cv.circle(m, p1, 2, (0, 255, 255), -1)
            cv.circle(m, p2, 2, (0, 255, 255), -1)

    return m 
开发者ID:papagina,项目名称:Auto_Conditioned_RNN_motion,代码行数:21,代码来源:rotation2xyz.py

示例13: plot_kpt

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import line [as 别名]
def plot_kpt(image, kpt):
    ''' Draw 68 key points
    Args: 
        image: the input image
        kpt: (68, 3).
    '''
    image = image.copy()
    kpt = np.round(kpt).astype(np.int32)
    for i in range(kpt.shape[0]):
        st = kpt[i, :2]
        image = cv2.circle(image,(st[0], st[1]), 1, (0,0,255), 2)  
        if i in end_list:
            continue
        ed = kpt[i + 1, :2]
        image = cv2.line(image, (st[0], st[1]), (ed[0], ed[1]), (255, 255, 255), 1)
    return image 
开发者ID:joseph-zhong,项目名称:LipReading,代码行数:18,代码来源:cv_plot.py

示例14: plot_kpt

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import line [as 别名]
def plot_kpt(image, kpt):
    ''' Draw 68 key points
    Args: 
        image: the input image
        kpt: (68, 3).
    '''
    image = image.copy()
    kpt = np.round(kpt).astype(np.int32)
    for i in range(kpt.shape[0]):
        st = kpt[i, :2]
        image = cv2.circle(image, (st[0], st[1]), 1, (0, 0, 255), 2)
        if i in end_list:
            continue
        ed = kpt[i + 1, :2]
        image = cv2.line(image, (st[0], st[1]), (ed[0], ed[1]), (255, 255, 255), 1)
    return image 
开发者ID:tensorboy,项目名称:centerpose,代码行数:18,代码来源:cv_plot.py

示例15: apply_keypoint

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import line [as 别名]
def apply_keypoint(image, keypoint, num_joints=17):
    image = image.astype(np.uint8)
    
    edges = [[0, 1], [0, 2], [1, 3], [2, 4], 
                    [3, 5], [4, 6], [5, 6], 
                    [5, 7], [7, 9], [6, 8], [8, 10], 
                    [5, 11], [6, 12], [11, 12], 
                    [11, 13], [13, 15], [12, 14], [14, 16]]
    
    for j in range(num_joints):
        if keypoint[j][2]>0.:
            cv2.circle(image,
                      (keypoint[j, 0], keypoint[j, 1]), 3, (255,255,255), 2)
                     
    stickwidth = 2
           
    for j, e in enumerate(edges):
        if keypoint[e[0],2] > 0. and keypoint[e[1],2] > 0.:
            centerA = keypoint[e[0],:2]
            centerB = keypoint[e[1],:2]
            cv2.line(image,(centerA[0], centerA[1]),(centerB[0], centerB[1]),(255, 255,255),2)
    return image 
开发者ID:tensorboy,项目名称:centerpose,代码行数:24,代码来源:data_inspect_utils.py


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