Skip to content
capothehooliganPublic

About

Blender addon that automatically finds the X/Y/Z perspective in an image and builds the matched camera (fSpy-style, no manual line placement)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AutoSpy

A Blender addon that finds the X, Y and Z perspective in an image automatically and builds the matched camera, like fSpy but without placing the lines by hand. Needs only Blender (numpy is bundled).

Install

  1. Run python build_zip.py to produce AutoSpy.zip.
  2. In Blender: Edit > Preferences > Add-ons > Install, pick AutoSpy.zip, and tick AutoSpy.

Use

Open the 3D viewport sidebar (press N), then the AutoSpy tab. The panel is five numbered steps.

1. Align

  1. Choose an image, or an existing .fspy file.
  2. Press Auto Align. This creates a camera named after the file, sets its lens, render size and background image, and switches to camera view.
  3. Check the result. The detected edges are drawn in camera view: red = X, green = Y, blue = Z.
  4. If the horizontal axes are the wrong way round, press Swap X/Y. Change Up picks a different axis as Z.

If the lens is known, tick Lock focal length and enter it (mm on a 36mm sensor).

2. Origin

Press Set Origin, then click a point on the real ground in the photo (a corner where a wall meets the floor works well). That point becomes world (0, 0, 0). Needed before Scale, the scaffold, or tracing, since they all measure from the ground plane.

3. Scale

Enter a real length and pick what it measures: Height, Along X, Along Y, or On Ground for a distance between two ground points. Press Set Scale, click the start of that reference (on the ground), then the end. The whole scene is rescaled so Blender units become real metres.

4. Scene

Add Scene Scaffold adds a ground plane set as a shadow catcher, a sun light, and compositor nodes that layer your render over the photo. Switches the renderer to Cycles (needed for the shadow catcher in 3.6) and the view transform to Standard, since Filmic would wash out the photo. Safe to run again: it updates its own objects rather than duplicating them, and leaves your compositor nodes alone if you've already customised them.

5. Build

Auto Build Box (experimental) needs no clicking. It takes the vertical edges AutoSpy already detected, works out where each one touches the ground and how tall it is, and builds a box spanning all of them.

This is often wrong on real photos, and you should check it before trusting it. On a clean, simple scene it can work well. On a cluttered facade with windows, pipes or brickwork, those edges look just like real corners to the detector, and there's no reliable way to tell them apart from line geometry alone — in testing, it sometimes produced a box the wrong size or shape entirely. Compare the result against the photo, and prefer Trace Walls when it matters.

Manual trace, the reliable way to build, for anything the box doesn't fit or get right:

  • Trace Walls: click a wall's base start, base end, then its top, which adds a vertical quad. The base snaps to the X or Y axis; hold Shift for a free angle. Click again to continue to the next wall from the last corner. Backspace undoes the last click or wall, Esc or right-click finishes.
  • Trace Floor: click two opposite corners of a ground rectangle.

All tools work in camera view. A click above the horizon, or with the camera below the ground, gives a message instead of placing anything — set the origin on the ground first if you see that.

Save

Save .fspy writes a project you can open in the fSpy app to fine tune. It carries the camera's rotation and lens, but not the real-world scale from step 3, since fSpy's own format has no field for it.

What makes a good image

Clear straight edges running in at least two different directions: building corners, window frames, floor and wall lines, tables. Heavily rounded, blurry or cluttered scenes give a Low confidence rating, and the panel says why. Strongly fisheye or wide-angle lenses with visible barrel distortion should be corrected first.

Notes

  • Z is the axis closest to straight up the image, X the remaining one closest to the right, and Y completes a right-handed set.
  • Everything AutoSpy creates (ground, sun, walls, floors) lives in an AutoSpy collection, and moves together when you set the origin or scale.
  • Re-running Auto Align resets the camera to the image's default framing. If you've already set an origin or scale and added traced geometry, it warns that those objects may no longer line up.
  • Tests: python -m pytest tests.

About

Blender addon that automatically finds the X/Y/Z perspective in an image and builds the matched camera (fSpy-style, no manual line placement)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages