Browse Source

Adding service install to setup shell-script

master
Georgios Gerontakis 5 years ago
parent
commit
5c6207f3bf
  1. 12
      camera module/camera_module.service
  2. 7
      camera module/setup.sh
  3. 29
      camera module/streamer.py

12
camera module/camera_module.service

@ -0,0 +1,12 @@
[Unit]
Description=Camera Module Service
After=multi-user.target
Conflicts=getty@tty1.service
[Service]
Type=simple
ExecStart=/usr/bin/python3 /usr/bin/main.py
StandardInput=tty-force
[Install]
WantedBy=multi-user.target

7
camera module/setup.sh

@ -4,3 +4,10 @@ sudo apt install python3-pip
sudo apt-get install rpi.gpio
sudo apt-get install python3-opencv
sudo pip3 install pyzmq
sudo cp servo.py /usr/bin/servo.py
sudo cp main.py /usr/bin/main.py
sudo cp camera_module.service /lib/systemd/system/camera_module.service
sudo systemctl daemon-reload
sudo systemctl enable camera_module.service
sudo systemctl start camera_module.service
sudo systemctl status camera_module.service

29
camera module/streamer.py

@ -1,29 +0,0 @@
import base64
import cv2
import zmq
context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://*:4444")
while True:
client_ip = socket.recv()
break
footage_socket = context.socket(zmq.PUB)
footage_socket.connect('tcp://' + client_ip.decode() + ':5555')
camera = cv2.VideoCapture(0) # init the camera
while True:
try:
grabbed, frame = camera.read() # grab the current frame
frame = cv2.resize(frame, (640, 480)) # resize the frame
encoded, buffer = cv2.imencode('.jpg', frame)
jpg_as_text = base64.b64encode(buffer)
footage_socket.send(jpg_as_text)
except KeyboardInterrupt:
camera.release()
cv2.destroyAllWindows()
break
Loading…
Cancel
Save