Figure 2: Two possible configurations of two collinear line
segments.
Y
min
= max(min(s
0
y
,e
0
y
), min(s”
y
,e”
y
)),
Y
max
= min(max(s
0
y
,e
0
y
), max(s”
y
,e”
y
)),
therefore, overlap length can be expressed by its
Cartesian length by:
L
0
i
= L
0
ix
+ L
0
iy
where
L
0
ix
= (X
max
− X
min
), L
0
iy
= (Y
max
−Y
min
)
Note that the output of this new measure of overlap
length is exactly equal to that of Equ. 1 but with-
out need for a i f − then construct with four OR con-
ditions. While computing the relative non-overlap
length, computational time can further be reduced by
half by considering only one of the Cartesian com-
ponents of the overlap part and the segment in the
second image (we chose x component) based on the
relation shown in Fig. 3:
H
i
= (1 −
L
0
ix
||l
0
ix
||
) (3)
However care should be taken when the segment
is vertical where y components should be used to
avoid undefined division 0/0. In order to have a very
accurate comparison between two measures, we care-
fully counted the number of CPU cycles needed to
run the assembly instructions for the new non-overlap
length measure as defined by Equ. 3 versus the mea-
sure defined by Equ. 2 compiled using a C com-
piler on an Intel Pentium machine. Our new non-
overlap length measure needs 302 clockticks (includ-
ing the conditional i f for proper treating of verti-
cal segments). The original measure of non-overlap
needs a minimum of 720 clockticks (if the first in-
equality condition among four inequalities in Equ. 1
is satisfied) and a maximum of 858 clockticks (if none
of four inequalities are satisfied). We can not use
clockticks average since for the majority of samples
in motion space and except for some random lines,
the rest of lines do not exhibit an overlap therefore the
computation of the objective function for these sam-
ples requires maximum number of clockticks. This
means our new measure can be computed on average
slightly less than 858/302 = 2.841 times faster than
Figure 3: The relation between Cartesian components of
the overlap part and the segment in the second image. The
ratios of corresponding sides of two right triangles are con-
stant.
the measure introduced in (Zhang, 1995), assuming
that the variation of the line segments is random. Re-
fer to the result section for a comparison using real
data.
4 RECOVERING MOTION BASED
ON DENSE SAMPLING
Sparse sampling of the 5 dimensional motion space
(3 for the rotation and 2 for the translation) followed
by refinement of the best samples as suggested in
(Zhang, 1995) is problem-in-hand dependent and de-
pending on how far the best initial guesses are to the
global minimum, the optimization stage can use con-
siderable iterations to converge to a good solution or
it may not be able to converge at all. Thanks to our
faster method for calculating the objective function,
we are able to sample the motion space more densely,
resulting in a better initial guess closer to the global
minimum with less time required by optimization al-
gorithm to converge to a good solution. The results in
the next section demonstrate how this new approach
can help to recover the motion for the examples where
the sparse sampling followed by a refinement of the
best samples cannot converge to a good solution.
5 RESULTS
We have already shown the efficiency of the new ob-
jective function in the terms of execution cycles. In
this section, however, we give the results on two real
data sets where for the last set the original algorithm
fails to recover the motion due to sparse sampling of
the motion space. The first set of real data is an image
pair of a bakery (Fig. 4). The position and rotation
of the second camera with respect to the first one was
obtained through a very careful setup and use of a gy-
roscope:
R = [−0.0073,−0.3049, −0.0036],
VISAPP 2011 - International Conference on Computer Vision Theory and Applications
682