Showing posts with label photography. Show all posts
Showing posts with label photography. Show all posts

Friday, August 28, 2026

Determining camera pose from three landmarks and accelerometer: initial notes

Suppose we have three landmarks at known locations in three dimensional space, not all on one line, and a camera that is not located at any landmark but sees all three landmarks, with known optical parameters such as focal length. The problem of determining the camera pose—the camera position and angles—from the positions of the landmarks in the camera image is known as the P3P problem. It is known that in general there will be at most four solutions for camera pose. And indeed sometimes there will be four solutions.

What if we have some additional information, namely we know how the camera is oriented with respect to gravity (e.g., because the camera is held horizontally or it’s equipped with an accelerometer)? Call the problem of reconstructing the camera image from n landmarks and gravity data PnPA. I recently showed that with just two landmarks, i.e., P2PA, there will be either one, two or infinitely many solutions, and geometrically characterized exactly which case occurs when.

Question: What can we say about the number of solutions to P3PA?

In this post I will make some slight progress on this question.

First we characterize when there are more than two solutions. Note that once we know the camera position, we can calculate the direction it’s pointing from the camera image (Lemma 4 in my paper). So we only need to look at the number of solutions for camera position.

Fact 1: There are at most two solutions for P3PA, except in the case where the three landmarks and camera all lie on one horizontal circle, in which case there are infinitely many solutions.

Proof: For P2PA, we have more than two solutions in precisely the following cases: (a) the two landmarks are on a single vertical line; (b) the two landmarks are in the same horizontal plane and so is the camera; and (c) the two landmarks and the camera are all on one line. To have more that two solutions for P3PA, each pair of landmarks must satisfy at least one of (a)–(c). Suppose this is so.

Suppose first that two landmarks, say m1 and m2, satisfy (a). Next suppose that no two landmarks lie on the same horizontal plane, so (b) is satisfied for no pair of landmarks. Then the third landmark m3 does not lie on the same line as both m1 and m2, and hence neither the pair m1 and m3 nor th epair m2 and m3 satisfies (a), and at least one of these pairs fails to satisfy (c). Hence we have a pair that fails to satisfy any of (a)–(c), and we have at most two solutions by my P2PA result.

Now, continuing to suppose m1 and m2 satisfy (a), suppose that some pair of landmarks lies on the same horizontal plane. It can’t be m1 and m2 (as then they will be at the same point, and hence all three landmarks will be on one line). Without loss of generality, suppose m1 and m3 lie on the same horizontal plane H. The pair m1 and m3 cannot satisfy (a) (or else m3 is at the same point as m1). If it satisfies either (b) or (c), the camera is on the plane P, and hence in any case we have (b).

Furthermore, if no two landmarks satisfy (a), then since it can’t be that every pair of landmarks satisfies (c) as that would put all the landmarks on one line, at least one pair of landmarks must satisfy (b).

We thus have reduced to the case where a pair of landmarks satisfies (b): they are on the same horizontal plane H as the camera C. Let’s say that these landmarks are m1 and m2. Let m3 be the projection of m3 to this plane. From the camera’s optical parameters and the camera image, we can calculate the angles m1Cm2, m1Cm3 and m2Cm3. It is known that the locus of points in a plane that subtend the same angle to two fixed points is an arc through these points. Thus, if we are to have more than two solutions, the arcs respectively through m1Cm2, m1Cm3 and m2Cm3 must intersect in at least three points. This would require m1, m2, m3 and C to all lie on the same circle T.

Now, suppose m3 lies off the plane H. Then given the camera image and the gravity vector, we can measure the angle between m3, the camera and the plane H, and given the position of m3 we can compute the distance from m3 to the camera. This constrains the camera to lie on the circle T as well as on a second circle T′ around m3. Since m3 lies on T, these two circles intersect in at most two points. Thus, we have at most two solutions.

On the other hand, when m3 is in the same plane, so m1, m2, m3 and the camera lie on the same horizontal circle, we will have infinitely many solutions. For if A and B are two fixed points on a circle, and C is a third point on the same side as A and B, the angle ACB will be constant regardless of the choice of C. The landmarks m1, m2 and m3 split T into three arcs, and the camera could be anywhere in the arc it’s in as far as the image goes.

Fact 2: There are cases where there are exactly two solutions.



Proof by picture: Suppose m1 and m2 lie on the same plane and m3 lies off the plane. Suppose the camera is horizontally oriented, and pointed at m1. Wherever the camera is on the blue arc, it sees m1 and m2 the same way (because the angle indicated by the dotted lines does not change, as discussed above). The image of m3 in the camera is always directly above or below the image of m1, and as long as the distance from camera to m1 is the same, the image of m3 does not move. Thus, the image of m3 does not change as the camera moves on the red circle. Hence, at the two points where the red and blue circles intersect, the camera sees the same thing, and hence we have two solutions.


Thursday, August 13, 2026

My first (and last?) computer science paper

Some years back I was searching for a better method to play lightgun games like Duck Hunt under emulation by using a Wii remote as a light gun.

The standard Wii remote way of pointing at a TV with a sensor bar underneath is not precise enough. The Wii remote has an infrared camera that tracks the LEDs in the sensor bar, and uses that to estimate where the remote is pointing. But since all the LEDs in the sensor bars lie in a single line, there is no way to determine from the camera image exactly how the Wii remote points. (It’s easy to visualize how rotating the Wii remote about the axis defined by the sensor bar won’t change the camera image in it.) The Wii just guesses, but that’s not good enough for lightgun games.

I already had a way that involved putting four infrared LEDs around my TV, but I was wondering if one could do this with a standard sensor bar by leveraging the additional information from the accelerometer in the Wii remote. A web search came up with a paper by d’Alfonso et al. on determining camera pose using two landmarks and accelerometer. The paper claimed a theorem that, except in certain singular cases, one could determine the pose up to a two-option ambiguity—i.e., there will be two camera orientation/position setups that would result in the same landmark images and accelerometer data.

After thinking about the paper, I realized that the claimed theorem was incorrect: there were singular cases the authors didn’t know about, but more interestingly I discovered cases where one could determine camera pose from two landmark images and accelerometer data without any ambiguity. Moreover, one of these cases was precisely the one relevant to me: the two landmarks are on the same horizontal line (the Wii sensor bar supplies precisely that) and the camera is above or below the plane of that line (easy to arrange). Sadly, experiments showed that Wii remote accelerometer precision was insufficient to determine camera pose in this way.

Anyway, I don’t like the idea of there being a published “theorem” that is incorrect. At some point I worked out all the details with trigonometry, and found a precise characterization of the exact conditions under which in theory (i.e., given a sufficiently precise accelerometer, unlike the one in the Wii remote) one could determine camera pose from two landmark images and gravity data with no ambiguity, with an ambiguity of two, or with an ambiguity of infinity (in some singular cases).

I just got a paper with all the details published.

Sadly, as noted, the Wii remote application didn’t pan out. However, I did write some proof of concept code for my Pixel 7 Pro, and found that it worked pretty decently with its accelerometer. Here’s a screenshot where the accelerometer data plus the screen positions of the (centers of) the bottom two Aruco markers, together with data about the camera and the dimensions of my display board, is used to calculate the screen positions of the upper two Aruco markers (the calculated positions are marked in red).



I kind of suspect that the accelerometer in the right-hand Nintendo Switch joycon might be sufficiently precise for use as a lightgun with two infrared LEDs for positioning, but I haven’t had time to implement this. (Part of the problem is that the infrared LEDs that I have at home are the wrong wavelength for the joycon.)

While this may be my last computer science paper, if some computer science grad student or the like is interested in working with me, we could do some empirical work on seeing how applicable the algorithm is.

Monday, March 24, 2025

Our Baylor alligator

A year or two ago, some juvenile alligators moved into our area or were moved in (we are right on the edge of the alligator zone in Waco). I've been hoping to see one of them. Finally, today, I did, right by Baylor's marina, as you can see from the reflection of the Baylor logo.




Monday, April 8, 2024

Eclipse

The day started off all cloudy, but the clouds got less dense, and then when the eclipse in our front yard reached totality, we had a big break in the clouds.




The first picture has a sunspot in the middle. In the totality picture, slightly to the right of the bottom of the sun in the totality picture there is a hint of a reddish prominence which in my 8" telescope had lovely structure. A quick measurement from the photo shows that the prominence is about seven times the size of the earth.

Tuesday, March 26, 2024

Today's sunspots

Today I was testing the solar filter I got for the eclipse. (300mm f/5.6, cropped).

Sunday, October 15, 2023

Partial eclipse

Handheld, through welder's glass


Hanheld, through eclipse glasses, with a whiff of sunspots (I'll have to get proper solar film for total eclipse photography this spring)

Monday, August 21, 2023

Full professor position at Baylor Philosophy Department

We have an open area full professor position in our Department. If you qualify, I encourage you to apply. If you know someone who qualifies, I encourage you to encourage you to apply. Email me if you need more information or encouragement.

Waco is a lovely place. Here is a bittern at sunset last week. The spot is an easy one mile bike trail-ride along the river from campus.


Sony A7RII with Retina Xenon Schneider-Kreuznach F/1.9 50mm lens (wide-open, cropped).

Wednesday, August 9, 2023

Playing with photo developing

My ten year old and I developed a roll of 35mm film that I shot over the past year in my grandfather's Voigtlander Vito I camera. I've never developed film before. 


2022 Heart of Texas Fair. Fomapan 200.

Wednesday, June 7, 2023

Alligator statue

Waco riverwalk, Yashica 12, HPS5+

Saturday, June 3, 2023

More film photography

I acquired a Yashica 12 medium-format TLR camera from the 1960s. (The lens hood is 3D printed, though.)


I'm still learning how to use it, but here are some pictures on the Waco river walk. The bridge was taken with Arista 400 and the other pictures with HPS5. I need to learn to focus better. 





Wednesday, August 25, 2021

Analog photography

For over a decade, all my photography has been digital, but this spring I finally pulled out the 1939 Voigtlaender Vito 35mm camera I inherited from my grandfather, checked with an oscilloscope (photo-detector on one side, flashlight on the other) that the shutter timer was still correct, loaded it up with 100 ISO black and white film, and took a bunch of pictures around Waco over several months. 

I had the pictures developed and scanned by OneStopDeveloping on Etsy.

Last years, Waco installed a bunch of animal-themed sculptures near the zoo. Though one of the pictures is of real animals.

 









Monday, May 25, 2020

Manual Star Tracker

My Instructable for a simple manual star tracker for astrophotography is now up. The idea is that you manually rotate a knob together in sync with a stopwatch to compensate for the earth's rotation. There is little that is innovative, except for the fact that I accidentally found that a carriage bolt head compensates for tangent error very nicely.


Tuesday, October 4, 2016

The camera as a temporal microscope

For a long time I wanted to take one of those high speed water splash pictures that I've seen other people take. I played around with controlling my Lumix GH3 camera (thanks, Dad!) via WiFi, and considered setting up a microcontroller and a light sensor to time a photo for when an object hits water, like I've seen in some instructions online.

But then I had a much, much simpler idea. Just take pictures in continuous mode. Then if I just drop an object in the water enough times, one of these times I'll capture a nice splash.

I set up a bowl in sunlight, put the camera on a tripod, set exposure time to 1/1300 s, focused manually, and started taking pictures while dropping a rubber ball (to avoid contortions, I used a wired remote). To my surprise, almost every run captured something nice-looking, even though I was only using 6 picture per second mode. And I didn't expect 1/1300 s to be good enough, but it was.

Eternalists like me can think of a still camera as a temporal microscope, stretching an image temporally.

Wednesday, July 3, 2013

Snapping photos of the sky

I took my Panasonic DMC-G1 camera, set it on the widest setting, focused on something lit up in the distance, set it on manual, maximal aperture, 14mm F/3.5 setting on the 14-45mm lens, 30 second exposure, and put it upside down a table on our balcony.  I was surprised how much more you see than with the naked eye.  Here's the result (with the slightest bit of editing to crop and to darken the sky).


That's Lyra at the bottom and Hercules in the middle. If you look really closely, you should be able to see M13:


At 30 seconds, even at this low, low magnification, star trails start.

And here's the Baylor Science Building with Venus setting over it:

Sunday, December 2, 2012

Feeling cold? Apply to our graduate program!

Are you thinking of grad school and feeling cold? As your December days get colder and darker, you may want to reflect on the warm weather in Waco. It was over 80F today.

Of course, the really great thing is the warmth of the graduate student community.

We've extended our deadline for the Baylor Philosophy PhD program this year until January 2.


The anole photo is from today, from the path by the river on campus (or just off campus?).  The butterflies are from Thanksgiving, though I saw a number today, too.