Signal in frequency domain with OpenCV dft I am experimenting with cv::dft: a 1HZ sinus signal is generated, and displayed in the frequency domain. But for some reason it hasn't got the maximum component at 1Hz. My code is the following:
       const int FRAME_RATE = 20;             //!&lt; sampling rate in [Hz]
       const int WINDOW_SIZE = 256;         
    
       double len = double(WINDOW_SIZE)/double(FRAME_RATE);   // signal length in seconds
       double Fb = 1./len;                                     // frequency bin in Hz
    
       // Constructing frequency vector
       std::vector&lt;double&gt; f;
       double freq_step = 0;
       for (int i = 0; i &lt; WINDOW_SIZE; ++i)
       {
          f.push_back(freq_step);
          freq_step += Fb;
       }


   // Create time vector
   std::vector&lt;double&gt; t;
   double time_step = 0;
   for(int i = 0; i&lt;WINDOW_SIZE; ++i)
   {
       t.push_back(time_step);
       time_step += 1./double(FRAME_RATE);
   }

   // Creating sin signal with 1Hz period
   std::vector&lt;double&gt; y;
   for(auto val : t)
   {
       y.push_back(sin(1*FRAME_RATE*val));
   }

   // Compute DFT
   cv::Mat fd;
   cv::dft(y, fd, cv::DFT_REAL_OUTPUT);
   fd = cv::abs(fd);

If I plot the signal in time and frequency domain: plot(t, y); plot(f, fd) the result is the following:

The time signal is good, but the frequency signal has maximum around 6HZ instead of 1HZ.
Where did I take the mistake?
Your sine wave should use 2pi instead of frame rate.  Also, your frequency data should have window size/2 points and go from 0 to frame rate/2, not frame rate.