Пример #1
0
def showlive():
  global count, frames
  cv.NamedWindow('Depth')
  cv.NamedWindow('Video')
  cv.MoveWindow('Depth', 100, 100)
  cv.MoveWindow('Video', 745, 100)

  print('Press ESC in window to stop')
  print('Press Space to convert current to PLY')
  print('Press k to stop live capture')

  while 1:
      imgdepth = fc.depth_cv(freenect.sync_get_depth()[0])
      imgvideo = fc.video_cv(freenect.sync_get_video()[0])

      cv.ShowImage('Depth', imgdepth)
      cv.ShowImage('Video', imgvideo)

      inp = cv.WaitKey(100)

      if inp != -1:
        inp = chr(inp % 1048576)
        if inp == ' ': # space for capture and convert
          print 'capturing images'
          captureimage()
          print 'done capturing'
        elif inp.isdigit():
          frames = ord(inp) - ord('0')
          print 'setting the number of frames to capture to %d' % frames
        elif inp == 'k':
          break
      count = count + 1

  cv.DestroyWindow('Depth')
  cv.DestroyWindow('Video')
Пример #2
0
def captureimage():
  global frames

  depthframes = np.zeros((frames, rownum, colnum))
  rgbframes = np.zeros((frames, rownum, colnum, 3))

  for i in range(frames):
    depthframes[i] = freenect.sync_get_depth()[0]
    rgbframes[i] = freenect.sync_get_video()[0]
    arargb = freenect.sync_get_video()[0]
    time.sleep(0.05)

  arargb   = fc.robustavg(rgbframes)
  aradepth = fc.robustavg(depthframes)
  serial = time.time()

  cv.SaveImage('img/depth%d.png' % serial, fc.depth_cv(aradepth.astype(int)))
  cv.SaveImage('img/video%d.png' % serial, fc.video_cv(arargb.astype(np.uint8)))
  #f = open('poly/poly%d.ply' % serial,'w')
  
    
  meterdepth = fc.meter_depth(aradepth)
  #newrgb2 = fc.matchrgb2(meterdepth, arargb)
  newrgb = fc.matchrgb(meterdepth, arargb)
  
  #meterdepth = ndi.gaussian_filter(fc.meter_depth(aradepth), [sigma, sigma])
  
  meterdepth[meterdepth > 1.5] = -1.
  meterdepth[meterdepth < 0.5] = -1.
  scipy.io.savemat('data/aligned%d.mat' % serial, {'depth':meterdepth, 'rgb':newrgb})