コード例 #1
0
ファイル: dsgrab.py プロジェクト: droter/LettuceThink
def grab_images():
    im = DS.getColourMap()
    cv2.imwrite("%s/rgb.png"%(imdir), im)   
    
    im = DS.getDepthMap()
    cv2.imwrite("%s/depth.png"%(imdir), im)   

    im = DS.getConfidenceMap()
    cv2.imwrite("%s/confidence.png"%(imdir), im)   
    
    im = DS.getDepthColouredMap()
    cv2.imwrite("%s/rgbd.png"%(imdir), im)   
    
    im = DS.getGreyScaleMap()
    cv2.imwrite("%s/gscale.png"%(imdir), im)   
    
    im = DS.getSyncMap()
    np.save("%s/sync"%(imdir), im)   
    
    im = DS.getUVMap()
    np.save("%s/uv"%(imdir), im)   
    
    im = DS.getVertices()
    np.save("%s/vert"%(imdir), im)   
    return
コード例 #2
0
ファイル: ds325.py プロジェクト: Snkz/DepthSense-SimpleCV
    def getConvolvedImage(self, kern, rep, bias):
        ''' Return a simple cv compatiable 8bit greyscaled image that has had 
        the specified kernel applied rep times with bias supplied'''

        conv = ds.convolveColourMap(kern, rep, bias)
        iE = Image(conv.transpose())
        return iE.invert()
コード例 #3
0
ファイル: ds325.py プロジェクト: Snkz/DepthSense-SimpleCV
    def getSync(self):
        ''' Return a simplecv compatiable synced map with dimensions of the 
        depth map and colours from the colour map. Indexes here match indexes 
        in the vertex map '''

        sync = ds.getSyncMap()
        sync = sync[:,:,::-1]
        return Image(sync.transpose([1,0,2]))
コード例 #4
0
ファイル: ds325.py プロジェクト: AIWEBBOT/VIZ12a
    def getSync(self):
        ''' Return a simplecv compatiable synced map with dimensions of the 
        depth map and colours from the colour map. Indexes here match indexes 
        in the vertex map '''

        sync = ds.getSyncMap()
        sync = sync[:, :, ::-1]
        return Image(sync.transpose([1, 0, 2]))
コード例 #5
0
ファイル: ds325.py プロジェクト: Snkz/DepthSense-SimpleCV
    def getDepth(self):
        ''' Return a simple cv compatiable 8bit depth image '''

        depth = ds.getDepthMap()
        np.clip(depth, 0, 2**10 - 1, depth)
        depth >>=2
        depth = depth.astype(np.uint8)
        iD = Image(depth.transpose())
        return iD.invert()
コード例 #6
0
ファイル: ds325.py プロジェクト: AIWEBBOT/VIZ12a
    def getDepth(self):
        ''' Return a simple cv compatiable 8bit depth image '''

        depth = ds.getDepthMap()
        np.clip(depth, 0, 2**10 - 1, depth)
        depth >>= 2
        depth = depth.astype(np.uint8)
        iD = Image(depth.transpose())
        return iD.invert()
コード例 #7
0
def getframe(imdir, sfx):
    im = DS.getColourMap()
    cv2.imwrite("%s/rgb%s.png" % (imdir, sfx), im)
    #im=DS.getConfidenceMap()
    #cv2.imwrite("%s/confidence%s.png"%(imdir,sfx), im)
    #im=DS.getDepthColouredMap()
    #cv2.imwrite("%s/DepthColored%s.png"%(imdir,sfx), im)
    im = DS.getDepthMap()
    cv2.imwrite("%s/depth%s.png" % (imdir, sfx), im)
    #im=DS.getGreyScaleMap()
    #cv2.imwrite("%s/gscale%s.png"%(imdir,sfx), im)
    im = DS.getSyncMap()
    np.save("%s/sync%s" % (imdir, sfx), im)
    im = DS.getUVMap()
    np.save("%s/uv%s" % (imdir, sfx), im)
    im = DS.getVertices()
    np.save("%s/vert%s" % (imdir, sfx), im)
    return "OK"
コード例 #8
0
ファイル: ds325.py プロジェクト: Snkz/DepthSense-SimpleCV
    def getConvolvedDepth(self, kern, rep, bias):
        ''' Return a simple cv compatiable 8bit depth map that has had 
        the specified kernel applied rep times '''

        conv = ds.convolveDepthMap(kern, rep, bias)
        np.clip(conv, 0, 2**10 - 1, conv)
        conv >>=2
        conv = conv.astype(np.uint8)
        iE = Image(conv.transpose())
        return iE.invert()
コード例 #9
0
def get_confidenceMap():
    conf_mat = dsc.getConfidenceMap()
    conf_gray = conf_mat.copy()
    np.clip(conf_gray, 0, 2**10 - 1, conf_gray)
    conf_gray >>= 2
    conf_gray = conf_gray.astype(np.uint8)
    cmap = plt.get_cmap('jet_r')
    conf_col = cmap(conf_gray)
    conf_col = np.delete(conf_col, 3, 2)
    conf_col = cv2.resize(conf_col, (640, 480))
    conf_gray = cv2.resize(conf_gray, (640, 480))
    return conf_gray, conf_col
コード例 #10
0
def get_depthMap():
    depth_mat = dsc.getDepthMap()
    depth_mat[depth_mat > 30000] = 0
    depth_gray = depth_mat.copy()
    np.clip(depth_gray, 0, 2**10 - 1, depth_gray)
    depth_gray >>= 2
    depth_gray = depth_gray.astype(np.uint8)
    cmap = plt.get_cmap('jet_r')
    depth_col = cmap(depth_gray)
    depth_col = np.delete(depth_col, 3, 2)
    depth_col = cv2.resize(depth_col, (640, 480))
    depth_gray = cv2.resize(depth_gray, (640, 480))
    return depth_mat, depth_gray, depth_col
コード例 #11
0
ファイル: LettuceScan.py プロジェクト: droter/LettuceThink
def grab_images(imdir, i):
    im = DS.getColourMap()
    cv2.imwrite("%s/rgb-%03d.png"%(imdir,i), im)       

    im = DS.getDepthMap()
    cv2.imwrite("%s/depth-%03d.png"%(imdir,i), im)   

    im = DS.getConfidenceMap()
    cv2.imwrite("%s/confidence-%03d.png"%(imdir,i), im)   
     
    im = DS.getDepthColouredMap()
    cv2.imwrite("%s/rgbd-%03d.png"%(imdir,i), im)   
  
    im = DS.getGreyScaleMap()
    cv2.imwrite("%s/gscale-%03d.png"%(imdir,i), im)   
    
    im = DS.getSyncMap()
    print im.shape
    np.save("%s/sync-%03d"%(imdir,i), im)   
    
    im = DS.getUVMap()
    np.save("%s/uv-%03d"%(imdir,i), im)   

    im = DS.getVertices()
    np.save("%s/vert-%03d"%(imdir,i), im)   
    
    #subprocess.call(['python', dir_path + '/dsgrab.py'])
    """
            {"href": "static/img/confidence.png", "name": "Confidence levels (image)"},
            {"href": "static/img/rgbd.png", "name": "Coloured depth image"},
            {"href": "static/img/gscale.png", "name": "Grey-scale image"}
    """
    return [{"href": imdir+"/rgb-%03d.png"%i, "name": "RGB image"},
            {"href": imdir+"/depth-%03d.png"%i, "name": "Depth image"},
            {"href": imdir+"/confidence-%03d.png"%i, "name": "Confidence levels (image)"},
            {"href": imdir+"/rgbd-%03d.png"%i, "name": "Coloured depth image"},
            {"href": imdir+"/gscale-%03d.png"%i, "name": "Grey-scale image"}]
コード例 #12
0
ファイル: ds325.py プロジェクト: Snkz/DepthSense-SimpleCV
    def getVertexFP(self):
        ''' Return a floating point vertex map for points in the depth map as 
        a numpy array'''

        return ds.getVerticesFP()
コード例 #13
0
ファイル: ds325.py プロジェクト: AIWEBBOT/VIZ12a
    def getUV(self):
        ''' Return a uv map, the map represents a conversion from depth 
        indicies to scaled colour indicies from 0 - 1 '''

        return ds.getUVMap()
コード例 #14
0
ファイル: ds325.py プロジェクト: Snkz/DepthSense-SimpleCV
    def getVertex(self):
        ''' Return a vertex map for points in the depth map as a numpy array'''

        return ds.getVertices()
コード例 #15
0
def get_vertices():
    vertices_mat = dsc.getVertices()
    return vertices_mat
コード例 #16
0
#!/bin/python2

import DepthSense as ds
import numpy as np
import copy as copy
from SimpleCV import *
import sys
from time import sleep

ds.initDepthSense()
# disp = Display(flags = pg.FULLSCREEN)
# disp = Display()
points = []
squares = []


# Main loop closes only on keyboard kill signal
while True:

    # Get depth and colour images from the kinect
    # image = ds.getColourMap()
    # image = image[:,:,::-1]
    # img = Image(image.transpose([1,0,2]))

    depth = ds.getDepthMap()
    deepDepth = depth.transpose()  # later proccessing
    np.clip(depth, 0, 2 ** 10 - 1, depth)
    depth >>= 2
    depth = depth.astype(np.uint8).transpose()
    depth = Image(depth)
    depth = depth.invert()
コード例 #17
0
ファイル: ds325.py プロジェクト: Snkz/DepthSense-SimpleCV
    def getGreyScale(self):
        ''' Return a simple cv compatiable 8bit colour image ''' 

        grey = ds.getGreyScaleMap()
        return Image(grey.transpose())
コード例 #18
0
ファイル: ds325.py プロジェクト: Snkz/DepthSense-SimpleCV
    def getDepthColoured(self):
        ''' Return a simple cv compatiable 8bit colour image ''' 

        depthc = ds.getDepthColouredMap()
        #depthc = depthc[:,:,::-1]
        return Image(depthc.transpose([1,0,2]))
コード例 #19
0
ファイル: dsgrab.py プロジェクト: droter/LettuceThink
    im = DS.getDepthMap()
    cv2.imwrite("%s/depth.png"%(imdir), im)   

    im = DS.getConfidenceMap()
    cv2.imwrite("%s/confidence.png"%(imdir), im)   
    
    im = DS.getDepthColouredMap()
    cv2.imwrite("%s/rgbd.png"%(imdir), im)   
    
    im = DS.getGreyScaleMap()
    cv2.imwrite("%s/gscale.png"%(imdir), im)   
    
    im = DS.getSyncMap()
    np.save("%s/sync"%(imdir), im)   
    
    im = DS.getUVMap()
    np.save("%s/uv"%(imdir), im)   
    
    im = DS.getVertices()
    np.save("%s/vert"%(imdir), im)   
    return

imdir = "static/img"

ds = DS.initDepthSense()
time.sleep(4)
grab_images()
time.sleep(1)
grab_images()

コード例 #20
0
ファイル: test.py プロジェクト: meatcar/augmented-reality
#!/bin/python2

import DepthSense as ds
import numpy as np
from SimpleCV import *
c = 0
ds.initDepthSense()
while True:
    depth = ds.getDepthMap()
    np.clip(depth, 0, 2**10 - 1, depth)
    depth >>=2
    depth = depth.astype(np.uint8)
    iD = Image(depth.transpose())
    #iD.show()


    vertex = ds.getVertices()
    iV = Image(vertex.transpose([1,0,2]))
    #iV.show()


    image = ds.getColourMap()
    image = image[:,:,::-1]
    iS = Image(image.transpose([1,0,2]))
    #iS.show()

    #print ds.getAcceleration()

    uv = ds.getUVMap()

    sync = ds.getSyncMap()
コード例 #21
0
#!/bin/python2

import DepthSense as ds
import numpy as np
import copy as copy
from SimpleCV import *
import sys
from time import sleep

ds.initDepthSense()
#disp = Display(flags = pg.FULLSCREEN)
disp = Display()
points = []
squares = []

# Main loop closes only on keyboard kill signal
while True:

    # Get depth and colour images from the kinect
    image = ds.getColourMap()
    image = image[:, :, ::-1]
    img = Image(image.transpose([1, 0, 2]))

    depth = ds.getDepthMap()
    np.clip(depth, 0, 2**10 - 1, depth)
    depth >>= 2
    depth = depth.astype(np.uint8).transpose()
    depth = Image(depth)
    depth = depth.invert()

    #vertex = ds.getVertices()
コード例 #22
0
ファイル: ds325.py プロジェクト: Snkz/DepthSense-SimpleCV
    def getUV(self):
        ''' Return a uv map, the map represents a conversion from depth 
        indicies to scaled colour indicies from 0 - 1 '''

        return ds.getUVMap()
コード例 #23
0
ファイル: ds325.py プロジェクト: AIWEBBOT/VIZ12a
 def __init__(self, dim=[320, 240]):
     # TODO: Pass in dim to init (currently defaults to 640, 480 for camera)
     # TODO: Allow for enabling camera/depth/accel independantly
     ''' The maps returned by the ds mod are not transposed, the maps
     used '''
     ds.initDepthSense()
コード例 #24
0
ファイル: ds325.py プロジェクト: AIWEBBOT/VIZ12a
    def getSyncFull(self):
        ''' Return a colour synced depth map, like above indicies here work on
        both the depth map and vertex map '''

        return ds.getSyncMap()
コード例 #25
0
ファイル: ds325.py プロジェクト: AIWEBBOT/VIZ12a
    def getImage(self):
        ''' Return a simple cv compatiable 8bit colour image '''

        image = ds.getColourMap()
        image = image[:, :, ::-1]
        return Image(image.transpose([1, 0, 2]))
コード例 #26
0
ファイル: ds325.py プロジェクト: Snkz/DepthSense-SimpleCV
    def getImage(self):
        ''' Return a simple cv compatiable 8bit colour image ''' 

        image = ds.getColourMap()
        image = image[:,:,::-1]
        return Image(image.transpose([1,0,2]))
コード例 #27
0
def get_syncMap():
    sync = dsc.getSyncMap()
    sync_gray = cv2.cvtColor(sync, cv2.COLOR_BGR2GRAY)
    sync = cv2.resize(sync, (640, 480))
    sync_gray = cv2.resize(sync_gray, (640, 480))
    return sync, sync_gray
コード例 #28
0
ファイル: ds325.py プロジェクト: Snkz/DepthSense-SimpleCV
 def __init__(self, dim=[320,240]):
     # TODO: Pass in dim to init (currently defaults to 640, 480 for camera)
     # TODO: Allow for enabling camera/depth/accel independantly
     ''' The maps returned by the ds mod are not transposed, the maps
     used ''' 
     ds.initDepthSense()
コード例 #29
0
ファイル: ds325.py プロジェクト: AIWEBBOT/VIZ12a
    def getVertex(self):
        ''' Return a vertex map for points in the depth map as a numpy array'''

        return ds.getVertices()
コード例 #30
0
ファイル: ds325.py プロジェクト: rhythm92/augmented-reality
    def getDepthFull(self):
        """ Return the pure 16bit depth map as a numpy array """

        return ds.getDepthMap()
コード例 #31
0
ファイル: ds325.py プロジェクト: AIWEBBOT/VIZ12a
    def getDepthFull(self):
        ''' Return the pure 16bit depth map as a numpy array '''

        return ds.getDepthMap()
コード例 #32
0
ファイル: ds325.py プロジェクト: Snkz/DepthSense-SimpleCV
    def getAcceleration(self):
        ''' Return the current acceleration of the device (x,y,z) measured in 
        g force as a numpy array '''

        return ds.getAcceleration()
コード例 #33
0
ファイル: ds325.py プロジェクト: Snkz/DepthSense-SimpleCV
 def getDepthFull(self):
     ''' Return the pure 16bit depth map as a numpy array '''
      
     iD = ds.getDepthMap()
     return iD
コード例 #34
0
#!/bin/python2

import DepthSense as ds
import numpy as np
import copy as copy
from SimpleCV import *
import sys
from time import sleep

ds.initDepthSense()
#disp = Display(flags = pg.FULLSCREEN)
#disp = Display()
points = []
squares = []

# Main loop closes only on keyboard kill signal
while True:

    # Get depth and colour images from the kinect
    #image = ds.getColourMap()
    #image = image[:,:,::-1]
    #img = Image(image.transpose([1,0,2]))

    depth = ds.getDepthMap()
    deepDepth = depth.transpose()  # later proccessing
    np.clip(depth, 0, 2**10 - 1, depth)
    depth >>= 2
    depth = depth.astype(np.uint8).transpose()
    depth = Image(depth)
    depth = depth.invert()
コード例 #35
0
ファイル: ds325.py プロジェクト: Snkz/DepthSense-SimpleCV
    def getConvolvedDepthFull(self, kern, rep, bias):
        ''' Return a pure numpy array of the convolved in the depthmap ''' 

        iE = ds.convolveDepthMap(kern, rep, bias)
        return iE
コード例 #36
0
def get_colorMap():
    cim = dsc.getColourMap()
    cim_gray = cv2.cvtColor(cim, cv2.COLOR_BGR2GRAY)
    return cim, cim_gray
コード例 #37
0
ファイル: ds325.py プロジェクト: AIWEBBOT/VIZ12a
    def getAcceleration(self):
        ''' Return the current acceleration of the device (x,y,z) measured in 
        g force as a numpy array '''

        return ds.getAcceleration()
コード例 #38
0
ファイル: ds325.py プロジェクト: Snkz/DepthSense-SimpleCV
    def getSyncFull(self):
        ''' Return a colour synced depth map, like above indicies here work on
        both the depth map and vertex map '''

        return ds.getSyncMap()
コード例 #39
0
ファイル: ds325.py プロジェクト: Snkz/DepthSense-SimpleCV
    def saveMap(self, name, file_name):
        ''' Save the specified map to file file_name '''

        ds.saveMap(name, file_name);
        return
コード例 #40
0
#!/bin/python2

import DepthSense as ds
import numpy as np
import copy as copy
from SimpleCV import *
import sys
from time import sleep

ds.initDepthSense()
#disp = Display(flags = pg.FULLSCREEN)
disp = Display()
points = []
squares = []

# Main loop closes only on keyboard kill signal 
while True: 
 
    # Get depth and colour images from the kinect
    image = ds.getColourMap()
    image = image[:,:,::-1]
    img = Image(image.transpose([1,0,2]))
 
    depth = ds.getDepthMap()
    np.clip(depth, 0, 2**10 - 1, depth)
    depth >>=2
    depth = depth.astype(np.uint8).transpose()
    depth = Image(depth)
    depth = depth.invert()
 
    #vertex = ds.getVertices()
コード例 #41
0
    conf_gray = cv2.resize(conf_gray, (640, 480))
    return conf_gray, conf_col


#============================= GET COLOR FRAME =============================#
def get_colorMap():
    cim = dsc.getColourMap()
    cim_gray = cv2.cvtColor(cim, cv2.COLOR_BGR2GRAY)
    return cim, cim_gray


#============================= GET SYNC FRAME =============================#
def get_syncMap():
    sync = dsc.getSyncMap()
    sync_gray = cv2.cvtColor(sync, cv2.COLOR_BGR2GRAY)
    sync = cv2.resize(sync, (640, 480))
    sync_gray = cv2.resize(sync_gray, (640, 480))
    return sync, sync_gray


#============================= GET VERTICES MATRIX =============================#
def get_vertices():
    vertices_mat = dsc.getVertices()
    return vertices_mat


#============================= MAIN =============================#
dsc.start()
img_cap()
dsc.stop()