5.Running Raspberry Pi Camera Module With OpenCV - NaimFuad/RaspberryPiWithOpenCV GitHub Wiki

Raspberry Pi Camera Module

Enable Camera On Your Raspberry Pi

  1. On terminal run the following command
$ sudo raspi-config
  1. Navigate to Interface Option, on Camera option, choose_ Yes _to enable it.
  2. Reboot you Raspberry Pi
$ sudo reboot now
  1. Connect your Raspberry Pi Camera Module to the onboard MIPI connector.
  2. Create a new Python on Python IDE (or Thonny)script by copy paste the given code and run it.
import cv2
import numpy as np
import time

cap=cv2.VideoCapture(0)
cap.set(3,320) #set heigt   >>refer propId
cap.set(4,240)  #set width
time.sleep(0.1)


while True:
  ret,frame = cap.read()
  cv2.imshow('frame',frame)

  if cv2.waitKey(1)&0xFF == ord('q'):
  break

cap.release()
cv2.destroyAllWindows()

Streming From Raspberry Pi Camera Module