コード例 #1
0
ファイル: Detect.py プロジェクト: davidsoncolin/IMS
def detect_dots_with_box(data, pixel_threshold, opts, x1, y1, x2, y2):
    """
	Extract the dots from data contained in a single frame. The detected dots are then filtered based on
	the min/max dot size, circularity, etc.
	"""
    min_min, max_max = 2, opts['max_dot_size'] * 2

    if isinstance(pixel_threshold, tuple) and len(pixel_threshold) == 3:
        dots = ISCV.detect_bright_dots(data, pixel_threshold[0],
                                       pixel_threshold[1], pixel_threshold[2],
                                       x1, y1, x2, y2)
    else:
        dots = ISCV.detect_bright_dots(data, pixel_threshold, pixel_threshold,
                                       pixel_threshold, x1, y1, x2, y2)

    min_ds, max_ds, circ = opts['min_dot_size']**4, opts[
        'max_dot_size']**4, opts['circularity_threshold']**2
    filtered_dots = [
        dot for dot in dots
        if (dot.x1 - dot.x0 + dot.y1 -
            dot.y0) > min_min and (dot.x1 - dot.x0 + dot.y1 - dot.y0) < max_max
        and (dot.sxx * dot.syy) > min_ds and (dot.sxx * dot.syy) < max_ds
        and dot.sxx < circ * dot.syy and dot.syy < circ * dot.sxx
    ]

    height, width, chans = data.shape
    psc = np.array([2.0 / width, -2.0 / width], dtype=np.float32)
    pof = np.array([-1.0, height / float(width)], dtype=np.float32)

    dotScreenCoords = np.array([[dot.sx, dot.sy] for dot in filtered_dots],
                               dtype=np.float32).reshape(-1, 2) * psc + pof

    return filtered_dots, dotScreenCoords
コード例 #2
0
ファイル: TestSkel.py プロジェクト: davidsoncolin/IMS
def setFrame(newFrame):
    global frame, view, allSkels, points, joints, bones
    frame = newFrame
    for Gs3, Ls3, skelDict3, animData3, skel3 in allSkels:
        dofs3 = animData3[frame % len(animData3)]
        Gs3 = ASFReader.pose_skeleton(Gs3, Ls3, skelDict3['jointParents'],
                                      skelDict3['jointDofs'],
                                      skelDict3['dofSplits'], dofs3)
        skel3.vertices[:] = Gs3[:, :, 3]

    global md, img, g_detectingDots, g_readingMovie
    if g_readingMovie and md is not None:
        try:
            MovieReader.readFrame(md, seekFrame=(frame - videoFrameOffset) / 4)
        except:
            frame = videoFrameOffset
            MovieReader.readFrame(md, seekFrame=(frame - videoFrameOffset) / 4)
        if g_detectingDots:
            ret = ISCV.detect_bright_dots(img, 254, 200, 190)
            good = [
                r for r in ret
                if min(r.sxx, r.syy) > 0.1 and min(r.sxx, r.syy) < 100.0
            ]  # and r.sxy*r.sxy<=0.01*r.sxx*r.syy]
            print len(good), 'good points'
            for r in good:
                #print r.sx,r.sy,r.sxx,r.sxy,r.syy
                img[int(r.sy - 5):int(r.sy + 5),
                    int(r.sx - 5):int(r.sx + 5), :] = [0, 255, 0]
        view.refreshImageData()
    global animJoints, stablePointsGroups, displayFrames, groupRepresentatives
    pfr = np.searchsorted(goodFrames, frame)
    points.vertices = displayFrames[pfr % len(displayFrames)]
    if animJoints is not None:
        joints.vertices[:] = animJoints[pfr % len(animJoints)]
    bones.vertices[::2] = joints.vertices
    bones.vertices[1::2] = points.vertices[
        groupRepresentatives[stablePointsGroups]]

    view.updateGL()