1. 程式人生 > >極簡光流(optical flow)

極簡光流(optical flow)

實在時間緊,還是僅上英文版的,諸位見諒。原文在我的個人主頁上。

Simple optical flow based on depth and pose information

Recently, I was helping to implement a simple program that performs optical flow calculation between frames of video images with the help of known depth and pose information associated with the images.

Let us define the first frame as Frame 0, and the second to be Frame 1. And for my current task, the camera is under constant movement. For optical flow, it is usually represented by a color image with HSV color space. In this image, Channel H (Hue) is used to represent the flow direction of the individual pixel of the Frame 0. That is if the camera is moving, every pixel of Frame 0 seems to move with respect to Frame 1 and exhibiting a representative color regarding the flow direction. Channel V (Value or Lightness) tells the magnitude of the movement of a pixel. The larger the movement, the brighter it should be. We leave the S (Saturation) Channel to be its highest value and never touch it.

The thing is, once you know the camera pose and depth information of each frame, you know everything. No fancy algorithm is needed to perform optical flow calculation since you can calculate the movement of the individual pixel. The overall process looks very much like the following.

As shown in

figure 1, the overall process is really straightforward. If the camera is rectified and has no distortion, all of the transformations could be expressed by simple linear algebra expressions.

Actually, the images are extracted from video frames recorded in the Unreal Engine. We are simulating a UAV in Unreal with the help of

AirSim, an open-source project implementing drone simulators. AirSim is maintained by Microsoft. The video stream comes from the virtual camera mounted on the simulated UAV in Unreal. Individual frame images are extracted from the video stream, with associated depth and camera pose information. Two sample image frames are shown in figure 2.

Figure 2 Original frame images. Top: first frame, bottom: second frame.

As one can easily perceive, the camera has a yaw movement from left to right direction. The global coordinate system is defined in such a way that the z-axis is pointing downwards. Then this yaw movement is represented by a rotation with positive angle value along the z-axis. The resulting optical flow image may look like figure 3. The values for the H and V channels of the resulting HSV image are calculated in a way similar to one of the OpenCV tutorials.

Figure 3 The optical flow.

The color in figure 3 shows that all the pixels of Image 0 are moving in roughly the same direction. In this case, the direction is from left to right. The brightness of figure 3 shows the magnitude of pixel movements. For pure yaw movement, the close a pixel locates to the vertical center line of the image, the less it moves in magnitude.

Since we have these data, we could do something else like computing the 3D point clouds based on Image 0 and 1. We could import these point clouds into MeshLab and check the consistency between the depth and cameras poses. The point clouds may look like figure 4 and figure 5.

Figure 4 Point cloud of Image 0.

Figure 5 Point clouds of Image 0 and 1. White: Image 0. Red: Image 1.

In figure 4, I use color to indicate the distance from the camera. Blue means points are near the camera and red means far away. I generate my own color mapping method with the help of this post. In figure 5, the two point clouds get aligned, meaning that the depths and camera poses are consistent with each other. Good job.

One other thing one may do with these data is warping Image 0 to Image 1. After obtaining the optical flow between the two images, we could easily warp Image 0 and see how it will look like from the perspective of Image 1. Figure 6 shows the result of warping.

Figure 6 Warped image.

In figure 6, all the regions that could be seen originally in Image 0 but could not be perceived in Image 1 are rendered black. The pixels of Image 0 move to their new locations in Image 1. Since the camera is rotating from left to right, objects in the camera view will move to the left. The black ripples in figure 6 are the result of transformation with discretized pixels, pixels originally located at the left of Image 0 simply could not cover a relatively larger area in Image 1, leaving holes after warping.


This work is done with the help of Wenshan Wang.

相關推薦

optical flow

實在時間緊,還是僅上英文版的,諸位見諒。原文在我的個人主頁上。 Simple optical flow based on depth and pose information Recently, I was helping to implement a simpl

optical flow

概念 光流是Gibson在1950年首先提出的,它是指空間運動物體在觀察成像平面上的畫素運動瞬時速度。是利用影象序列中畫素在時間域上的變化以及相鄰幀之間的相關性來找到上一幀跟當前幀之間存在的相應關係。一般而言,光流是因為場景中前景目標本身的移動、相機的運動

Optical Flow及OpenCV實現

Optical Flow Optical flow 有兩個假設: 亮度恆定:在相鄰連續兩幀中一個目標的畫素強度不會變化。 空間一致性:周圍畫素有類似執行。 時間規律:相鄰幀時間足夠短,以至於在考慮執行變化時可以忽略它們之間的差異。 假設在第一幀中畫素

版秒錶java GUI

package javaPractice; import javax.swing.*; import java.text.*; import java.util.*; import java.awt.*; import java.awt.event.*; public class Stopwat

OpenCascade環境搭建QT環境

min 打開 windows 調整 需要 lease 分享 操作系統。 路徑 現在網上關於OpenCascade(OCCT)的環境搭建幾乎都是下載源碼,然後實時MinGW來編譯生成源碼。但是,官方有提供Windows平臺下的可執行文件,如果想快速了解OpenCascade(

機器學習入門教程

這是機器學習入門教程系列的第三部分,點選這裡跳轉到第一部分,點選這裡跳轉到第二部分。 part6 通過前面的學習,我們掌握了用已有資料對目標進行預測的方法。在使用模型的時候,有些人或許會好奇,模型究竟是怎樣的?這裡我們通過一個獨特的視角——部分依賴圖(Partial De

04.主義——熱情筆記

1.我們被教育累死累活地位一家沒有生命的單位辛勤工作,顯出最寶貴的東西(我們的時間),職位換的一張工資單。 2.你的身份應該源於有意義的生活,而不在於你如何掙得工資。 3.利用你所熱愛的事物集中精神,為自己補充更多熱情,這對尋找使命而言非常關鍵。但首先,你必須發現你熱愛的

網路入門Network Flow

網路流的相關定義: 源點:有n個點,有m條有向邊,有一個點很特殊,只出不進,叫做源點。 匯點:另一個點也很特殊,只進不出,叫做匯點。 容量和流量:每條有向邊上有兩個量,容量和流量,從i到j的容量通常用c[i,j]表示,流量則通常是f[i,j]. 通常可以把這些邊想象成

網路演算法Network Flow

網路流概覽 1.網路流(Network Flow)概念 網路流起源於對於交通網路的分析,舉一個非正式的例子,網路流演算法的目的就是找到帶權有向圖中從源點到匯點的traffic的大小。我們的目標是在多項式時間內解決問題。 我們一般要求的是最大流,如果把源點比

--Brox演算法DeepFlow

原文: http://www.cnblogs.com/dzyBK/p/5096860.html 參考論文: 1. High Accuracy Optical Flow Estimation Based on a Theory for Warping, Thomas Box

--Kanade-Lucas-Tomasi(KLT)目標跟蹤

原文: http://www.cnblogs.com/moondark/archive/2012/05/12/2497391.html 近來在研究跟蹤,跟蹤的方法其實有很多,如粒子濾波(pf)、meanshift跟蹤,以及KLT跟蹤或叫Lucas光流法,這些方法各自有各自的

--HS及稠密

轉自: 稠密光流 稠密光流是一種針對影象進行逐點匹配的影象配準方法,不同於稀疏光流只針對影象上若干個特徵點,稠密光流計算影象上所有的點的偏移量,從而形成一個稠密的光流場。通過這個稠密的光流場,可以進行畫素級別的影象配準,所以其配準後的效果也明顯優於稀疏光流配準的效果。但是

Java核心類庫-IO-打印PrintStream/PrintWriter

int div leo obj clas 打印流 println 不換行 pan 打印流,打印數據的,打印流只能是輸出流: PrintStream:字節打印流。 PrintWriter:字符打印流。 對於PrintWriter來說,當啟用字段刷新之後 PrintWrite

HDU 5988最小網絡浮點數

blank empty pac scanf for continue -- math != 題目鏈接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5988 哇,以前的模版一直T,加了優先隊列優化才擦邊過。 建圖很好建,概率

Java多線程析——Synchronized同步鎖、Lock以及線程池

ati auto bsp lock eas 根據 引入 封裝 util Java多線程 Java中,可運行的程序都是有一個或多個進程組成。進程則是由多個線程組成的。最簡單的一個進程,會包括mian線程以及GC線程。 線程的狀態 線程狀態由以下一張網上圖片來說明:

java基礎類庫學習六.3位元組 字元輸入輸出

前言: 位元組流和字元流的操作方式幾乎相同,區別只是操作的資料單元不同而已 位元組流操作的資料單元是位元組8位,字元流操作的資料單元是字元16位 輸入流 字元輸入流/位元組輸入流原始碼(輸入流的抽象基類) InputStream public abstract class

DOM Event:事件流動Event Flow

哪怕一個web開發的初學者都會知道,當我們滑鼠在button上點選時,會在button上觸發一個click事件。但是: button是div的一個子Node;從介面上來看,在button裡點選相當於在div裡點選;那click事件也會觸發在div上嗎? 如果click事件也觸發在div

【洛谷 P3381】最小費用最大SPFA+EK

在最大流的基礎上把BFS換成SPFA即可。 #include<bits/stdc++.h> using namespace std; const int maxn = 100050; const int INF = 0x3f3f3f3f; int head[maxn]; bo

驗驗證demodjango+vue

在使用之前,曾經試過用阿里雲的人機驗證,不過在簽名部分比較複雜,下載sdk後需要自己寫很多,折騰了一下,還是放棄。而騰訊雲的人機驗證python版本有demo,直接填寫keyhe1secret就可以使用,但是demo使用的是web.py的框架,這個之前有了解過,比較好用,但是作者去世了,只有

LiberOJ ~ 116 ~ 有源匯有上下界可行 模板題

//#include<bits/stdc++.h> #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #inc