Imports cameras, images and point cloud of a Bundler scene
Closed, ArchivedPublic

Description

Project: Blender Extensions
Tracker: Py Scripts Upload
Blender: 2.62
Category: Import Export
Python: 3.1
Homepage: http://koelzk.crispy-cow.de
Script name: import_bundler.py
Author(s): Konrad Kölzer
Status: Open

Features

This script imports a Bundler scene into Blender. Bundler is a free structure-from-motion software developed at the University of Washington that automatically generates an image-based representation using unordered images as input (see more here: http://phototour.cs.washington.edu/bundler/).

A Bundler scene consists of a set of images with reconstructed camera parameters (position, orientation and focal length) and a point cloud that represents a rough estimate of the scene geometry. The import_bundler.py script loads the cameras and point cloud into Bundler. Associated images are added as textured quads in fron of the camera. Imported Bundler scenes can be used as a sketch for 3d modeling.

Setup

The script can be installed as Blender addon in "File > User Preferences > Addons > Install addon...". After that it is displayed as single entry. Click on the checkbox on the right to enable the addon. Now you can start the Import by selecting "File > Import > Bundler (bundle.out)".

Manual

Setting up Bundler is not easy, so feel free to use one of the following scenes for testing:

http://koelzk.crispy-cow.de/temp/hanau_images_800.zip
http://koelzk.crispy-cow.de/temp/test3.zip

After you installed the addon, just click on "File > Import > Bundler (bundle.out)". Now you can select the bundle.out file of your Bundler scene. After the import, you should see something like this:

http://koelzk.crispy-cow.de/temp/blender_bundler_import1.png
http://koelzk.crispy-cow.de/temp/blender_bundler_import2.png

If something went wrong, please let me know.

Some details about the imported data:

  • The whole scene is rotated 90 degrees about the X axis to convert the Up-vector convention from Y-axis (Bundler) to Z-axis (Blender).
  • The image quads are added in front of the camera at a distance of 1 Blender unit. You can adjust this distance by scaling the image quad (camera position is used as scale center)
  • Each camera-image pair is in an individual group. This is useful for finding camera pose or images in huge scenes.

Current limitations of the import:

  • The cameras in Blender represent the aspect ratio of the output, not the aspect ratio of the image.
  • To see the images you have to switch the Viewport shading to Texture first.

Details

Type
Patch

Hi!
Great project!
But i’m can’t import bundler.rd.out (from vsfm) to blender
I have error
[code]
Traceback (most recent call last): File “/home/bm/.config/blender/2.69/scripts/addons/import_bundler.py”, line 282, in execute load(self, context, path) File “/home/bm/.config/blender/2.69/scripts/addons/import_bundler.py”, line 254, in load bfr = load_scene(scene_path) File “/home/bm/.config/blender/2.69/scripts/addons/import_bundler.py”, line 151, in load_scene bfr = BundleFileReader(os.path.join(filepath, “bundle”, “bundle.out”)) File “/home/bm/.config/blender/2.69/scripts/addons/import_bundler.py”, line 90, in init f = open(filepath, “r”)
FileNotFoundError: [Errno 2] No such file or directory: ‘/home/bm/test2/v3/ver3.nvm.cmvs/bundle/bundle.out’

location: <unknown location>:-1
[/code]

My blender version is 2.69.
Fix it please.

Hey brothermechanic,

I ran into this problem as well. The importer expects a certain file name and file structure. That being said if you try to use the scene the author provided to check out exactly what the addon expects. http://koelzk.crispy-cow.de/temp/hanau_images_800.zip

You'll need to find where bundler saved a few files: your image directory, your .out file and your list.txt file
Once you've found these files follow the below instructions:

Rename your file to bundle.out
Put your bundle.out file in a directory called bundle
Take the bundle folder and copy it to your image directory
Copy your list.txt file to your directory
Now try to see if the importer will work :)

Now I'm running into the problem of not being able to see the images in the viewport, despite setting shading to glsl and setting the viewport mode to texture display XD

Cheers,
Ray

Hi,

If you have problems making the images appear in the viewport, check this link:
http://koelzk.crispy-cow.de/article/9/importing-bundler-scenes-to-blender#c000025

Added lights in the scene and seems to have fixed the issues.

Hi, rayfigs!
Thank you so much !!! I do it!
I don't know where is new fixed version (i get that https://developer.blender.org/file/info/PHID-FILE-jcod7twrkeoopplmawlo/)
But i follow your instructions of file placement and get it!!!
Thank you!
http://i.imgur.com/FlxLToT.jpg
http://i.imgur.com/bYiUdXf.jpg
http://i.imgur.com/g1EP5Wv.jpg

Hello
Is it possible to add forsed select focal leight and sensor size of cameras, and import without image planes?

You can modify/extend the import_bundler.py to your needs.

Import without image planes

Just comment out the call to addImagePlane() in line 242 and 243.

Forcing a specific focal length

If you know sensor size and focal length in mm, you should replace line 236 and 237 with the following code:

bcamera.angle_x = math.atan(sensor_width / (focal_length * 2.0)) * 2.0
bcamera.angle_y = math.atan(sensor_height / (focal_length * 2.0)) * 2.0

sensor_width and sensor_height are the sensor width and height in mm. focal_length is the focal length in mm. As you can see in the existing code of script, I am using the same equations, however I use the image resolution and focal length in pixel.

Hello
Thank's for reply
This is not so simply for me
https://bpaste.net/show/c2d10ee3c33f
I do this changes in scrept, but get this error
[code]
Traceback (most recent call last):

File "/home/yeti/.config/blender/2.74/scripts/addons/import_bundler.py", line 282, in execute
  load(self, context, path)
File "/home/yeti/.config/blender/2.74/scripts/addons/import_bundler.py", line 255, in load
  addToBlenderScene(bfr, scene_path) 
File "/home/yeti/.config/blender/2.74/scripts/addons/import_bundler.py", line 248, in addToBlenderScene
  group.objects.link(planeObj)

NameError: name 'planeObj' is not defined

location: <unknown location>:-1
[/code]

Then i uncoment planes and all import as usually
and cameras do not have trye fical leight and sensor
http://wstaw.org/m/2015/05/13/plasma-desktoptZ4168.png
This is what i want
http://wstaw.org/m/2015/05/13/plasma-desktopay4168.png

And it will be usefull if camera settings will be as import option
Thank you anyway

Sorry, I forgot something. You are getting the error, because if you are commenting out line 242 and 243, you also need to comment out line 254. Last but not least I added some code to pass the focal length and sensor size in mm to Blender.

The resulting addToBlenderScene() funciton should look like this then:

def addToBlenderScene(bfr, scene_path):
    global xrot
    print("Adding point cloud...")
    name = "Point_Cloud"
    mesh = bpy.data.meshes.new(name)
    mesh.update()
    mesh.validate()

    points = [point.position for point in bfr.points]
    mesh.from_pydata(points, [], [])
    meshobj = add_obj(mesh, name)
    meshobj.matrix_world = xrot

    # Adding cameras and image planes:
    for index, camera in enumerate(bfr.cameras):
        camera_name = "Camera %d" % index
        # Load image:
        bimage = bpy.data.images.load(
            os.path.join(scene_path, camera.image_path))
        width, height = bimage.size

        # Add camera:
        bcamera = bpy.data.cameras.new(camera_name)
        bcamera.sensor_width = 22.3
        bcamera.sensor_height = 14.9
        bcamera.lens = 18.0
        bcamera.angle_x = math.atan(bcamera.sensor_width / (bcamera.lens * 2.0)) * 2.0
        bcamera.angle_y = math.atan(bcamera.sensor_height / (bcamera.lens * 2.0)) * 2.0
        cameraObj = add_obj(bcamera, camera_name)
        cameraObj.matrix_world = xrot * camera.world

        # Add image plane:
        #planeObj = addImagePlane(camera, bimage, width, height,
        #                         camera.focal_length, "Image Plane %d" % index)

        # Group image plane and camera:
        group = bpy.data.groups.new("Camera Group %d" % index)
        group.objects.link(cameraObj)
        #group.objects.link(planeObj)

Thank you for help.

Last question.

The image name is "0000X.jpg" (for ex), its camera name is "Camera X"
Can you modify your script that cameras have names like its images, like "Camera-0000X"?
It will be more properly i think, and more useful to work.
Thank you for script!

no activity 18 months, Archived.