小编Rah*_*bub的帖子

检查列表是否是另一个与重复项一起使用的列表的轮换

我有这个函数来确定列表是否是另一个列表的轮换:

def isRotation(a,b):
  if len(a) != len(b):
    return False

  c=b*2
  i=0

  while a[0] != c[i]:
    i+=1

  for x in a:
    if x!= c[i]:
      return False
    i+=1

  return True
Run Code Online (Sandbox Code Playgroud)

例如

>>> a = [1,2,3]
>>> b = [2,3,1]
>>> isRotation(a, b)
True
Run Code Online (Sandbox Code Playgroud)

如何使用重复项进行此操作?例如

a = [3,1,2,3,4]
b = [3,4,3,1,2]
Run Code Online (Sandbox Code Playgroud)

它可以及时完成O(n)吗?

python arrays algorithm time-complexity

18
推荐指数
3
解决办法
5264
查看次数

尽管初始大小固定,但BoundingBox/ROI跟踪对象的大小仍在不断增加

我试图使用Media Flow Tracker根据区域跟踪我的手,但是一段时间后边界框会不断增加.它在前10秒左右正常工作.

这是一段代码片段:

def main():
display = SimpleCV.Display()
cam = Kinect()
ts = []
bb = None
img = cam.getDepth().flipHorizontal()
while display.isNotDone():
    depth = cam.getDepth().flipHorizontal()
    filtered = depth.stretch(0, 180).binarize().dilate(1)

    if bb is None:
        blobs = filtered.findBlobs()
        if blobs:
            hand = blobs.filter(abs(7000 - blobs.area()) < 500)
            print hand
            if hand:
                bb = hand[0].boundingBox()
                print bb
    if bb is not None:
        ts = filtered.track("mftrack", ts, img, bb)
        if ts:
            ts.drawBB()
            ts.showPixelVelocityRT()
            ts.drawPath()
    filtered.show()
Run Code Online (Sandbox Code Playgroud)

c++ python opencv kinect simplecv

9
推荐指数
1
解决办法
717
查看次数

标签 统计

python ×2

algorithm ×1

arrays ×1

c++ ×1

kinect ×1

opencv ×1

simplecv ×1

time-complexity ×1