Destruction of Tamron rear lens cap

This is an update on my camera lens fail post, where my Tamron rear lens cap got permanently stuck on a Samyang lens. Here is the picture story of how it went down.

Camera lens FAIL

Over the weekend I was shooting with my new Samyang 85mm F1.4 and decided to swap it over with a Sigma 30mm F1.4 to do wider shooting. I had a Tamrom rear lens cap in the bag so I used that. I’m lazy when it comes to camera, I just re-use the same rear lens cap for every lens, one size fit all. Never had an issue until recently. The picture below summarises what happened:

Samyang 85mm F1.4 with Tamron rear lens cap
Samyang 85mm F1.4 with Tamron rear lens cap

So what now? My initial plan is to use the CNC as shown below.

What could go wrong? Well, we’ll find out soon enough!

Using Maxima to help write compact and fast matrix maths code and more

I’ve recently discovered this cool piece of open source software called Maxima. For those unfamiliar, it is a Computer Algebra System (CAS). You can express maths problem using symbols (as oppose to numerical values only) and apply common maths operations like integration, differentiation, matrix manipulation, finding roots, solving for x, simplification  etc. etc. to name a few. In fact, it could probably do most of your calculus homework for you, provided the teacher overlooks the fact that you didn’t show any working step.

Maxima operates on the command line but I tend to use the GUI frontend wxMaxima.

Here’s a programming scenario, you need to do a simple matrix operation, like an inversion of a 3×3 matrix to solve a linear problem. You want it fast but don’t want the hassle of linking to an external library, for whatever reason. Sure, you could do a quick Google and probably find an answer or use it as an excuse to play with Maxima. Here is how to do this in wxMaxima.

3x3 matrix inversion
3x3 matrix inversion

M is the 3×3 matrix with each element index by some letter. The output can now be translated directly into C, C++ code or whatever your favourite language is. Notice how the denominator is all the same, so you can improve efficiency by storing it into a variable. You can also check if the denominator is near zero, which would indicate a singular matrix that can’t be inverted.

Eigenvalues of a 3×3 matrix? Sure !

Eigenvalues of a 3x3 matrix
Eigenvalues of a 3x3 matrix ... bad idea

Err okay, maybe not such a great idea.

Need to solve Ax = b? Just re-arrange to x = invert(A)b and you got your answers. You probably only need one IF statement and the rest are maths operation. Not a single FOR loop. How’s that for lean and mean code.

Plans for next RunSFM release

So I found some spare time this weekend to work on RunSFM. I’m working on a version of RunSFM that supports larger dataset, tentatively called RunSFM_Large. It’s just going to be another script that the user can call.

The reason behind RunSFM_Large, besides the obvious need for one, is I’m working on a uni project on the side that requires reconstruction of a large collection of images (> 1000 8MP images). And by working I mean doing a freebie for fun 🙂 Here is what I’ve implemented into RunSFM_Large so far (but not well tested):

  • Reconstruction of large dataset by splitting into smaller manageable ‘bundles’ (chunks, subsets, batch …), and re-combing them later. I’ll probably stick to the term bundle, since it is somewhat consistent with the project.
  • Recovery support for SiftMatcher that allows it to resume from last successful match. The need for recovery support is, again, obvious. When you got a dataset that takes days or weeks to run, the last thing you want to worry is a power failure stuffing up everything.

Things to do:

  • Recovery support for Bundler and PMVS stage. This one should be easy because I only need to keep track of which bundle has been completed or not.

I think RunSFM_Large should work well once done, with some compromise on accuracy. I’m already seeing slight imperfections on a small dataset. It might be a issue with how I’m doing the global optimisation.

Some updates

I’ve been working on the next release of RunSFM to run on a large image set in a reasonable amount of time, instead of what appears to be an ungodly exponential computation time. My plan was to break up the image set into smaller overlapping subsets, run Bundler on each subset in parallel, combine the results together and run PMVS. Sounds great in theory, like most theories, but this venture might be a fail. So far, I’ve got the 3D points from each subset to align up nicely, but the cameras do not! The camera position is probably highly dependent on the sequence of images used. The alternative plan is to run Bundler and PMVS on each subset, then combine the 3D points afterwards. This has a good chance of working, but the camera information will be lost, which might be okay for most applications.

Other than that, I’ve added 2 more tutorial style post in the Notes section, one about finding paths in a directed graph and the other on calculating the Rigid transform between 3D dataset.