Robobot webcam server: Difference between revisions

From Rsewiki
No edit summary
Line 15: Line 15:
  /usr/bin/python3 stream_server.py &
  /usr/bin/python3 stream_server.py &


=== Motion ===
=== Watch result using a browser ===


* NO! use Python web server instead
Using the IP of the robot (in this case, robot Coco), the robot camera image can be viewed at this address:
* @todo update this page


A motion camera ser is installed called "motion", it can detect motion and save video-clip, if motion is detected.
http://10.197.218.233:7123
 
Motion detection is the primary purpose, but being able to see what the camera sees.
 
=== Configuration file ===
 
Edit the configuration file
 
$ sudo nano /etc/motion/motion.conf
# File to write log messages into.  If not defined, stderr and syslog are used.
log_file /home/local/.motion/motion.log
# Target directory for pictures, snapshots and movies
target_dir /home/local/Video/motion
# Video device (e.g. /dev/video0) to be used for capturing.
videodevice /dev/video0
# The port number for the live stream.
stream_port 8081
# Restrict stream connections to the localhost (if 'stream_localhost on').
stream_localhost off
# Image width in pixels.
width 640
# Image height in pixels.
height 480
# Maximum number of frames to be captured per second.
framerate 5
 
=== run motion ===
 
To run the streamer, SSH to the robot and start motion
 
$ motion
[0:motion] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motion/motion.conf
[0:motion] [NTC] [ALL] motion_startup: Logging to file (/home/local/.motion/motion.log)
 
Stop by ctrl-C
 
Note! Remember to stop the streamer before using the camera for other purposes.
There is an alternative if you want both:
 
Start a loopback feature to create a copy with the same information when the camera is opened.
Run:
sudo modprobe v4l2loopback
 
When /dev/video0 is opened a /dev/video1 will be created (with the data determined by the first user).
 
- not tested much.
 
=== View the stream ===
 
To view the result, use a browser to the address of the robot and port 8081, e.g. if the robot has IP '10.197.218.248':
 
10.197.218.248:8081
 
You should now see a stream of default 640x480 at 5 FPS as default; more options are available in /etc/motion/motion.conf.
 
==2024==
 
Test a new method from https://pimylifeup.com/raspberry-pi-webcam-server/
 
Install:
 
sudo apt install autoconf automake build-essential pkgconf libtool git libzip-dev libjpeg-dev gettext libmicrohttpd-dev libavformat-dev libavcodec-dev libavutil-dev libswscale-dev libavdevice-dev default-libmysqlclient-dev libpq-dev libsqlite3-dev libwebp-dev libcamera-v4l2
 
 
sudo wget https://github.com/Motion-Project/motion/releases/download/release-4.6.0/$(lsb_release -cs)_motion_4.6.0-1_$(dpkg --print-architecture).deb
 
sudo dpkg -i $(lsb_release -cs)_motion_4.6.0-1_$(dpkg --print-architecture).deb
 
change the /etc/motion/motion.conf
 
* not much luck; it seems not compatible with libcamera.
 
installed
sudo apt install libqt5dxcb-plugin
 
to try
rpicam-vid --qt-preview
 
But (also) not over ssh -X login
 
A libcamera wrapper: https://github.com/kbarni/LCCV
With opencv, install
libcamera-dev

Revision as of 10:11, 3 January 2025

Back to Robobot_B

View camera

Python cam server

Try this https://medium.com/@studymattersinlife/building-a-simple-video-streaming-server-client-in-python-e88d3b9e7158

This server is part of the Robobot repository at svn/robobot/stream_server and should be started at boot-time. (see ~/on_reboot.bash)

Or try:

cd /home/local/svn/robobot/stream_server
/usr/bin/python3 stream_server.py &

Watch result using a browser

Using the IP of the robot (in this case, robot Coco), the robot camera image can be viewed at this address:

http://10.197.218.233:7123