📂
my database
  • Introduction
  • Home setup
    • Raspberry
      • OS Installation
      • Enable SSH and first access
      • SSH configuration
      • Change default credentials
      • Home DNS
      • WiFi USB
      • Live cam
      • ESP32
      • AD/DA
      • Humidity sensors
    • Remote access
      • ssh
      • Turn on/off remote computer
      • Dynamic DNS
      • Remote ssh
      • Home VPN
  • GNU/Linux commands
    • locale
    • crontab
    • chmod
    • router
  • Future sections
    • Topics
  • Research
    • Introduction to Sustainability
Powered by GitBook
On this page

Was this helpful?

  1. Home setup
  2. Raspberry

Live cam

Configuration of a live cam.

Next, we want to configure a live cam connected to the Raspberry. With a cam, there can be multiple applications:

  • 24h live stream of whatever. Exposing a port in the local network should suffice.

  • Take a picture at a certain point of the day and save it. Then, timelapse can be done.

source:

To use cv2:

  • Create virtual environment python3 -m venv venv

  • Activate it . venv/bin/activate

  • Install cv2 pip install opencv-python

  • Install extra libs required sudo apt-get install libatlas-base-dev

  • Run following script

import cv2
import time

cap = cv2.VideoCapture(0)
ret, frame = cap.read()

def takePicture():
    (grabbed, frame) = cap.read()
    showimg = frame
    # cv2.imshow('img1', showimg)  # display the captured image
    cv2.waitKey(2000)
    #time.sleep(1) # Wait 300 miliseconds
    image = 'test-image.png'
    cv2.imwrite(image, frame)
    cap.release()
    return image

print(takePicture())

Play with waitKey(*) to let some seconds to focus light. Also, adjust cam.

PreviousWiFi USBNextESP32

Last updated 3 years ago

Was this helpful?

https://github.com/opencv/opencv-python
https://raspberrypi-guide.github.io/electronics/using-usb-webcams
https://stackoverflow.com/questions/53347759/importerror-libcblas-so-3-cannot-open-shared-object-file-no-such-file-or-dire
https://gist.github.com/Luxato/384a7c8a6bfdeba09d54cb5bd6b2c9fb