Skip to content

Commit d5926e9

Browse files
authored
Raw feed2 (#78)
* _raw cam * dont show raw in cams * show detections switch
1 parent 211b49b commit d5926e9

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

clearcam.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def __init__(self, src,cam_name="clearcamPy"):
450450

451451
# Start threads
452452
threading.Thread(target=self.capture_loop, daemon=True).start()
453-
threading.Thread(target=self.inference_loop, daemon=True).start()
453+
if not cam_name.endswith("_raw"): threading.Thread(target=self.inference_loop, daemon=True).start()
454454

455455
def _open_ffmpeg(self):
456456
if self.proc:
@@ -842,7 +842,7 @@ def do_GET(self):
842842
cam_name = query.get("cam", [None])[0]
843843

844844
if parsed_path.path == "/list_cameras":
845-
available_cams = [d.name for d in self.base_dir.iterdir() if d.is_dir()]
845+
available_cams = [d.name for d in self.base_dir.iterdir() if d.is_dir() and not d.name.endswith("_raw")]
846846
self.send_response(200)
847847
self.send_header("Content-Type", "application/json")
848848
self.end_headers()
@@ -859,6 +859,9 @@ def do_GET(self):
859859

860860
start_cam(rtsp=rtsp,cam_name=cam_name,yolo_variant=yolo_variant)
861861
cams[cam_name] = rtsp
862+
start_cam(rtsp=rtsp,cam_name=(cam_name+"_raw"),yolo_variant=yolo_variant)
863+
cams[(cam_name+"_raw")] = rtsp
864+
862865
with open(CAMS_FILE, 'wb') as f:
863866
pickle.dump(cams, f)
864867

@@ -1260,6 +1263,9 @@ def do_GET(self):
12601263
if parsed_path.path == '/' or parsed_path.path == f'/{cam_name}':
12611264
selected_dir = parse_qs(parsed_path.query).get("folder", [datetime.now().strftime("%Y-%m-%d")])[0]
12621265
start_param = parse_qs(parsed_path.query).get("start", [None])[0]
1266+
show_detections_param = parse_qs(parsed_path.query).get("show_detections", ["true"])[0]
1267+
show_detections = show_detections_param.lower() in ("true", "1", "yes")
1268+
show_detections_checked = "checked" if show_detections else ""
12631269

12641270
event_image_path = event_image_dir / selected_dir
12651271
event_images = sorted(event_image_path.glob("*.jpg")) if event_image_path.exists() else []
@@ -1609,6 +1615,9 @@ def do_GET(self):
16091615
<video id="video" controls></video>
16101616
<div class="date-picker-container">
16111617
<input type="date" id="folderPicker" value="{selected_dir}">
1618+
<label style="display: flex; align-items: center; gap: 6px; margin-left: 10px;">
1619+
<input type="checkbox" id="showDetections" {show_detections_checked}> Show detections
1620+
</label>
16121621
</div>
16131622
<h3>Active Alerts</h3>
16141623
<div id="alertsContainer">
@@ -1985,8 +1994,18 @@ def do_GET(self):
19851994
if (event.target === alertModal) closeAlertModal();
19861995
}});
19871996
1997+
document.getElementById("showDetections").addEventListener("change", function() {{
1998+
const currentTime = video.currentTime;
1999+
const params = new URLSearchParams(window.location.search);
2000+
params.set('show_detections', this.checked);
2001+
params.set('start', currentTime);
2002+
window.location.search = params.toString();
2003+
}});
2004+
19882005
function loadStream(folder) {{
1989-
const url = `${{cameraName}}/streams/${{folder}}/stream.m3u8`;
2006+
const showDetections = document.getElementById("showDetections").checked;
2007+
const streamSuffix = showDetections ? "" : "_raw";
2008+
const url = `${{cameraName}}${{streamSuffix}}/streams/${{folder}}/stream.m3u8`;
19902009
19912010
async function waitForManifest(maxRetries = 30, delay = 2000) {{
19922011
for (let i = 0; i < maxRetries; i++) {{

0 commit comments

Comments
 (0)