當前位置: 首頁>>代碼示例>>Python>>正文


Python cv2.circle方法代碼示例

本文整理匯總了Python中cv2.circle方法的典型用法代碼示例。如果您正苦於以下問題:Python cv2.circle方法的具體用法?Python cv2.circle怎麽用?Python cv2.circle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cv2的用法示例。


在下文中一共展示了cv2.circle方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: blob

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import circle [as 別名]
def blob(x):
    """Given an Nx3 matrix of blob positions and size, 
    create N img_size x img_size images, each with a blob drawn on 
    them given by the value in each row of x
    
    One row of x = [x,y,radius]."""
    y = np.zeros((x.shape[0], img_size, img_size))
    for i, particle in enumerate(x):
        rr, cc = skimage.draw.circle(
            particle[0], particle[1], max(particle[2], 1), shape=(img_size, img_size)
        )
        y[i, rr, cc] = 1
    return y


#%%

# names (this is just for reference for the moment!) 
開發者ID:johnhw,項目名稱:pfilter,代碼行數:20,代碼來源:example_filter.py

示例2: ProcessFrame

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import circle [as 別名]
def ProcessFrame(self, frame):
        # segment arm region
        segment = self.SegmentArm(frame)

        # make a copy of the segmented image to draw on
        draw = cv2.cvtColor(segment, cv2.COLOR_GRAY2RGB)

        # draw some helpers for correctly placing hand
        cv2.circle(draw,(self.imgWidth/2,self.imgHeight/2),3,[255,102,0],2)       
        cv2.rectangle(draw, (self.imgWidth/3,self.imgHeight/3), (self.imgWidth*2/3, self.imgHeight*2/3), [255,102,0],2)

        # find the hull of the segmented area, and based on that find the
        # convexity defects
        [contours,defects] = self.FindHullDefects(segment)

        # detect the number of fingers depending on the contours and convexity defects
        # draw defects that belong to fingers green, others red
        [nofingers,draw] = self.DetectNumberFingers(contours, defects, draw)

        # print number of fingers on image
        cv2.putText(draw, str(nofingers), (30,30), cv2.FONT_HERSHEY_SIMPLEX, 1, (255,255,255))
        return draw 
開發者ID:PacktPublishing,項目名稱:OpenCV-Computer-Vision-Projects-with-Python,代碼行數:24,代碼來源:chapter2.py

示例3: update

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import circle [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

示例4: mark_hand_center

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import circle [as 別名]
def mark_hand_center(frame_in,cont):    
    max_d=0
    pt=(0,0)
    x,y,w,h = cv2.boundingRect(cont)
    for ind_y in xrange(int(y+0.3*h),int(y+0.8*h)): #around 0.25 to 0.6 region of height (Faster calculation with ok results)
        for ind_x in xrange(int(x+0.3*w),int(x+0.6*w)): #around 0.3 to 0.6 region of width (Faster calculation with ok results)
            dist= cv2.pointPolygonTest(cont,(ind_x,ind_y),True)
            if(dist>max_d):
                max_d=dist
                pt=(ind_x,ind_y)
    if(max_d>radius_thresh*frame_in.shape[1]):
        thresh_score=True
        cv2.circle(frame_in,pt,int(max_d),(255,0,0),2)
    else:
        thresh_score=False
    return frame_in,pt,max_d,thresh_score

# 6. Find and display gesture 
開發者ID:mahaveerverma,項目名稱:hand-gesture-recognition-opencv,代碼行數:20,代碼來源:HandRecognition.py

示例5: draw_humans

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import circle [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

示例6: draw_limbs

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import circle [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

示例7: plot_3d_pts

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import circle [as 別名]
def plot_3d_pts(img, pts, center, calib_file=None, cam_to_img=None, relative=False, constraint_idx=None):
    if calib_file is not None:
        cam_to_img = get_calibration_cam_to_image(calib_file)

    for pt in pts:
        if relative:
            pt = [i + center[j] for j,i in enumerate(pt)] # more pythonic

        point = project_3d_pt(pt, cam_to_img)

        color = cv_colors.RED.value

        if constraint_idx is not None:
            color = constraint_to_color(constraint_idx)

        cv2.circle(img, (point[0], point[1]), 3, color, thickness=-1) 
開發者ID:skhadem,項目名稱:3D-BoundingBox,代碼行數:18,代碼來源:Plotting.py

示例8: annotate

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import circle [as 別名]
def annotate(self, img):
    # paint annotations on the image
    for i1 in range(len(self.kpus)):
      u1, v1 = int(round(self.kpus[i1][0])), int(round(self.kpus[i1][1]))
      if self.pts[i1] is not None:
        if len(self.pts[i1].frames) >= 5:
          cv2.circle(img, (u1, v1), color=(0,255,0), radius=3)
        else:
          cv2.circle(img, (u1, v1), color=(0,128,0), radius=3)
        # draw the trail
        pts = []
        lfid = None
        for f, idx in zip(self.pts[i1].frames[-9:][::-1], self.pts[i1].idxs[-9:][::-1]):
          if lfid is not None and lfid-1 != f.id:
            break
          pts.append(tuple(map(lambda x: int(round(x)), f.kpus[idx])))
          lfid = f.id
        if len(pts) >= 2:
          cv2.polylines(img, np.array([pts], dtype=np.int32), False, myjet[len(pts)]*255, thickness=1, lineType=16)
      else:
        cv2.circle(img, (u1, v1), color=(0,0,0), radius=3)
    return img


  # inverse of intrinsics matrix 
開發者ID:geohot,項目名稱:twitchslam,代碼行數:27,代碼來源:frame.py

示例9: load_shapes

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import circle [as 別名]
def load_shapes(self, count, height, width):
        """Generate the requested number of synthetic images.
        count: number of images to generate.
        height, width: the size of the generated images.
        """
        # Add classes
        self.add_class("shapes", 1, "square")
        self.add_class("shapes", 2, "circle")
        self.add_class("shapes", 3, "triangle")

        # Add images
        # Generate random specifications of images (i.e. color and
        # list of shapes sizes and locations). This is more compact than
        # actual images. Images are generated on the fly in load_image().
        for i in range(count):
            bg_color, shapes = self.random_image(height, width)
            self.add_image("shapes", image_id=i, path=None,
                           width=width, height=height,
                           bg_color=bg_color, shapes=shapes) 
開發者ID:dmechea,項目名稱:PanopticSegmentation,代碼行數:21,代碼來源:shapes.py

示例10: draw_shape

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import circle [as 別名]
def draw_shape(self, image, shape, dims, color):
        """Draws a shape from the given specs."""
        # Get the center x, y and the size s
        x, y, s = dims
        if shape == 'square':
            image = cv2.rectangle(image, (x - s, y - s),
                                  (x + s, y + s), color, -1)
        elif shape == "circle":
            image = cv2.circle(image, (x, y), s, color, -1)
        elif shape == "triangle":
            points = np.array([[(x, y - s),
                                (x - s / math.sin(math.radians(60)), y + s),
                                (x + s / math.sin(math.radians(60)), y + s),
                                ]], dtype=np.int32)
            image = cv2.fillPoly(image, points, color)
        return image 
開發者ID:dmechea,項目名稱:PanopticSegmentation,代碼行數:18,代碼來源:shapes.py

示例11: random_shape

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import circle [as 別名]
def random_shape(self, height, width):
        """Generates specifications of a random shape that lies within
        the given height and width boundaries.
        Returns a tuple of three valus:
        * The shape name (square, circle, ...)
        * Shape color: a tuple of 3 values, RGB.
        * Shape dimensions: A tuple of values that define the shape size
                            and location. Differs per shape type.
        """
        # Shape
        shape = random.choice(["square", "circle", "triangle"])
        # Color
        color = tuple([random.randint(0, 255) for _ in range(3)])
        # Center x, y
        buffer = 20
        y = random.randint(buffer, height - buffer - 1)
        x = random.randint(buffer, width - buffer - 1)
        # Size
        s = random.randint(buffer, height // 4)
        return shape, color, (x, y, s) 
開發者ID:dmechea,項目名稱:PanopticSegmentation,代碼行數:22,代碼來源:shapes.py

示例12: update

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import circle [as 別名]
def update(_=None):
    noise = cv2.getTrackbarPos('noise', 'fit line')
    n = cv2.getTrackbarPos('point n', 'fit line')
    r = cv2.getTrackbarPos('outlier %', 'fit line') / 100.0
    outn = int(n*r)

    p0, p1 = (90, 80), (w-90, h-80)
    img = np.zeros((h, w, 3), np.uint8)
    cv2.line(img, toint(p0), toint(p1), (0, 255, 0))

    if n > 0:
        line_points = sample_line(p0, p1, n-outn, noise)
        outliers = np.random.rand(outn, 2) * (w, h)
        points = np.vstack([line_points, outliers])
        for p in line_points:
            cv2.circle(img, toint(p), 2, (255, 255, 255), -1)
        for p in outliers:
            cv2.circle(img, toint(p), 2, (64, 64, 255), -1)
        func = getattr(cv2, cur_func_name)
        vx, vy, cx, cy = cv2.fitLine(np.float32(points), func, 0, 0.01, 0.01)
        cv2.line(img, (int(cx-vx*w), int(cy-vy*w)), (int(cx+vx*w), int(cy+vy*w)), (0, 0, 255))

    draw_str(img, (20, 20), cur_func_name)
    cv2.imshow('fit line', img) 
開發者ID:makelove,項目名稱:OpenCV-Python-Tutorial,代碼行數:26,代碼來源:fitline.py

示例13: drawMatch

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import circle [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

示例14: visualize_joints

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import circle [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

示例15: visualize_joints2

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import circle [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


注:本文中的cv2.circle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。