當然 所有程式的開始都是 Hello World
這個也不例外
第一個功能,就是開啟相機,然後偵測畫面中央的深度距離相機多遠
我的成果如下:
https://github.com/soarwing52/RealsensePython/blob/master/phase%201/Hello%20World.py
—————————————————————-
當然 所有程式的開始都是 Hello World
這個也不例外
第一個功能,就是開啟相機,然後偵測畫面中央的深度距離相機多遠
我的成果如下:
https://github.com/soarwing52/RealsensePython/blob/master/phase%201/Hello%20World.py
—————————————————————-
因為工作的關係,老闆決定買了Intel D435的深度相機
然後就叫我做出他們未來可以測量照片裡面物體的大小
大概就是萊卡他們的產品那樣
我們公司做的是道路資料蒐集road survey
現在能看到的主要都是F200 跟一些比較舊的教學文,新一代D400 系列的比較少
所以就想來教學相長一下,希望看到這篇也能夠跟我一起交流
——————————————————————————————————
求助區
目前我卡關的有
rs.syncer
playback.seek
poll_for_frames
如果有看到的可以指導一下就拜託了!
——————————————————————————————————-
我比較了D415/D435 基本上大同小異的深度相機,不過435有比較廣的視角
所以在我們的需求上選用的他
Rolling shutte/Global shutter是另外主要的差異
不過在我們的使用上是沒有影響的
——————————————————————————————————-
首先就是基礎安裝啦
這款相機主要定位是給開發者/教學/研究用途,算是把未完成的產品拿出來賣然後由使用者開發?
不過畢竟是intel 這產品主要也是賣晶片 以供未來普及在筆電/汽車/遊戲機等
安裝完之後 打開viewer會說需要升級韌體
一樣按照連結,打開之後是個簡單的command line
先在2確定可以升級的裝置之後會到1,輸入完整連結即可
安裝完成之後裡面含有:
Intel® RealSense™ viewer:可以直接顯示RGB/深度 2D/3D影像 並且可以錄製
Depth quality tool:檢視深度影像
Debug tools:裝置的校正回報時候會用到的套件
Code samples:最一開始學習時候,就是這個Visual Studio示範開始的
Wrappers:支援C++以外的 C、Python、Node.js API、ROS、LabVIEW語言套件
打開之後開啟所有的stream 影像 可以看到紅外線IR 可見光RGB 跟深度 depth
RGB相機的設定值有:
有灰階:
RGB
BGR
深度相機
主要就是設定 preset還有後製post-processing
hole filling是我在這次主要會用到的功能
前後比較
除了這個 還有3D模式
一個角度當然不夠,是在做pointcloud 3D模型的時候用的
然後depth viewer我用起來 就像是只用深度的部分
其他功能看起來都一樣 就是沒有RGB
最後 錄製的成果可以選擇儲存在哪裡
————————————————————————————————————————
比較重要的幾個使用須知:
一定!一定一定!!!!!! 要使用USB3.0的接孔,才有足夠的頻寬可以把相機的影像傳到電腦裡面
相機本身就是一個感測器 除了鏡頭接收之外,還有小部分的硬體同步與修正,其他都回傳到電腦裡面做處理
因此,在線材的選用也必須要找usb typeC 然後也是3.1的USB線才可以用,也有一些因為太長而導致了資料傳輸失敗
最常出現的就是frame drop 當頻寬不足的時候 30fps錄下來的可能會有許多幀數遺失
還有一個我看到的問題,就是快速抽差
在使用的時候如果把線慢慢滑進去,可能就會偵測為USB2.0 所以務必一鼓作氣 直搗黃蓉
———————————————————————————————————————–
序就寫了開始的一些步驟 還沒開始到程式碼的部分
基本上安裝沒什麼問題,唯一在公司就是因為管理員權限鎖住,所以一路請主管過來輸入
直到韌體升級已經花了半天,從早上十點到下午兩點了
後來我問能不能調整權限,於是獲得了"新的"工作用電腦
ram 4G 2014年的lenovo電腦 沒有SSD
說這台完全沒有任何權限問題 你就拿去用吧!
It’s been one month I’ve been working on this Intel realsense D435, and still I’m not so sure with a lot of functions and some parameters. Like when to add () and when not, which function need which
parameter to fit in. First I read the
https://buildmedia.readthedocs.org/media/pdf/pyrealsense/dev/pyrealsense.pdf
And the python.cpp in the python wrapper to find the options Actually it didn’t help much, mainly I started with the examples in python wrapper and then read the corresponding codes in the C++ example. It is also because this project is to measure objects in the picture, and in the example there is already one measuring in stream, so translating that code is the first approach. And here
https://pyrealsense.readthedocs.io/en/master/index.html
The starting part of the camera:
With the Intel Realsense Viewer we can get all the possible control options
the picture of IR/Depth/RGB stream
For RGB the highest resolution can be up to 1920*1080
auto exposure sometimes is turned off to reduce frame drop
Setting of the environment
Pip install pyrealsense2
This is the current easiest way to install it, while the other method is through CMake which I never tested
Other plugins needed will be: numpy, opencv-python, matplotlib
Also can be done with pip install
————————————————————————————————————————
So start scripting:
My first example is to rewrite the Hello World into python
https://github.com/soarwing52/RealsensePython/blob/master/phase%201/Hello%20World.py
Import pyrealsense2 as rs
This is the library import line for realsense, in all further scripts it will be all in this form
The pipeline:
For video processing all the instructions are in a pipeline, so start it and combine the next moves.
Pipeline = rs.pipeline()
pipeline.start()
And then the configurations of the pipeline:
config = rs.config()
config.enable_stream()
This sets up streams of frames which not only when using camera but also when reading from bag files, mainly I use for alignment of frames, other I still haven’t found the function for it
Parameters:
(stream type,resolution, image format, fps)
Example:
config.enable_stream(rs.stream.depth, 640, 360, rs.format.z16, 30)
config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)
The possible can be found in the Intel Realsense Viewer, color,depth,infrared.
One thing I found interesting is that when it in default is the bgr format
in Intel Viewer it shows bgr in rgb, which means where red is blue and the colors are not correct to human eye.
So when I record as rgb8/rgba8, and view in opencv-python, it shows also again wrong, shows rgb in bgr format.
and when I use matplotlib, it showed rgb as default view.
so I need to add one cv2.convert if I want to show RGB image correctly in opencv window.
It is not a big problem just one interesting phenomenon
https://www.learnopencv.com/why-does-opencv-use-bgr-color-format/
RGB/Y16/BGR
In order to get the frames one after one, perform as a stream/video, a try and a while loop is required
Try:
while True:
Except Runtimeerror:
No frames came or ended
Finally:
pipeline.stop()
So for getting the frames
frame = pipeline.wait_for_frames()
depth_frame = frame.get_depth_frame()
color_frame = frame.get_color_frame()
This is quite straightforward
The get frame options for pipeline are:
poll_for_frames()
Get frames immediately
Somehow I can’t make it work, it just always reply no frames coming until the end
wait_for_frames()
It will block the stream until the next stream came, this caused a matching problem which I will describe later when I tested measuring
try_wait_for_frames
I haven’t really get to know this one yet
This is also same options for the syncer, but as I wrote before, I can’t get the syncer to function yet.
For frame queue there are more options
rs.frame_queue()
This will put the frames first in memory and then process and save, if there’s a lot of frames while streaming, this is the method to prevent drop frames since it saves the frame data first.
In this project I didn’t need this function, just came across it while searching
So back to the Hello World sample.
width = depth_frame.get_width()
height = depth_frame.get_height()
dist = depth_frame.get_distance(width / 2, height / 2)
This is getting attribute from frames
The options are
get_width
get_height
get_stride_in_bytes
get_bits_per_pixel
get_bytes_per_pixel
And for the metadata of the frames:
var = rs.frame.get_frame_number(color_frame)
print ‘frame number: ‘+ str(var)
time_stamp = rs.frame.get_timestamp(color_frame)
time = datetime.now()
print ‘timestamp: ‘ + str(time_stamp)
domain = rs.frame.get_frame_timestamp_domain(color_frame)
print domain
meta = rs.frame.get_data(color_frame)
print ‘metadata: ‘ + str(meta)
Frame number, timestamp are the ones I used, others I haven’t get my hands on yet
The get_distance is only for depth_frames while the others apply to all other frames.
So this can get the basic distance. But for accuracy, even though it shows the number up to 76,
The detecting distance of D435 is 10 meters, and for my test, it’s accurate within 5-6m up to +-10cm on measuring objects
key = cv2.waitKey(1)
This is window controlling, with 1 means 1ms the window will show, and 0 means forever
if key & 0xFF == ord(‘q’) or key == 27:
Break
This means when esc/q is pressed, exit the while loop, and proceed to next frame because there is a try outside of the while loop.
Well well well, this is a house of stories
two years in here, gives me a lot of adventures
so this is the article for “public-available stories"
————————————————————————————————————————–
so first, 195 per month, unbeatable in Frankfurt
and the room, big enough
our hallway, we had some epic water slides here
The fridge and the microwave I got from friends, the fridge was unplugged with food inside, they said: keep it if you want it
so I washed it
————————————————————————————————————————-
I started this story in this article
https://soarwing52.blogspot.com/2017/04/adam-opel-strasse-room-of-king-and_28.html
that was before I left my prints here
and in the two years, people come, people left
first is Kamal left for his job at 2017, while i was in Turkey
and when I’m back, Dustin also decided to move out, and we made one of the biggest party in the house
there was a castle
and I’m the dragon
After that, we had two Christmas big dinner,
this family grows
we did many crazy things that other places wont even think of
dropping a tower from the window?
turning aisle into water slide?
Well, the two years here, quite nice
and of course, my last night
one night, two groups
https://soarwing52.blogspot.com/2019/02/chapter-frankfurt-one-step-of-life_8.html
I said what should be said here, still, its not goodbye
————————————————————————————————————————–
this house, though I’m not like the 8.5 year Dustin, I also spent part of my life here
from this room
to this room
that’s how my life started in Germany, this house gave me a start, a pressure free space
which there is basically no rules, to accept all the challenges
I think, this is something worth remembering.
來到了現在的這個城鎮兩個禮拜了,上工兩個禮拜,或許該有點心得了
至於未來會怎麼樣,我也不知道
目前還沒有什麼照片,就先文字描述吧
中文翻譯可以叫做梅勒,是一個只有五萬人的小鎮
而辦公室 就在離火車站五分鐘的地方,所以大部分的員工都不住在這。
我的公司叫做 Ge-Komm,標榜著為了交通而存在的社群,表示我們是一群關心大家通勤交通的人們
而實際業務呢,在面試的時候就是分兩大項,道路網路跟下水道
那時候展示的有ArcGIS路網 跟下水道用類似胃鏡的東西探勘,檢視哪裡需要整治
實際到職之後呢,第一個禮拜就是開始接觸各種業務
第一件事情,ArcGIS只有Basic的使用權 太難過啦,很常想處理個什麼整頓資料,然後權限不足
而且公司電腦也是要安裝什麼都需要管理員帳戶,所以當我問能不能裝Office的英文語言套件,就被打槍了
好險換系統語言不需要權限,不然德文的ArcGIS我看了一下,我選擇死亡
前幾天的業務,在填入道路的表格
表格內有:
是否有農業/林業使用
是否有大眾生活使用需求
是否有觀光價值-以下有單車道、步道,還有很酷的是騎馬路線
然後就是生態價值
判定標準呢,就是用航照圖、官方的步道、單車道等資訊,然後用editor決定是:
頻繁/偶爾/幾乎不使用
這樣的標準
有在田旁邊的就是會有農業,有樹林的就寫有林業
重點就是要連成一個網絡,讓這些不易迴轉的重機具有一個可以繞一圈的路
填完表格之後呢,就是最重要的分類啦
基於上述的基本資料,把現況分類
分成A-I的幾個等級之後,提出未來定位的建議
最主要就是要建議鋪面,有:瀝青/碎石/無鋪面
所以主要是找出哪裡鋪面需要甚麼,讓政府省錢
而接案的地區就是大概都在周圍,目前看到最遠的在科隆附近
大概都是開車2小時內的各城鎮吧,所以才主要對於農林產業道路的規畫做案子
各種路網的維護
而這些他們需要開車在現場拍照並場刊,不過目前我沒有駕照,所以我只有跟過一次
因為平常他們人力就是一個人獨自開車,獨自紀錄道路實際使用情況
然後時速只能25以下,不然照片會糊掉
比較有趣的是在農田間有爛泥,不是四輪驅動就要高超的技術
因此他們問候就是:你今天有卡住嗎?
而電腦作業內容的話幾乎都在填表格
不過也有時間剛好拿來做arcpy的使用,因為這個禮拜所有人都出外拍照了
據老闆表示,本季這樣的案子有10個做好到大概10月前緊湊的完成,然後輕鬆(這是一個適合滑雪的工作? 冬天輕鬆
不過就是個耗眼力的工作,而且以地理系水準應該大二就可以做了吧
雖然可以說是學以致用?
就看著辦囉 累積點經驗、德文能力,最好能申請公司錢考個駕照
————————————————————————————————————————-
接下來就是住的環境了
今天看到了房東的後花園 不是後庭花
然後有一窩四隻兔子,兩隻狗
請問總共有幾隻腳?
房東的媽媽種菜,房東種樹,還有花
其實完全就是一種退休田園生活呀
房子是一棟三層樓的大房子,不過排水問題一直困擾著
總體而言是真的挺舒服的,走路20分鐘上班,不過晨跑就是大概8-10分鐘
而其他房間有一對老夫婦、一個19歲的阿富汗人、一個德國人
老先生因為要看病才搬過來,離醫院近
而每天都有喉嚨痛、肺積水、腿痛
令人十分的難過,也無法說甚麼,就是陪著這位76歲爺爺聊天
其餘時間,德國女生是一個純素主義,每天自己做麵包,或是吃些草葉種子
他跟房東聊的比較來,禮拜天房東都會上來一起吃早餐,而我就算聽得懂也是插不上話的
————————————————————————————————————-
總之,體驗了兩個禮拜和平的生活,比起舊家的各種冒險,是很有溫度的房子
周末去了附近的大學城Osnabruck、跟城市Bielefeld
這樣的生活目前這樣,工作很快上軌道只要去把簽證的藍卡處理好
住的也沒什麼問題,380一個月
但是就是十分養老
而且我還沒有正式上班的感覺,或許是因為試用期,而我也還真的想去更有挑戰性的地方吧
除了分類做基礎資料,額外做了寫小程式讓工作自動化、安裝了平板現地資料蒐集的QGIS APP,下禮拜工讀生會回報好不好用
我覺得有個規律的生活,目前是挺喜歡的,比起上學期間的許多課間時間更容易把運動、學習排進去
總之,這就是在德第一份工的前兩周,看過完第一個月會不會有另外的感想呢
Chapter Frankfurt:
in this part of the story, I lived a different life, even for a student in Germany.
The house of Adam-Opel-Straße, is where it started, brings us happiness and pain in the ass. And the reason my life can be such an adventure.
But what can be carried out, it because of our community.
FH, the Uni is the main reason but turned out to be the smallest part of this adventure, we all studied, worked, loved and went on.
Among the adventure, there must be a safe house, and my friends from Taiwan, provided the calm and
safeness, we were brought together because we’re here together in Frankfurt, or else we’ll never get to know each other for we all are so different yet in the same city. Nationally is only a name, but there’s somewhat in us made us friends and family.
For everyone been here, stayed, we all share some bond, the fact that we’ve became together, I’d say, thank you all, for being in my life making it better.
—————————————————————————————————————————————
Well, among the touching words, life is still a moving wheel.
after the first week of office life, there are more words.
So first introduce the daily in the office, usually starts around 8-9, ends at 17-18. With 15 minute breakfast and 30 minutes lunch break.
and Friday people all leave around 13:00.
Its quite a descent job for the first week, no technical issues in ArcGIS, pretty familiar with the software and everything.
Though the job is really basic, but I guess when doing location information, the local database is always needed to be created.
The atmosphere is quiet in the office, not challenging but getting use to an all German working environment
so far, good
—————————————————————————————————————————————-
and the new place, its the first time I really stayed in a german WG, shared apartment.
everything is big and nice.
the owner is a lady who lives with her mom downstairs.
currently the roommates are a guy call Mohhamad, which I only seen once, a german girl moved in the same day as me, and one Croatian couple, which is old enough to be my grandparents.
—————————————————————————————————————————————-
the quiet nights in this new room, there’s much to think about.
and also this is the time of Chinese new year
something ends, something starts.
in the past two years, every one just bypass each others life in this busy city.
the first year, kind of the first taste of new life here, trying everything.
after the exchange, back here, and start to be more serious for the next steps of life.
and also because I’m not so into the Erasmus group and the german language class classmates are less
my friends became the Taiwanese around, and my Adam-Opel group.
I had a lot of quiet time in my room back in Adam-Opel also, but this now here is different.
being more pragmatic now, facing what will be in front of me, and looking at whos beside me.
Allen once asked me if we do a film of the Franfurters of our friends, but its kind of hard.
we are all friends, we had fun together, but what will be the thing that bring us more together?
only same all are Taiwanese? yet we are still very different.
so to leave a mark is kind of hard. So we end up making dumplings together.
Its nice to have everyone around, yet after the meal, we all go back to our own ways to our life in here.
And for the Adam-Opel fight club, we had great times, and I believe we will always be the same no matter how we moved,so I’m not worried at all.
As I said, this is not the end, it’s just one chapter.
after this chapter, which characters will keep on showing up in the next, and maybe who will jump back after a few pages, who knows?
still, my attitude is stay open, and embrace what will come.
Always I tried my best, or even always better than my best, and I can’t afford to worry about the result, it’s just to overwhelming when I used all my energy on my efforts.
So, this chapter for me, is a reminder, a milestone, and a tombstone for the 2 years in Frankfurt.
and this is also a message, for my friends, the moments were kept in mind, and the future pages are still empty,
invitation awaits here, who will be in the next page?
繼續閱讀 “Zusammenfassung: Die Entscheidung- Kapitalismus vs. Klima"
今年稍早,曾經有個人在他生日的時候問我:25歲是甚麼感覺呢?
我已經準備好成熟,但是還沒想好怎麼辦到,以及會變成什麼未來
擁有面對一切的勇氣,仍欠缺通過難關的智慧;
還有過關斬將的毅力,卻沒有趨吉避凶的能力。
先回顧一下這一年,或是說,從出國以來吧
第一年的法蘭生涯,跟現在著實大不同
初出茅廬,不畏虎的心態,迎接一切,當一個yes man
第一年 我擁抱所有可能性,嘗試一切的可能
德文、課業、打工、球隊、朋友、運動
都是迎接新的變化,我也欣然接受,享受了快樂的時光
直到我離開了德國
我到了一個文化迥異的國度,語言、人文通通不同
當初想像的是體驗各種不同、旅遊傳聞中的美景、吃中東的美食還有真正體驗Erasmus的感覺
但卻是人生最痛苦的一段時間。
不可否認的是土耳其的這段時間在我的生命留下深刻的痕跡
如果回到那時那刻,我好像怎麼樣會做同樣的決定,我無可抱怨。
————————————————————————————————————————-
再次回到法蘭,有點像是一個重啟
去年的交換生們早已各奔東西,回到殭屍橫行的故居,只剩下七年老兵Dustin仍屹立不搖。
重返到德國校園,我的目標,是完成這段最後的學生生涯
要做好選擇,面對,不再yes to all
而是要專注在該完成的事情上,該認真了
聯絡了僅存的友人們,開始結交新的朋友們,不再像去年那麼國際化,說國語的時間多了很多
去年努力嘗試讓英語變成母語,現在則是兩個隨意使用,並加強德文
從德文班的感覺,當年的A2.1跟現在B2.2就是個遙遠的距離,心態也是大不同
這裡交朋友已不是主體,每個人學德文到這個程度都是有自己的目標要走
我也不再惋惜沒交上的朋友,因為我沒有那種閒暇心思
用五天的滑雪找回身體運行的平衡,用一周的德國人雪隊抓回德文的口感
————————————————————————————————————————–
重生以後的日子,遇到的人們,當然最重要的大哥兼麻吉,Otto Ramsay
還有Kelsterbach幫、FH新的交換生、在法蘭打拼的台灣人們
為甚麼都是在說中文呢?
因為我與各國交換生本質上的不同,我不再努力加入、融入他們的派對、群體,而必須走到我該走的路
人是群區的動物,但是如何找到可以、值得的群體,需要嘗試與努力
朋友,我一直都是推心置腹,儘管在土國被踐踏過後,
不過,與老友橫跨瑞士後,我也體認到,時間在向前,唯一不變的就是改變
儘管六度分帶能連結世界上所有的人,一個人能維持的,最多就150個人,值得留下的需要花心思照顧,向前的同時,也要帶著行囊中有價值的東西
同時要能打破德國人社交的柏林圍牆,並且維持台灣海峽上的蕃薯藤,是我的課題
————————————————————————————————————————-
大部分人對我的定義,就是狂
我從台灣就帶著這個狂,並且讓他成長
這是我繼續努力的目標
曾經我向大哥解釋了 強跟狂的差別
強,是實力穩扎穩打的構建
而狂不一定比強厲害
但是要帶有離經叛道,還有絕對的自信
但是也需要絕對的實力基礎,膽大心細,臨危但從不亂,貌似亂來但井然有序
接下來,我要繼續狂下去
——————————————————————————————————————————-
時間的流逝,第一個要敲的是警鐘
最後一個學期,儘管我一路都是以最認真的態度做每件事情
但是這次是要動真格的
喪鐘,是我該送走的各項舊物
我沒有能力留住我身邊所有的事物,流逝與消失是自然的一部分
鼓盆而歌,唯有把沙子淘盡才會顯出金子
而地球鐘,是我的初衷
對於自然環境的關懷,其實地球無論如何都會存在,能否永續的是人們
繼續向前走,在歐洲感受到的是機會更多,隨時都要準備好
沒有所謂穩定,但是心中要有一個秤陀,否則很容易迷失
————————————————————————————————————————–
最後,回到最初的問題
其實我發現,這個問題沒有一個固定的答案,因為是一個變動的存在
跨過了四分之一個世紀,可以當人生第一個里程碑吧
十年之後,我又會是怎麼看我自己呢?我不知道,我只希望是一個不會後悔
我很習慣做決定前,用一個未來檢視,如果以後我不在乎這個決定造成的不同
我現在就沒有必要在乎
其實在一個充滿未知與不安的這個年紀,卻又好像掌握了自己部份的人生
還是老梗,機會是留給準備好的人
在這個時代,關公門前耍大刀,就要耍出新花樣,並抱著耍贏的勇氣
二六的我,不是四二六
在接下來的日子,膽大更要心細,成熟同時輕狂,穩重加上飆揚
所有的挑戰,我單刀赴會
英文版洋洋灑灑的流水帳寫了八篇,詳細的風景、GPS軌跡紀錄都在那裏了,自己去找吧!
這篇不能當作一個總論,而是一個隨筆
單車是我神聖不可分割的一部分,是建構、是生活、是靈魂
It’s the last day biking and actually we also biked a lot
some unexpected things happened, and we were drained again
what is it? let’s peddal