title: Why SIFT costs more time with fewer octave layers?
body: <p>I'm using SIFT feature detector in <a href="https://docs.opencv.org/4.5.2/d7/d60/classcv_1_1SIFT.html" rel="nofollow noreferrer">OpenCV 4.5.2</a>. By tuning the <code>nOctaveLayers</code> parameter in <code>cv::SIFT::create()</code>, I get these results from <code>detectAndCompute()</code>:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>nOctaveLayers</th>
  <th>KeyPoints</th>
  <th>Time Cost (ms)</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>1026</td>
  <td>63.41</td>
  </tr>
  <tr>
  <td>2</td>
  <td>1795</td>
  <td>45.07</td>
  </tr>
  <tr>
  <td>3</td>
  <td>2043</td>
  <td>45.74</td>
  </tr>
  <tr>
  <td>4</td>
  <td>2173</td>
  <td>47.83</td>
  </tr>
  <tr>
  <td>5</td>
  <td>2224</td>
  <td>51.86</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>To my understanding, there should be less computation with fewer octave layers, but <strong>why SIFT costs significantly more time with only 1 octave layer</strong>?</p>
  <p>I also tested <code>detect()</code> and <code>compute()</code> separately, and they both cost more time when <code>nOctaveLayers</code> is 1, which confuses me a lot.</p>
  <p>The test image is <a href="https://i.stack.imgur.com/OHNHN.jpg" rel="nofollow noreferrer">here</a> (from TUM open dataset). Thanks ahead for any help.</p>
  <hr />
  <p>[Edit for @Micka] My test code:</p>
  <pre class="lang-cpp prettyprint-override"><code>const int test_num = 100;
  const int layers = 5;
  cout &lt;&lt; &quot;layers: &quot; &lt;&lt; layers &lt;&lt; endl;
  
  auto sift = SIFT::create(0, layers);
  vector&lt;KeyPoint&gt; kps;
  Mat descs;
  
  auto t1 = chrono::high_resolution_clock::now();
  for (int i = 0; i &lt; test_num; ++i)
      sift-&gt;detectAndCompute(img_src, noArray(), kps, descs);
  auto t2 = chrono::high_resolution_clock::now();
  cout &lt;&lt; &quot;num of kps: &quot; &lt;&lt; kps.size() &lt;&lt; endl;
  cout &lt;&lt; &quot;avg time cost: &quot; &lt;&lt; chrono::duration&lt;double&gt;(t2 - t1).count() * 1e3 / test_num &lt;&lt; endl;
  </code></pre>
  <p>For each <code>nOctaveLayers</code> configuration, I change <code>layers</code> value in the code, recompile &amp; run &amp; record the result.</p>