sciveo 0.1.16__tar.gz → 0.1.17__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sciveo-0.1.16 → sciveo-0.1.17}/PKG-INFO +1 -1
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/__init__.py +1 -1
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/cli.py +1 -1
- sciveo-0.1.17/sciveo/network/__init__.py +0 -0
- sciveo-0.1.17/sciveo/network/camera.py +63 -0
- sciveo-0.1.16/sciveo/monitoring/network.py → sciveo-0.1.17/sciveo/network/tools.py +57 -1
- sciveo-0.1.17/sciveo/version.py +2 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo.egg-info/PKG-INFO +1 -1
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo.egg-info/SOURCES.txt +3 -1
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo.egg-info/requires.txt +2 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/setup.py +2 -0
- sciveo-0.1.16/sciveo/version.py +0 -2
- {sciveo-0.1.16 → sciveo-0.1.17}/README.md +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/api/__init__.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/api/base.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/api/upload.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/common/__init__.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/common/configuration.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/common/model.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/common/optimizers.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/common/sampling.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/common/tools/__init__.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/common/tools/compress.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/common/tools/configuration.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/common/tools/crypto.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/common/tools/daemon.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/common/tools/formating.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/common/tools/hardware.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/common/tools/logger.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/common/tools/random.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/common/tools/synchronized.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/common/tools/timers.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/content/__init__.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/content/dataset.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/content/experiment.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/content/project.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/content/runner.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/monitoring/__init__.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/monitoring/monitor.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo/monitoring/start.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo.egg-info/dependency_links.txt +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo.egg-info/entry_points.txt +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/sciveo.egg-info/top_level.txt +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/setup.cfg +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/test/test_compress.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/test/test_configuration.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/test/test_crypto.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/test/test_monitoring.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/test/test_runner.py +0 -0
- {sciveo-0.1.16 → sciveo-0.1.17}/test/test_sampling.py +0 -0
|
@@ -21,7 +21,7 @@ try:
|
|
|
21
21
|
from sciveo.content.runner import ProjectRunner
|
|
22
22
|
from sciveo.content.dataset import Dataset
|
|
23
23
|
from sciveo.monitoring.start import MonitorStart
|
|
24
|
-
from sciveo.
|
|
24
|
+
from sciveo.network.tools import NetworkTools
|
|
25
25
|
from sciveo.version import __version__
|
|
26
26
|
|
|
27
27
|
|
|
@@ -16,7 +16,7 @@ import argparse
|
|
|
16
16
|
from sciveo.common.tools.logger import *
|
|
17
17
|
from sciveo.common.tools.timers import Timer
|
|
18
18
|
from sciveo.monitoring.start import MonitorStart
|
|
19
|
-
from sciveo.
|
|
19
|
+
from sciveo.network.tools import NetworkTools
|
|
20
20
|
from sciveo.common.tools.configuration import GlobalConfiguration
|
|
21
21
|
|
|
22
22
|
|
|
File without changes
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import threading
|
|
2
|
+
import cv2
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
from sciveo.common.tools.logger import *
|
|
6
|
+
from sciveo.common.tools.timers import FPSCounter
|
|
7
|
+
from sciveo.network.tools import StreamSniffer
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class RTSPStreamSniffer(StreamSniffer):
|
|
11
|
+
def on_packet(self, packet):
|
|
12
|
+
if self.is_rtsp_packet(packet):
|
|
13
|
+
self.append_ip_packet(packet)
|
|
14
|
+
|
|
15
|
+
def is_rtsp_packet(self, packet):
|
|
16
|
+
return IP in packet and TCP in packet and (packet[TCP].dport == 554 or packet[TCP].sport == 554)
|
|
17
|
+
|
|
18
|
+
def get_rtsp_frames(self, ip_src):
|
|
19
|
+
frames = []
|
|
20
|
+
current_packets = self.get_ip_stream(ip_src)
|
|
21
|
+
for packet in current_packets:
|
|
22
|
+
frame = self.packet_to_frame(packet)
|
|
23
|
+
if frame is not None:
|
|
24
|
+
frames.append(frame)
|
|
25
|
+
return frames
|
|
26
|
+
|
|
27
|
+
def packet_to_frame(self, packet):
|
|
28
|
+
payload = bytes(packet[TCP].payload)
|
|
29
|
+
nparr = np.frombuffer(payload, np.uint8)
|
|
30
|
+
frame = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
|
|
31
|
+
return frame
|
|
32
|
+
|
|
33
|
+
def play(self, ip_src):
|
|
34
|
+
fps = FPSCounter(tag=f"play {ip_src}")
|
|
35
|
+
while True:
|
|
36
|
+
frames = self.get_rtsp_frames(ip_src)
|
|
37
|
+
for frame in frames:
|
|
38
|
+
fps.update()
|
|
39
|
+
cv2.imshow(f'RTSP Stream from {ip_src}', frame)
|
|
40
|
+
if cv2.waitKey(1) & 0xFF == ord('q'):
|
|
41
|
+
return
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
if __name__ == '__main__':
|
|
45
|
+
sniffer = RTSPStreamSniffer(iface="eth0")
|
|
46
|
+
sniffer.start()
|
|
47
|
+
|
|
48
|
+
camera_ips = []
|
|
49
|
+
|
|
50
|
+
threads = []
|
|
51
|
+
for ip in camera_ips:
|
|
52
|
+
t = threading.Thread(target=sniffer.play, args=(ip,))
|
|
53
|
+
t.start()
|
|
54
|
+
threads.append(t)
|
|
55
|
+
|
|
56
|
+
try:
|
|
57
|
+
while True:
|
|
58
|
+
pass
|
|
59
|
+
except KeyboardInterrupt:
|
|
60
|
+
sniffer.stop_sniffing()
|
|
61
|
+
for t in threads:
|
|
62
|
+
t.join()
|
|
63
|
+
cv2.destroyAllWindows()
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
import socket
|
|
13
13
|
import threading
|
|
14
|
+
from scapy.all import sniff, IP, TCP
|
|
14
15
|
|
|
15
16
|
from sciveo.common.tools.logger import *
|
|
16
17
|
from sciveo.common.tools.timers import Timer
|
|
@@ -92,5 +93,60 @@ class NetworkTools:
|
|
|
92
93
|
pass
|
|
93
94
|
|
|
94
95
|
|
|
96
|
+
|
|
97
|
+
class StreamSniffer:
|
|
98
|
+
def __init__(self, iface=None):
|
|
99
|
+
self.iface = iface
|
|
100
|
+
self.running = False
|
|
101
|
+
self.lock = threading.Lock()
|
|
102
|
+
self.streams = {}
|
|
103
|
+
|
|
104
|
+
def start(self):
|
|
105
|
+
self.running = True
|
|
106
|
+
self.sniff_thread = threading.Thread(target=self.sniff_packets)
|
|
107
|
+
self.sniff_thread.start()
|
|
108
|
+
|
|
109
|
+
def stop(self):
|
|
110
|
+
debug(type(self).__name__, "stopping...")
|
|
111
|
+
self.running = False
|
|
112
|
+
self.sniff_thread.join()
|
|
113
|
+
|
|
114
|
+
def sniff_packets(self):
|
|
115
|
+
debug(type(self).__name__, "start sniffing on", self.iface)
|
|
116
|
+
sniff(iface=self.iface, prn=self.on_packet, stop_filter=self.should_stop)
|
|
117
|
+
|
|
118
|
+
def on_packet(self, packet):
|
|
119
|
+
if IP in packet:
|
|
120
|
+
self.append_ip_packet(packet)
|
|
121
|
+
|
|
122
|
+
def should_stop(self, packet):
|
|
123
|
+
return not self.running
|
|
124
|
+
|
|
125
|
+
def append_ip_packet(self, packet):
|
|
126
|
+
ip_src = packet[IP].src
|
|
127
|
+
with self.lock:
|
|
128
|
+
self.streams.setdefault(ip_src, [])
|
|
129
|
+
self.streams[ip_src].append(packet)
|
|
130
|
+
|
|
131
|
+
def get_ip_stream(self, ip):
|
|
132
|
+
current_packets = []
|
|
133
|
+
with self.lock:
|
|
134
|
+
if ip in self.streams:
|
|
135
|
+
current_packets = self.streams[ip][:]
|
|
136
|
+
self.streams[ip] = []
|
|
137
|
+
return current_packets
|
|
138
|
+
|
|
139
|
+
def keys(self):
|
|
140
|
+
with self.lock:
|
|
141
|
+
return list(self.streams.keys())
|
|
142
|
+
|
|
143
|
+
|
|
95
144
|
if __name__ == "__main__":
|
|
96
|
-
debug(NetworkTools(timeout=1.0, localhost=False).scan_port(port=9901))
|
|
145
|
+
# debug(NetworkTools(timeout=1.0, localhost=False).scan_port(port=9901))
|
|
146
|
+
|
|
147
|
+
import time
|
|
148
|
+
sniffer = StreamSniffer(iface="en0")
|
|
149
|
+
sniffer.start()
|
|
150
|
+
time.sleep(5)
|
|
151
|
+
sniffer.stop()
|
|
152
|
+
debug(sniffer.keys())
|
|
@@ -35,8 +35,10 @@ sciveo/content/project.py
|
|
|
35
35
|
sciveo/content/runner.py
|
|
36
36
|
sciveo/monitoring/__init__.py
|
|
37
37
|
sciveo/monitoring/monitor.py
|
|
38
|
-
sciveo/monitoring/network.py
|
|
39
38
|
sciveo/monitoring/start.py
|
|
39
|
+
sciveo/network/__init__.py
|
|
40
|
+
sciveo/network/camera.py
|
|
41
|
+
sciveo/network/tools.py
|
|
40
42
|
test/test_compress.py
|
|
41
43
|
test/test_configuration.py
|
|
42
44
|
test/test_crypto.py
|
sciveo-0.1.16/sciveo/version.py
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|