1. 程式人生 > 其它 >OpenMV4開發筆記1-感光元件初始化

OpenMV4開發筆記1-感光元件初始化

技術標籤:計算機視覺嵌入式opencv

import sensor, image, time
#引入此例程依賴的模組,
#sensor 是與攝像頭引數設定相關的模組,
#image 是影象處理相關的模組,
#time 時鐘控制相關的模組。
#import 相當於 c 語言的#include <>,模組相當於 c 語言的庫。

sensor.reset()  #初始化相機感測器
sensor.set_pixformat(sensor.RGB565) #設定相機模組的畫素模式。
sensor.set_framesize(sensor.QVGA)  #設定相機模組的幀大小。
sensor.
skip_frames(time = 2000) #Let new settings take affect. clock = time.clock() #初始化時鐘 while(True): clock.tick() #Track elapsed milliseconds between snapshots() img = sensor.snapshot() #擷取當前影象,存放於變數 img 中。 print(clock.fps()) #列印當前的幀率。

sensor.set_pixformat(pixformat)

設定相機模組的畫素模式。

sensor.GRAYSCALE

: 8-bits per pixel.
sensor.RGB565: 16-bits per pixel.
sensor.BAYER: 8-bits per pixel bayer pattern.

sensor.set_framesize(framesize)

設定相機模組的幀大小。
OpenMV4 H7預設配置的OV7725 感光元件處理640×480 8-bit 灰度圖或者640×480 16-bit RGB565彩色影象可以達到60 FPS;當解析度低於320×240可以達到120FPS。大多數簡單的演算法可以執行60FPS以上。你的 OpenMV 攝像頭有一個2.8mm焦距鏡頭在一個標準M12鏡頭底座上。如果你想使用更多的特殊的鏡頭,你可以很容易的安裝。

sensor.QQCIF: 88x72
sensor.QCIF: 176x144
sensor.CIF: 352x288
sensor.QQSIF: 88x60
sensor.QSIF: 176x120
sensor.SIF: 352x240
sensor.QQQQVGA: 40x30
sensor.QQQVGA: 80x60
sensor.QQVGA: 160x120
sensor.QVGA: 320x240
sensor.VGA: 640x480
sensor.HQQQVGA: 80x40
sensor.HQQVGA: 160x80
sensor.HQVGA: 240x160
sensor.B64X32: 64x32 (for use with image.find_displacement())
sensor.B64X64: 64x64 (for use with image.find_displacement())
sensor.B128X64: 128x64 (for use with image.find_displacement())
sensor.B128X128: 128x128 (for use with image.find_displacement())
sensor.LCD: 128x160 (for use with the lcd shield)
sensor.QQVGA2: 128x160 (for use with the lcd shield)
sensor.WVGA: 720x480 (for the MT9V034)
sensor.WVGA2:752x480 (for the MT9V034)
sensor.SVGA: 800x600 (only in JPEG mode for the OV2640 sensor)
sensor.SXGA: 1280x1024 (only in JPEG mode for the OV2640 sensor)
sensor.UXGA: 1600x1200 (only in JPEG mode for the OV2640 sensor)

sensor.skip_frames([n, time])

使用 n 個快照,讓相機影象在改變相機設定後穩定下來。 n 作為普通引數傳輸, 例如: skip_frames(10) 跳過 10 幀。您應在改變相機設定後呼叫該函式。

或者,您可通過關鍵字引數 time 來跳過幾毫秒的幀數,例如: kip_frames(time = 2000) ,跳過2000毫秒的幀。

若 n 和 time 皆未指定,該方法跳過300毫秒的幀。

若二者皆指定,該方法會跳過 n 數量的幀,但將在 time 毫秒後超時。

更多感光元件函式參考:https://docs.singtown.com/micropython/zh/latest/openmvcam/library/omv.sensor.html