Exemple #1
0
camdata = '../Examples/camenv_data/camenvs/CameraEnvironmentData_KR2_2014.txt'
camvmask = '../Examples/camenv_data/masks/KR2_2014_vmask.jpg'
caminvmask = '../Examples/camenv_data/invmasks/KR2_2014_inv.jpg'
camimgs = '../Examples/images/KR2_2014_subset/*.JPG'


#Define data output directory
destination = '../Examples/results/velocity1/'
if not os.path.exists(destination):
    os.makedirs(destination)


#-----------------------   Create camera object   -----------------------------

#Define camera environment
cameraenvironment = CamEnv(camdata)

#Report camera data and show corrected image
cameraenvironment.reportCamData()
cameraenvironment.showGCPs()
cameraenvironment.showPrincipalPoint()
cameraenvironment.showCalib()

#----------------------   Calculate homography   ------------------------------

#Set homography parameters
hgback=1.0                      #Back-tracking threshold
hgmax=50000                     #Maximum number of points to seed
hgqual=0.1                      #Corner quality for seeding
hgmind=5.0                      #Minimum distance between seeded points
hgminf=4                        #Minimum number of seeded points to track
Exemple #2
0
#Define data inputs
camdata = '../Examples/camenv_data/camenvs/CameraEnvironmentData_KR3_2014.txt'
camamask = '../Examples/camenv_data/masks/KR3_2014_amask.jpg'
caminvmask = '../Examples/camenv_data/invmasks/KR3_2014_inv.jpg'
camimgs = '../Examples/images/KR3_2014_subset/*.JPG'

#Define data output directory
destination = '../Examples/results/autoarea/'
if not os.path.exists(destination):
    os.makedirs(destination)

#-------------   Create and optimise camera environment object   --------------

#Define camera environment
cameraenvironment = CamEnv(camdata)

#Set camera optimisation parameters
optparams = 'YPR'  #Flag to denote which parameters to optimise:
#YPR=camera pose; INT=intrinsic camera model;
#EXT=extrinsic camera model; ALL=all camera
#parameters
optmethod = 'trf'  #Optimisation method: trf=Trust Region
#Reflective algorithm; dogbox=dogleg algorithm;
#lm=Levenberg-Marquardt algorithm

#Optimise camera
cameraenvironment.optimiseCamEnv(optparams, optmethod, True)

#Report camera data and show corrected image
cameraenvironment.reportCamData()
Exemple #3
0
# Define data input directories
camdata = '../Examples/camenv_data/camenvs/CameraEnvironmentData_KR1_2014.txt'
invmask = '../Examples/camenv_data/invmasks/KR1_2014_inv.jpg'
# Main Image Folder
camimgs = '../Examples/images/Kronebreen/'
# Initial Image
initial_image = 'IMG_3038.JPG'
camimgs_start = camimgs + initial_image
# Define data output directory
destination = '../Examples/results/trackingline/'

if not os.path.exists(destination):
    os.makedirs(destination)
# Define camera environment
cam = CamEnv(camdata)

# ---------------------   Calculate homography   -------------------------------
# Set homography parameters
hgback = 1.0  # Back-tracking threshold
hgmax = 50000  # Maximum number of points to seed
hgqual = 0.1  # Corner quality for seeding
hgmind = 5.0  # Minimum distance between seeded points
hgminf = 4  # Minimum number of seeded points to track

# Set up Homography object
homog = Homography(camimgs_start,
                   cam,
                   invmask,
                   calibFlag=True,
                   band='L',
    loc_x.append(float(temp[3].rstrip()))           #Calving event location x
    loc_y.append(float(temp[4].rstrip()))           #Calving event location y

      
#--------------------------   Georectify points   -----------------------------
        
#Compile xy locations
tu1_xy=[] 
for a,b in zip(loc_x,loc_y):
    tu1_xy.append([a,b])
print '\n\n' + str(len(tu1_xy)) + ' locations for calving events detected'
tu1_xy=np.array(tu1_xy)


#Define camera environment
tu1cam = CamEnv(tu1camenv)

#Get DEM from camera environment
dem = tu1cam.getDEM() 

#Get inverse projection variables through camera info               
invprojvars = setProjection(dem, tu1cam._camloc, tu1cam._camDirection, 
                            tu1cam._radCorr, tu1cam._tanCorr, tu1cam._focLen, 
                            tu1cam._camCen, tu1cam._refImage)
        
#Show GCPs                           
tu1cam.showGCPs()                        

#Inverse project image coordinates using function from CamEnv object                       
tu1_xyz = projectUV(tu1_xy, invprojvars)
print '\n\n' + str(len(tu1_xyz)) + ' locations for calving events georectified'
#-----------------------------   Map data files   -----------------------------

#Define data inputs
camdata = '../Examples/camenv_data/camenvs/CameraEnvironmentData_KR1_2014.txt'
caminvmask = '../Examples/camenv_data/invmasks/KR1_2014_inv.jpg'
camimgs = '../Examples/images/KR1_2014_subset/*.JPG'

#Define data output directory
destination = '../Examples/results/manualarea/'
if not os.path.exists(destination):
    os.makedirs(destination)

#--------------------   Create camera and area objects   ----------------------

#Define camera environment
cameraenvironment = CamEnv(camdata)

#Optimise camera environment
optparams = 'YPR'
cameraenvironment.optimiseCamEnv(optparams)

##Show ground control points
#cameraenvironment.showGCPs()
#cameraenvironment.showResiduals()

#-----------------------   Calculate homography   -----------------------------

#Set homography parameters
hmethod = 'sparse'  #Method
hgwinsize = (25, 25)  #Tracking window size
hgback = 1.0  #Back-tracking threshold
Exemple #6
0
#from PyTrx.Utilities import plotLinePX, plotLineXYZ

#---------------------------   Initialisation   -------------------------------

#Define data input directories
camdata = '../Examples/camenv_data/camenvs/CameraEnvironmentData_TU1_2015.txt'
invmask = '../Examples/camenv_data/invmasks/TU1_2015_inv.jpg'
camimgs = '../Examples/images/TU1_2015_subset/*.JPG'

#Define data output directory
destination = '../Examples/results/manualline/'
if not os.path.exists(destination):
    os.makedirs(destination)

#Define camera environment
cam = CamEnv(camdata)

#--------------------   Optimise camera environment   -------------------------

#Optimisation parameters
optflag = 'YPR'  #Parameters to optimise (YPR/INT/EXT/ALL)
optmethod = 'trf'  #Optimisation method (trf/dogbox/lm)
show = False  #Show refined camera environment

#Optimise camera environment
cam.optimiseCamEnv(optflag, optmethod, show)

#---------------------   Calculate homography   -------------------------------

#Set homography parameters
hmethod = 'sparse'  #Method
Exemple #7
0
#-----------------------------   Map data files   -----------------------------

#Define data inputs
camdata = '../Examples/camenv_data/camenvs/CameraEnvironmentData_KR3_2014.txt'
cammask = '../Examples/camenv_data/masks/KR3_2014_amask.JPG'
camimgs = '../Examples/images/KR3_2014_subset/*.JPG'

#Define data output directory
destination = '../Examples/results/autoarea/'
if not os.path.exists(destination):
    os.makedirs(destination)

#--------------------   Create camera and area objects   ----------------------

#Define camera environment
cameraenvironment = CamEnv(camdata)

#Define Area class initialisation variables
calibFlag = True  #Detect with corrected or uncorrected images
maxim = 0  #Image number of maximum areal extent
imband = 'R'  #Desired image band
quiet = 2  #Level of commentary
loadall = False  #Load all images?
time = 'EXIF'  #Method to derive image times

#Set up Area object, from which areal extent will be measured
lakes = Area(camimgs, cameraenvironment, calibFlag, cammask, maxim, imband,
             quiet, loadall, time)

#---------------------   Set area detection parameters   ----------------------
Exemple #8
0
    region.append(temp[1].rstrip())  #Calving event region
    style.append(temp[2].rstrip())  #Calving event style
    loc_x.append(float(temp[3].rstrip()))  #Calving event location x
    loc_y.append(float(temp[4].rstrip()))  #Calving event location y

#--------------------------   Georectify points   -----------------------------

#Compile xy locations
tu1_xy = []
for a, b in zip(loc_x, loc_y):
    tu1_xy.append([a, b])
print '\n\n' + str(len(tu1_xy)) + ' locations for calving events detected'
tu1_xy = np.array(tu1_xy)

#Define camera environment
tu1cam = CamEnv(tu1camenv)

#Show GCPs
tu1cam.showGCPs()

#Inverse project image coordinates using function from CamEnv object
tu1_xyz = tu1cam.invproject(tu1_xy)
print '\n\n' + str(len(tu1_xyz)) + ' locations for calving events georectified'

#-----------------------   Plot xyz location on DEM   -------------------------

print '\n\nPLOTTING XYZ CALVING LOCATIONS'

#Boolean flags (True/False)
save = True  #Save plot?
show = True  #Show plot?
Exemple #9
0
#Define data inputs
camdata = '../Examples/camenv_data/camenvs/CameraEnvironmentData_KR3_2014.txt'
camamask = '../Examples/camenv_data/masks/KR3_2014_amask.jpg'
caminvmask = '../Examples/camenv_data/invmasks/KR3_2014_inv.jpg'
camimgs = '../Examples/images/KR3_2014_subset/*.JPG'

#Define data output directory
destination = '../Examples/results/autoarea/'
if not os.path.exists(destination):
    os.makedirs(destination)


#--------------------   Create camera and area objects   ----------------------

#Define camera environment
cameraenvironment = CamEnv(camdata)

#Report camera data and show corrected image
cameraenvironment.reportCamData()
#cameraenvironment.showGCPs()
#cameraenvironment.showPrincipalPoint()
#cameraenvironment.showCalib()


#---------------------   Calculate homography   -------------------------------

#Set homography parameters
hgback=1.0                      #Back-tracking threshold
hgmax=50000                     #Maximum number of points to seed
hgqual=0.1                      #Corner quality for seeding
hgmind=5.0                      #Minimum distance between seeded points
#-----------------------------   Map data files   -----------------------------

#Define data inputs
camdata = '../Examples/camenv_data/camenvs/CameraEnvironmentData_KR1_2014.txt'
camimgs = '../Examples/images/KR1_2014_subset/*.JPG'

#Define data output directory
destination = '../Examples/results/manualarea/'
if not os.path.exists(destination):
    os.makedirs(destination)


#--------------------   Create camera and area objects   ----------------------

#Define camera environment
cameraenvironment = CamEnv(camdata)

#Show ground control points
cameraenvironment.showGCPs()


#Define Area class initialisation variables
calibFlag = True            #Detect with corrected or uncorrected images
maxim = 0                   #Image number of maximum areal extent 
imband = 'R'                #Desired image band
loadall = False             #Load all images?
time = 'EXIF'               #Method to derive image times
quiet = 2                   #Level of commentary

#Set up Area object, from which areal extent will be measured
plumes = Area(camimgs, cameraenvironment, calibFlag, None, maxim, imband, 
Exemple #11
0
#Define data inputs
camdata = '../Examples/camenv_data/camenvs/CameraEnvironmentData_KR1_2014.txt'
caminvmask = '../Examples/camenv_data/invmasks/KR1_2014_inv.jpg'
camimgs = '../Examples/images/KR1_2014_subset/*.JPG'

#Define data output directory
destination = '../Examples/results/manualarea/'
if not os.path.exists(destination):
    os.makedirs(destination)


#--------------------   Create camera and area objects   ----------------------

#Define camera environment
cameraenvironment = CamEnv(camdata)

##Show ground control points
#cameraenvironment.showGCPs()


#-----------------------   Calculate homography   -----------------------------

#Set homography parameters
hgback=1.0                      #Back-tracking threshold
hgmax=50000                     #Maximum number of points to seed
hgqual=0.1                      #Corner quality for seeding
hgmind=5.0                      #Minimum distance between seeded points
hgminf=4                        #Minimum number of seeded points to track

#Set up Homography object
Exemple #12
0
from FileHandler import writeLineFile, writeSHPFile, importLineData
from Utilities import plotPX, plotXYZ

#---------------------------   Initialisation   -------------------------------

#Define data input directories
camdata = '../Examples/camenv_data/camenvs/CameraEnvironmentData_TU1_2015.txt'
camimgs = '../Examples/images/TU1_2015_subset/*.JPG'

#Define data output directory
destination = '../Examples/results/manualline/'
if not os.path.exists(destination):
    os.makedirs(destination)

#Define camera environment
cam = CamEnv(camdata)

#Set up line object
terminus = Line(camimgs, cam)

#-----------------------   Calculate/import lines   ---------------------------

#Choose action "plot", "importtxt" or "importshp". Plot proceeds with the
#manual  definition of terminus lines, importtxt imports line data from text
#files, and  importshp imports line data from shape file (.shp)
action = 'importtxt'

#Manually define lines from imagery
if action == 'plot':
    rline, rlength = terminus.calcManualLinesXYZ()
    pxlength = terminus._pxline
Exemple #13
0
#Get data needed for processing
camdata = '../Examples/camenv_data/camenvs/CameraEnvironmentData_KR2_2014.txt'
camvmask = '../Examples/camenv_data/masks/KR2_2014_vmask.JPG'
caminvmask = '../Examples/camenv_data/invmasks/KR2_2014_inv.JPG'
camimgs = '../Examples/images/KR2_2014_subset/*.JPG'

#Define data output directory
destination = '../Examples/results/velocity/'
if not os.path.exists(destination):
    os.makedirs(destination)

#-----------------------   Create camera object   -----------------------------

#Define camera environment
cameraenvironment = CamEnv(camdata, quiet=2)

#----------------------   Calculate velocities   ------------------------------

#Set up Velocity object
velo = Velocity(camimgs,
                cameraenvironment,
                camvmask,
                caminvmask,
                image0=0,
                band='L',
                quiet=2)

#Set velocity parameters
hmg = True  #Calculate homography?
err = True  #Calculate errors?