(self, com, size=(250, 250, 250), dsize=(128, 128), doHandSize=True)
Detect the hand as closest object to camera
        :param size: bounding box size
        :return: center of mass of hand
Detect the hand as closest object to camera
        :param size: bounding box size
        :return: center of mass of hand
Detect the hand as closest object to camera : param size : bounding box size : return : center of mass of hand
def track(self, com, size=(250, 250, 250), dsize=(128, 128), doHandSize=True):
        """
        Detect the hand as closest object to camera
        :param size: bounding box size
        :return: center of mass of hand
        """

        # calculate boundaries
        xstart, xend, ystart, yend, zstart, zend = self.comToBounds(com, size)

        # crop patch from source
        cropped = self.getCrop(self.dpt, xstart, xend, ystart, yend, zstart, zend)

        # predict movement of CoM
        if self.refineNet is not None and self.importer is not None:
            rz = self.resizeCrop(cropped, dsize)
            newCom3D = self.refineCoM(rz, size, com) + self.importer.jointImgTo3D(com)
            com = self.importer.joint3DToImg(newCom3D)
            if numpy.allclose(com, 0.):
                com[2] = cropped[cropped.shape[0]//2, cropped.shape[1]//2]
        else:
            raise RuntimeError("Need refineNet for this")

        if doHandSize is True:
            # refined contour for size estimation
            zstart = com[2] - size[2] / 2.
            zend = com[2] + size[2] / 2.
            part_ref = self.dpt.copy()
            part_ref[part_ref < zstart] = 0
            part_ref[part_ref > zend] = 0
            part_ref[part_ref != 0] = 10  # set to something
            ret, thresh_ref = cv2.threshold(part_ref, 1, 255, cv2.THRESH_BINARY)
            contours_ref, _ = cv2.findContours(thresh_ref.astype(dtype=numpy.uint8), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
            # find the largest contour
            areas = [cv2.contourArea(cc) for cc in contours_ref]
            c_max = numpy.argmax(areas)

            # final result
            return com, self.estimateHandsize(contours_ref[c_max], com, size)
        else:
            return com, size
def track ( self , com , size = ( 250 , 250 , 250 ) , dsize = ( 128 , 128 ) , doHandSize = True ) : # calculate boundaries xstart , xend , ystart , yend , zstart , zend = self . comToBounds ( com , size ) # crop patch from source cropped = self . getCrop ( self . dpt , xstart , xend , ystart , yend , zstart , zend ) # predict movement of CoM if self . refineNet is not None and self . importer is not None : rz = self . resizeCrop ( cropped , dsize ) newCom3D = self . refineCoM ( rz , size , com ) + self . importer . jointImgTo3D ( com ) com = self . importer . joint3DToImg ( newCom3D ) if numpy . allclose ( com , 0. ) : com [ 2 ] = cropped [ cropped . shape [ 0 ] // 2 , cropped . shape [ 1 ] // 2 ] else : raise RuntimeError ( "Need refineNet for this" ) if doHandSize is True : # refined contour for size estimation zstart = com [ 2 ] - size [ 2 ] / 2. zend = com [ 2 ] + size [ 2 ] / 2. part_ref = self . dpt . copy ( ) part_ref [ part_ref < zstart ] = 0 part_ref [ part_ref > zend ] = 0 part_ref [ part_ref != 0 ] = 10 # set to something ret , thresh_ref = cv2 . threshold ( part_ref , 1 , 255 , cv2 . THRESH_BINARY ) contours_ref , _ = cv2 . findContours ( thresh_ref . astype ( dtype = numpy . uint8 ) , cv2 . RETR_TREE , cv2 . CHAIN_APPROX_SIMPLE ) # find the largest contour areas = [ cv2 . contourArea ( cc ) for cc in contours_ref ] c_max = numpy . argmax ( areas ) # final result return com , self . estimateHandsize ( contours_ref [ c_max ] , com , size ) else : return com , size