LoginSignup
1
0

More than 5 years have passed since last update.

(MEMO)ラズパイ with カメラモジュール とOpenCVで動画のFrame取得する

Last updated at Posted at 2018-10-17

(作成日 2018/10/17)
ラズパイとカメラモジュール、Opencvを使用して動画のFrameを取得。

1.ラズパイにカメラモジュールを接続後terminalを立ち上げ、下記コマンドでモジュールをロードする。
>sudo modprobe bcm2835-v4l2
v4(エル小文字)2。

2.下記区スクリプトでframe取得して表示。

#!/user/bin/python

import cv2

cap = cv2.VideoCapture(0)
print(cap)
while True:
    ret,frame = cap.read()

    ########################
    #ここに画像に対する処理を入れる
    # 
    ########################

    cv2.imshow('window',frame)

    # sを押すとStop
    k = cv2.waitKey(0)
    if k == ord('s'):
        break

cap.release()
cv2.destroyAllWindow()


こっちの方が、以前の記事より機械学習とかやりやすいのかも?
fpsの設定やサイズなどの設定/取得は下記のキーワードでググる。
cv2.CAP_PROP_FPS

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0