簡體   English   中英

有沒有辦法增加樹莓派中實時攝像頭的幀率?

[英]Is there a way of increasing fps of real time camera feed in raspberry pi?

我正在使用 Raspberry Pi 4 和 HTPA32x32d 熱像儀傳感器。 我正在使用https://github.com/cjcbusatto/thermografree這個叉子來讀取帶 I2C 的相機。 我的主要代碼采用 32x32 傳感器 output 並使用 cv2.resize() function 轉換為可視圖像並顯示在屏幕上。 我的范圍在 2-4 fps 之間。 我想提高實時熱成像的 fps。 你能建議什么來增加我的fps嗎?

我正在考慮預測幀,但我不知道一種方法,或者它對於實時 fps 增量是否足夠? 如果沒有,或者您有更好的方法,我可以使用這些信息。

更新#1

我還沒有嘗試過任何東西。 我正在尋找增加fps的方法。 我有一個想法來收集 3 幀並預測它們之間的幾幀以增加到 10 fps。 由於視頻的 2 幀之間的變化最小。 但我不知道如何開始。

示例代碼如下:

#IMPORT PACKAGES
import time
import cv2
import numpy as np
from htpa import *

size = (256,256) #frame size

#initialize IR camera module 
ir = HTPA(0x1A)

while(1):
    start_time = time.time()
    #generate termal image and temperature array
    temps, ta = ir.capture_temperatures()
    irIm = cv2.resize(temps, size, interpolation = cv2.INTER_CUBIC)
    norm_image = np.uint8(cv2.normalize(irIm, None, alpha = 0, beta = 255, 
    norm_type = cv2.NORM_MINMAX, dtype = cv2.CV_8UC1))
    hotIm = cv2.applyColorMap(norm_image,cv2.COLORMAP_HOT)

    cv2.imshow("Result", hotIm)
    key = cv2.waitKey(1) & 0xFF
    print("fps ; ", 1.0/(time.time()-start_time))

    #if the 'q' key was pressed, break from the loop
    if key == ord("q"):
       break
cv2.destroyAllWindows()

相機饋送的示例幀:

在此處輸入圖像描述

更新#2

當我只讀取temps, ta = ir.capture_temperatures()沒有任何處理(甚至顯示),fps 是 4.0 的平均值,在 3.2 到 4.2 之間移動。

讀取和處理(未顯示)時,fps 在 3.0 和 4.0 之間移動,平均為 3.7。

我查看了 htpa32x32d 的數據表。 我看到這個解決方案在 htpa.py 中輸入圖像描述

    def set_clock_speed(self, clk):
    if clk > 63:
        clk = 63
    if clk < 0:
        clk = 0

    clk = int(clk)
    print(clk)
    clk_speed = self.generate_command(0x06,clk)

    self.send_command(clk_speed)

您可以更改 clk 值,這樣就解決了您的問題。

鏈接到源代碼

查看代碼, htpa.py中的第 252 行可能是延遲的原因。

while not self.block_capture_finished(block, blind, vdd):

time.sleep(0.005)

試試time.sleep(0.001)看看有沒有改善。

另一個原因可能是在capture_display.py第 20 行中使用了調整大小。

試試im = cv2.resize(im, None, fx=4, fy=4)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM