示例#1
0
    def draw(self, image):

        def draw_thumb(poly):
            line = Curve([poly.center, self.thumb_point])
            line.draw(image, constants.COLOR_GREEN, close=False, circle=True)

        def draw_extra(our_poly):
            self.in_defects.draw_points(image, constants.COLOR_PURPLE,
                                        size=constants.SMALL_CIRCLE_SIZE, label=True)
                                        #size=constants.SMALL_CIRCLE_SIZE)

            #self.out_defects.draw_points(image, constants.COLOR_YELLOW,
            #                             size=constants.TINY_CIRCLE_SIZE)
            #our_poly.draw_points(image, constants.COLOR_WHITE, label=True)
            our_poly.draw_points(image, constants.COLOR_WHITE, label=True, offset=-20)
            #our_poly.draw_points(image, constants.COLOR_WHITE)

        if constants.HAND_DRAW[Finger.MAJOR]:
            draw_extra(self.onion_geometry[constants.GEO_POLY].poly_curve)

        if constants.HAND_DRAW[Finger.WRIST] and self.fingers is not None:
            self.fingers[Finger.WRIST].draw(image, constants.COLOR_YELLOW)

        if constants.HAND_DRAW[Finger.THUMB]:
            draw_thumb(self.onion_geometry[constants.GEO_POLY])

        if constants.HAND_DRAW[Finger.INDEX] and self.fingers is not None:
            Finger.draw_all(image, self.fingers)
示例#2
0
def Gripper(parentNode=None):
    selfNode = parentNode.createChild("Gripper")

    f1 = Finger(selfNode,
                "Finger1",
                rotation=[0, 0, 105],
                translation=[20.0, 0.0, 0.0],
                fixingBox=[-20, -10, 0, 20, 10, 15],
                pullPointLocation=[3, 10.5, 3])

    f2 = Finger(selfNode,
                "Finger2",
                rotation=[180, 0, 65],
                translation=[-10.0, 0.0, -4.0],
                fixingBox=[-20, -10, -30, 20, 10, 0],
                pullPointLocation=[3, 10.5, -7])

    f3 = Finger(selfNode,
                "Finger3",
                rotation=[180, 0, 65],
                translation=[-10.0, 0.0, 34.0],
                fixingBox=[-20, -10, 0, 20, 10, 50],
                pullPointLocation=[3, 10.5, 31.5])

    GripperController(selfNode, [f1, f2, f3])

    return selfNode
示例#3
0
def Gripper(parentNode=None):
    gripper = Node(parentNode, "Gripper")

    #### YOU NEED TO PUT THE GRIPPER CONTENT HERE.
    f1 = Finger(gripper)
    f2 = Finger(gripper)
    f3 = Finger(gripper)

    GripperController(gripper, fingers=[f1, f2, f3])

    return gripper
示例#4
0
 def init_finger_table_start(self, M, maxId, existing_node):
     if property.DEBUG:
         print "Initialising finger table for node " + str(
             self.nodeId) + " with M=" + str(M)
     for i in range(1, M + 1):
         fingr = Finger(self, M, i, maxId, existing_node)
         self.fingerTable[i] = fingr
     #self.M = M
     if property.DEBUG:
         print "Finger table initilization for node " + str(
             self.nodeId) + " completed."
示例#5
0
    def print_angles_report(self):
        """

        :return:
        """
        #defect_pts = Finger.get_defect_pts(self.fingers)
        finger_tips = Finger.get_finger_tips(self.fingers)

        axis = Vector(self.fingers[Finger.WRIST].palm_pt2, self.fingers[Finger.WRIST].tip)
        print self.get_angles_table(finger_tips, self.fingers[Finger.WRIST].tip, axis)

        print Hand.TABLE
示例#6
0
    def init_finger_table(self) -> None:
        for i in range(self.n.bit_length() - 1):
            finger_entry: int = (self.node_id + 2**i) % self.n

            successor_id: int = finger_entry + 1
            finger_port: int = (self.port - self.node_id + finger_entry)
            finger: Finger = Finger(
                start=finger_entry,
                interval=(finger_entry, finger_entry + 1),
                node_id=successor_id,
                port=finger_port
            )
            self.finger_table[finger_entry] = finger
示例#7
0
def combine_2(a_finger, b_finger, c, debug=False):
    # Create new finger (in case of mutation)
    # If neither exist:
    #	If mutation:
    #		return mutation
    # If both exist:
    #	flip coin and return one of them
    # If a exists:
    #	return a
    # Else:
    #	return b
    #print(a_finger,b_finger)
    if a_finger is None and b_finger is None:
        if mutate():
            if debug:
                print('Finger was added through mutation')
            return Finger()
        return None
    if mutate():
        if debug:
            print("Finger {} was mutated".format(c + 1))
        return Finger()
    if a_finger is not None and b_finger is not None:
        if np.random.uniform() < .5:
            if debug:
                print("Finger {} was selected from A".format(c + 1))
            return a_finger
        else:
            if debug:
                print("Finger {} was selected from B".format(c + 1))
            return b_finger
    if a_finger is not None:
        if debug:
            print("Finger {} was selected from A".format(c + 1))
        return a_finger
    if debug:
        print("Finger {} was selected from B".format(c + 1))
    return b_finger
示例#8
0
 def __init__(self, fingers=None):
     dist_covered = 0
     if fingers is None:
         self.fingers = []
         for i in range(np.random.randint(1, 5)):
             finger = Finger(dist_covered=dist_covered)
             self.fingers.append(finger)
             if i != 0:
                 dist_covered += finger.increment
     else:
         self.fingers = fingers
     if len(self.fingers) > 0:
         self.start_fret = self.fingers[0].start_fret
     else:
         self.start_fret = 0
     self.fitness = float('inf')
     self.alive = True
     self.subplot = None
示例#9
0
    def __init__(self, img, g, shape):
        #  local import due to circular dependencies
        from silhouette import Silhouette

        self.image = img
        self.onion_geometry = g

        #TODO
        # work on OPENED, CLOSED, partial to correct finger!
        # refine Thumb, Wrist make them work together, no duplicate code
        #   Robust Algo
        self.shape = shape
        #print self.onion_geometry[constants.GEO_BBOX].__str__()
        if Hand.PREVIOUS_PROMPT is None:
            print "First prompt"
            Hand.set_wrist_delta_y(self.onion_geometry[constants.GEO_BBOX])

        self.thumb_left, self.thumb_point = Hand.find_thumb(self.onion_geometry)
        self.wrist_pt1, self.wrist_pt2 = self.find_wrist(self.onion_geometry[constants.GEO_HULL])

        #  produce two Curve objects. GEO_POLY not enough points?
        self.in_defects, self.out_defects = \
            Silhouette.get_defect_pts(self.onion_geometry[constants.GEO_CONTOUR], self.shape) #.curve)

#       self.in_defects.draw_points(self.image, constants.COLOR_GREEN, size=constants.BIG_CIRCLE_SIZE)

        # make our main CURVE object for the fingers, self.in_defects is CHANGED to have
        # near points of the curve be exactly the same
        # TODO: add points in ref if two in_defects in a row
        self.onion_geometry[constants.GEO_POLY].create_poly_curve(self.in_defects, self.wrist_pt1,
                                                                  self.wrist_pt2, self.thumb_point)

        #print "first", self.onion_geometry[constants.GEO_POLY].poly_curve
        # reorientation of POLY and self.in_defects
        #self.onion_geometry[constants.GEO_POLY].poly_curve = self.align_points_wrt_wrist()
        #print "second", self.onion_geometry[constants.GEO_POLY].poly_curve

        self.remove_extra_points()
        self.fingers = Finger.create_fingers(self.onion_geometry[constants.GEO_POLY].poly_curve)

        self.print_angles_report()
示例#10
0
文件: arsenic.py 项目: nealey/firebot
 def finger(self, sender, forum, addl, match):
     command = 'finger'
     argstr = match.group('args')
     Finger(('finger.lanl.gov', 79), argstr,
            lambda l: self.proc_cb('%s: ' % command, sender, forum, l, 0))
示例#11
0
        if '.txt' in file:
            txtfiles.append(os.path.join(r, file))
mylines = []
metaDataList = []
txtfiles_length = len(txtfiles)
for i in range(txtfiles_length):
    with open(txtfiles[i], 'rt') as myfile:
        for myline in myfile:
            mylines.append(myline.rstrip('\n'))
        metaDataLine = fingerMetadata(mylines[0][8:9], mylines[1][7:9],
                                      mylines[2][9:33])
        metaDataList.append(metaDataLine)
        mylines.clear()
dactList = []
for idx, onePic in enumerate(pngfiles):
    nFinger = Finger(onePic, metaDataList[idx].gender,
                     metaDataList[idx].typeclass, metaDataList[idx].history)
    dactList.append(nFinger)

# for i in range(9):
#     pyplot.subplot(330 + 1 + i)
#     filename = dactList[i].pic
#     image = imread(filename)
#     pyplot.imshow(image)
# pyplot.show()

# script to create test and train subdirectories with copies from dataset for the flow_from_directory API
# dataset_home = 'C:/FingerprintCNN/API_dataset_NISTDB4/'
# subdirs = ['train/', 'test/']
# for subdir in subdirs:
#     labeldirs = ['A', 'L', 'R', 'T', 'W']
#     for labldir in labeldirs:
示例#12
0
#!/usr/bin/env python
import rospy
from std_msgs.msg import Int32
from finger import Finger

a=Finger()

def callback(data):
    rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.data)
    randno=int(data.data)

    if randno == 1:
        a.rock()
    elif randno == 2:
        a.paper()
    else:
        a.scissors()    
    a.end()


def finalresult(data):
    rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.data)
    randno=int(data.data)

    if randno == 1:
        file='/home/pi/hand/win.json'
    elif randno == 2:
        file='/home/pi/hand/lose.json'
    elif randno ==3:
        file='/home/pi/hand/tie.json'
    else:
示例#13
0
			evolution_step(step, pop, fitnesses,
			 save_best=True, display_chords=display_chords,
			 console_prints=False)
			
	else:
		step = 0
		while patient(fitnesses, monitor='mean'):
			plt.clf()
			evolution_step(step, pop, fitnesses,
			 save_best=True, display_chords=display_chords,
			 console_prints=False)
			step+=1

if __name__ == "__main__":
	# Defining master chord
	f1 = Finger(string=2, technique='Single_Note', start_fret=1)
	f2 = Finger(string=4, technique='Single_Note', increment=1)
	f3 = Finger(string=5, technique='Single_Note_Mute_Above', increment=1)
	#f4 = Finger(string=1, technique='Single_Note', increment=3)
	master_chord = Chord(fingers=[f1,f2,f3])
	master_frequencies = Guitar.frequency_list(master_chord.read())
	master_chord.plot()
	plt.title('Master Chord')
	plt.show()
	#master_frequencies = q_transform.analyze('./tmp/target.wav', plot_q_transform=True, debug=True)
	print('Master frequencies:',master_frequencies)
	print('Showing {0}% of organisms in the population'.format(MAX_SHOW_SIZE/MAX_POP_SIZE*100))
	
	# Initializing the population randomly
	f, axs = plt.subplots(n_rows, n_cols, sharex=True)
	#f.tight_layout(pad=1.0)