
рдирдорд╕реНрдХрд╛рд░ред рдЗрд╕ рд▓реЗрдЦ рдореЗрдВ, рдореИрдВ рдЖрдкрдХреЛ рдмрддрд╛рдКрдВрдЧрд╛, рдкрд╣рд▓реА рдмрд╛рд░ рдореЗрдВ, рд░рд╛рд╕реНрдкрдмреЗрд░реА рдкрд╛рдИ 3 рдФрд░ рдХрдордЬреЛрд░ рдкреНрд▓реЗрдЯрдлрд╛рд░реНрдореЛрдВ рдкрд░ H264 рдкреНрд░рд╛рд░реВрдк рдореЗрдВ рдЧрддрд┐ рдХрд╛ рдкрддрд╛ рд▓рдЧрд╛рдиреЗ рдФрд░ / рдкреНрд░рд╕рд╛рд░рдг рд╡реАрдбрд┐рдпреЛ рдХреЛ рдмрдЪрд╛рдиреЗ рдХреЗ рд▓рд┐рдП рдХреИрд╕реЗред рдореИрдВ рд░рд╛рд╕реНрдкрдмреЗрд░реА рдкрд╛рдИ рдХреА рджреБрдирд┐рдпрд╛ рдореЗрдВ рдПрдХ рд╣реА рдирд╡рд╛рдЧрдВрддреБрдХ рдХреЗ рд╕рд╛рде рд╕рд╛рдЭрд╛ рдХрд░реВрдВрдЧрд╛, рдЬреИрд╕рд╛ рдХрд┐ рдореИрдВрдиреЗ, рдХреБрдЫ рджрд┐рдиреЛрдВ рдореЗрдВ рдореБрдЭреЗ рдЬреЛ рдкрддрд╛ рдЪрд▓рд╛, рдЬрдмрдХрд┐ рдореБрдЭреЗ рд▓рдЧрд╛ рдХрд┐ рд╕рдорд╕реНрдпрд╛ рдХреЛ рдХреИрд╕реЗ рд╣рд▓ рдХрд┐рдпрд╛ рдЬрд╛рдПред рдореИрдВ рд╕рд░рд▓ рдорд╛рдирд╡ рднрд╛рд╖рд╛ рдореЗрдВ рд░рд╛рд╕реНрдкрдмреЗрд░реА рдкрд╛рдИ рдХреИрдорд░рд╛ рдХреЗ рд╕рд╛рде рдХрд╛рдо рдХрд░рдиреЗ рдХреЗ рдмрд╛рд░реЗ рдореЗрдВ рдмрд╛рдд рдХрд░реВрдБрдЧрд╛ред
" CSI- Raspberry Pi v.1.3 2.1 720p @ 25 FPS, 1 h264, , ".
, , .
, , , ( ) , , .
RPi, , OpenCV, , - , ffmpeg, - .
OpenCV, , : " RGB/MJPEG, - H264 MP4...".
Raspberry Pi , - , datasheets- ( ), тАФ , .
, Raspberry Pi . , , , 2.8-3.2 . , , CS-mount , . - 3d-, тАФ , Thingverse .

Raspberry 3 / тАФ . FullHD OpenMAX.
: Raspberry Pi - H264 -.
FFmpeg :
#!/bin/bash
SS=$1
FPS=$2
WIDTH=1600
HEIGHT=1200
while :
do
ffmpeg -f video4linux2 -input_format h264 -video_size ${WIDTH}x${HEIGHT} \
-framerate $FPS -i /dev/video0 -vcodec copy -map 0 \
-segment_time $SS -f segment \
-strftime 1 -reset_timestamps 1 \
-segment_format mp4 /video/file_%s.mp4
done
$SS
FPS $FPS
, unix-timestamp. , MP4. CPU . , FTP.
v2.1 1080p тАФ ( FOV). 1600x1200 тАФ FPS. , , ffmpeg raspivid (. ) . .

, , , RAM GPU Raspberry Pi, - тАФ .
H264, , . : Raspberry Pi 3 FullHD OpenCV , 1280x720 @ 30 FPS .
H264? тАФ H264.
Raspberry Pi (motion vectors) H264. . , .
Raspberry Pi , MV :
typedef struct
{
signed char x_vector;
signed char y_vector;
short sad;
} INLINE_MOTION_VECTOR;
{x,y}_vector тАФ , sad
тАФ . sad vectors . sad, motion vectors.
FFmpeg motion vectors , Raspivid:
#!/bin/bash
SS=$1
FPS=$2
W=1600
H=1200
while :
do
raspivid -pts -stm -w $W -h $H -fps $FPS -t 0 \
-sn $(date +%s) -sg $(($SS*1000)) \
-o /video/video_%d.h264 -x /video/mv_%d.txt
done
, raspivid +1, , timestamp, stat .
FFmpeg CVLC, RTSP . , тАФ motion vectors .
, "", , , . . FPS=25 ( 30) , , 50Hz , .
тАФ , , MV, , . . , , .
, , RPi тАФ H264 , MV.
, *.h264 тАФ H264, MP4, VLC, , , . Raspberry Pi gpac:
sudo apt install -y gpac
h264 mp4 :
time MP4Box -add /video/video_1588645858.h264 /video/video_1588645858.mp4
AVC-H264 import - frame size 1280 x 720 at 25.000 FPS
AVC Import results: 1560 samples - Slices: 26 I 1534 P 0 B - 0 SEI - 26 IDR
Saving to /video/video_1588645858.mp4: 0.500 secs Interleaving
real 0m11.164s
user 0m0.548s
sys 0m0.469s
11 Raspberry Pi 3, .
MV :
import os
import sys
import struct
import numpy as np
resolution = [1280, 720]
framelength = int(((resolution[0] + 16) / 16) * (resolution[1] / 16) * 4)
framedata = []
cnt = 0
while True:
data = sys.stdin.read(framelength)
if data == '':
break
cnt += 1
framedata = struct.unpack('>%db' % framelength, data)
vectors = np.reshape(framedata[:(resolution[1]/16 * (resolution[0]/16 + 1) * 4)], (resolution[1]/16, resolution[0]/16 + 1, 4)).astype(np.float32)
vectors = np.multiply(vectors[:, :, 0:1], vectors[:, :, 0:1])
print int(np.sum(vectors))
C, .
time $(cat /video/mv_1588645871.txt| python proc.py > /dev/null)
real 0m26.288s
user 0m25.005s
sys 0m0.583s
, NumPy ( C), , , , 50% , . MV, , .
, :

, , тАФ . тАФ . .
:
cat /video/mv_1588645871.txt | python proc.py | awk '{ if ($1 > 0) print "motion" }' | grep motion > /dev/null
echo $?
0
, . , FTP, .
, " " , , Raspberry Pi .
, , , MV . Medium, MV Python.
рд▓реЗрдЦ рдкреЗрд╢реЗрд╡рд░реЛрдВ рдХреЗ рд▓рд┐рдП рдЖрдо рд▓рдЧ рд╕рдХрддрд╛ рд╣реИ, рд▓реЗрдХрд┐рди рдореБрдЭреЗ рдЗрди рдЪреАрдЬреЛрдВ рд╕реЗ рдирд┐рдкрдЯрдиреЗ рдХреЗ рд▓рд┐рдП рдкрд░реНрдпрд╛рдкреНрдд рд╕рдордп рдмрд┐рддрд╛рдирд╛ рдкрдбрд╝рд╛ред рдореБрдЭреЗ рдЖрд╢рд╛ рд╣реИ рдХрд┐ рд░рд╛рд╕реНрдкрдмреЗрд░реА рдкрд╛рдИ рдкреНрд▓реЗрдЯрдлреЙрд░реНрдо рдкрд░ рд╡реАрдбрд┐рдпреЛ рдХреЗ рд╕рд╛рде рдХрд╛рдо рдХрд░рдирд╛ рд╢реБрд░реВ рдХрд░рдиреЗ рд╡рд╛рд▓реЗ рд╢реБрд░реБрдЖрддреА рд▓реЛрдЧреЛрдВ рдХреЗ рд▓рд┐рдП рдпрд╣ рдЙрдкрдпреЛрдЧреА рд╣реЛрдЧрд╛ред