Example #1
0
    def drawGrid(self, placed_list, source_dir=None,
                 cm_per_pixel=15.0, blend_cm=200,
                 dim=4096):
        # compute blend diameter in consistent pixel units
        blend_px = int(blend_cm/cm_per_pixel)+1
        if blend_px % 2 == 0:
            blend_px += 1

        (xmin, ymin, xmax, ymax) = ImageList.coverage(self.image_list)
        grid_m = (dim * cm_per_pixel) / 100.0
        print "grid square size = (%.2f x %.2f)" % (grid_m, grid_m)
        #xpixel = (xmax - xmin) * 100.0 / cm_per_pixel
        #ypixel = (ymax - ymin) * 100.0 / cm_per_pixel

        f = open('gdalscript.sh', 'w')
        f.write('#!/bin/sh\n\n')
        f.write('rm -f tile*.tif\n')
        count = 0
        y = ymin
        while y < ymax:
            x = xmin
            while x < xmax:
                print "grid = (%.2f %.2f)" % (x, y)
                base = "tile%03d" % count
                jpgfile = base + ".jpg"
                tifffile = base + ".tif"
                images = self.drawSquare( placed_list, source_dir=source_dir,
                                          cm_per_pixel=cm_per_pixel,
                                          blend_cm=blend_cm,
                                          bounds=(x, y, x+grid_m, y+grid_m),
                                          file=jpgfile)
                if len(images):
                    (ul_lon, ul_lat) = ImageList.cart2wgs84(x, y+grid_m,
                                                            self.ref_lon,
                                                            self.ref_lat)
                    (lr_lon, lr_lat) = ImageList.cart2wgs84(x+grid_m, y,
                                                            self.ref_lon,
                                                            self.ref_lat)
                    cmd = 'gdal_translate -a_srs "+proj=latlong +datum=WGS84" '
                    cmd += '-of GTiff -co "INTERLEAVE=PIXEL" '
                    cmd += '-a_ullr %.15f %.15f %.15f %.15f ' % \
                           ( ul_lon, ul_lat, lr_lon, lr_lat )
                    cmd += '%s %s\n' % (jpgfile, tifffile)
                    f.write('echo running gdal_translate...\n')
                    f.write(cmd)
                    count += 1
                x += grid_m
            y += grid_m
        f.write('rm output.tif\n')
        f.write('echo running gdal_merge\n')
        f.write('gdal_merge.py -o output.tif tile*.tif\n')
        f.write('echo running gdalwarp\n')
        f.write('rm output_3857.tif\n')
        f.write('gdalwarp -t_srs EPSG:3857 output.tif output_3857.tif\n')
        f.write('echo running gdal2tiles.py\n')
        f.write('rm -rf output\n')
        f.write('gdal2tiles.py -z 16-21 -s_srs=EPSG:3857 output_3857.tif output\n')
        f.close()
Example #2
0
    def drawImages(self, draw_list=[], source_dir=None,
                   cm_per_pixel=15.0, blend_cm=200,
                   bounds=None, file=None, keypoints=False):
        print "drawImages() bounds = %s" % str(bounds)
        # compute blend diameter in consistent pixel units
        blend_px = int(blend_cm/cm_per_pixel)+1
        if blend_px % 2 == 0:
            blend_px += 1

        if bounds == None:
            (xmin, ymin, xmax, ymax) = ImageList.coverage(draw_list)
        else:
            (xmin, ymin, xmax, ymax) = bounds

        x = int(100.0 * (xmax - xmin) / cm_per_pixel)
        y = int(100.0 * (ymax - ymin) / cm_per_pixel)
        print "New image dimensions: (%d %d)" % (x, y)
        base_image = np.zeros((y,x,3), np.uint8)

        for image in reversed(draw_list):
            w, h, out = self.drawImage(image, source_dir,
                                       cm_per_pixel,
                                       keypoints,
                                       bounds=(xmin, ymin, xmax, ymax))
            base_image = self.compositeOverlayBottomup(base_image, out,
                                                       blend_px)
            #cv2.imshow('output', base_image)
            #cv2.waitKey()

        cv2.imwrite(file, base_image)
Example #3
0
 def reviewPoint(self, lon_deg, lat_deg, ref_lon, ref_lat):
     (x, y) = ImageList.wgs842cart(lon_deg, lat_deg, ref_lon, ref_lat)
     print "Review images touching %.2f %.2f" % (x, y)
     review_list = ImageList.getImagesCoveringPoint(self.image_list, x, y, pad=25.0, only_placed=False)
     #print "  Images = %s" % str(review_list)
     for image in review_list:
         print "    %s -> " % image.name,
         for j, pairs in enumerate(image.match_list):
             if len(pairs):
                 print "%s (%d) " % (self.image_list[j].name, len(pairs)),
         print
         r2 = image.coverage()
         p = ImageList.getImagesCoveringRectangle(self.image_list, r2)
         p_names = []
         for i in p:
             p_names.append(i.name)
         print "      possible matches: %d" % len(p_names)
Example #4
0
class R_CNN:
    list = ImageList()
    roi_pooling = ROIPooling()
    """
    Segments the given image and returns the segmented image.
   
    @param img: Image item retrieved from ImageList
    """
    def SegmentImages(img):
        pass
Example #5
0
class User:
    userImage = ""
    list = ImageList()
    itemsLibrary = ItemsLibrary()
    """
    Insert user provided image into the list.

    @param item: Image which is provided by user and stored in the array 
    """
    def InsertToList(item):
        pass
Example #6
0
 def reviewPoint(self, lon_deg, lat_deg, ref_lon, ref_lat):
     (x, y) = ImageList.wgs842cart(lon_deg, lat_deg, ref_lon, ref_lat)
     print("Review images touching %.2f %.2f" % (x, y))
     review_list = ImageList.getImagesCoveringPoint(self.image_list,
                                                    x,
                                                    y,
                                                    pad=25.0,
                                                    only_placed=False)
     #print "  Images = %s" % str(review_list)
     for image in review_list:
         print("    %s -> " % image.name, )
         for j, pairs in enumerate(image.match_list):
             if len(pairs):
                 print("%s (%d) " % (self.image_list[j].name, len(pairs)), )
         print
         r2 = image.coverage()
         p = ImageList.getImagesCoveringRectangle(self.image_list, r2)
         p_names = []
         for i in p:
             p_names.append(i.name)
         print("      possible matches: %d" % len(p_names))
Example #7
0
 def drawSquare(self, placed_list, source_dir=None,
                cm_per_pixel=15.0, blend_cm=200, bounds=None, file=None):
     (xmin, ymin, xmax, ymax) = bounds
     xcenter = (xmin + xmax) * 0.5
     ycenter = (ymin + ymax) * 0.5
     pad = (xmax - xmin) * 0.5
     draw_list = ImageList.getImagesCoveringPoint(placed_list, 
                                                  xcenter, ycenter, pad,
                                                  only_placed=True)
     if len(draw_list):
         self.drawImages( draw_list, source_dir=source_dir,
                          cm_per_pixel=cm_per_pixel, blend_cm=blend_cm,
                          bounds=bounds, file=file)
     return draw_list
Example #8
0
class ROIPooling:
    list = ImageList()

    # list of ItemDetails
    itemDetails = []
    
    """
    Classify item types of image details.
    
    @param img: Image item retrieved from R-CNN class 
    """
    def ClassifyItemType(img):
        return img

    """
    Frame objects on images
    
    @param item: Image item retrieved from R-CNN class 
    """
    def FrameImage(item):
        pass
Example #9
0
	def __init__(self, framesDir, width = 533, height = 300, width_margin_ratio  = 0.95, height_margin_ratio = 0.95) :
	
		self.framesDir			= framesDir
	
		self.width			= width
		self.height			= height

		self.width_margin_ratio		= width_margin_ratio
		self.height_margin_ratio	= height_margin_ratio
	
		self.win_width			= self.width * self.width_margin_ratio
		self.win_height 		= self.height * self.height_margin_ratio
	
		self.curr_frame 		= 0
		self.last_frame 		= fc.frame_counter(framesDir) - 1

		self.playing			= 0
		self.playing_thread		= 0
		
		self.progress_label_width	= 2 * fc.ndigits(self.last_frame) + 2
		self.progress_label_text	= "%d/%d" % (self.curr_frame+1, self.last_frame+1)
		
		self.appended_images 		= ImgList.Model()
Example #10
0
 def drawSquare(self,
                placed_list,
                source_dir=None,
                cm_per_pixel=15.0,
                blend_cm=200,
                bounds=None,
                file=None):
     (xmin, ymin, xmax, ymax) = bounds
     xcenter = (xmin + xmax) * 0.5
     ycenter = (ymin + ymax) * 0.5
     pad = (xmax - xmin) * 0.5
     draw_list = ImageList.getImagesCoveringPoint(placed_list,
                                                  xcenter,
                                                  ycenter,
                                                  pad,
                                                  only_placed=True)
     if len(draw_list):
         self.drawImages(draw_list,
                         source_dir=source_dir,
                         cm_per_pixel=cm_per_pixel,
                         blend_cm=blend_cm,
                         bounds=bounds,
                         file=file)
     return draw_list
Example #11
0
    def drawImages(self,
                   draw_list=[],
                   source_dir=None,
                   cm_per_pixel=15.0,
                   blend_cm=200,
                   bounds=None,
                   file=None,
                   keypoints=False):
        print "drawImages() bounds = %s" % str(bounds)
        # compute blend diameter in consistent pixel units
        blend_px = int(blend_cm / cm_per_pixel) + 1
        if blend_px % 2 == 0:
            blend_px += 1

        if bounds == None:
            (xmin, ymin, xmax, ymax) = ImageList.coverage(draw_list)
        else:
            (xmin, ymin, xmax, ymax) = bounds

        x = int(100.0 * (xmax - xmin) / cm_per_pixel)
        y = int(100.0 * (ymax - ymin) / cm_per_pixel)
        print "New image dimensions: (%d %d)" % (x, y)
        base_image = np.zeros((y, x, 3), np.uint8)

        for image in reversed(draw_list):
            w, h, out = self.drawImage(image,
                                       source_dir,
                                       cm_per_pixel,
                                       keypoints,
                                       bounds=(xmin, ymin, xmax, ymax))
            base_image = self.compositeOverlayBottomup(base_image, out,
                                                       blend_px)
            #cv2.imshow('output', base_image)
            #cv2.waitKey()

        cv2.imwrite(file, base_image)
def new_item():
    import ImageList
    response.content_type = 'application/json'
    return ImageList.getImageList()
Example #13
0
    def drawGrid(self,
                 placed_list,
                 source_dir=None,
                 cm_per_pixel=15.0,
                 blend_cm=200,
                 dim=4096):
        # compute blend diameter in consistent pixel units
        blend_px = int(blend_cm / cm_per_pixel) + 1
        if blend_px % 2 == 0:
            blend_px += 1

        (xmin, ymin, xmax, ymax) = ImageList.coverage(self.image_list)
        grid_m = (dim * cm_per_pixel) / 100.0
        print "grid square size = (%.2f x %.2f)" % (grid_m, grid_m)
        #xpixel = (xmax - xmin) * 100.0 / cm_per_pixel
        #ypixel = (ymax - ymin) * 100.0 / cm_per_pixel

        f = open('gdalscript.sh', 'w')
        f.write('#!/bin/sh\n\n')
        f.write('rm -f tile*.tif\n')
        count = 0
        y = ymin
        while y < ymax:
            x = xmin
            while x < xmax:
                print "grid = (%.2f %.2f)" % (x, y)
                base = "tile%03d" % count
                jpgfile = base + ".jpg"
                tifffile = base + ".tif"
                images = self.drawSquare(placed_list,
                                         source_dir=source_dir,
                                         cm_per_pixel=cm_per_pixel,
                                         blend_cm=blend_cm,
                                         bounds=(x, y, x + grid_m, y + grid_m),
                                         file=jpgfile)
                if len(images):
                    (ul_lon,
                     ul_lat) = ImageList.cart2wgs84(x, y + grid_m,
                                                    self.ref_lon, self.ref_lat)
                    (lr_lon,
                     lr_lat) = ImageList.cart2wgs84(x + grid_m, y,
                                                    self.ref_lon, self.ref_lat)
                    cmd = 'gdal_translate -a_srs "+proj=latlong +datum=WGS84" '
                    cmd += '-of GTiff -co "INTERLEAVE=PIXEL" '
                    cmd += '-a_ullr %.15f %.15f %.15f %.15f ' % \
                           ( ul_lon, ul_lat, lr_lon, lr_lat )
                    cmd += '%s %s\n' % (jpgfile, tifffile)
                    f.write('echo running gdal_translate...\n')
                    f.write(cmd)
                    count += 1
                x += grid_m
            y += grid_m
        f.write('rm output.tif\n')
        f.write('echo running gdal_merge\n')
        f.write('gdal_merge.py -o output.tif tile*.tif\n')
        f.write('echo running gdalwarp\n')
        f.write('rm output_3857.tif\n')
        f.write('gdalwarp -t_srs EPSG:3857 output.tif output_3857.tif\n')
        f.write('echo running gdal2tiles.py\n')
        f.write('rm -rf output\n')
        f.write(
            'gdal2tiles.py -z 16-21 -s_srs=EPSG:3857 output_3857.tif output\n')
        f.close()