Blender sensor sizes

October 28th, 2010 . 22 comments

Today I finally got around to fixing Blender’s weird camera to more closely resemble real-world counterparts. Previously Blender’s camera was hardcoded to use a sensor aperture width of 32mm, which doesn’t reflect any commonly available real-world camera sensor/film size. In turn, this meant the focal length (mm) for the lens didn’t resemble any real-world lenses whatsoever. It was pretty misleading when trying to intuitively choose lenses based on photographic experience, and also makes it a lot harder to match live-action footage.

I’ve made a patch to allow specifying a sensor size, along with a handful of common presets – easy to add some more. This first version isn’t 100% correct in that it doesn’t modify the FOV due to focus (in reality, the extension of the lens elements due to focusing slightly alters the FOV), but this can be added pretty easily as an option later. It’s also deriving the apparent FOV purely based on the horizontal aperture width, options for vertical/diagonal may be possible to add later, but would need to check how the renderer works with varying frame resolution aspect ratios.

I thought it would be fun to do some real-world tests, so I quickly set up a very rough set in my backyard to see if a virtual set in Blender would match up. The setup and measurements were very very dodgy and I didn’t expect it to match perfectly. I shot with two cameras – first a 5D Mk II with a 12-24mm on 24mm and a 24-70mm on 70mm. To compound the un-scientific sketchiness of the test even further I tried again with my 6×6 Mamiya C330f TLR with 65mm and 80mm lenses, using a compact digital camera shooting the ground glass focusing screen (yes, too cheap to spend film on this). Given all this, I was pretty surprised to see that with a bit of tweaking it looks like it’s doing the right thing.

Anyway, the patch is up on the blender patch tracker, would be good to get some testing first before trying to commit, especially since I’m not sure how it should interact with the game engine either.

§ 22 Responses to Blender sensor sizes"

  • ibkanat says:

    yea!!!!! Been waiting for this for a long time. Thanks Matt. Thought the 2010 Bconf was going to come up with a solution looks like you beat them to it. lol

  • You are an absolute genius.

    I so admire your contributions. Thank you so much for this one Matt.

    I will test this weekend.

  • Bupla says:

    These kind of “details” (as some people may believe) are so important. Thanks a lot for working on that.

  • blenderme says:

    great, thanks! small things that have great effect.

  • criaco says:

    A good improvement

    Thanks

  • tcharlss says:

    This is much, much appreciated. I use camera-matching in half of my projects, I cannot empasize enough how usefull it will be for me.

    Thanks man !

  • harkyman says:

    Hiya Matt. I’ll check it this weekend, but when I fixed UV unwrap from camera, I did it pretty generically. I’m not sure if that would need to be modified or not to take this into account. Can’t guarantee I’ll have time to look into it, but I can give it a shot.

  • Mike says:

    Yeah thanks a lot – always better when its consistent with most cameras.

  • William says:

    This is perfect! I’ve recently been doing a fair bit of matching up live action in Blender, and this issue has come up constantly.

    My only gripe is that I hope this doesn’t end in the graveyard of awesome patches.

    Cheers

  • Mitch says:

    Thanks, Matt. This should make camera mapping more accurate. YAY!

  • ibkanat says:

    Just tested with 1/6″(lol very pro camera) sensor finally solved my headaches on a shot

  • Matt says:

    Glad you like it, folks – will try and follow through to get it done properly (though limited time here, help is appreciated :)

  • ejnersan says:

    So nice! I was made aware of this patch just moments after I held my talk on cameras at bconf! This is a perfect time to finally (!!) learn how to patch code, but I hope to see it in trunk soon.

    Thank you, Matt!

  • Yellow says:

    Looking forward to trying this out. Did you correct the images before testing? Like barrel distortion etc, sort of PTLens type calibration?

    Lensfun is a free GPL’d C library going into apps like RawStudio for this very purpose.

  • Yellow says:

    Matt

    Could your code accommodate a crop factor? There are many users who use cameras with non full frame sensors BUT use full frame SLR/DSLR lenses via an adaptor.

    A Canon like a 7D or 550D (APS-C sensor size) or a Lumix can take many different makes of full frame lens. I use lenses from 60’s & 1970’s a lot for example.

    So a 50mm full frame lens is not a 50mm on a APS-C sensor, we have to apply a crop factor, APS-C is 1.6x so 50mm becomes an 80mm.

    It’s a simple calculation of coarse but to have it in the code, would be very useful to many too.

  • Virgilio says:

    This is amazing! This is something incredibly important, and often overlooked. Thank you for yet another great contribution to Blender. :)

  • ejnersan says:

    Yellow,

    The code does take crop factor into account as far as I can see, by setting the correct horizontal field of view in degrees (which is the value that matters ultimately).

    Changing the focal length value by multiplying it with the crop factor will only confuse IMO, since this is not a common pratice in reality (even if you are correct). The lens focal length is still the same even if the crop factor changes the outcome/FoV.

  • Matt says:

    Hi guys, should really get around to finishing this up some time, tsk.

    Yellow: No I didn’t calibrate anything, I thought I mentioned it was a very dodgy and un-scientific test :)

    As for crop factor, ejnersan is correct I think. The size of the sensor that you’re using to record the image doesn’t change the actual focal length (defined as the distance from the center of the lens to the focal point). This is something that is purely a property of the lens, not dependent on anything else.

    Where you say on an APS-C 50mm becomes 80mm, it doesn’t actually become a focal length of 80mm, but rather, it shows the same apparent FOV as an 80mm lens would on a 35mm sensor – it’s a subtle but important difference.

    Anyway, I don’t own an APS-C lens, so I’m not sure how they’re usually labelled, whether they give you the actual focal length or give you a fake ’35mm equivalent’, but as long as you type in the correct data you should get correct results.

  • ejnersan says:

    Hi Matt,

    Lenses for APS-C cameras, like the EF-S series from Canon, are still labelled with their actual focal length. I think it is expected of the user to do the calculation themselves, and as you point out, nothing changes the actual focal length.

    That is also why I’m so happy you made this patch, because we typically only (if ever..) get the focal length used in a shot, and this is pointless if we don’t know which camera (sensor) was used. That’s why if you get told that the focal length was 10mm (which is SUPER wide on a “full frame” sensor), it first makes sense when you find out it was shot on a HDV cam (where the apparent focal length is closer to 50mm). It all comes down to the correct FoV in degrees, which is a value nobody uses directly!

    Also, EXIF data includes the actual focal length used, and camera model, so with that data we can now get the correct FoV. If only it also included location data!

    Last thing, will it be possible to get the vertical FoV in Blender as a property? With this patch we have the data to get this, and it will be easier to make exporters/importers.

  • Yellow says:

    Matt

    re Crop Factor / Full frame lenses on APS-C

    I think there is some confusion here. Field of view and angle of view are two different things. The field of view is the part of the scene that is visible in the viewfinder at any moment and as such it is dependent on crop factor and currently not fully accounted for in your patch re crop. That is the subtle difference.

    The angle of view, the most important aspect of camera matching however is a lens attribute and doesn’t change with crop factor.

    But it crop factor does come into play when real world dimensions are taken to aide camera matching. Using your patch currently, if I use input 50mm as lens focal length(but the 50mm is on a APS-C based camera with a crop factor 1.6 making it 80mm) the real world dimension is useless regardless of whether angle of view is consistent. 80mm is 80mm not 50mm.

    It’s all very well saying that the user should do the calculation themselves with regard to crop factor. That is fine if you use a prime focal length lens (I personally stick to them), however when using a lens with variable focal length ie 50.25 whatever, that calculation becomes annoying, when it could be accounted for in the patch.

    Including the crop factor variable in the patch also indicates that it is acknowledged that it exists and accounted for.

    A tiny addition to the patch that even I as a useless coder could probably hack. Where’s the problem accounting for it?

  • ejnersan says:

    Yellow,

    I think you misunderstood something, “field of view” (FoV) and “angle of view” (AoV) is the exact same thing. And it is highly dependant on sensor sizes.

    If you try to match a scene taken with a 50mm lens on a APS-C camera, the focal length is still 50mm. The FoV/AoV changes to a value that corresponds to a 80mm lens on a “full frame” sensor, but the actual focal length is still 50mm, and that is what you should type in. If you type in 80mm the scene will not match.

    The good thing about Matt’s patch is that users don’t have to think about this, if we know the _actual_ focal length and camera model. If the focal length is 50.25 whatever, that is what we type in together with the sensor size, and we get the correct FoV/AoV. No need to calculate anything ourselves.

    The crop factor calculation is only important for the photographer deciding what lens to use for a shot. If I’m going for a “classic” 50mm FoV/AoV on my APS-C camera, I would use a 30mm lens. You as a VFX artist would then type in 30mm in Blender.

  • zebus says:

    Because they have not even added the patch to blender 2.57? Anyone know anything? Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

What's this?

You are currently reading Blender sensor sizes at Matt Ebb.

meta