Skip to content

Commit

Permalink
Add Node.js installation instructions and update
Browse files Browse the repository at this point in the history
camera settings
  • Loading branch information
infinitel8p committed Nov 13, 2023
1 parent 2d99c2c commit 96a4b19
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 21 deletions.
35 changes: 34 additions & 1 deletion docs/SCRIPT.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,37 @@ sudo pip3 install -r requirements.txt
- Start the security camera script with the following command:
```bash
python3 main.py
```
```

## Install Node.js
- Install Node.js with the following commands:
1. Update the Raspberry Pi
```bash
sudo apt update
sudo apt upgrade
```
2. Check the Node.js Version Available
```bash
apt-cache policy nodejs
```
The output should look like this:
```bash
pi@raspberrypizero2:~ $ apt-cache policy nodejs
nodejs:
Installed: (none)
Candidate: 12.22.12~dfsg-1~deb11u4
Version table:
12.22.12~dfsg-1~deb11u4 500
500 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages
```
The apt-cache policy nodejs command shows that Node.js version 12.22.12 is available for installation from the Raspberry Pi repositories, but it hasn't been installed (Installed: (none)).
3. Install Node.JS and npm on the Raspberry Pi
```bash
sudo apt install nodejs
sudo apt install npm
```
4. Check the version
```bash
nodejs -v # Checks Node.js version
npm -v # Checks npm version
```
36 changes: 16 additions & 20 deletions main2.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@

# Initialize the camera
camera = picamera.PiCamera()
camera.annotate_background = picamera.Color('black')
camera.resolution = (1920, 1080)
camera.framerate = 24
recording = False

# Set up GPIO
Expand All @@ -61,29 +64,22 @@
# Function to stream frames


def stream_frames():
global should_stream_frames, streaming_running
streaming_running = True

with picamera.PiCamera() as camera:
camera.resolution = (1920, 1080)
camera.framerate = 24
stream = io.BytesIO()

for _ in camera.capture_continuous(stream, 'jpeg', use_video_port=True):
if not should_stream_frames:
break
def stream_frames(camera):
global should_stream_frames
stream = io.BytesIO()

# Send frame
stream.seek(0)
buffer = stream.read()
if should_stream_frames:
ws.send(buffer, opcode=websocket.ABNF.OPCODE_BINARY)
for _ in camera.capture_continuous(stream, 'jpeg', use_video_port=True):
if not should_stream_frames:
break

stream.seek(0)
stream.truncate()
# Send frame
stream.seek(0)
buffer = stream.read()
if should_stream_frames:
ws.send(buffer, opcode=websocket.ABNF.OPCODE_BINARY)

streaming_running = False
stream.seek(0)
stream.truncate()

# WebSocket handlers

Expand Down

0 comments on commit 96a4b19

Please sign in to comment.