def _unselected_cb(self, li, it): CList._unselected_cb(self, li, it) if not self._selected: if (len(self._items) > 1): self._options_edje.signal_emit("up,disable", "") self._options_edje.signal_emit("down,disable", "") self._options_edje.signal_emit("remove,disable", "")
def __init__(self, n=5): self.cam = scv.Kinect() #initialize meanvect self.meanvect = CList(n) for i in range(n): self.meanvect.push(self.getavg()) self.oldidx = -1 #old
class Walk(): def __init__(self, n=5): self.cam = scv.Kinect() #initialize meanvect self.meanvect = CList(n) for i in range(n): self.meanvect.push(self.getavg()) self.oldidx = -1 #old def getcam(self): return self.cam def getavg(self): dm=self.cam.getDepthMatrix() #Get depth and height h,w = dm.shape #h=480, w=640 left = dm[:, 0:w/3] #dm[:, 0:w/2] center = dm[:, w/3: 2*w/3]#dm[:, w/4:3*w/4] right = dm[:, 2*w/3:]#dm[:, w/2:] leftMean = np.sum(left)/left.size centerMean = np.sum(center)/center.size rightMean = np.sum(right)/right.size mean = np.sum(dm)/dm.size return np.array([mean, leftMean, centerMean, rightMean]) #return index of side to walk on; idxmap[index] equals direction to walk def walk(self,n=5): newidx = -1 smat = self.meanvect.getn(n=n) #sample matrix median = np.median(smat, axis=0) #print "median is {}".format(median) minidx = median.argmin() #backup if against a wall if median[dirmap["all"]] > 1900: newidx=dirmap["back"] #walk in center if walkable elif median[dirmap["center"]] <= 1100 or minidx == dirmap["center"]: newidx = dirmap["center"] else: #pick left or right based on whichever is cleaner newidx = minidx #store new sample mean=self.getavg() self.meanvect.push(mean) #print "{} {}".format(newidx, self.oldidx) if newidx != self.oldidx: self.oldidx=newidx return newidx else: return -1
class Walk(): def __init__(self, n=5): self.cam = scv.Kinect() #initialize meanvect self.meanvect = CList(n) for i in range(n): self.meanvect.push(self.getavg()) self.oldidx = -1 #old def getcam(self): return self.cam def getavg(self): dm = self.cam.getDepthMatrix() #Get depth and height h, w = dm.shape #h=480, w=640 left = dm[:, 0:w / 3] #dm[:, 0:w/2] center = dm[:, w / 3:2 * w / 3] #dm[:, w/4:3*w/4] right = dm[:, 2 * w / 3:] #dm[:, w/2:] leftMean = np.sum(left) / left.size centerMean = np.sum(center) / center.size rightMean = np.sum(right) / right.size mean = np.sum(dm) / dm.size return np.array([mean, leftMean, centerMean, rightMean]) #return index of side to walk on; idxmap[index] equals direction to walk def walk(self, n=5): newidx = -1 smat = self.meanvect.getn(n=n) #sample matrix median = np.median(smat, axis=0) #print "median is {}".format(median) minidx = median.argmin() #backup if against a wall if median[dirmap["all"]] > 1900: newidx = dirmap["back"] #walk in center if walkable elif median[dirmap["center"]] <= 1100 or minidx == dirmap["center"]: newidx = dirmap["center"] else: #pick left or right based on whichever is cleaner newidx = minidx #store new sample mean = self.getavg() self.meanvect.push(mean) #print "{} {}".format(newidx, self.oldidx) if newidx != self.oldidx: self.oldidx = newidx return newidx else: return -1
def _selected_cb(self, list_, list_item): CList._selected_cb(self, list_, list_item) name = list_item.label_get() self._edit_grp.part.name = name if (len(self._items) > 1): self._options_edje.signal_emit("up,enable", "") self._options_edje.signal_emit("down,enable", "") self._options_edje.signal_emit("remove,enable", "")
def _selected_cb(self, list_, list_item): if not self._edit_grp.animation.name: return part_name = list_item.label_get() if self._edit_grp.animation.parts.get(part_name): CList._selected_cb(self, list_, list_item) self._edit_grp.part.name = part_name else: self._edit_grp.part.name = None CList._unselected_cb(self, list_, list_item)
def __init__(self, parent, editable_grp, new_sig_cb, sigs_list_cb, operation_stack_cb): CList.__init__(self, parent) self._edit_grp = editable_grp self._new_sig_cb = new_sig_cb self._sigs_list_cb = sigs_list_cb self._operation_stack_cb = operation_stack_cb self._options_load() self.options = True self._edit_grp.callback_add("signals.changed", self._signals_update) self._edit_grp.callback_add("signal.added", self._signal_added) self._edit_grp.callback_add("signal.removed", self._signal_removed) self._edit_grp.signal.callback_add("program.changed", self._signal_changed) self._edit_grp.signal.callback_add("program.unselected", self._signal_changed) self._edit_grp.signal.callback_add("program.name.changed", self._name_changed_cb)
def __init__(self, parent, new_anim_cb, anims_list_cb, parts_list_cb, op_stack_cb): CList.__init__(self, parent) self._edit_grp = parent.e self._new_anim_cb = new_anim_cb self._anims_list_cb = anims_list_cb self._parts_list_cb = parts_list_cb self._operation_stack_cb = op_stack_cb self._options_load() self.options = True self._edit_grp.callback_add("animations.changed", self._animations_update) self._edit_grp.callback_add("animation.added", self._animation_added) self._edit_grp.callback_add("animation.removed", self._animation_removed) self._edit_grp.animation.callback_add("animation.changed", self._animation_changed) self._edit_grp.animation.callback_add("animation.unselected", self._animation_changed)
def __init__(self, parent, editable_grp, operation_stack_cb, img_new_img_cb=None, img_list_get_cb=None, img_id_get_cb=None, workfile_name_get_cb=None): CList.__init__(self, parent) self._edit_grp = editable_grp self._operation_stack_cb = operation_stack_cb self._new_img_cb = img_new_img_cb self._img_list_get_cb = img_list_get_cb self._img_id_get_cb = img_id_get_cb self._workfile_name_get_cb = workfile_name_get_cb self._options_load() self._edit_grp.callback_add("parts.changed", self._parts_update_cb) self._edit_grp.callback_add("part.added", self._part_added_cb) self._edit_grp.callback_add("part.removed", self._part_removed_cb) self._edit_grp.part.callback_add("part.changed", self._part_changed_cb) self._edit_grp.part.callback_add( "part.unselected", self._part_changed_cb) self._edit_grp.part.callback_add("name.changed", self._name_changed_cb)
def __init__(self, parent, new_anim_cb, anims_list_cb, parts_list_cb, op_stack_cb): CList.__init__(self, parent) self._edit_grp = parent.e self._new_anim_cb = new_anim_cb self._anims_list_cb = anims_list_cb self._parts_list_cb = parts_list_cb self._operation_stack_cb = op_stack_cb self._options_load() self.options = True self._edit_grp.callback_add( "animations.changed", self._animations_update) self._edit_grp.callback_add( "animation.added", self._animation_added) self._edit_grp.callback_add( "animation.removed", self._animation_removed) self._edit_grp.animation.callback_add( "animation.changed", self._animation_changed) self._edit_grp.animation.callback_add( "animation.unselected", self._animation_changed)
class ListTests(unittest.TestCase): def setUp(self): self._list = CList() def test_push(self): self.assertEqual(self._list.size, 0) self._list.push(1) self.assertEqual(self._list.size, 1) def test_pop(self): self.assertEqual(self._list.size, 0) self.assertEqual(self._list.pop(), (0, False)) self._list.push(10) self.assertEqual(self._list.size, 1) self.assertEqual(self._list.pop(), (10, True)) self.assertEqual(self._list.size, 0)
def _unselected_cb(self, li, it): CList._unselected_cb(self, li, it) if not self._selected: self._options_edje.signal_emit("remove,disable", "")
def _selected_cb(self, li, it): CList._selected_cb(self, li, it) name = it.label_get() self._edit_grp.animation.name = name self._options_edje.signal_emit("remove,enable", "")
def __str__(self): c = CList(self.constants) l = CList(self.links) return "({0},{1},{2})".format(self.mode, c.toTypedString('c'), l.toTypedString('l'))
def setUp(self): self._list = CList()
def _selected_cb(self, li, it): CList._selected_cb(self, li, it) name = it.label_get() self._edit_grp.signal.name = name self._options_edje.signal_emit("remove,enable", "")
from clist import CList if __name__ == '__main__': s = CList() s.insert('pear') s.insert('cherry') s.insert('orange') s.insert('apple') s.print_list() print('s의 길이 =', s.no_items()) print('s의 첫항목 =', s.first()) s.delete() print("첫 노드 삭제 후: ", end='') s.print_list() print('s의 길이 =', s.no_items()) print('s의 첫항목 =', s.first()) s.delete() print("첫 노드 삭제 후: ", end='') s.print_list() s.delete() print('첫 노드 삭제 후: ', end='') s.print_list() s.delete() print('첫 노드 삭제 후: ', end='') s.print_list()