日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Intel Realsense D435 测试摄像头在不同曝光值下的帧生成时间(防止曝光时间过长导致fps下降)auto_exposure_priority(没成功)

發布時間:2025/3/20 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Intel Realsense D435 测试摄像头在不同曝光值下的帧生成时间(防止曝光时间过长导致fps下降)auto_exposure_priority(没成功) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • 不用測了
  • 下面測試auto_exposure_priority參數在自動曝光下的作用
  • 下面測試在自動曝光模式下如何實時獲取曝光值
  • 測試攝像頭在不同曝光值下的幀生成時間

不用測了

參考文章:Intel Realsense D435 pyrealsense2 get_option_range() 獲取rs.option中參數值取值范圍

突然發現,option.py中有option.auto_exposure_priority參數能夠限制自動曝光以維持恒定的fps速率,所以就不用擔心曝光時間過長導致fps下降了

想了想,不對,還是要測

因為自動曝光優先是在自動曝光開啟時才用到的,當自動曝光關閉時,它就失去作用了。。。我檢驗一下

# -*- coding: utf-8 -*- """ @File : 200108_測試獲取Intel_Realsense_options參數.py @Time : 2020/1/8 13:18 @Author : Dontla @Email : sxana@qq.com @Software: PyCharm """ import timeimport numpy as np import pyrealsense2 as rs import cv2ctx = rs.context()pipeline = rs.pipeline(ctx) cfg = rs.config() cfg.enable_device('838212073161') cfg.enable_stream(rs.stream.depth, 640, 360, rs.format.z16, 30) cfg.enable_stream(rs.stream.color, 640, 360, rs.format.bgr8, 30) pipeline_profile = pipeline.start(cfg)sensor = pipeline.get_active_profile().get_device().query_sensors()[1] sensor.set_option(rs.option.enable_auto_exposure, True) print(sensor.get_option(rs.option.exposure)) # 156.0 sensor.set_option(rs.option.exposure, 5000.000) print(sensor.get_option(rs.option.exposure)) # 5000.0 sensor.set_option(rs.option.auto_exposure_priority, True) print(sensor.get_option(rs.option.exposure)) # 5000.0

結果:

將曝光值設置為5000后,明顯感覺傳輸幀變慢了(其實沒慢,就是沒曝光完全,存在殘影),說明auto_exposure_priority并未限制曝光值以維持幀速率,為了保證驗證的準確性,我又將auto_exposure_priority設置為False,發現還是同樣的結果

下面測試auto_exposure_priority參數在自動曝光下的作用

# -*- coding: utf-8 -*- """ @File : 200109_測試攝像頭自動曝光優先.py @Time : 2020/1/9 14:43 @Author : Dontla @Email : sxana@qq.com @Software: PyCharm """import numpy as np import pyrealsense2 as rs import cv2ctx = rs.context()pipeline = rs.pipeline(ctx) cfg = rs.config() cfg.enable_device('838212073161') cfg.enable_stream(rs.stream.depth, 640, 360, rs.format.z16, 30) cfg.enable_stream(rs.stream.color, 640, 360, rs.format.bgr8, 30) pipeline_profile = pipeline.start(cfg)sensor = pipeline.get_active_profile().get_device().query_sensors()[1] sensor.set_option(rs.option.enable_auto_exposure, True) sensor.set_option(rs.option.auto_exposure_priority, False)while True:frames = pipeline.wait_for_frames()color_frame = frames.get_color_frame()color_image = np.asanyarray(color_frame.get_data())cv2.imshow('win', color_image)cv2.waitKey(1)

結果:
將auto_exposure_priority設置為False,發現并沒有出現幀速率下降的現象,每幀傳來都約0.033秒(設置幀速率為30幀每秒):

將auto_exposure_priority設置為True,結果還是相同

那這個auto_exposure_priority參數有啥用???

仔細觀察,還是有區別的,當設置auto_exposure_priority為True時,當攝像頭的場景由暗向光轉變,圖像會突然閃亮一下,像是曝光過度的感覺,當場景由光向暗轉變時,攝像頭會在一瞬間暗得特別厲害,就是過渡不平滑;但是如果auto_exposure_priority設置為False時,過渡就會非常平滑

由于不知道這種平滑過渡或不平滑過渡會對我們項目帶來哪些影響,就暫時按照它默認的設置吧,默認為Ture,參考:Intel Realsense D435 pyrealsense2 get_option_range() 獲取rs.option中參數值取值范圍

下面測試在自動曝光模式下如何實時獲取曝光值

# -*- coding: utf-8 -*- """ @File : 200108_測試獲取Intel_Realsense_options參數.py @Time : 2020/1/8 13:18 @Author : Dontla @Email : sxana@qq.com @Software: PyCharm """ import time import numpy as np import pyrealsense2 as rs import cv2ctx = rs.context()pipeline = rs.pipeline(ctx) cfg = rs.config() cfg.enable_device('838212073161') cfg.enable_stream(rs.stream.depth, 640, 360, rs.format.z16, 30) cfg.enable_stream(rs.stream.color, 640, 360, rs.format.bgr8, 30) pipeline_profile = pipeline.start(cfg)sensor = pipeline.get_active_profile().get_device().query_sensors()[1] sensor.set_option(rs.option.enable_auto_exposure, True)while True:print(sensor.get_option(rs.option.exposure))frames = pipeline.wait_for_frames()color_frame = frames.get_color_frame()color_image = np.asanyarray(color_frame.get_data())cv2.imshow('win', color_image)cv2.waitKey(1)

程序啟動后,分別將攝像頭在光暗處來回移動
結果:

曝光值一直都是156沒變。。。。

然后我手動將曝光值設置成156,發現:

沒有自動曝光的效果,極差!

難道說,在pipeline start后,就沒有辦法獲取到實時曝光值了嗎???

測試攝像頭在不同曝光值下的幀生成時間

我擦嘞,發現測不出來,無論把曝光時間設為多少,它都是按照設置的幀率傳過來,30fps,每幀就約33ms。。。

增大曝光值,它的殘影就多了,就像本來要曝光200ms,它強制33ms就傳過來一樣,沒爆光完全。。。

所以以前看到視頻一卡一卡的,以為是幀傳送慢了,其實不是,這是假象,真實的情況是圖片存在殘影,感覺里面物體移動變慢了,所以看起來像一卡一卡的一樣

無論如何,現在還是暫時就使用它的自動曝光吧

# -*- coding: utf-8 -*- """ @File : 200109_測試不同曝光值下幀生成時間.py @Time : 2020/1/9 16:52 @Author : Dontla @Email : sxana@qq.com @Software: PyCharm """import timeimport numpy as np import pyrealsense2 as rs import cv2ctx = rs.context()for dev in ctx.query_devices():# 先將設備的序列號放進一個變量里,免得在下面for循環里訪問設備的信息過多(雖然不知道它會不會每次都重新訪問)dev_serial = dev.get_info(rs.camera_info.serial_number)# 匹配序列號,重置我們需重置的特定攝像頭(注意兩個for循環順序,哪個在外哪個在內很重要,不然會導致剛重置的攝像頭又被訪問導致報錯)if '838212073161' == dev_serial:dev.hardware_reset()# 像下面這條語句居然不會報錯,不是剛剛才重置了dev嗎?莫非區別在于沒有通過for循環ctx.query_devices()去訪問?# 是不是剛重置后可以通過ctx.query_devices()去查看有這個設備,但是卻沒有存儲設備地址?如果是這樣,# 也就能夠解釋為啥能夠通過len(ctx.query_devices())函數獲取設備數量,但訪問序列號等信息就會報錯的原因了print('攝像頭{}初始化成功'.format(dev.get_info(rs.camera_info.serial_number))) # 如果只有一個攝像頭,要讓它睡夠5秒(避免出錯,保險起見) time.sleep(5)pipeline = rs.pipeline(ctx) cfg = rs.config() cfg.enable_device('838212073161') cfg.enable_stream(rs.stream.depth, 640, 360, rs.format.z16, 30) cfg.enable_stream(rs.stream.color, 640, 360, rs.format.bgr8, 30) pipeline_profile = pipeline.start(cfg)sensor = pipeline.get_active_profile().get_device().query_sensors()[1] sensor.set_option(rs.option.exposure, 330) sensor.set_option(rs.option.auto_exposure_priority, True)time0 = time.time() while True:frames = pipeline.wait_for_frames()color_frame = frames.get_color_frame()color_image = np.asanyarray(color_frame.get_data())cv2.imshow('win', color_image)cv2.waitKey(1)time_difference = time.time() - time0print(time_difference)time0 = time.time()# cv2.imwrite('{:.3f}.jpg'.format(time.time()), color_image)


參考文章:Intel Realsense D435 pyrealsense2 get_option_range() 獲取rs.option中參數值取值范圍 獲取默認值

總結

以上是生活随笔為你收集整理的Intel Realsense D435 测试摄像头在不同曝光值下的帧生成时间(防止曝光时间过长导致fps下降)auto_exposure_priority(没成功)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。