configure pyopencv

pull/249/head
edgarriba 2015-11-19 12:00:34 +00:00
rodzic 483b600e14
commit c5ed1e5fae
4 zmienionych plików z 6 dodań i 260 usunięć

Wyświetl plik

@ -66,4 +66,4 @@ NUM_CORES=`grep -c processor /proc/cpuinfo`
## Compile SuperBuild
cd SuperBuild
mkdir -p build && cd build
cmake .. && make -j ${NUM_CORES}
cmake .. && make -j ${NUM_CORES}

Wyświetl plik

@ -1,85 +0,0 @@
class ODMJob:
''' ODMJob - a class for ODM Activities
'''
def __init__(self, inputDir, args):
self.args = args
self.pathDirJPGs = inputDir
self.count = 0
self.good = 0
self.bad = 0
self.minWidth = 0.
self.minHeight= 0
self.maxWidth = 0
self.maxHeight= 0
self.resizeTo = 0.
self.srcDir = CURRENT_DIR
self.utmZone = -999
self.utmSouth = False
self.utmEastOffset = 0.
self.utmNorthOffset = 0.
self.jobOptions = {'resizeTo': 0, 'srcDir': CURRENT_DIR, 'utmZone': -999,
'utmSouth': False, 'utmEastOffset': 0, 'utmNorthOffset': 0}
self.dictJobLocations = {} # hold our filepaths and dirs
self.listFiles = os.listdir(CURRENT_DIR)
self.listJPG = []
self.listObjPhotos = []
# create obj.listJPG of all jpegs
for files in self.listFiles:
(pathfn,ext) = os.path.splitext(files)
if 'jpg' in ext.lower() :
#print files
self.listJPG.append(files)
elif 'jpeg' in ext.lower() :
self.listJPG.append(files)
print "\n - source files - " + now()
for filename in self.listJPG:
filename = filename.rstrip('\n')
if not filename:
continue
filename = CURRENT_DIR + os.sep + filename
print filename
self.listObjPhotos.append( ODMPhoto( filename, self) )
def resize(self):
print "\n - preparing images - " + now()
os.chdir(self.jobDir)
for objPhotos in self.listObjPhotos:
if objPhotos.isOk:
if not os.path.isfile(objPhotos.dictStepVals["step_0_resizedImage"]):
if self.resizeTo != 0 and \
((int(objPhotos.width) > self.resizeTo) or (objPhotos.height > self.resizeTo)):
sys.stdout.write(" resizing " + objPhotos.strFileName +" \tto " \
+ objPhotos.dictStepVals["step_0_resizedImage"])
run("convert -resize " + str(self.resizeTo) + "x" + str(self.resizeTo)\
+" -quality 100 \"" + self.srcDir + "/" + objPhotos.strFileName + "\" \"" \
+ objPhotos.dictStepVals["step_0_resizedImage"] + "\"")
else:
sys.stdout.write(" copying " + objPhotos.strFileName + " \tto " \
+ objPhotos.dictStepVals["step_0_resizedImage"])
shutil.copyfile(CURRENT_DIR + "/" + objPhotos.strFileName, objPhotos.dictStepVals["step_0_resizedImage"])
else:
print " using existing " + objPhotos.strFileName + " \tto " \
+ objPhotos.dictStepVals["step_0_resizedImage"]
file_resolution = runAndReturn('jhead "' + objPhotos.dictStepVals["step_0_resizedImage"] \
+ '"', 'grep "Resolution"')
match = re.search(": ([0-9]*) x ([0-9]*)", file_resolution)
if match:
objPhotos.width = int(match.group(1).strip())
objPhotos.height = int(match.group(2).strip())
print "\t (" + str(objPhotos.width) + " x " + str(objPhotos.height) + ")"

Wyświetl plik

@ -1,172 +0,0 @@
class ODMPhoto:
""" ODMPhoto - a class for ODMPhotos
"""
def __init__(self, inputJPG, objODMJob):
#general purpose
verbose = False
# object attributes
self.dictStepVals = {}
self.pathToContainingFolder = os.path.split(inputJPG)[0]
self.strFileName = os.path.split(inputJPG)[1]
self.strFileNameBase = os.path.splitext(self.strFileName)[0]
self.strFileNameExt = os.path.splitext(self.strFileName)[1]
#start pipe for jhead
cmdSrc = BIN_PATH + os.sep + "jhead "+ CURRENT_DIR + os.sep + self.strFileName
srcProcess = subprocess.Popen(cmdSrc, stdout=subprocess.PIPE)
stdout, stderr = srcProcess.communicate()
stringOutput = stdout.decode('ascii')
#listOutput is the list of params to be processed
listOutput_ori = stringOutput.splitlines()
listOutput = remove_values_from_list(listOutput_ori,u"")
intListCount = 0
intNumCameraAtts = len(listOutput)
flagDoneList = False
if verbose: print listOutput
for lines in listOutput:
# check if we've read all atts
intListCount += 1
if intListCount == intNumCameraAtts: flagDoneList = True
#extract and proceed
firstColon = lines.find(":")
tempKey = lines[:firstColon].strip()
tempVal = lines[firstColon+1:].strip()
if verbose: print tempKey,tempVal
# all them values
if tempKey == 'File name': self.fileName = tempVal
elif tempKey == 'File size': self.fileSize= tempVal
elif tempKey == 'File date': self.fileDate = tempVal
elif tempKey == 'Camera make': self.cameraMake = tempVal
elif tempKey == 'Camera model': self.cameraModel = tempVal
elif tempKey == 'Date/Time': self.dateTime = tempVal
elif tempKey == 'Resolution': self.resolution = tempVal
elif tempKey == 'Flash used': self.flashUsed = tempVal
elif tempKey == 'Focal length': self.focalLength = tempVal
elif tempKey == 'CCD width': self.ccdWidth = tempVal
elif tempKey == 'Exposure time': self.exposureTime = tempVal
elif tempKey == 'Aperture': self.aperture = tempVal
elif tempKey == 'Focus dist.': self.focusDist = tempVal
elif tempKey == 'ISO equiv.': self.isoEquiv= tempVal
elif tempKey == 'Whitebalance': self.whitebalance = tempVal
elif tempKey == 'Metering Mode': self.meteringMode = tempVal
elif tempKey == 'GPS Latitude': self.gpsLatitude = tempVal
elif tempKey == 'GPS Longitude': self.gpsLongitude = tempVal
elif tempKey == 'GPS Altitude': self.gpsAltitude = tempVal
elif tempKey == 'JPEG Quality': self.jpgQuality = tempVal
# better object attribute names; keep old for compatability
# shallow references point to same stack space
self.fullPathAndName = self.fileName
# attribute 'id' set to more specific of the maker or model
try:
if self.cameraMake:
self.make = self.cameraMake
self.id = self.cameraMake
except: pass
try:
if self.cameraModel:
self.model = self.cameraModel
self.id = self.cameraModel
except: pass
# parse resolution field
try:
match = re.search("([0-9]*) x ([0-9]*)",self.resolution)
if match:
self.width = int(match.group(1).strip())
self.height = int(match.group(2).strip())
except: pass
#parse force-focal
try:
if not '--force-focal' in args:
match = re.search(":[\ ]*([0-9\.]*)mm", self.focalLength)
if match:
self.focal = float((match.group()[1:-2]).strip())
else:
self.focal = args['--force-focal']
except: pass
#parse force-ccd
if 'ccd' in lines.lower():
if not '--force-ccd' in args:
try:
floats = extractFloat(self.ccdWidth)
self.ccd = floats[0]
except:
try:
self.ccd = float(ccdWidths[self.id])
except: pass
else:
self.ccd = args['--force-ccd']
if verbose: print intListCount
if flagDoneList:
try:
if self.width > self.height:
self.focalpx = self.width * (self.focal / self.ccd)
else:
self.focalpx = self.height * (self.focal / self.ccd)
self.isOk = True
objODMJob.good += 1
print " using " + self.fileName + " dimensions: " + \
str(self.width) + "x" + str(self.height)\
+ " | focal: " + str(self.focal) \
+ "mm | ccd: " + str(self.ccd) + "mm"
except:
self.isOk = False
objODMJob.bad += 1
try:
print "\n no CCD width or focal length found for "\
+ self.fileName+ " - camera: \"" + self.id+ "\""
except:
print "\n no CCD width or focal length found"
#either way increment total count
objODMJob.count += 1
#populate & update max/mins
if objODMJob.minWidth == 0:
objODMJob.minWidth = self.width
if objODMJob.minHeight == 0:
objODMJob.minHeight = self.height
if objODMJob.minWidth < self.width:
objODMJob.minWidth = self.minWidth
else:
objODMJob.minWidth = self.width
if objODMJob.minHeight < self.height:
objODMJob.minHeight = objODMJob.minHeight
else:
objODMJob.minHeight = self.height
if objODMJob.maxWidth > self.width:
objODMJob.maxWidth = objODMJob.maxWidth
else:
objODMJob.maxWidth = self.width
if objODMJob.maxHeight > self.height:
objODMJob.maxHeight = objODMJob.maxHeight
else:
objODMJob.maxHeight = self.height

Wyświetl plik

@ -1,4 +1,5 @@
import os
import sys
# Define some needed locations
scripts_path = os.path.abspath(os.path.dirname(__file__))
@ -7,9 +8,11 @@ root_path, _ = os.path.split(scripts_path)
superbuild_path = os.path.join(root_path, 'SuperBuild')
ccd_widths_path = os.path.join(root_path, 'ccd_defs.json')
pyopencv_path = os.path.join(superbuild_path, 'lib/python2.7/dist-packages')
opensfm_path = os.path.join(superbuild_path, "src/opensfm")
# add opencv to python path
pyopencv_path = os.path.join(superbuild_path, 'install/lib/python2.7/dist-packages')
sys.path.append(pyopencv_path)
opensfm_path = os.path.join(superbuild_path, "src/opensfm")
# Define supported image extensions
supported_extensions = {'.jpg','.jpeg'}