예제 #1
0
    def doSFM(self, context, pluginPath, absolutePhotoPath, outputPath, photos):

        print("Starting Structure From Motion")
        numberOfPhotos = photos.__len__()

        # Initialize Bundler
        bundler = osmbundler.OsmBundler(pluginPath, absolutePhotoPath, outputPath, "siftvlfeat", 1200, 1)

        # Prepare photos
        bundler.openFiles()
        for i in range(0, numberOfPhotos):
            print("\n\nProcessing photo {0} of {1}...".format(i+1,numberOfPhotos))
            photoInfo = dict(dirname=absolutePhotoPath, basename=photos[i])
            bundler._preparePhoto(photoInfo)
        bundler.closeFiles()

        # Match features and do bundle adjustment
        print("\n\nMatching features...")
        bundler.matchFeatures()
        bundler.doBundleAdjustment()

        # Multi-view stereo
        cmvs = osmcmvs.OsmCmvs(pluginPath, outputPath, 10)
        cmvs.doBundle2PMVS()
        cmvs.doCMVS()
        bpy.ops.import_mesh.ply(filepath=outputPath + "\\pmvs\\models\\option-0000.ply")

        os.chdir("C:\\")
        print(outputPath)
        print("\nStructure From Motion finished.")
예제 #2
0
def run(a):
    print "inside runBundler"

    manager = osmbundler.OsmBundler(a)

    manager.preparePhotos()

    manager.matchFeatures()

    manager.doBundleAdjustment()
예제 #3
0
import logging
import osmbundler

logging.basicConfig(level=logging.INFO, format="%(message)s")

# initialize OsmBundler manager class
manager = osmbundler.OsmBundler()

manager.preparePhotos()

manager.matchFeatures()

manager.doBundleAdjustment()

# manager.openResult()

예제 #4
0
def prepandmatchprocess():
    _time = datetime.now()
    name = request.args.get('name')
    target = os.path.join(APP_ROOT, 'static/images/' + str(name) + '/')

    # initialize OsmBundler manager class
    workaddress = str(target) + 'temp/'
    manager = osmbundler.OsmBundler(target, workaddress)

    try:
        manager.preparePhotos()
        print("Finish preparing photos, time taken ",
              (datetime.now() - _time).total_seconds())
        sys.stdout.flush()
        _time = datetime.now()

        manager.matchFeatures()
        print("Finish matching features, time taken ",
              (datetime.now() - _time).total_seconds())
        sys.stdout.flush()
        _time = datetime.now()

        # update quality and processing stage in .txt file (1st digit = quality, 2nd digit = stage)
        completeName = os.path.join(target, "data.txt")
        saver = open(completeName, "r")
        savedData = saver.read()
        saver.close()
        sys.stdout.flush()

        saver = open(completeName, "w")
        saver.write(str(savedData[0]))
        saver.write("1")
        saver.close()
        sys.stdout.flush()
    #

    except AttributeError as e:
        print("AttributeError", e.message)
        return redirect(url_for('error', msg=e.message))
    except IOError as e:
        print("IOError", e.message)
        if e.message:
            return redirect(url_for('error', msg=e.message))
        else:
            return redirect(
                url_for(
                    'error',
                    msg=
                    "IOError when updating or saving quality and current stage process"
                ))
    except ValueError as e:
        print("ValueError", e.message)
        return redirect(url_for('error', msg=e.message))
    except WindowsError as e:
        print("WindowsError", e.message)
        return redirect(
            url_for(
                'error',
                msg=
                "A model of the same name already exists in the server. Please rename your model or delete the model with the same name"
            ))

    return redirect(url_for('bundleadjustment', name=name))