mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
The heart of the 1D FFT works. I tested this on the PC. However, 2D FFTs may have issues and the phase correlation algorithm does not generate the expected results. That said, most of the work is done. Stuff just needs to be deubgged. The FFT lib is designed to handle up to 1024 point real FFTs and 512 complex FFTs. As for 2D FFTs, we can do up to 64x64 pixels. After which, we don't have enough RAM to handle them because they use up about 128KB each. Things to do... the 2D FFT needs to be verified. So, we need to run an image through it and then back again to verify that there are no problems. Then we need to compare the 2D FFT output with another 2D FFT algorithm on the PC... Once the FFTs are known to be good we then need to make sure the phase corelation algorithm outs the correct results. We need to test that with multiple shifted images, etc.
30 lines
808 B
Python
30 lines
808 B
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import sys, math
|
|
# https://www.nayuki.io/page/fast-fourier-transform-in-x86-assembly
|
|
|
|
sys.stdout.write("const float cos_table[512] = {\n")
|
|
for i in range(512):
|
|
if not (i % 8):
|
|
sys.stdout.write(" ")
|
|
sys.stdout.write("%9.6ff" % math.cos((math.pi * i) / 512))
|
|
if (i + 1) % 8:
|
|
sys.stdout.write(", ")
|
|
elif i != 511:
|
|
sys.stdout.write(",\n")
|
|
else:
|
|
sys.stdout.write("\n};\n")
|
|
|
|
sys.stdout.write("const float sin_table[512] = {\n")
|
|
for i in range(512):
|
|
if not (i % 8):
|
|
sys.stdout.write(" ")
|
|
sys.stdout.write("%9.6ff" % math.sin((math.pi * i) / 512))
|
|
if (i + 1) % 8:
|
|
sys.stdout.write(", ")
|
|
elif i != 511:
|
|
sys.stdout.write(",\n")
|
|
else:
|
|
sys.stdout.write("\n};\n")
|