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


Python Target.calculate_gps方法代码示例

本文整理汇总了Python中Target.calculate_gps方法的典型用法代码示例。如果您正苦于以下问题:Python Target.calculate_gps方法的具体用法?Python Target.calculate_gps怎么用?Python Target.calculate_gps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Target的用法示例。


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

示例1: __init__

# 需要导入模块: import Target [as 别名]
# 或者: from Target import calculate_gps [as 别名]

#.........这里部分代码省略.........
        self.segment_size = 250

    def set_for_redownload(self):
        """reset crop properties for redownloading"""
        self.completed = False
        self.inqueue = False
        self.segments_downloaded = 0
        self.segments_total = 0
        self.size = 0
        self.target = None

    def set_for_manual(self):
        """set crop to be completed for manually picture dragging"""
        self.available = True
        self.completed = True
        self.segments_downloaded = 1
        self.segments_total = 1
        self.size = self.segment_size
        
    def calculate_total_segments(self):
        self.segments_total = math.ceil(float(self.size)/float(self.segment_size))  
        
    def total_segments(self):
        return math.ceil(float(self.size)/float(self.segment_size))
        
    def save_segment(self, segment_data, segment_num):
        
        #make sure the file exists
        fout = open(self.path, 'a')
        fout.close()
        
        #save the data (you can't use seek with 'a')
        fout = open(self.path, 'r+')
        fout.seek(segment_num * self.segment_size)
        fout.write(segment_data)
        fout.truncate(fout.tell())
        fout.close()
        
        #update info
        self.segments_downloaded = self.segments_downloaded + 1;
        
    def get_percent_complete(self):
        if self.total_segments() == 0:
            return 0
        else:
            percent_complete = \
                math.floor( (self.segments_downloaded*100) / (self.total_segments()) )
            return percent_complete
        
    def calculate_real_coordinates(self, crop_x, crop_y):
        """ takes the actual coordinates on the crop and returns the
            correspondin coordinates on the full size image"""
        real_x = int((self.x_offset + crop_x) * (self.picture.x_resolution / self.picture.x_thumbnail_resolution))
        real_y = int((self.y_offset + crop_y) * (self.picture.y_resolution / self.picture.y_thumbnail_resolution))
        return (real_x, real_y)
    
    def set_target(self, crop_x, crop_y):
        self.target = Target(self)
        
        # need these for rendering the target
        self.target.x_coord = crop_x
        self.target.y_coord = crop_y
        
        # need this stuff for calculating latitude and longitude
        # * needs pitch, yaw, roll, pan, tilt from picture, etc.
        gps_x = float(self.picture.gps_x)
        gps_y = float(self.picture.gps_y)
        pan = self.picture.pan
        tilt = self.picture.tilt
        yaw = self.picture.yaw
        pitch = self.picture.pitch
        roll = self.picture.roll
        plane_orientation = self.picture.plane_orientation
        altitude = self.picture.altitude
        
        # * needs intrinsic camera matrix (should be in picture)
        # -> in picture constructor put a bloggie = Camera() part
        # -> right now all pictures should use the default image size of
        #    fully zoomed out, and the corresponding intrinsic params.
        #    If this were to change the image station would have to get
        #    the zoom level and use it to calculate new intrinsic params
        M_int = self.picture.bloggie.get_intrinsic_matrix()
        
        # * needs to determine real coordinates from crop coordinates
        # -> for this define a seperate function.
        # -> e.g. (real_x, real_y) = self.calculate_real_coordinates(
        #                                        crop_x + self.x_offset, 
        #                                        crop_y + self.y_offset)
        #
        # *** to get x_offset and y_offset
        # --> look at '_execute_generate_crop' and make it so xa and ya are stored
        (real_x, real_y) = self.calculate_real_coordinates(crop_x, crop_y)
        print "lat is: %f and long is %f" % (gps_x, gps_y,)
        print "crop_coords are x: %d, y: %d" % (crop_x, crop_y,)
        print "real coords are x: %d, y: %d" % (real_x, real_y,)
        # FINALLY: pass all this info to the calculate_gps function, which
        # will do matrix mults and math described in the blue notebook
        #
        self.target.calculate_gps(M_int, real_x, real_y, gps_x, gps_y, \
                pan, tilt, yaw, pitch, roll, plane_orientation, altitude)
开发者ID:OpenGelo,项目名称:RU-AUVSI-ImageStation,代码行数:104,代码来源:Crop.py


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