Robobot webcam server

From Rsewiki

Back to Robobot_B

View camera

Python cam server

The source is copied from 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

Change configuration

Change the configuration in the streamer source code:

/home/local/svn/robobot/stream_server/stream_server.py

The resolution need to be changed 2 places!

In the HTML script in the beginning of the file, and the camera configuration near the end

HTML file

Select one of these lines (comment or uncomment < ... />) as needed

<body>

Picamera2 MJPEG Streaming from {}

<img src="stream.mjpg" width="820" height="616" />
</body>

Camera configuration

Select the matching line to the settings above:

picam2 = Picamera2()
#picam2.configure(picam2.create_video_configuration(main={"size": (1296, 972)},controls={'FrameDurationLimits': (200000, 200000)}))
picam2.configure(picam2.create_video_configuration(main={"size": (820, 616)},controls={'FrameDurationLimits': (200000, 500000)}))
#picam2.configure(picam2.create_video_configuration(main={"size": (1296, 972)},controls={'FrameDurationLimits': (200000, 500000)}))
#picam2.configure(picam2.create_video_configuration(main={"size": (640, 480)},controls={'FrameDurationLimits': (200000, 500000)}))
#picam2.configure(picam2.create_video_configuration(main={"size": (320, 240)},controls={'FrameDurationLimits': (200000, 500000)}))

Reboot or restart to see the effect.

Restart streaming

Restart by first stopping the running version:

 pkill python3

Then restart

cd /home/local/svn/robobot/stream_server
python3 stream_server.py

[0:41:06.196852273] [12840]  INFO Camera camera_manager.cpp:297 libcamera v0.0.5+83-bde9b04f
[0:41:06.226600078] [12841]  INFO RPI vc4.cpp:437 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media1 and ISP device /dev/media3
[0:41:06.226689448] [12841]  INFO RPI pipeline_base.cpp:1101 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'
[0:41:06.233368984] [12840]  INFO Camera camera.cpp:1033 configuring streams: (0) 320x240-XBGR8888 (1) 640x480-SGBRG10_CSI2P
[0:41:06.233900943] [12841]  INFO RPI vc4.cpp:565 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 640x480-SGBRG10_1X10 - Selected unicam format: 640x480-pGAA