当前位置: 首页>>代码示例>>Python>>正文


Python tracker.Tracker类代码示例

本文整理汇总了Python中tracker.Tracker的典型用法代码示例。如果您正苦于以下问题:Python Tracker类的具体用法?Python Tracker怎么用?Python Tracker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Tracker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ObjectTracker

class ObjectTracker(OpenCVVideoFilter):
    __gstmetadata__ = (
        "Object tracker plugin",
        "newelement",
        "Description",
        "Contact")

    def __init__(self):
        super(ObjectTracker, self).__init__()
        self.tracker = Tracker([self.h, self.w])
        self.api = GstVideo.VideoRegionOfInterestMeta.get_info()

    def do_transform(self, b, outbuffer):
        img = self.gst_to_cv(b)
        ts = time.time()
        self.tracker.track(ts, img)
        tag_list = Gst.TagList.new_empty()
	
        for t in self.tracker.to_log():
            blob = t.bestblob()
            info = Gst.Structure.new_empty('roi')
            info.set_value('id', t.id)
            info.set_value('ts', ts)
            info.set_value('bbox', blob.bbox )
            sample = Gst.Sample.new(b, None, None, info)
            logging.debug('new tag with object track info for track %s',str(t.id))
            tag_list.add_value(Gst.TagMergeMode.APPEND, Gst.TAG_APPLICATION_DATA, sample)	
        if tag_list.n_tags()>0:
            outbuffer.add_meta(self.api, tag_list)
            self.post_message(Gst.Message.new_tag(self, tag_list))

        return Gst.FlowReturn.OK
开发者ID:MirichST,项目名称:patchcap,代码行数:32,代码来源:objecttracker.py

示例2: __init__

class Client:

    def __init__(self, config: ConfigurationFile):
        self.config = config
        self.database = Database(self.config.db_file)
        self.organizer = Organizer(self.config, self.config.db_file)
        self.downloader = Downloader(self.config.db_file, self.organizer,
                                     self.config)
        self.tracker = Tracker(self.config.db_file, self.downloader,
                               self.config.update_period)

        self.tracker.start()
        self.downloader.start()
        self.organizer.start()

    def add_tvshow(self, tvshow_id: int):
        tvshow_name = showrss.get_name(tvshow_id)
        self.database.put_tvshow(TVShow(tvshow_id, tvshow_name))

    def remove_tvshow(self, tvshow_id: int):
        self.database.remove_tvshow(tvshow_id)

    def list_tvshows(self):
        return self.database.tvshows()

    def list_episodes(self, state: EpisodeState = None):
        return self.database.episodes(state)

    def download_progress(self):
        return self.downloader.downloads()

    def exit(self):
        self.tracker.stop()
        self.downloader.stop()
开发者ID:davidfialho14,项目名称:showtracker,代码行数:34,代码来源:client.py

示例3: main

def main ():

    #Introduction
    print ("This program graphically depicts the flight of a cannonball. ")
    print ()

    #Get inputs
    a = eval(input("Enter the launch angle in degrees: "))
    v = eval(input("Enter the initial velocity in meters per second: "))
    h = eval(input("Enter the initial height in meters: "))

    #Create tracker
    projectile = Projectile(a, v, h)
    win = GraphWin(200, 200)
    win.setCoords(0.0, 0.0, 25.0, 25.0)
    tracker = Tracker(win, projectile)
    time = 0.0
    while projectile.getY() >= -5:
        time += .0005
        projectile.update(time)
        tracker.update()

    #Close window
    win.getMouse()
    win.close()
开发者ID:MichelleJaeg,项目名称:Exercises-from-Chapter-10,代码行数:25,代码来源:337.15.py

示例4: compute_gradient

def compute_gradient((model, dialog, n_data, )):
    print 'here'
    return 1
    tracker = Tracker(model)
    tracker.new_dialog()
    last_state = tracker.get_state()

    accum_loss_grad = []
    for shape in model.shapes:
        accum_loss_grad.append(np.zeros(shape, dtype=theano.config.floatX))

    total_loss = 0.0
    for act in dialog:
        act_ndx = model.acts[act]

        # Run tracker to get the new state and the true state.
        curr_state, true_state = tracker.next(act)

        # Compute the loss & gradient of the loss.
        val = [model.values[true_state[slot]] for slot in model.slots]

        total_loss += model.f_curr_slot_loss(curr_state, val)

        for param_loss_grad, accum in zip(model.loss_grads, accum_loss_grad):
            accum += 1.0 / n_data * param_loss_grad(last_state, act_ndx, val)

        last_state = curr_state

    return accum_loss_grad, total_loss
开发者ID:ticcky,项目名称:vspace,代码行数:29,代码来源:vspace1_computer.py

示例5: test_canConvertItemToType

 def test_canConvertItemToType(self):
     tracker = Tracker()
     contents = mock()
     timezone = mock()
     item = tracker._convertToItem(testType, contents, timezone )
     storedItem, storedTimezone = item.contains()
     self.assertEqual(storedItem, contents)
     self.assertEqual(storedTimezone, timezone)
开发者ID:lwoydziak,项目名称:pivotal-tracker-syncing,代码行数:8,代码来源:tracker_test.py

示例6: iterations_from_file

def iterations_from_file(config, filename):
    tracker = Tracker(dbdir=config.tracker.get('local_store_directory'))
    f = open(filename)
    contents = ''
    for l in f: contents += l
    f.close()
    iterations = tracker.parse_stories(contents)
    return iterations
开发者ID:esminc,项目名称:pivotal_visual,代码行数:8,代码来源:runner.py

示例7: beer_fitness

def beer_fitness(population):
    for p in population:
        #perform simulation
        points = []
        for i in range(10):
#            print p.ann
            t = Tracker(p.ann)
            points.append(t.run())
        p.fitness = sum(points)*1.0/len(points)*1.0
开发者ID:JohnArneOye,项目名称:it3708-subsym3,代码行数:9,代码来源:FitnessEval.py

示例8: main

def main ():

    #Introduction
    print ("This program uses a cannonball to shoot at a target.")

    #Create graphics window
    win = GraphWin(200, 200)
    win.setCoords(0.0, 0.0, 25.0, 25.0)
    target = Target(win)

    flag = False
    targetHit = False
    while not flag:

    #Get inputs
        print ()
        a = eval(input("Enter the launch angle in degrees: "))
        v = eval(input("Enter the initial velocity in meters per second: "))
        h = eval(input("Enter the initial height in meters: "))

    #Create tracker
        projectile = Projectile(a, v, h)
        tracker = Tracker(win, projectile)
        time = 0.0
        while projectile.getY() >= -5:
            time += .0005
            projectile.update(time)
            tracker.update()

    #Calculate if cannonball hit target
            points = target.points()
            center = tracker.circ.getCenter()
            center_x = center.getX()
            center_y = center.getY()
            radius = tracker.circ.getRadius()
            for point in points:
                x = point.getX()
                y = point.getY()
                square_dist = (center_x-x) ** 2 + (center_y-y) ** 2
                if square_dist <= radius ** 2:
                    targetHit = True
        if targetHit:
            print ("\nYou hit the target!")
            flag = True
        else:
            flag = False
            print ("\nTry again!")


    #Close window
    win.getMouse()
    win.close()
开发者ID:MichelleJaeg,项目名称:Exercises-from-Chapter-10,代码行数:52,代码来源:338.16.py

示例9: translate

 def translate(self, readline, result=None, no_imports=None):
     # Tracker to keep track of information as the file is processed
     self.tokens = Tokens(self.default_kls)
     self.tracker = Tracker(result, self.tokens, self.wrapped_setup)
     
     # Add import stuff at the top of the file
     if self.import_tokens and no_imports is not True:
         self.tracker.add_tokens(self.import_tokens)
     
     # Looking at all the tokens
     with self.tracker.add_phase() as tracker:
         for tokenum, value, (_, scol), _, _ in generate_tokens(readline):
             self.tracker.next_token(tokenum, value, scol)
     
     # Add attributes to our Describes so that the plugin can handle some nesting issues
     # Where we have tests in upper level describes being run in lower level describes
     if self.with_describe_attrs:
         self.tracker.add_tokens(self.tracker.make_describe_attrs())
     
     # If setups should be wrapped, then do this at the bottom
     if self.wrapped_setup:
         self.tracker.add_tokens(self.tracker.wrapped_setups())
     
     # Add lines to bottom of file to add __testname__ attributes
     self.tracker.add_tokens(self.tracker.make_method_names())
     
     # Return translated list of tokens
     return self.tracker.result
开发者ID:benauthor,项目名称:nose-of-yeti,代码行数:28,代码来源:tokeniser.py

示例10: linear_regression

def linear_regression(points):

    if Tracker.distance(points[0], meanPoint(points)) < 10:
        return [0, 1]

    num_pts = len(points)
    xc = points[:, [0]]
    yc = points[:, [1]]
    ones = np.ones((num_pts, 1))
    X = np.concatenate((ones, xc), axis=1)

    X_intermediary = np.dot(X.T, X)
    Y_intermediary = np.dot(X.T, yc)

    R = np.dot(inv(X_intermediary), Y_intermediary)

    k = R[1][0]
    last_2 = points[-2:]
    first_x = last_2[0][0]
    second_x = last_2[1][0]

    if first_x < second_x:
        return [1, k]
    else:
        return [-1, -k]
开发者ID:pbsinclair42,项目名称:SDP-2016,代码行数:25,代码来源:ball_trajectory.py

示例11: __init__

    def __init__(self, window):

        self.gwin = window

        self.projectile = Projectile(0, 0, 10)
        self.tracker = Tracker(self.gwin, self.projectile)
        self.target = Target(self.gwin)
        self.hits = False
开发者ID:AigarsG,项目名称:zelle,代码行数:8,代码来源:cannon.py

示例12: Torrent_Downloader

class Torrent_Downloader():
	''' Manages download logic:
		- Creation and removal of peers. 
		- Book keeping of pieces downloaded and in progress.
		- Checking completed pieces and writing to file.
	'''
	def __init__(self, torrent, start_listener_callback):
		self.torrent = torrent
		self.message_handler = MessageHandler(self.torrent, self)
		self.start_listener_callback = start_listener_callback
		self.ip = self.get_IP_address()
		self.tracker = Tracker(self.torrent.announce, self.torrent.get_params())
		self.peers = self.create_peers()
		self.io_loop = get_event_loop()
		self.index = 0
		self.callback_dict = {
			'check_piece' : self.torrent.check_piece_callback,
			'pieces_changed' : self.pieces_changed_callback,
			'start_listener' : self.start_listener_callback,
		}
		self.pieces_needed = []


	def get_IP_address(self):
		response = get('http://api.ipify.org?format=json')
		ip_object = loads(response.text)
		return ip_object["ip"]

	def create_peers(self):
		peers = []
		for p in self.tracker.parse_peer_address():
			if p[0] == self.ip:
				continue
			peers.append(Peer(p[0], p[1], self))
		return peers

	def pieces_changed_callback(self, peer):
		'''	Check if connected peer has pieces I need. Send interested message.
			Call choose_piece.
			If peer has no pieces I need, disconnect and remove from peers list.
		'''
		self.torrent.update_pieces_needed()
		for i in self.torrent.pieces_needed:
			if peer.has_pieces[i]:
				self.io_loop.create_task(self.message_handler.send_message(peer=peer, message_id=2))
				self.choose_piece(peer=peer)	
				break
			else:
				self.peers.remove(peer)

	def choose_piece(self, peer):
		'''	Finds the next needed piece, updates self.have and self.pieces_needed.
			calls construct_request_payload.
		'''
		piece_index = self.torrent.pieces_needed[0]
		self.torrent.have[piece_index] = True
		self.torrent.update_pieces_needed()
		self.message_handler.construct_request_payload(peer=peer, piece_index=piece_index)
开发者ID:TansyArron,项目名称:bittorrent,代码行数:58,代码来源:torrent_downloader.py

示例13: main

def main():
    file_location, download_dir = get_args()
    
    # parse the torrent file and make into an object
    torrentfile = TorrentFile(file_location)

    # create bittorrent client (brain behind everything)
    client = BitTorrentClient(download_dir, torrentfile)
    client.create_files()

    # create tracker and add it to the client
    tracker = Tracker(client.peer_id, torrentfile)
    client.add_tracker(tracker)

    # connect to the peers associated to the tracker
    tracker.get_peers_and_connect(client, torrentfile)
    
    reactor.run()
开发者ID:paulvstheworld,项目名称:pyttorrent,代码行数:18,代码来源:main.py

示例14: main

def main(ball):
    c = Camera()
    color = ball

    log.info("Ball: " + color)
    t = BallTracker(color)
    ballpos = None
    while ballpos is None:
        frame = c.get_frame()
        ballpos = t.getBallCoordinates(frame)
        ballpos = Tracker.transformCoordstoDecartes(ballpos)

    previous_positions = np.array([ballpos])

    k = 20
    while True:

        frame = c.get_frame()
        ballpos = t.getBallCoordinates(frame)
        log.debug(ballpos)

        if ballpos is None:
            continue
        ballpos = Tracker.transformCoordstoDecartes(ballpos)
        previous_positions = np.append(previous_positions, [ballpos], axis=0)

        last_k_positions = previous_positions[-k:]

        direction_vector = linear_regression(last_k_positions)
        direction_vector = [20 * x for x in direction_vector]

        p1 = Tracker.transformCoordstoCV(round_point(ballpos))
        p2 = Tracker.transformCoordstoCV(round_point(add_points(
            ballpos, direction_vector)))
        frame = cv2.circle(frame, p1, 20, (0, 0, 0), 2)
        cv2.line(frame, p1, p2, (0, 255, 122), 2)

        cv2.imshow('frame', frame)
        l = cv2.waitKey(5) & 0xFF
        if l == 27:
            break

    c.close()
    cv2.destroyAllWindows()
开发者ID:pbsinclair42,项目名称:SDP-2016,代码行数:44,代码来源:ball_trajectory.py

示例15: __init__

class Main:
    def __init__(self, trackerUrl, trackerPass):
        self.tracker = Tracker(trackerUrl, trackerPass)
    
    def packetHandler(self, aprsString):
        print 'APRS String: %s' % aprsString
        packet = APRSPacket()
        if packet.parse(aprsString):
            print '%s -> %s' % (packet.source, packet.dest)
            print 'Report type: %s' % packet.reportType
            if packet.hasLocation:
                print 'Time: %sZ' % packet.time
                print 'Coordinates: %f, %f, Altitude: %d ft' % (packet.latitude, packet.longitude, packet.altitude)
                print 'Course: %d, Speed: %d kn, Bearing: %d' % (packet.course, packet.speed, packet.bearing)
            print 'Comment: %s' % packet.comment
            
            print 'Uploading to tracker'
            self.tracker.track(packet)
            
            print ''
开发者ID:akarpenko,项目名称:APRS2Tracker,代码行数:20,代码来源:aprs2tracker.py


注:本文中的tracker.Tracker类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。