6

At the moment, i have Pi Camera > Pi > Ethernet Cable > Pi > Display, and using the codes from, https://www.youtube.com/watch?v=r80dcfzClD4 i am able to stream video from one Pi to another.

What i was wondering, how would i need to change these codes to allow me to take photos while streaming? i did have a python script that allowed me to do this by pressing a button, if i can incorporate it somehow

Steve Robillard
  • 34,687
  • 17
  • 103
  • 109
Darquesse
  • 61
  • 1
  • 2
  • Try looking into the preinstalled software called fb (framebuffer) - There should be a way to dump the region into a still media image. – Piotr Kula Jul 24 '17 at 10:30
  • I would have written the function in Python. – kuzeyron Aug 14 '17 at 09:00
  • Give this a try. It's a possible solution for web streaming and taking pictures (almost simultaneously). https://www.youtube.com/watch?v=gqv1_-f2H98 – Alex M Jun 25 '19 at 17:37

2 Answers2

1

You can stream raspivid output as RTSP stream using various software like vlc,ffmpeg, etc..

Here is the example VLC command:

raspivid -o - -t 9999999 -w 1280 -h 720 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:554/}' :demux=h264

After create a rtsp stream, you can save some screenshot using this rtsp stream

Here is the example FFMPEG command:

ffmpeg -i {RTSP_SOURCE} -ss 00:00:01 -f image2 -vframes 1 thumb.jpg
MatsK
  • 2,791
  • 3
  • 16
  • 20
Mehmet Bayrak
  • 123
  • 1
  • 1
  • 9
0

I am doing it with OpenCV. I am taking picture right from camera stream, but it is possible to capture picture from device too. My example:

import urllib.request
import cv2
import numpy as np    

def CaptureFrontCamera():
    _bytes = bytes()
    stream = urllib.request.urlopen('http://192.168.0.51/video.cgi?resolution=1920x1080')
    while True:
        _bytes += stream.read(1024)
        a = _bytes.find(b'\xff\xd8')
        b = _bytes.find(b'\xff\xd9')
        if a != -1 and b != -1:
            jpg = _bytes[a:b+2]
            _bytes = _bytes[b+2:]
            filename = '/home/pi/capture.jpeg'
            i = cv2.imdecode(np.fromstring(jpg, dtype=np.uint8), cv2.IMREAD_COLOR)
            cv2.imwrite(filename, i)
            return filename
Koxo
  • 151
  • 2