1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
3  <head>
4    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5    <meta http-equiv="Content-Style-Type" content="text/css" />
6    <link rel="stylesheet" href="../../../css/manpage.css" type="text/css" />
7    <title>GetStereoCameraCalibrationMatrixEx</title>
8  </head>
9  <body>
10    <h1><CODE><a href="../../../nn/Overview.html">nn</a>::<a href="../../../nn/camera/Overview.html">camera</a>::<a href="../../../nn/camera/CTR/Overview.html">CTR</a>::GetStereoCameraCalibrationMatrixEx</CODE> Function</h1>
11    <h2>Syntax</h2>
12    <div class="section">
13      <pre class="definition">
14void GetStereoCameraCalibrationMatrixEx(
15     <a href="../../../nn/math/MTX34/Overview.html">nn::math::MTX34</a> * pDstR,
16     <a href="../../../nn/math/MTX34/Overview.html">nn::math::MTX34</a> * pDstL,
17     <a href="../../../nn_types/f32.html">f32</a> * pDstScale,
18     const <a href="../../../nn/camera/CTR/StereoCameraCalibrationData/Overview.html">StereoCameraCalibrationData</a> & cal,
19     const <a href="../../../nn_types/f32.html">f32</a> translationUnit,
20     const <a href="../../../nn_types/f32.html">f32</a> parallax,
21     const <a href="../../../nn_types/s16.html">s16</a> orgWidth,
22     const <a href="../../../nn_types/s16.html">s16</a> orgHeight,
23     const <a href="../../../nn_types/s16.html">s16</a> dstWidth,
24     const <a href="../../../nn_types/s16.html">s16</a> dstHeight
25);
26</pre>
27    </div>
28    <h2>Parameters</h2>
29    <div class="section">
30      <table class="arguments">
31        <thead>
32          <tr>
33            <td width="15" />
34            <th>Name</th>
35            <td>Description</td>
36          </tr>
37        </thead>
38        <tr>
39          <td>out</td>
40          <th><CODE>pDstR</CODE></th>
41          <td>Specifies the location where the correction matrix for the right camera image is stored.</td>
42        </tr>
43        <tr>
44          <td>out</td>
45          <th><CODE>pDstL</CODE></th>
46          <td>Specifies the location where the correction matrix for the left camera image is stored.</td>
47        </tr>
48        <tr>
49          <td>out</td>
50          <th><CODE>pDstScale</CODE></th>
51          <td>Specifies the location where the scale is stored. This is necessary to render in the area where the left and right images overlap, in the size specified by <SPAN class="argument">dstWidth</SPAN> and <SPAN class="argument">dstHeight</SPAN>.</td>
52        </tr>
53        <tr>
54          <td>in</td>
55          <th>cal</th>
56          <td>Specifies the calibration data.</td>
57        </tr>
58        <tr>
59          <td>in</td>
60          <th>translationUnit</th>
61          <td>Specifies the unit of translation in 3D space. Specify a value that is equal to the ratio between the sizes of the VGA image and screen image, multiplied by the amount of movement to translate the camera image by one pixel.</td>
62        </tr>
63        <tr>
64          <td>in</td>
65          <th>parallax</th>
66          <td>Specifies the parallax in the VGA image. Specify a value that expresses the movement of the left-camera image, with the right-camera image as the reference. This is measured in pixels.</td>
67        </tr>
68        <tr>
69          <td>in</td>
70          <th><CODE>orgWidth</CODE></th>
71          <td>Specifies the width of the camera image. If trimming, specify (in pixels) the desired width of the trimmed image. This value is measured in pixels.</td>
72        </tr>
73        <tr>
74          <td>in</td>
75          <th>orgHeight</th>
76<td>Specifies the height of the camera image. If trimming, specify the desired height (in pixels) of the trimmed image. This value is measured in pixels.</td>
77        </tr>
78        <tr>
79          <td>in</td>
80          <th>dstWidth</th>
81          <td>Specifies the width necessary to render in the size of the area where the left and right images overlap.</td>
82        </tr>
83        <tr>
84          <td>in</td>
85          <th>dstHeight</th>
86<td>Specifies the height that is necessary to render in the size of the area where the left and right images overlap.</td>
87        </tr> </table>
88    </div>
89    <h2>Return Values</h2>
90    <div class="section">
91                None.
92               </div>
93    <h2>Description</h2>
94    <div class="section">
95      <p>Calculates a correction matrix used to make the left-camera image match the right-camera image in 3D space.</p><P>The <CODE><a href="../../../nn/camera/CTR/GetStereoCameraCalibrationMatrix.html">nn::camera::CTR::GetStereoCameraCalibrationMatrix</a></CODE> function returns a matrix for correcting errors in the placement of the stereo camera. Using this matrix, however, will prevent a 3D view on the edges of the screen if the position offset of the system's stereo camera is near the limit, because the edges of the area where the left and right images overlap (for convenience, we will call this the &quot;overlapping area&quot;) will be cut off (see figure below). Although the position offset in the figure below is extreme for purposes of illustration, the actual limit of positional offset is smaller than in this figure.
96            </P><IMG src="./CalEx_00.png" width="50%" height="50%" /><P>
97                This function returns a correction matrix that will not cut off the edges of the overlapping area, even if the placement error is at the limit. It does this by enlarging the image if the overlapping area is too small.
98            </P><P>
99                Unless you have a specific reason, we recommend using this function instead of the <a href="../../../nn/camera/CTR/GetStereoCameraCalibrationMatrix.html">nn::camera::CTR::GetStereoCameraCalibrationMatrix</a> function.
100            </P><P>
101                The internal processing of this function is as follows.
102            </P><P>
103                (1) Finds the rectangle where the left and right images overlap, based on the calibration data and <SPAN class="argument">orgWidth</SPAN>/<SPAN class="argument">orgHeight</SPAN> (see figure below). Here, the width : height ratio of the rectangle is <SPAN class="argument">dstWidth</SPAN> : <SPAN class="argument">dstHeight</SPAN>.
104            </P><IMG src="./CalEx_01.png" width="50%" height="50%" /><P>
105                (2) If the screen is configured so that the image will appear in the center, it moves the horizontal correction matrix so that the center of the rectangle is in the center of the screen (see figure below).
106            </P><IMG src="./CalEx_02.png" width="50%" height="50%" /><P>
107                (3) On some systems, the size of the rectangle may be smaller than <CODE>dstWidth x dstHeight</CODE>. On other systems, the size of the rectangle may be larger than <CODE>dstWidth x dstHeight</CODE>. Here, we scale the horizontal correction matrix so that the clipped rectangle is the same size as <CODE>dstWidth x dstHeight</CODE> (see figure below). For example, if the specification to the function is <CODE><SPAN class="argument">dstWidth</SPAN> = 400, <SPAN class="argument">dstHeight </SPAN>= 240</CODE>, and the size of the rectangle is <CODE>320 x 192</CODE>, then the correction matrix will scale to <CODE>400/320 = 1.25x</CODE>.
108            </P><IMG src="./CalEx_03.png" width="50%" height="50%" /><P>
109                Specify in <SPAN class="argument">dstWidth</SPAN>/<SPAN class="argument">dstHeight</SPAN> the size of the overlapping rectangle to display; in other words, specify the size of image that you want the rectangle to appear as.
110            </P><P>
111                The correction matrix calculated by the above process is stored in <CODE>pDstR</CODE> and <CODE>pDstL</CODE>. The scale calculated in step (3), above is stored in <CODE>pDstScale</CODE>.
112            </P><P>
113		        The output correction matrix is used to move the camera image horizontally. This matrix is simply a three-dimensional extension of a two-dimensional matrix that expands and shrinks images, rotates around the light axis, and performs horizontal and vertical translations; it does not include three-dimensional transformations, such as rotations about the horizontal and vertical axes.
114            </P><P>
115                The translation distance needed for correction will differ depending on the size of the image, the size of the object, and such graphics settings as the perspective. If you use <CODE>nn::camera::SetSize</CODE> to set the image size to other than VGA (640 x 480), the camera will shrink the image internally, causing the subject to appear smaller. The amount of translation needed for correction will then be reduced by this amount. The amount of translation needed will also vary depending on whether you display the image pixel by pixel or display it after scaling. Specify the argument <SPAN class="argument">translationUnit</SPAN> as the translation distance required to move the camera image by one pixel, multiplied by the ratio of the size of a VGA image to the size of the image you wish to display.
116            </P><P>
117                For example, let us assume that you are displaying a VGA image pixel by pixel, and you have configured your graphics so that the translation distance needed to move that image by one pixel is <CODE>1.0f</CODE>. In this case, specify <SPAN class="argument">translationUnit</SPAN> as <CODE>1.0f</CODE>. Next, let us assume that you will change the image size to 512 x 384. If you do not stretch the image using texture mapping, the subject will be 0.8 times the size of a VGA image (512 / 640). This will reduce the amount of translation needed for correction, so specify <SPAN class="argument">translationUnit</SPAN> as <CODE>1.0f x 0.8f = 0.8f</CODE>. Note that if you enlarge the object, and display the subject in the same way as you display a VGA image pixel by pixel before applying the correction matrix, then <SPAN class="argument">translationUnit</SPAN> will be <CODE>1.0f</CODE>. Conversely, if you enlarge the object after applying the correction matrix, then <SPAN class="argument">translationUnit</SPAN> will be <CODE>0.8f</CODE> because you will be enlarging the image after translation.
118            </P></div>
119    <h2>Revision History</h2>
120    <div class="section">
121      <dl class="history">
122        <dt>2011/06/22</dt>
123        <dd>Added description of <CODE>translationUnit</CODE> parameter.
124        </dd>
125        <dt>2011/03/24</dt>
126        <dd>Added figures.<br />
127        </dd>
128        <dt>2011/03/22</dt>
129        <dd>Initial version.<br />
130        </dd>
131      </dl>
132    </div>
133  <hr><p>CONFIDENTIAL</p></body>
134</html>