logo

光流中find_displacement

2018-03-16 14:05
3
haha

我在看 通过mavlink实现光流的例程时发现:

1. 在`mainloop`中有这样一段代码:

    new_img = sensor.snapshot().mean_pooled(4, 4) # 160x120 -> 40x30
    x, y, c = new_img.find_displacement(old_img)
    old_img = new_img

请问上述代码中的find_displacement可以直接使用的?

2. 当我在openmv的github上搜索这个函数是,搜到这样的提示

# NOTE!!! You have to use a small power of 2 resolution when using
# find_displacement(). This is because the algorithm is powered by
# something called phase correlation which does the image comparison

请问,上述`You have to use a small power of 2 resolution `是什么意思。

3. 在`send_optical_flow_packet`函数中:

`struct.pack`函数的第一个参数具体有什么用处,mavlink协议中不存在第一个参数啊。

2018-03-16 14:24
X
Yuan

1.文档中关于find_displacement函数是这样描述的。

f1f1604f-ee0f-48f3-a60c-c269aa2a0a18.png
new_img = sensor.snapshot().mean_pooled(4, 4) # 160x120 -> 40x30

这一句是利用池化函数将图像缩小。由于内存的限制,在调用find_displacement函数之前,需要使用mean_pooled(4, 4) 函数将图像缩小。

2.find_displacement函数通过对旧图像和新图像进行二维FFT运算并使用相位相关性进行比较。您的OpenMV只有足够的内存才能在两个64x64 FFT(或128x32,32x128等)上工作。

参考资料:

- find_displacement函数中文文档 (http://doc.singtown.cc/openmv_zh/library/omv.image.html)

- 光流例程 (http://book.openmv.cc/example/09-Feature-Detection/optical-flow.html)

2018-03-16 14:51
3
haha

首先,非常感谢,我忘记去看这个函数库了,惭愧...

还有,请问一下,你知道我的第三个问题吗?

2018-03-16 15:02
I
网红小智智 星瞳科技

python使用struct.pack来打包二进制。这是python标准库里的。

如果你搜一下pack,会发现官方文档里<https://docs.python.org/3/library/struct.html#format-strings>:第一个参数,也就是"<qfffhhbb",是用来打包的格式:

- <代表小端

- q代表long long

- f代表float

- h代表short

- b代表signed char

也就是后面的数据,按照"<qfffhhbb"的格式来打包。

3
haha

@kidswong999 OK,超级感谢