使用opencv呼叫攝像頭介面,獲取自己拍攝的資料集
import tensorflow as tf
import cv2 as cv
#自己捕捉訓練資料集
#1.設定roi區域引數
img_roi_x =
30img_roi_y =
200img_roi_heigh =
350img_roi_width =
350capture = cv.
videocapture(0
)#呼叫攝像頭介面
index =
1#設定頻率,初始為1;
num =
1#設定計數器,初始為1;
while true:#布林值迴圈
ret,frame = capture.
read
( if ret is true:
img_roi = frame[img_roi_y:
(img_roi_y + img_roi_heigh)
,img_roi_x:
(img_roi_x + img_roi_width)
]#找出感興趣區域
cv.imshow
("frame"
,img_roi)#顯示
index +=1
if index %5==
0: # 設定每5幀儲存一次影象
,img_roi)#設定儲存路徑
c = cv.
waitkey(50
)#每50ms判斷按下鍵盤觸發
if c ==
27: #27在ascii碼中表示esc
break#按下esc表示跳出迴圈
if index ==
1000
:break
else
:break
cv.destroyallwindow
()#該函式可以正常關閉圖形視窗
capture.
release
()
FindResource 如何獲取自定義資源
來自 在.exe中可以這樣新增和訪問 1,新增資料 資源 在resource 資源 中 通過 add resource import.選擇需要新增的 資料 資源,其中的 resource type 可以自己命名,需要注意的是需要利用字串命名,譬如可以為 myrestype 資源id可以為字串,譬如為...
js 如何獲取自定義屬性的值
用點操作符來獲取。也可以用element物件的getattribute 函式來獲取。示例var datatype 當前元素物件.value 只能使用getattribute函式來獲取。示例var datatype 當前元素物件.getattribute 自定義屬性 用prop 函式。用attr 函式...
hibernate 怎麼獲取 自定義的 列
什麼也不說了 先上 吧 public mapgetusernoticesbyuserid long userid throws exception session session getsession 這裡是框架中使用的 大家可以通過 gethibernatetemplate 獲取session q...