# Fisheye-Lens-Based Visual Sun Compass for Perception of Spatial Orientation

Authors: Liang Wang; Fuqing Duan; Ke Lv
Journal: Mathematical Problems in Engineering
 (2012)

---

## Abstract

In complex aeronautical and space engineering systems, conventional sensors used for environment perception fail to determine the orientation because of the influences of the special environments, wherein geomagnetic fields are exceptional and the Global Positioning System is unavailable. This paper presents a fisheye-lens-based visual sun compass that is efficient in determining orientation in such applications. The mathematical model is described, and the absolute orientation is identified by image processing techniques. For robust detection of the sun in the image of the visual sun compass, a modified maximally stable extremal region algorithm and a method named constrained least squares with pruning are proposed. In comparison with conventional sensors, the proposed visual sun compass can provide absolute orientation with a tiny size and light weight in especial environments. Experiments are carried out with a prototype validating the efficiency of the proposed visual sun compass.


---

## Body

## 1. Introduction

Mobile robots possessing various sensors are widely employed for taking measurements and performing tasks in outdoor applications in many fields, including the complex aeronautical and space engineering systems. These applications present many great challenges, one of which is that conventional sensors do not work in emerging special environments. For example, in some planets, magnetic heading detection devices are nonfunctional because of the negligible magnetic fields, and the Global Positioning System (GPS) receiver does not work because there is no GPS available. Therefore, a novel sensor is required to perceive the environment and the robot’s own state.The special aeronautical and space environments have little influence on visual sensors. In addition, being a type of passive sensor, visual sensors do not need a precise and complex mechanical structure, indicating that vibration has little effect on them and there is no mechanical fault. More importantly, visual sensors can provide abundant information, including details of depth, texture, illumination, and so on, with only one measurement (image) [1, 2]. All of these characteristics ensure that visual sensors have the potential to overcome the aforementioned challenges. Therefore, the visual sun compass is proposed to determine orientation for applications in aeronautical and space engineering systems.The concept of the sun compass is derived from studies of the migration of birds [3]. It has been found that birds navigate and orient themselves with the sun as the reference during their migration. Some ornithologists analyzed this sun compass both in theory and by experiment [3]. Then, sun compasses were designed and used for navigation. These compasses were found to perform well in regions with exceptional geomagnetic fields where the magnetic compass fails to work. However, the existing sun compasses (denoted as the classical sun compass) were designed on the basis of the sundial. To obtain precise orientation measurements, the sundial should be sufficiently large, which makes its volume and weight very huge and limits its applications. As a mechanical sensor, it is difficult to embed such a compass in a measuring system and coordinate it with electronic sensors.The visual sun compass proposed in this paper is composed of a fisheye lens and a camera. With improvements and advances in manufacturing techniques, fisheye lens and cameras with high precision and compact structure have been developed, which make the visual sun compass satisfy the requirements of many applications and be easily embedded in a measuring system. In addition, such cameras can cooperate with other electronic sensors because of its electronic output. This type of lens has a large field of view of about 180 degrees, and there is no occlusion to the view and no requirement for precise mechanical assembly.There exist some related works in the literature. The star tracker [4], which comprises a conventional lens and an Active Pixel Sensor camera, is a very precise attitude-measurement sensor. This sensor uses stars as the frame of reference and performs estimation of orientation by identifying the observed stars and measuring their relative positions. However, this sensor is susceptible to various errors, particularly the bright sunlight, because it has high sensibility and is significantly dependent on the star identification algorithm. In addition, the high costs limit its use. Sun sensors are another type of instrument that is similar to the proposed visual sun compass. The sun sensor proposed by Cozman and krotkov [5] is made up of a telephoto lens and a camera. Because a telephoto lens has a very small field of view, a precise mechanical tracking system is needed to capture the sun, and this makes the sensor susceptible to vibration and mechanical fault. Sun sensors proposed by Deans et al. [6] and Trebi-Ollennu el al. [7], which comprise a fisheye lens and a camera, can determine the relative orientation. The imaging model of a pinhole camera is used to describe the imaging mechanism of the fisheye lenses. In addition, extensions with some distortion terms have been proposed; these do not take the characteristics of fisheye lenses into account, but rather introduce some nuisance parameters and increase the computational burden. The centroid of pixels whose intensity values are above a certain threshold is taken as the image of the sun’s center while taking image measurements of the sun [6–9]. In fact, the centroid of these pixels may not be the image of the sun’s center because of image noise and outliers.In this paper, a mathematical model of the visual sun compass, which takes into account characteristics of fisheye lenses, is presented. An effective method for detecting and delineating the sun’s image is provided to robustly calculate the azimuth and elevation angle of the sun. Finally, with the knowledge of the celestial navigation, an estimation of absolute orientation can be obtained. The remainder of this paper is organized as follows. In Section2, the classical sun compass has been introduced. The model of the proposed visual sun compass has been described in Section 3. Section 4 provides a method for detecting and delineating the sun’s image in the visual sun compass. Section 5 presents some experimental results and, finally, in Section 6 the conclusions of this study are presented.


## 2. The Classical Sun Compass

The design of the classical sun compass is based on the sundial, which is originally used to measure time on the basis of the position of the sun’s shadow. A sundial is composed of a style (usually a thin rod or a straight edge) and a dial plate on which hour (or angle) lines are marked. The sun casts a shadow from the style onto the dial plate (see Figure1(a)). As the sun moves, the shadow aligns itself with different angle lines on the plate. If the absolute direction is known, the time at the measuring moment can be calculated on the basis of the shadow. The classical sun compass inverts the traditional role of a sundial. Instead of measuring time, it calculates the absolute direction with the shadow and the time information at the measuring moment.Illustration of the classical sun compass. (a) A sketch of the principle of the classical sun compass. (b) Angles on the dial plate (β: the direction to be measured, γ: the azimuth angle of the sun, φ: the angle of the style’s shadow).
(a)(b)To calculate the absolute direction, first, the dial plate of the classical sun compass should be adjusted to be horizontal. Then, the direction to be estimated should be aligned with one angle line; in general, the angle line with mark 0 is selected. The angle of the style’s shadow, that is, the angleφ in Figure 1(b), and the time at the measuring moment should be measured. To determine the direction β (β=γ-α), the azimuth angle of the sun γ must be calculated. With the knowledge of celestial navigation, the azimuth angle γ can be calculated. As shown in Figure 2, O is the observer’s position, L is the latitude of the observer, N is the north pole of the planet, P is the projection point of the sun on the planet, D is the declination of the sun (the declination is the angle between the rays of the sun and the planet’s equator), and H is the local hour angle (the local hour angle of a point is the angle between the half plane determined by this point and the planet’s axis, and the half plane determined by the sun’s projection point and the planet’s axis, and it can be used to describe the position of a point on the celestial sphere). In the spherical triangle ΔPNO, by the spherical law of cosines (also called the cosine rule for sides), we have(2.1)cos⁡(h)=sin⁡(L)sin⁡(D)+cos⁡(L)cos⁡(D)cos⁡(H).
In (2.1), the observer’s latitude L should be known, and from this the declination of the sun D can be calculated on the basis of the time at measuring moment, and the local hour angle H can be calculated with longitudes of the observer and the projection point of the sun. After the side of spherical triangle ΔPNO, h, being obtained by the spherical law of cosines, the azimuth angle of the sun, γ, can be expressed as(2.2)sin⁡(γ)=-cos⁡(D)sin⁡(H)sin⁡(h).
In addition, by the spherical cosine law for sides,(2.3)cos⁡(γ)=(sin⁡(D)-cos⁡(L)cos⁡(h))cos⁡(L)sin⁡(h).
Thus, the azimuth angle γ can be determined uniquely, and the direction β(=γ-α) can be obtained. In general, it is difficult to obtain precise values of the observer’s longitude and latitude in advance. However, the exact position can be obtained with assumed values of two or more positions and observed azimuth angles by the intercept method [10].Figure 2
Illustration of various angles on the planet when measuring with the sun compass (see text for details of N,P, H, D, O, L, and γ).


## 3. The Visual Sun Compass

The proposed visual sun compass, which is composed of a fisheye lens and a camera, is essentially a fisheye camera. Figure3 shows its imaging process. For a space point P=[XYZ]T (where [•]T denotes the transpose of a vector or matrix), its fisheye image is p=[xy]T, whereas its virtual perspective image would be p′=[x′y′]T as obtained by a pinhole camera. In comparison with a pinhole camera, a fisheye camera has a large field of view of about 180 degrees, which ensures that the sun can be captured with only one image when its optical axis points at the sky. Further, it can be regarded as a sundial, where the optical axis is the style and the image plane is the dial plate. Thus, the sun needs to be identified in the captured fisheye image. Then the azimuth and elevation angle of the sun can be calculated with its imaging model. If the optical axis upright points at the sky when capturing images, the absolute direction (and by the intercept method [10] even the exact position) can be calculated with the time at the image-capture moment and the longitude and latitude of the observer by the method presented in Section 2. Otherwise, the measured azimuth and elevation angles should, first, be transformed into the ground coordinate system with the assistance of an inclinometer or inertial sensor.Illustration of a visual sun compass. (a) Light path. (b) A captured image.
(a)(b)The image of a space pointP is p whereas it would be p′ by a pinhole camera; (θ,φ) is the incidence angle of p (or the direction of the incoming ray from P); r is the distance between the image point p and the principal point (u0,v0); and f is the focal length.


### 3.1. Imaging Model of Fisheye Camera

A pinhole camera model with some distortion terms is used to describe the fisheye lens and determine the relative direction in [6, 7], which do not consider the characteristics of fisheye lenses. In fact, fisheye lenses are usually designed to follow some types of projection geometry. Table 1 shows some ideal projection models of fisheye lenses [11]. Because the ideal model is not strictly satisfied and, in some cases, the type of a fisheye lens may be unknown in advance; a more general mathematical model is needed to describe the visual sun compass.Table 1
Projection geometry of fisheye lens.
Project typeModelStereographicr=2ftan(θ⁄2)Orthogonalr=fsin(θ)Equidistantr=fθEquisolid angler=2fsin(θ/2)Various imaging models of fisheye cameras have been proposed in the literature. These models can be divided into two categories as follows.


#### 3.1.1. Mapping from an Incident Ray to a Fisheye Image Point

A fisheye camera can be described by the mapping from an incident ray to a fisheye image point:[X/RY/RZ/R]T→[xy]T or θ→r, where R=X2+Y2+Z2, the incidence angle θ is the angle between the principle axis and the incident ray p′P (see Figure 3), and r=x2+y2.


#### 3.1.2. Mapping from a Virtual Perspective Image to a Fisheye Image

A fisheye camera can also be described with the mapping from a virtual perspective image to a fisheye image by[x′y′]T→[xy]T or r′→r, where r′=x′2+y′2. The rational function [12] belongs to this class(3.1)r=ε1r′(1-ε2r′2),
where ε1 and ε2 are two parameters for the lens type.The former class is more straightforward and popular and represents the real imaging process of a fisheye camera [12]. In fact, the latter class can also be described in the form of the former. For example, (3.1) can be expressed as r=ε1ftan(θ)/(1-ε2f2tan2(θ)).Different to fisheye cameras, central catadioptric cameras have an elegant unified imaging model [13]. Ying and Hu [14] discovered that this unified imaging model could be extended to some fisheye cameras.As shown in Figure4, the unified imaging model for central catadioptric cameras can be described as follows. A space point [XYZ]T is first projected to a point [X/RY/RZ/R]T on the unit sphere. Then, it is mapped on the image plane, z=-m, via a projection from the point [00ξ]T. The coordinates of the point on the image plane are(3.2)[xy]T=[(ξ+m)XξR-Z(ξ+m)YξR-Z]T.
Now, with r=x2+y2, we have a mapping: θ→r,(3.3)r=(ξ+m)sin⁡(θ)ξ+cos⁡(θ).
Equation (3.3) can describe the imaging process of catadioptric projections with parabolic, hyperbolic, and elliptical mirrors with different ξ and m [13]. Let ξ=∞, for all m≠∞; then (3.3) can describe the imaging process of a fisheye camera with the orthogonal projection. Let ξ=1, m=2f-1, then (3.3) can describe the imaging process of a fisheye camera with the stereographic projection. All of these mean that the unified imaging model (3.3) can be used to describe some fisheye cameras, which are consistent with conclusions of Ying and Hu [14].Figure 4
The unified imaging model for central catadioptric cameras.However, for fisheye cameras with equidistant and equisolid angle projections, which are more widely used in real applications, the unified imaging model does not fit. Assuming without loss of generality thatm=1 and f=1, submit r=fθ and r=2fsin(θ/2) into (3.3), respectively. The obtained type parameters ξ are (sin(θ)-θcos(θ))/(θ-sin(θ)) and cos(θ/2)/(1-cos(θ/2)). This shows that the parameters ξ of these two types of fisheye cameras vary with the incident angle θ. This indicates that these fisheye cameras do not have a unique central view point. Therefore, the unified model (3.3) does not exactly describe the imaging process of all fisheye cameras.In fact, the Maclaurin Series of all fisheye lenses listed in Table1 have the same form(3.4)r=k1θ+k2θ3+k3θ5+⋯.
Without loss of generality, we take (3.4) as the model of fisheye lenses. Different from the model proposed by Trebi-Ollennu et al. [7], there are only odd-order terms. As shown in Figure 5, there are only slight differences between the ideal models and their 3rd- and 5th-order Maclaurin Series when θ∈[0,π/2], that is, within the field of view of fisheye lenses. In practice, the 3rd-order Maclaurin Series is taken as a compromise between precision and computation efficiency:(3.5)r=k1θ+k2θ3.
Then, the projection procedure of a fisheye camera can be described with the following four steps.Figure 5
The ideal models of fisheye lenses and their 3rd- and 5th-order Maclaurin Series.Step 1.
A space pointP in the world coordinate system is transformed to incident angles (θ,φ) in the camera coordinate system with the relative rotation R and translation t of two coordinate systems:
(3.6)[sin⁡(θ)cos⁡(φ)sin⁡(θ)sin⁡(φ)cos⁡(θ)]T=(RX+t)‖RX+t‖.Step 2.
The incoming direction(θ,φ) is transformed into the normalized image coordinates (x,y). In this case, the general form (3.5) of fisheye cameras’ model is considered. Then, the normalized image coordinates can be expressed as
(3.7)[xy]T=(k1θ+k2θ3)[cos⁡(φ)sin⁡(φ)]T.Step 3.
To compensate for deviations of the fisheye model from the real camera, distortion terms, called radial distortion and decentering distortion, can be introduced. The former represents the distortion of ideal image points along radial directions from the distortion center. The latter represents the distortion of ideal image points in tangential directions. The distortions can be expressed as functions of radial distancer=x2+y2:
(3.8)δx=x(m1r2+m2r4)+[p1(r2+2x2)+p2xy](1+p3r2),δy=y(m1r2+m2r4)+[p1xy+p2(r2+2y2)](1+p3r2),
where mi is the coefficient of radial distortions and pi the coefficient of decentering distortions.Step 4.
Apply affine transformation to the coordinates(x,y). Assuming that the pixel coordinate system is orthogonal, we get the pixel coordinates
(3.9)[uv]=[fu00fv]([xy]+[δxδy])+[u0v0],
where fu, fv are the scale factors along the horizontal and vertical directions, respectively, and (u0,v0) is the principal point.
Therefore, we have a more general imaging model of fisheye cameras:(3.10)[uv]=[fu00fv]((k1θ+k2θ3)[cos⁡(φ)sin⁡(φ)]+[δxδy])+[u0v0].
Parameters in this model can be obtained by camera calibration. It appears rational that an elaborate model (3.10) with distortions (3.8) may perfectly model the real imaging process. However, we find that, just like the case of a pinhole camera [15], a more elaborate modeling would not help (negligible when compared with sensor quantization), but cause numerical instability. In addition, it makes the calibration of the system more complicated and brings in a very high computation cost, which most applications cannot afford currently. Therefore, we omit distortions and take the following model in practice:
(3.11)[uv]=(k1θ+k2θ3)[fu00fv][cos⁡(φ)sin⁡(φ)]+[u0v0].


### 3.2. The Model of the Visual Sun Compass

With the imaging model of fisheye cameras (3.11), the absolute direction of a point p in the captured image can be determined from its pixel coordinates (u,v). Firstly the normalized image coordinates can be expressed as(3.12)[xy]=([fu00fv])-1([uv]-[u0v0]).
Then, the incidence angles (θ,φ) of the incoming ray in the visual sun compass coordinate system can be calculated with(3.13)φ=arctan2(y,x),k1θ+k2θ3=sqrt(x2+y2).
If the optical axis upright points at the sky when taking images, which means the visual sun compass coordinate system is parallel with the ground coordinate system and the rotation matrix between them is a 3×3 identity matrix, angles (θ,φ) calculated by (3.13) are also the incidence angles in the ground coordinate system. Otherwise, the calculated (θ,φ) should be first transformed to the ground coordinate system. With an inclinometer or inertial sensor, the rotation matrix from the visual sun compass coordinate system to the ground plane coordinate system, Rf2g, can be obtained. The unit vector indicating the incidence angle of an image point p is denoted as P̂s=[x̂sŷsẑs]T in the ground plane coordinate system, which satisfies(3.14)P̂s=[x̂sŷsẑs]T=[cos⁡(φ̂)sin⁡(θ̂)sin⁡(φ̂)sin⁡(θ̂)cos⁡(θ̂)]T=Rf2g[cos⁡(φ)sin⁡(θ)sin⁡(φ)sin⁡(θ)cos⁡(θ)]T.
The corresponding azimuth angle and elevation angle (θ̂,φ̂) in the ground plane coordinate system can be expressed as:(3.15)θ̂=arccos(ẑs),φ̂=arctan2(x̂ssin⁡(θ̂),ŷssin⁡(θ̂)).
With (3.12)–(3.15), the incidence angle in the ground plane coordinate system of an image point can be calculated, where parameters of the fisheye lens, (fu,fv,s,u0,v0,k1,k2), can be calibrated off-line in advance. The obtained azimuth angle φ̂ corresponds to the φ shown in Section 2. Then, with local time and estimated longitude, the angle γ can be calculated. Finally, the absolute direction β can be derived with the obtained φ̂ and γ, as shown in Section 2.


## 3.1. Imaging Model of Fisheye Camera

A pinhole camera model with some distortion terms is used to describe the fisheye lens and determine the relative direction in [6, 7], which do not consider the characteristics of fisheye lenses. In fact, fisheye lenses are usually designed to follow some types of projection geometry. Table 1 shows some ideal projection models of fisheye lenses [11]. Because the ideal model is not strictly satisfied and, in some cases, the type of a fisheye lens may be unknown in advance; a more general mathematical model is needed to describe the visual sun compass.Table 1
Projection geometry of fisheye lens.
Project typeModelStereographicr=2ftan(θ⁄2)Orthogonalr=fsin(θ)Equidistantr=fθEquisolid angler=2fsin(θ/2)Various imaging models of fisheye cameras have been proposed in the literature. These models can be divided into two categories as follows.


### 3.1.1. Mapping from an Incident Ray to a Fisheye Image Point

A fisheye camera can be described by the mapping from an incident ray to a fisheye image point:[X/RY/RZ/R]T→[xy]T or θ→r, where R=X2+Y2+Z2, the incidence angle θ is the angle between the principle axis and the incident ray p′P (see Figure 3), and r=x2+y2.


### 3.1.2. Mapping from a Virtual Perspective Image to a Fisheye Image

A fisheye camera can also be described with the mapping from a virtual perspective image to a fisheye image by[x′y′]T→[xy]T or r′→r, where r′=x′2+y′2. The rational function [12] belongs to this class(3.1)r=ε1r′(1-ε2r′2),
where ε1 and ε2 are two parameters for the lens type.The former class is more straightforward and popular and represents the real imaging process of a fisheye camera [12]. In fact, the latter class can also be described in the form of the former. For example, (3.1) can be expressed as r=ε1ftan(θ)/(1-ε2f2tan2(θ)).Different to fisheye cameras, central catadioptric cameras have an elegant unified imaging model [13]. Ying and Hu [14] discovered that this unified imaging model could be extended to some fisheye cameras.As shown in Figure4, the unified imaging model for central catadioptric cameras can be described as follows. A space point [XYZ]T is first projected to a point [X/RY/RZ/R]T on the unit sphere. Then, it is mapped on the image plane, z=-m, via a projection from the point [00ξ]T. The coordinates of the point on the image plane are(3.2)[xy]T=[(ξ+m)XξR-Z(ξ+m)YξR-Z]T.
Now, with r=x2+y2, we have a mapping: θ→r,(3.3)r=(ξ+m)sin⁡(θ)ξ+cos⁡(θ).
Equation (3.3) can describe the imaging process of catadioptric projections with parabolic, hyperbolic, and elliptical mirrors with different ξ and m [13]. Let ξ=∞, for all m≠∞; then (3.3) can describe the imaging process of a fisheye camera with the orthogonal projection. Let ξ=1, m=2f-1, then (3.3) can describe the imaging process of a fisheye camera with the stereographic projection. All of these mean that the unified imaging model (3.3) can be used to describe some fisheye cameras, which are consistent with conclusions of Ying and Hu [14].Figure 4
The unified imaging model for central catadioptric cameras.However, for fisheye cameras with equidistant and equisolid angle projections, which are more widely used in real applications, the unified imaging model does not fit. Assuming without loss of generality thatm=1 and f=1, submit r=fθ and r=2fsin(θ/2) into (3.3), respectively. The obtained type parameters ξ are (sin(θ)-θcos(θ))/(θ-sin(θ)) and cos(θ/2)/(1-cos(θ/2)). This shows that the parameters ξ of these two types of fisheye cameras vary with the incident angle θ. This indicates that these fisheye cameras do not have a unique central view point. Therefore, the unified model (3.3) does not exactly describe the imaging process of all fisheye cameras.In fact, the Maclaurin Series of all fisheye lenses listed in Table1 have the same form(3.4)r=k1θ+k2θ3+k3θ5+⋯.
Without loss of generality, we take (3.4) as the model of fisheye lenses. Different from the model proposed by Trebi-Ollennu et al. [7], there are only odd-order terms. As shown in Figure 5, there are only slight differences between the ideal models and their 3rd- and 5th-order Maclaurin Series when θ∈[0,π/2], that is, within the field of view of fisheye lenses. In practice, the 3rd-order Maclaurin Series is taken as a compromise between precision and computation efficiency:(3.5)r=k1θ+k2θ3.
Then, the projection procedure of a fisheye camera can be described with the following four steps.Figure 5
The ideal models of fisheye lenses and their 3rd- and 5th-order Maclaurin Series.Step 1.
A space pointP in the world coordinate system is transformed to incident angles (θ,φ) in the camera coordinate system with the relative rotation R and translation t of two coordinate systems:
(3.6)[sin⁡(θ)cos⁡(φ)sin⁡(θ)sin⁡(φ)cos⁡(θ)]T=(RX+t)‖RX+t‖.Step 2.
The incoming direction(θ,φ) is transformed into the normalized image coordinates (x,y). In this case, the general form (3.5) of fisheye cameras’ model is considered. Then, the normalized image coordinates can be expressed as
(3.7)[xy]T=(k1θ+k2θ3)[cos⁡(φ)sin⁡(φ)]T.Step 3.
To compensate for deviations of the fisheye model from the real camera, distortion terms, called radial distortion and decentering distortion, can be introduced. The former represents the distortion of ideal image points along radial directions from the distortion center. The latter represents the distortion of ideal image points in tangential directions. The distortions can be expressed as functions of radial distancer=x2+y2:
(3.8)δx=x(m1r2+m2r4)+[p1(r2+2x2)+p2xy](1+p3r2),δy=y(m1r2+m2r4)+[p1xy+p2(r2+2y2)](1+p3r2),
where mi is the coefficient of radial distortions and pi the coefficient of decentering distortions.Step 4.
Apply affine transformation to the coordinates(x,y). Assuming that the pixel coordinate system is orthogonal, we get the pixel coordinates
(3.9)[uv]=[fu00fv]([xy]+[δxδy])+[u0v0],
where fu, fv are the scale factors along the horizontal and vertical directions, respectively, and (u0,v0) is the principal point.
Therefore, we have a more general imaging model of fisheye cameras:(3.10)[uv]=[fu00fv]((k1θ+k2θ3)[cos⁡(φ)sin⁡(φ)]+[δxδy])+[u0v0].
Parameters in this model can be obtained by camera calibration. It appears rational that an elaborate model (3.10) with distortions (3.8) may perfectly model the real imaging process. However, we find that, just like the case of a pinhole camera [15], a more elaborate modeling would not help (negligible when compared with sensor quantization), but cause numerical instability. In addition, it makes the calibration of the system more complicated and brings in a very high computation cost, which most applications cannot afford currently. Therefore, we omit distortions and take the following model in practice:
(3.11)[uv]=(k1θ+k2θ3)[fu00fv][cos⁡(φ)sin⁡(φ)]+[u0v0].


## 3.1.1. Mapping from an Incident Ray to a Fisheye Image Point

A fisheye camera can be described by the mapping from an incident ray to a fisheye image point:[X/RY/RZ/R]T→[xy]T or θ→r, where R=X2+Y2+Z2, the incidence angle θ is the angle between the principle axis and the incident ray p′P (see Figure 3), and r=x2+y2.


## 3.1.2. Mapping from a Virtual Perspective Image to a Fisheye Image

A fisheye camera can also be described with the mapping from a virtual perspective image to a fisheye image by[x′y′]T→[xy]T or r′→r, where r′=x′2+y′2. The rational function [12] belongs to this class(3.1)r=ε1r′(1-ε2r′2),
where ε1 and ε2 are two parameters for the lens type.The former class is more straightforward and popular and represents the real imaging process of a fisheye camera [12]. In fact, the latter class can also be described in the form of the former. For example, (3.1) can be expressed as r=ε1ftan(θ)/(1-ε2f2tan2(θ)).Different to fisheye cameras, central catadioptric cameras have an elegant unified imaging model [13]. Ying and Hu [14] discovered that this unified imaging model could be extended to some fisheye cameras.As shown in Figure4, the unified imaging model for central catadioptric cameras can be described as follows. A space point [XYZ]T is first projected to a point [X/RY/RZ/R]T on the unit sphere. Then, it is mapped on the image plane, z=-m, via a projection from the point [00ξ]T. The coordinates of the point on the image plane are(3.2)[xy]T=[(ξ+m)XξR-Z(ξ+m)YξR-Z]T.
Now, with r=x2+y2, we have a mapping: θ→r,(3.3)r=(ξ+m)sin⁡(θ)ξ+cos⁡(θ).
Equation (3.3) can describe the imaging process of catadioptric projections with parabolic, hyperbolic, and elliptical mirrors with different ξ and m [13]. Let ξ=∞, for all m≠∞; then (3.3) can describe the imaging process of a fisheye camera with the orthogonal projection. Let ξ=1, m=2f-1, then (3.3) can describe the imaging process of a fisheye camera with the stereographic projection. All of these mean that the unified imaging model (3.3) can be used to describe some fisheye cameras, which are consistent with conclusions of Ying and Hu [14].Figure 4
The unified imaging model for central catadioptric cameras.However, for fisheye cameras with equidistant and equisolid angle projections, which are more widely used in real applications, the unified imaging model does not fit. Assuming without loss of generality thatm=1 and f=1, submit r=fθ and r=2fsin(θ/2) into (3.3), respectively. The obtained type parameters ξ are (sin(θ)-θcos(θ))/(θ-sin(θ)) and cos(θ/2)/(1-cos(θ/2)). This shows that the parameters ξ of these two types of fisheye cameras vary with the incident angle θ. This indicates that these fisheye cameras do not have a unique central view point. Therefore, the unified model (3.3) does not exactly describe the imaging process of all fisheye cameras.In fact, the Maclaurin Series of all fisheye lenses listed in Table1 have the same form(3.4)r=k1θ+k2θ3+k3θ5+⋯.
Without loss of generality, we take (3.4) as the model of fisheye lenses. Different from the model proposed by Trebi-Ollennu et al. [7], there are only odd-order terms. As shown in Figure 5, there are only slight differences between the ideal models and their 3rd- and 5th-order Maclaurin Series when θ∈[0,π/2], that is, within the field of view of fisheye lenses. In practice, the 3rd-order Maclaurin Series is taken as a compromise between precision and computation efficiency:(3.5)r=k1θ+k2θ3.
Then, the projection procedure of a fisheye camera can be described with the following four steps.Figure 5
The ideal models of fisheye lenses and their 3rd- and 5th-order Maclaurin Series.Step 1.
A space pointP in the world coordinate system is transformed to incident angles (θ,φ) in the camera coordinate system with the relative rotation R and translation t of two coordinate systems:
(3.6)[sin⁡(θ)cos⁡(φ)sin⁡(θ)sin⁡(φ)cos⁡(θ)]T=(RX+t)‖RX+t‖.Step 2.
The incoming direction(θ,φ) is transformed into the normalized image coordinates (x,y). In this case, the general form (3.5) of fisheye cameras’ model is considered. Then, the normalized image coordinates can be expressed as
(3.7)[xy]T=(k1θ+k2θ3)[cos⁡(φ)sin⁡(φ)]T.Step 3.
To compensate for deviations of the fisheye model from the real camera, distortion terms, called radial distortion and decentering distortion, can be introduced. The former represents the distortion of ideal image points along radial directions from the distortion center. The latter represents the distortion of ideal image points in tangential directions. The distortions can be expressed as functions of radial distancer=x2+y2:
(3.8)δx=x(m1r2+m2r4)+[p1(r2+2x2)+p2xy](1+p3r2),δy=y(m1r2+m2r4)+[p1xy+p2(r2+2y2)](1+p3r2),
where mi is the coefficient of radial distortions and pi the coefficient of decentering distortions.Step 4.
Apply affine transformation to the coordinates(x,y). Assuming that the pixel coordinate system is orthogonal, we get the pixel coordinates
(3.9)[uv]=[fu00fv]([xy]+[δxδy])+[u0v0],
where fu, fv are the scale factors along the horizontal and vertical directions, respectively, and (u0,v0) is the principal point.
Therefore, we have a more general imaging model of fisheye cameras:(3.10)[uv]=[fu00fv]((k1θ+k2θ3)[cos⁡(φ)sin⁡(φ)]+[δxδy])+[u0v0].
Parameters in this model can be obtained by camera calibration. It appears rational that an elaborate model (3.10) with distortions (3.8) may perfectly model the real imaging process. However, we find that, just like the case of a pinhole camera [15], a more elaborate modeling would not help (negligible when compared with sensor quantization), but cause numerical instability. In addition, it makes the calibration of the system more complicated and brings in a very high computation cost, which most applications cannot afford currently. Therefore, we omit distortions and take the following model in practice:
(3.11)[uv]=(k1θ+k2θ3)[fu00fv][cos⁡(φ)sin⁡(φ)]+[u0v0].


## 3.2. The Model of the Visual Sun Compass

With the imaging model of fisheye cameras (3.11), the absolute direction of a point p in the captured image can be determined from its pixel coordinates (u,v). Firstly the normalized image coordinates can be expressed as(3.12)[xy]=([fu00fv])-1([uv]-[u0v0]).
Then, the incidence angles (θ,φ) of the incoming ray in the visual sun compass coordinate system can be calculated with(3.13)φ=arctan2(y,x),k1θ+k2θ3=sqrt(x2+y2).
If the optical axis upright points at the sky when taking images, which means the visual sun compass coordinate system is parallel with the ground coordinate system and the rotation matrix between them is a 3×3 identity matrix, angles (θ,φ) calculated by (3.13) are also the incidence angles in the ground coordinate system. Otherwise, the calculated (θ,φ) should be first transformed to the ground coordinate system. With an inclinometer or inertial sensor, the rotation matrix from the visual sun compass coordinate system to the ground plane coordinate system, Rf2g, can be obtained. The unit vector indicating the incidence angle of an image point p is denoted as P̂s=[x̂sŷsẑs]T in the ground plane coordinate system, which satisfies(3.14)P̂s=[x̂sŷsẑs]T=[cos⁡(φ̂)sin⁡(θ̂)sin⁡(φ̂)sin⁡(θ̂)cos⁡(θ̂)]T=Rf2g[cos⁡(φ)sin⁡(θ)sin⁡(φ)sin⁡(θ)cos⁡(θ)]T.
The corresponding azimuth angle and elevation angle (θ̂,φ̂) in the ground plane coordinate system can be expressed as:(3.15)θ̂=arccos(ẑs),φ̂=arctan2(x̂ssin⁡(θ̂),ŷssin⁡(θ̂)).
With (3.12)–(3.15), the incidence angle in the ground plane coordinate system of an image point can be calculated, where parameters of the fisheye lens, (fu,fv,s,u0,v0,k1,k2), can be calibrated off-line in advance. The obtained azimuth angle φ̂ corresponds to the φ shown in Section 2. Then, with local time and estimated longitude, the angle γ can be calculated. Finally, the absolute direction β can be derived with the obtained φ̂ and γ, as shown in Section 2.


## 4. Detecting the Sun in the Image

To calculate the absolute direction with the proposed visual sun compass, the sun’s image in captured images should be detected and measured. In practice, image noises may make the apparent outline of the sun’s image greatly deviate from the real configuration, and outliers may generate false alarms with regard to the sun’s image. Therefore, the conventional method, which takes the centroid of pixels whose intensity values are above a certain threshold as the image of the sun’s center, may fail to find the real image of the sun’s center. Because the image of a sphere under the unified imaging model is an ellipse and fisheye lenses model (3.11) approximates the unified imaging model (3.3), we take the image of the sun as a blob. Then, use a modified maximally stable extremal region (MSER) algorithm, which can remove redundant blobs and accelerate the processing speed of MSER, to detect the blob. Finally, fit an ellipse with the blob’s contour and take the ellipse’s center as the image of the sun’s center. The details are as follows.Firstly, narrow down the threshold’s varying range of the MSER and detect the sun’s image. The MSER [16] was originally proposed to establish tentative correspondences between a pair of images taken from different viewpoints. Its principle can be summarized as follows [16]. For a gray-level picture, take all possible thresholds. The pixels whose intensity values are equal to or greater than the threshold t are taken as white, and the others are denoted as black. By increasing the threshold t continually, a series of binary pictures Et would be seen, where the subscript t indicates the frame corresponding to a threshold t. Initially, a white frame would be obtained. Thereafter, black spots corresponding to local intensity minima would emerge and grow with increase in the threshold. Neighboring regions corresponding to two local minima will merge to a larger one gradually, and the last frame would be black. An MSER is a connected region in Et with little size change across a range of thresholds.By the original MSER method, not only the blob corresponding to the image of the sun but also some blobs corresponding to other regions would be found. Consider that the intensity value of the sun’s image is very close to 255 because it is sufficiently bright. Let the threshold vary only in a small range[255-δ1,255] when performing MSER detection, where δ1 is a variable of limiting the varying range of thresholds. The computation cost can be dramatically reduced and those regions with great difference from the sun’s image in intensity can be removed.Secondly, remove the false alarms of the sun’s image with the aspect ratio constraint. The sun’s image in the visual sun compass is close to a circle. The constraint that the aspect ratio of the sun’s image approximates to 1 can be used to further refine detected MSERs. By these modifications, only one or some nested MSERs can be obtained.Thirdly, remove redundant nested MSERs and obtain the blob corresponding to the sun’s image. In this step, the kernel MSER, which refers to the most stable one among nested MSERs, is proposed to remove redundant nested MSERs. For a sequence of nested MSERs,Q1, …, Qk-1, Qk, …, Qm, where Qk-1⊂Qk, the kernel MSER Q̂ satisfies(4.1)Q̂:min⁡k=1m(std(I(qk))),qk∈Qk,
where std(I(qk)) is the standard deviation of the intensity of all pixels qk in MSER Qk. The kernel MSER takes not only the maximally stable region’s cardinality but also the statistical property of intensity into account.Fourthly, prune contour points are contaminated by image noise and fit ellipse with the remaining points. Because the blob detected by the modified MSER is a continuous region, only few contiguous outliers and noises contaminate the sun’s image. For further robust processing, an ellipse is fitted with points of the blob contour to describe the sun’s image. A direct method to fit ellipse is the constrained least squares (LS) method [17]. In images captured by the visual sun compass, although contiguous outliers and contaminated points are within the detected blob, they are far away from the real geometric configuration and greatly change the shape of the sun’s image. Therefore, the distance from the boundary point to the blob’s center is taken as the measure to purify the data. Points whose distance is the least under a certain percentage are used to fit the ellipse, and other points which are far away from the geometric configuration are taken as outliers and pruned. This method is called the constrained LS with pruning.Finally, use coefficients of the fitted ellipse to calculate its center. Then, take the center as the image of the sun’s center to estimate the sun’s azimuth and elevation angle.


## 5. Experiments

A prototype of the visual sun compass (as shown in Figure6) was built, which comprised a Feith intelligent CANCam and a FUJION FE185C057HA-1 fisheye lens. A two-dimensional (2D) calibration board [15] was used to calibrate the visual sun compass. The calibrated parameters in (3.11) are k1=1.7941, k2=-0.0043, fu=166.1549, fv=167.1770, u0=654.5771, and v0=532.6644. Experiments with this prototype were conducted to validate the proposed visual sun compass.Figure 6
The prototype of the proposed visual sun compass.


### 5.1. Detecting the Sun

Some images were captured with the optical axis of the sun compass’s prototype upright pointing at the sky at different hours in the daytime from May to July. The sun was detected in these images with the original MSER method, the conventional method, and the proposed modified MSER method. Figure7(a) shows an image captured by the visual sun compass. Figure 7(b) shows the blobs detected by the original MSER method. It can be seen that, with the original MSER method, some redundant blobs were detected and the image of the sun’s center could not be uniquely determined. For the conventional method, the estimated center is far away from the real configuration as shown in Figure 7(c), because intensity values of outliers are close to those of the sun’s image. By applying the proposed modified MSER and the constrained LS with pruning to this image, the obtained result is shown in Figure 7(d). It is evident that only one region is obtained and the difference between the fitted ellipse and the image of the sun is slight. These results prove the validity of the proposed method.An image captured by the visual sun compass and experiment results. (a) Image captured by the visual sun compass. (b) Blobs detected by the original MSER. (c) The center detected by the conventional method. (d) The detected sun and its center by the proposed method.
(a)(b)(c)(d)


### 5.2. Orientation Estimation

By the proposed visual sun compass model, the elevation angle of the sunθ and “the angle of the style’s shadow” φ can be calculated with the calibrated parameters and the detected sun’s center. Table 2 shows some results, where “G.T.” denotes the ground truth and “est.” denotes the estimation. It is obvious that, for the estimated sun’s elevation angle θ, there is a little difference from the ground truth (values from the astronomic almanac corresponding to the time and the latitude and longitude information). Then, the azimuth angle γ of the sun and the absolute directions β in the ground plane coordinate system are calculated with the time, the latitude, and longitude information. Results are shown in Table 2. For the azimuth angle γ, the difference between the estimated values and the ground truth is very slight. The errors of the absolute direction with proposed method are less than 3.5°. They may arise from several sources. The primary source is the current rudimentary experimental setup: the visual sun compass is made horizontal using barely eye inspection with a spirit level, and the ground truth of the estimated direction is obtained by eye inspection of a simple magnetic needle compass. Nonetheless, experiments show the validity of the proposed visual sun compass.Table 2
Orientation results with visual sun compass (in degrees).
ElevationθAngleφAzimuthγOrientationβG.T.est.est.G.T.est.G.T.est.35.4736.57−87.64−89.87−89.870.0−2.2360.4360.86−125.1062.9262.92185.0188.0258.1059.92−115.6668.7868.77185.0184.43


### 5.3. Application

We also applied the prototype of the visual sun compass on a mobile robot to carry out orientation estimation. Figure8 shows the mobile robot, on which the visual sun compass prototype, a Crossbow VG700CB-200 IMU, and other sensors are mounted. The IMU can provide its own attitude relative to the ground coordinate system. The relative rotation between the IMU and the visual sun compass can be calibrated off-line in advance. Then, the rotation from the visual sun compass to the ground coordinate system, Rf2g in (3.14), can be determined. Orientation experiments are conducted with this mobile robot to validate the proposed visual sun compass. Some results are shown in Table 3. With the help of the IMU, the deviations from the ground truth are less than those reported above. All of these results prove the validity of the proposed visual sun compass.Table 3
Absolute orientation results with a mobile robot (in degrees).
G.T.30.0060.0090.00150.00180.00est.28.0859.6392.75152.31180.77Figure 8
The mobile robot mounted with the visual sun compass prototype and an IMU.


## 5.1. Detecting the Sun

Some images were captured with the optical axis of the sun compass’s prototype upright pointing at the sky at different hours in the daytime from May to July. The sun was detected in these images with the original MSER method, the conventional method, and the proposed modified MSER method. Figure7(a) shows an image captured by the visual sun compass. Figure 7(b) shows the blobs detected by the original MSER method. It can be seen that, with the original MSER method, some redundant blobs were detected and the image of the sun’s center could not be uniquely determined. For the conventional method, the estimated center is far away from the real configuration as shown in Figure 7(c), because intensity values of outliers are close to those of the sun’s image. By applying the proposed modified MSER and the constrained LS with pruning to this image, the obtained result is shown in Figure 7(d). It is evident that only one region is obtained and the difference between the fitted ellipse and the image of the sun is slight. These results prove the validity of the proposed method.An image captured by the visual sun compass and experiment results. (a) Image captured by the visual sun compass. (b) Blobs detected by the original MSER. (c) The center detected by the conventional method. (d) The detected sun and its center by the proposed method.
(a)(b)(c)(d)


## 5.2. Orientation Estimation

By the proposed visual sun compass model, the elevation angle of the sunθ and “the angle of the style’s shadow” φ can be calculated with the calibrated parameters and the detected sun’s center. Table 2 shows some results, where “G.T.” denotes the ground truth and “est.” denotes the estimation. It is obvious that, for the estimated sun’s elevation angle θ, there is a little difference from the ground truth (values from the astronomic almanac corresponding to the time and the latitude and longitude information). Then, the azimuth angle γ of the sun and the absolute directions β in the ground plane coordinate system are calculated with the time, the latitude, and longitude information. Results are shown in Table 2. For the azimuth angle γ, the difference between the estimated values and the ground truth is very slight. The errors of the absolute direction with proposed method are less than 3.5°. They may arise from several sources. The primary source is the current rudimentary experimental setup: the visual sun compass is made horizontal using barely eye inspection with a spirit level, and the ground truth of the estimated direction is obtained by eye inspection of a simple magnetic needle compass. Nonetheless, experiments show the validity of the proposed visual sun compass.Table 2
Orientation results with visual sun compass (in degrees).
ElevationθAngleφAzimuthγOrientationβG.T.est.est.G.T.est.G.T.est.35.4736.57−87.64−89.87−89.870.0−2.2360.4360.86−125.1062.9262.92185.0188.0258.1059.92−115.6668.7868.77185.0184.43


## 5.3. Application

We also applied the prototype of the visual sun compass on a mobile robot to carry out orientation estimation. Figure8 shows the mobile robot, on which the visual sun compass prototype, a Crossbow VG700CB-200 IMU, and other sensors are mounted. The IMU can provide its own attitude relative to the ground coordinate system. The relative rotation between the IMU and the visual sun compass can be calibrated off-line in advance. Then, the rotation from the visual sun compass to the ground coordinate system, Rf2g in (3.14), can be determined. Orientation experiments are conducted with this mobile robot to validate the proposed visual sun compass. Some results are shown in Table 3. With the help of the IMU, the deviations from the ground truth are less than those reported above. All of these results prove the validity of the proposed visual sun compass.Table 3
Absolute orientation results with a mobile robot (in degrees).
G.T.30.0060.0090.00150.00180.00est.28.0859.6392.75152.31180.77Figure 8
The mobile robot mounted with the visual sun compass prototype and an IMU.


## 6. Conclusions

A visual sun compass is proposed in this paper. It is competent for orientation in environments with a tiny size and light weight, such as in aeronautical and space applications where the conventional sensors cannot function. A mathematical model and the absolute orientation method are presented. Further, a modified MSER and constrained LS with pruning are proposed to deal with severe distortion while detecting the sun in captured images. Real image experiments show the validity of the proposed visual sun compass. In comparison with conventional orientation sensors, the proposed visual sun compass can not only work in special environments but also provide the absolute orientation. The measurements of the proposed visual sun compass are not precise enough as yet. Future steps for improvement of the proposed visual sun compass include building a more precise experiment platform, refining the measurements by finding a more precise calibration method, and analyzing the uncertainties of the projection of the sun’s center.



---

*Source: 460430-2012-03-07.xml*