Example #1
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)
Example #2
0
    def add_regions(self, regions, thumbs, filename, pos=None):
        '''add some regions'''
        for i in range(len(regions)):
            r = regions[i]

            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]
            thumb = self.make_thumb(full_thumb, r, 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])

            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):
                mapthumb = thumb
                if self.map_thumb_size != self.thumb_size:
                    mapthumb = self.make_thumb(full_thumb, r,
                                               self.map_thumb_size)

                slobj = mp_slipmap.SlipThumbnail(
                    "region %u" % ridx, (lat, lon),
                    img=cv2.cvtColor(mapthumb, cv2.COLOR_RGB2BGR),
                    layer=2,
                    border_width=1,
                    border_colour=(255, 0, 0),
                    popup_menu=self.popup_menu)
                for m in self.allmaps:
                    m.add_object(slobj)

        self.image_mosaic.set_image(self.mosaic)
        if self.autorefresh:
            self.re_sort(printsort=False)
            self.redisplay_mosaic()
            if not self.have_selected_region:
                self.show_region(self.regions_sorted[0].ridx)
        if self.topfifty:
            self.re_sort(printsort=False)
            self.redisplay_mosaic()
            self.topfiftyonly()
Example #3
0
    sm = mp_slipmap.MPSlipMap(lat=-26.6360,
                              lon=151.8436,
                              elevation=True,
                              service='GoogleSat')

    joelog = JoeIterator(sys.argv[1])
    tidx = 0
    thumb_filename = None
    for joe in joelog:
        thumb = cuav_util.LoadImage(joe.thumb_filename)
        if thumb_filename != joe.thumb_filename:
            tidx = 0
        else:
            tidx += 1
        (w, h) = cuav_util.image_shape(thumb)
        count = w // h
        thumbs = cuav_mosaic.ExtractThumbs(thumb, count)
        r = getattr(joe, 'r', None)
        if r is not None and r.score > opts.minscore:
            print joe
            sm.add_object(
                mp_slipmap.SlipThumbnail("time %u" % joe.frame_time,
                                         joe.latlon,
                                         img=thumbs[tidx],
                                         layer=2,
                                         border_width=1,
                                         border_colour=(255, 0, 0)))

#    sm.add_object(mp_slipmap.SlipPolygon('Search Pattern', gen.getMapPolygon(), layer=1, linewidth=2, colour=(0,255,0)))