HaiyangXu / osm-bundler

A Python routine for running Structure From Motion pipeline with Bundler and dense reconstruction with PMVS(CMVS) to reconstruct 3D geometry from a set of photos.
haiyangxu.github.com/osm-bundler
57 stars 12 forks source link

TypeError: memoryview: a bytes-like object is required, not 'str' #8

Closed ethansu1992 closed 4 years ago

ethansu1992 commented 4 years ago

Currently i am facing this issue when i run the osm-bundler, initially it was fine but now this issue surface after the command was run.

Processing photo '1.jpg': Copy of the photo has been scaled down to 900x1200 Extracting features with the SIFT method from VLFeat library... Traceback (most recent call last): File "RunBundler.py", line 12, in manager_osm.preparePhotos() File "C:\Users\Desktop\osm-bundler2\osm-bundlerWin64\osmbundler__init.py", line 162, in preparePhotos self._preparePhoto(photoInfo) File "C:\Users\Desktop\osm-bundler2\osm-bundlerWin64\osmbundler__init__.py", line 272, in _preparePhoto self.extractFeatures(photo) File "C:\Users\Desktop\osm-bundler2\osm-bundlerWin64\osmbundler\init__.py", line 350, in extractFeatures self.featureExtractor.extract(photo, self.photoDict[photo]) File "C:\Users\Desktop\osm-bundler2\osm-bundlerWin64\osmbundler\features\siftvlfeat.py", line 23, in extract loweGzipFile.write("%s 128\n" % numFeatures) File "C:\Users\AppData\Local\Continuum\anaconda3\lib\gzip.py", line 260, in write data = memoryview(data) TypeError: memoryview: a bytes-like object is required, not 'str'

ethansu1992 commented 4 years ago

Some one has posted it this online and it works to resolve this issue

def extract(self, photo, photoInfo): logging.info("\tExtracting features with the SIFT method from VLFeat library...") subprocess.call([self.executable, "%s.jpg.pgm" % photo, "-o", "%s.key" % photo])

perform conversion to David Lowe's format

    vlfeatTextFile = open("%s.key" % photo, "r")
    loweGzipFile = gzip.open("%s.key.gz" % photo, "wb")
    featureStrings = vlfeatTextFile.readlines()
    numFeatures = len(featureStrings)
    # write header
    loweGzipFile.write(bytes("%s 128\n" % numFeatures, 'UTF-8'))
    for featureString in featureStrings:
        features = featureString.split()
        # swap features[0] and features[1]
        tmp = features[0]
        features[0] = features[1]
        features[1] = tmp
        i1 = 0
        for i2 in (4,24,44,64,84,104,124,132):
            loweGzipFile.write(bytes("%s\n" % " ".join(features[i1:i2]), 'UTF-8'))
            i1 = i2
    loweGzipFile.close()
    vlfeatTextFile.close()
    # remove original SIFT file
    os.remove("%s.key" % photo)
    logging.info("\tFound %s features" % numFeatures)