Ejemplo n.º 1
0
def ExtractThumbs(img, count):
    '''extract thumbnails from a composite thumbnail image'''
    thumb_size = cuav_util.image_width(img) / count
    thumbs = []
    for i in range(count):
        thumb = cuav_util.SubImage(img, (i*thumb_size, 0, thumb_size, thumb_size))
        thumbs.append(thumb)
    return thumbs
Ejemplo n.º 2
0
def ExtractThumbs(img, count):
    '''extract thumbnails from a composite thumbnail image'''
    thumb_size = cuav_util.image_width(img) / count
    thumbs = []
    for i in range(count):
        thumb = cuav_util.SubImage(img, (i*thumb_size, 0, thumb_size, thumb_size))
        thumbs.append(thumb)
    return thumbs
Ejemplo n.º 3
0
    def add_regions(self, regions, thumbs, filename, pos=None):
        '''add some regions'''
        for i in range(len(regions)):
            r = regions[i]
            (x1, y1, x2, y2) = r.tuple()

            latlon = r.latlon
            if latlon is None:
                latlon = (None, None)

            (lat, lon) = latlon

            if self.boundary:
                if (lat, lon) == (None, None):
                    # its pointing into the sky
                    continue
#                if cuav_util.polygon_outside((lat,lon), self.boundary):
#                    # this region is outside the search boundary
#                    continue

# the thumbnail we have been given will be bigger than the size we want to
# display on the mosaic. Extract the middle of it for display
            full_thumb = thumbs[i]
            rsize = max(x2 + 1 - x1, y2 + 1 - y1)
            tsize = cuav_util.image_width(full_thumb)
            if rsize < tsize:
                thumb = cuav_util.SubImage(full_thumb,
                                           ((tsize - self.thumb_size) // 2,
                                            (tsize - self.thumb_size) // 2,
                                            self.thumb_size, self.thumb_size))
            else:
                thumb = cv.CreateImage((self.thumb_size, self.thumb_size), 8,
                                       3)
                cv.Resize(full_thumb, thumb)

            ridx = len(self.regions)
            self.regions.append(
                MosaicRegion(ridx,
                             r,
                             filename,
                             pos,
                             thumbs[i],
                             thumb,
                             latlon=(lat, lon)))
            self.regions_sorted.append(self.regions[-1])

            self.display_mosaic_region(ridx)

            if (lat, lon) != (None, None):
                self.slipmap.add_object(
                    mp_slipmap.SlipThumbnail("region %u" % ridx, (lat, lon),
                                             img=thumb,
                                             layer=2,
                                             border_width=1,
                                             border_colour=(255, 0, 0),
                                             popup_menu=self.popup_menu))

        self.image_mosaic.set_image(self.mosaic, bgr=True)
Ejemplo n.º 4
0
    def add_regions(self, regions, thumbs, filename, pos=None):
        '''add some regions'''
        for i in range(len(regions)):
            r = regions[i]
            (x1,y1,x2,y2) = r.tuple()

            latlon = r.latlon
            if latlon is None:
                latlon = (None,None)

            (lat, lon) = latlon

            if self.boundary:
                if (lat, lon) == (None,None):
                    # its pointing into the sky
                    continue
#                if cuav_util.polygon_outside((lat,lon), self.boundary):
#                    # this region is outside the search boundary
#                    continue

            # the thumbnail we have been given will be bigger than the size we want to
            # display on the mosaic. Extract the middle of it for display
            full_thumb = thumbs[i]
            rsize = max(x2+1-x1,y2+1-y1)
            tsize = cuav_util.image_width(full_thumb)
            if rsize < tsize:
                thumb = cuav_util.SubImage(full_thumb, ((tsize-self.thumb_size)//2,
                                                        (tsize-self.thumb_size)//2,
                                                        self.thumb_size,
                                                        self.thumb_size))
            else:
                thumb = cv.CreateImage((self.thumb_size, self.thumb_size),8,3)
                cv.Resize(full_thumb, thumb)

            ridx = len(self.regions)
            self.regions.append(MosaicRegion(ridx, r, filename, pos, thumbs[i], thumb, latlon=(lat,lon)))
            self.regions_sorted.append(self.regions[-1])
            
            max_page = (len(self.regions_sorted)-1) / self.display_regions
            self.image_mosaic.set_title("Mosaic (Page %u of %u)" % (self.page+1, max(max_page+1, 1)))

            frame_time = cuav_util.parse_frame_time(filename)
            if not frame_time in self.ridx_by_frame_time:
                self.ridx_by_frame_time[frame_time] = [ridx]
            else:
                self.ridx_by_frame_time[frame_time].append(ridx)

            self.display_mosaic_region(len(self.regions_sorted)-1)

            if (lat,lon) != (None,None):
                self.slipmap.add_object(mp_slipmap.SlipThumbnail("region %u" % ridx, (lat,lon),
                                                                 img=thumb,
                                                                 layer=2, border_width=1, border_colour=(255,0,0),
                                                                 popup_menu=self.popup_menu))

        self.image_mosaic.set_image(self.mosaic, bgr=True)
Ejemplo n.º 5
0
 def make_thumb(self, full, r, size):
     (x1, y1, x2, y2) = r.tuple()
     rsize = max(x2 + 1 - x1, y2 + 1 - y1)
     tsize = cuav_util.image_width(full)
     if rsize < tsize:
         thumb = cuav_util.SubImage(full, ((tsize - size) // 2,
                                           (tsize - size) // 2, size, size))
     else:
         thumb = cv2.resize(full, (size, size))
     return thumb
Ejemplo n.º 6
0
 def make_thumb(self, full, r, size):
     (x1,y1,x2,y2) = r.tuple()
     rsize = max(x2+1-x1,y2+1-y1)
     tsize = cuav_util.image_width(full)
     if rsize < tsize:
         thumb = cuav_util.SubImage(full, ((tsize-size)//2,
                                           (tsize-size)//2,
                                           size,
                                           size))
     else:
         thumb = cv2.resize(full, (size, size))
     return thumb
Ejemplo n.º 7
0
    def add_regions(self, regions, thumbs, filename, pos=None):
        '''add some regions'''
        for i in range(len(regions)):
            r = regions[i]
            (x1,y1,x2,y2) = r.tuple()

            latlon = r.latlon
            if latlon is None:
                latlon = (None,None)

            (lat, lon) = latlon

            if self.boundary:
                if (lat, lon) == (None,None):
                    # its pointing into the sky
                    continue
#                if cuav_util.polygon_outside((lat,lon), self.boundary):
#                    # this region is outside the search boundary
#                    continue

            # the thumbnail we have been given will be bigger than the size we want to
            # display on the mosaic. Extract the middle of it for display
            full_thumb = thumbs[i]
            tsize = cuav_util.image_width(full_thumb)
            thumb = cuav_util.SubImage(full_thumb, ((tsize-self.thumb_size)//2,
                                                    (tsize-self.thumb_size)//2,
                                                    self.thumb_size,
                                                    self.thumb_size))

            ridx = len(self.regions)
            self.regions.append(MosaicRegion(ridx, r, filename, pos, thumbs[i], thumb, latlon=(lat,lon)))
            self.regions_sorted.append(self.regions[-1])

            self.display_mosaic_region(ridx)

            if (lat,lon) != (None,None):
                import mp_slipmap
                self.slipmap.add_object(mp_slipmap.SlipThumbnail("region %u" % ridx, (lat,lon),
                                                                 img=thumb,
                                                                 layer=2, border_width=1, border_colour=(255,0,0)))

        self.image_mosaic.set_image(self.mosaic, bgr=True)