<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Assessment of camera orientation in Manhattan scenes using information from optical and inertial sensors</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Evgeny Myasnikov</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Geoinformatics and Information Security department Samara National Research University; Image Processing Systems Institute of RAS - Branch of the FSRC "Crystallography and Photonics" RAS Samara</institution>
          ,
          <country country="RU">Russia</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2020</year>
      </pub-date>
      <fpage>5</fpage>
      <lpage>9</lpage>
      <abstract>
        <p>-In the present paper, the solution to the problem of assessing the orientation of a camera is performed under the condition of two main limitations. The first limitation is the analysis of Manhattan scenes only. The second one is the presence of an accelerometer in a mobile device. To assess the characteristics of the proposed solution, a data set was prepared containing both photos and accelerometer readings, as well as information about the true orientation of the device. Experimental studies were carried out using the prepared data set.</p>
      </abstract>
      <kwd-group>
        <kwd>camera orientation</kwd>
        <kwd>vanishing point</kwd>
        <kwd>Manhattan scenes</kwd>
        <kwd>accelerometer</kwd>
        <kwd>inertial sensor</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>INTRODUCTION</p>
      <p>Assessing the camera orientation is one of the most
important tasks in three-dimensional computer vision.
Typically, camera orientation is estimated using calibration
patterns, and it requires human interaction. For this reason,
automatic methods for assessing the orientation are of
particular interest.</p>
      <p>Despite the presence of various sensors in modern mobile
devices, such as an accelerometer, compass, etc., their use
for orientation estimation is limited due to the low accuracy
and the influence of noise [1]. For this reason, both optical
information and information from the sensors of mobile
devices are used to determine the orientation of the camera.</p>
      <p>In this paper, we consider a method for assessing the
orientation of a camera, based on the analysis of the position
of vanishing points [2], i.e. the points in the plane of a
perspective image, in which projections of mutually parallel
lines of three-dimensional space converge. In this case, the
problem is solved under the condition of two main
limitations. The first limitation is the restriction of the class
of analyzed scenes only to Manhattan scenes [3], in which
the lines are aligned along three main mutually orthogonal
directions. Vivid examples of such scenes are photographs of
city buildings (the lines of building facades may possess
these characteristics), road scenes (border of the roadway,
markings, poles), indoor scenes (borders of rooms, furniture
lines, decoration elements - panels, tiles, etc.). The second
limitation is the presence of an accelerometer on a mobile
device.</p>
      <p>The orientation of the camera in this paper is determined
sequentially in several stages. At the first stage, using the
inertial sensor readings, the direction to the first vanishing
point corresponding to the direction of gravity is determined.
After that, the position of the first vanishing point is refined
along vertical lines in the optical image. At the second stage,
the vanishing points of the horizontal lines of the main and
side facades are determined. So the found vanishing points,
taking into account the data of the inertial sensor, determine
the orientation of the camera. The method for determining
vanishing points described in this paper is based on the idea
described in [4], according to which the search for horizontal
vanishing points can be performed along the horizon line
defined by a plane orthogonal to the direction of the vertical
vanishing point.</p>
      <p>Unfortunately, common data sets for the evaluation of
vanishing point assessment methods (see, for example, [5])
do not contain information from inertial sensors. For this
reason, their use for evaluating methods similar to those
described in this paper is possible only in the mode of
sensors emulation, as it was done, for example, in [6].</p>
      <p>For the above reason, to evaluate the characteristics of
the proposed solution, we prepared our own data set
containing both photos and accelerometer readings as well as
information about the true camera orientation. Experimental
studies were carried out using the prepared data set.</p>
      <p>It should be noted that the initial implementation of the
algorithm for determining vanishing points was previously
described in [6]. Thus, in the present work, the previously
proposed approach is further developed and studied, using
the data set prepared as part of the work.</p>
      <p>The work is organized as follows. Section 2 describes the
developed method for assessing camera orientation. Section
3 describes the modeling technique and conducts
experimental studies. The work ends with a conclusion and a
list of used literature.</p>
      <p>II.</p>
    </sec>
    <sec id="sec-2">
      <title>METHOD</title>
      <p>As it was mentioned in the introduction, the described
method consists of sequentially determining three vanishing
points, followed by finding the orientation of the camera.
The general scheme of the method is presented in Fig. 1.</p>
      <p>First, preliminary processing of the image received from
the camera is performed. In particular, it is scaled and rotated
with an accuracy of 90 degrees in accordance with the
information received from the inertial sensor. If necessary,
the vector received from the sensor is transformed so as to
correspond to the direction of gravity for the rotated image.</p>
      <p>After preliminary processing by one of the known
methods, for example, by the Canny method [7], contours are
extracted from the image. The extracted contours are traced
and the segments of straight lines are searched. The found
segments form the set L, which will be used subsequently to
find vanishing points.</p>
      <p>Further, the information obtained from the inertial sensor
is used for a preliminary assessment of the first vanishing
Pre-processing of an image and inertial sensor readings
Extraction and tracing of contours, search for line segments L
Preliminary assessment of the first vanishing point VP1 using
information from an inertial sensor
The formation of the set L1 of segments corresponding to the first
vanishing point VP1</p>
    </sec>
    <sec id="sec-3">
      <title>Finding VP1 by L1 is</title>
      <p>possible
yes</p>
    </sec>
    <sec id="sec-4">
      <title>Refinement of the position of VP1 using L1</title>
    </sec>
    <sec id="sec-5">
      <title>Estimation of the horizon plane and horizon line Г in the image plane</title>
      <p>Search for the points pi as intersections of the extracted lines
from L’
= L \ L1 with the horizon line Г
Search the interval h on the horizon line Г containing the maximum
number of intersection points pi
Formation of the set L2 of line segments corresponding to the
intersection points pi
no</p>
    </sec>
    <sec id="sec-6">
      <title>Finding VP2 by L2 is</title>
      <p>possible</p>
    </sec>
    <sec id="sec-7">
      <title>Estimation of the second vanishing point</title>
      <p>VP2 by the intersection points pi  h</p>
    </sec>
    <sec id="sec-8">
      <title>Estimation of the second vanishing point</title>
      <p>VP2 from the set of line segments L2</p>
    </sec>
    <sec id="sec-9">
      <title>Calculation of the third vanishing point VP3</title>
    </sec>
    <sec id="sec-10">
      <title>Assessment of the camera orientation R</title>
      <p>point VP1. It is assumed that the direction to the first
vanishing point corresponds, up to a sign, to the gravity
vector.</p>
      <p>In the direction obtained, a set L1 of segments is selected
such that the lines corresponding to this set deviate from the
direction to VP1 no more than the predefined angle.
Fig. 1. General scheme of the method.</p>
      <p>If there are enough selected segments, the first vanishing
point is refined by a weighted summation of the points
determined by all possible segments from L1. Moreover,
segments of greater length have more weight. If the
assessment of VP1 by L1 is not possible, the initial estimation
of VP1 is used for further processing.</p>
      <p>At the next stage, the direction to VP1 is used to
determine the horizon line plane as the plane passing through
the origin of the modeled optical system and orthogonal to
yes
the direction to VP1 (refined gravity vector). In addition to
the plane, the horizon line Г is also determined as the
projection of a line, which is in the horizon plane and
nonorthogonal to the image, on the image plane.</p>
      <p>Further, for all the lines l i  L’ extracted in the image,
with the exception of the lines used earlier to find the
vanishing point VP1 (L’ = L \ L1), the intersection points with
the horizon line Г are determined. A search is made for such
a segment h (with a predetermined angular size) on the
horizon line, at which the maximum number of intersection
points pi falls.</p>
      <p>After this, we form the set L2 of line segments, for which
the intersections pi with the horizon line Г fall in the
indicated interval h. If there are enough selected segments,
the second vanishing point is estimated by weighted
summation of the intersection points determined by all
possible segments from L2. If the estimation of VP2 by L2 is
not possible, the weighted sum of the points of intersection
of the corresponding lines with the horizon line Г is taken for
the position of VP2. In both cases, the segments of longer
length have more weight when determining VP2.</p>
      <p>After determining two vanishing points, the third is found
as a vector orthogonal to the vectors corresponding to the
first and second points: V3 = V1 × V2.</p>
      <p>After finding vanishing points, the camera orientation can
be found as follows:</p>
      <p>R=[r1 r2 r3],
where R is the rotation matrix, and vectors r1 r2 r3 are
calculated as</p>
      <p>r1 = mK-1VP1, r2 = mK-1VP2, r3 = r1 × r2,
where m is the scale factor, K is the matrix of internal
parameters of the camera [8] containing information on the
focal length, pixel size, tilt, the shift of the image center
relative to the optical axis.</p>
      <p>In general, the proposed method is the development of
the previously described method [6], the main idea of which
[4] is to search for horizontal vanishing points along the
horizon line defined by a plane orthogonal to the direction of
the vertical vanishing point. Compared with the previous
implementation, both the individual steps of the method
underwent changes (the search for segments on the contours
is now carried out according to the criterion of maximum
deviation, the weighted summation takes into account the
lengths of the segments of lines, which are separated from
each other by a sufficient distance, the second vanishing
point is refined without using histograms), as well as the
general scheme of the method (now contains branches that
increase the reliability of determining vanishing points, as
well as the actual orientation estimation stage).</p>
      <p>III.</p>
      <p>EXPERIMENTS</p>
      <p>To study the method described above, we used our own
specially prepared data set. This set was collected using the
Huawei Honor 9 lite smartphone [9]. Its camera has a CMOS
BSI sensor with an f / 2.2 aperture, a focal length of 3.46
mm, and produces a color image of 12.98 MP. To collect
images and inertial sensor data, we developed an Android
application that stores both the captured images and a custom
number of accelerometer readings recorded prior to the shot.</p>
      <p>To obtain information about the true position of the
camera, several (from 3 to 7 for each vanishing point) lines
were manually selected that reliably determine the directions
to the true vanishing points. This procedure was performed at
2x magnification, and normalized vanishing points obtained
using selected lines were considered as true vanishing points.
At the moment, the described data set consists of 40 images
of buildings with the corresponding inertial sensor data and
true orientation data.</p>
      <p>An example demonstrating the various stages of the
proposed method is shown in Fig. 2.</p>
      <p>To assess the quality of the developed method, modeling
was performed according to the following scheme:

for each image from the prepared data set, three
vanishing points and camera orientations relative
to the building depicted in the photograph were
determined;


using information about the true position, for
each vanishing point, the error was calculated as
the angular deviation of the direction to the
estimated vanishing point from the true direction;
based on the data obtained for each vanishing
point, a histogram of the angular deviation of the
found points from their true values was
constructed, and the average value of such a
deviation was also calculated.</p>
      <p>Each of the histograms shown in the figure shows the
angular deviation of the estimated vanishing point from its
true position. In the ideal case, such a histogram should have
a single column on the left side (first), which means the
minimum deviation of the vanishing point from the true
values for all test images. As can be seen from the above
figures, in most cases the position of the three vanishing
points was made with a deviation of up to 2º, while the
deviation exceeded 4º was observed for only 3 of 40 images.
The average error values were: 1.69º, 1.54º, and 1.88º for
the first, second, and third points, respectively.</p>
      <p>It should be noted that using only information from the
inertial sensor (see the histogram in Fig. 1 (a)) provided a
greater level of errors in determining the direction to the
first vanishing point. The average error value was 3.7º when
using only an inertial sensor versus 1.69º when refined with
an optical image. Thus, the accuracy of the algorithm can be
improved in conditions of noisy readings of the gravity
vector by selecting parameters. Another way to increase
accuracy may be to use previously obtained estimates in
processing a video stream, which is the subject of future
research.</p>
      <p>IV. CONCLUSION
The method for automatic assessment of the orientation of a
camera in Manhattan scenes using information from optical
and inertial sensors is proposed and investigated. To study
the developed technique, the data set was created containing
digital images of buildings, readings of inertial sensors, as
well as information about the true position of vanishing
points obtained by careful manual marking of the source
images.</p>
      <p>The described method is simple to implement, and
undemanding to computing resources. Its use allows
reducing the average level of errors in determining the
orientation in more than 2 times compared with the inertial
sensor.</p>
      <p>As a direction for further work, it is planned to expand
the method for assessing the orientation and position of the
camera when working with a video stream.</p>
      <p>ACKNOWLEDGMENT</p>
      <p>The work was partly funded by RFBR according to the
research project 17-29- 03190-ofi-m in parts of «2. Method»
- «3. Experiments» and by the Russian Federation Ministry
of Science and Higher Education within a state contract with
the «Crystallography and Photonics» Research Center of the
RAS in parts «1. Introduction» and «4. Conclusion».
Fig. 3. Estimation of the method quality. Histograms of the angles
deviations of directions to the vanishing points from their true values (in
degrees): a) the first vanishing point, estimated by inertial sensor readings;
b) the first vanishing point, refined by an optical image; c) the second
vanishing point; d) the third vanishing point.</p>
      <p>URL:</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          <string-name>
            <given-names>V.V.</given-names>
            <surname>Myasnikov</surname>
          </string-name>
          and
          <string-name>
            <given-names>E.A.</given-names>
            <surname>Dmitriev</surname>
          </string-name>
          , “
          <article-title>The accuracy dependency investigation of simultaneous localization and mapping on the errors from mobile device sensors</article-title>
          ,”
          <source>Computer Optics</source>
          , vol.
          <volume>43</volume>
          , no.
          <issue>3</issue>
          , pp.
          <fpage>492</fpage>
          -
          <lpage>503</lpage>
          ,
          <year>2019</year>
          . DOI:
          <volume>10</volume>
          .18287/
          <fpage>2412</fpage>
          -6179-2019-43-3-
          <fpage>492</fpage>
          -503.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <string-name>
            <given-names>B.</given-names>
            <surname>Caprile</surname>
          </string-name>
          and
          <string-name>
            <given-names>V.</given-names>
            <surname>Torre</surname>
          </string-name>
          , “
          <article-title>Using vanishing points for camera calibration</article-title>
          ,”
          <source>International Journal of Computer Vision</source>
          , vol.
          <volume>4</volume>
          , no.
          <issue>2</issue>
          , pp.
          <fpage>127</fpage>
          -
          <lpage>139</lpage>
          ,
          <year>1990</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          <string-name>
            <given-names>J.M.</given-names>
            <surname>Coughlan</surname>
          </string-name>
          and
          <string-name>
            <given-names>A.L.</given-names>
            <surname>Yuille</surname>
          </string-name>
          , “Manhattan World:
          <article-title>compass direction from a single image by Bayesian inference</article-title>
          ,
          <source>” Proceedings of the Seventh IEEE International Conference on Computer Vision</source>
          , vol.
          <volume>2</volume>
          , pp.
          <fpage>941</fpage>
          -
          <lpage>947</lpage>
          ,
          <year>1999</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          <string-name>
            <given-names>V.</given-names>
            <surname>Angladon</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Gasparini</surname>
          </string-name>
          and
          <string-name>
            <given-names>V.</given-names>
            <surname>Charvillat</surname>
          </string-name>
          , “The Toulouse vanishing points dataset,
          <source>” Proceedings of the 6th ACM Multimedia Systems Conference (MMSys '15)</source>
          , Portland, United States,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <string-name>
            <given-names>P.</given-names>
            <surname>Denis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.H.</given-names>
            <surname>Elder</surname>
          </string-name>
          and
          <string-name>
            <given-names>F.</given-names>
            <surname>Estrada</surname>
          </string-name>
          , “
          <article-title>Efficient Edge-Based Methods for Estimating Manhattan Frames in Urban Imagery,”</article-title>
          <source>Proc. European Conference on Computer Vision</source>
          , vol.
          <volume>5303</volume>
          , pp.
          <fpage>197</fpage>
          -
          <lpage>211</lpage>
          ,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          <string-name>
            <given-names>E.</given-names>
            <surname>Myasnikov</surname>
          </string-name>
          , “
          <article-title>Automatic search for vanishing points on mobile devices</article-title>
          ,
          <source>” CEUR Workshop Proceedings</source>
          , vol.
          <volume>2391</volume>
          , pp.
          <fpage>216</fpage>
          -
          <lpage>221</lpage>
          ,
          <year>2019</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          <string-name>
            <given-names>J.</given-names>
            <surname>Canny</surname>
          </string-name>
          , “A Computational Approach To Edge Detection,
          <source>” IEEE Transactions on Pattern Analysis and Machine Intelligence</source>
          , vol.
          <volume>8</volume>
          , no.
          <issue>6</issue>
          , pp.
          <fpage>679</fpage>
          -
          <lpage>698</lpage>
          ,
          <year>1986</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          <string-name>
            <given-names>R.</given-names>
            <surname>Hartley</surname>
          </string-name>
          and
          <string-name>
            <given-names>A.</given-names>
            <surname>Zisserman</surname>
          </string-name>
          , “Multiple View Geometry in Computer Vision,” Cambridge, Cambridge University Press,
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          Huawei.com, “HONOR 9 Lite,”
          <year>2020</year>
          . [Online]. https://consumer.huawei.com/ru/support/phones/honor-9-lite.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>