Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:jorhelp/Ingram into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jorhelp committed Jun 6, 2022
2 parents 1698765 + 384418f commit 724fe1b
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions utils/camera.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Some tools about camera"""
import os
import sys
import rtsp
import requests
import argparse
Expand Down Expand Up @@ -47,10 +46,14 @@ def snapshot_rtsp(ip, port, user, passwd, sv_path):
"""get snapshot through rtsp"""
with rtsp.Client(rtsp_server_uri=f"rtsp://{user}:{passwd}@{ip}:554", verbose=False) as client:
while client.isOpened():
img = client.read(raw=True)
if not img is None:
img_bgr = client.read(raw=True)
if not img_bgr is None:
img_rgb = img_bgr.copy()
img_rgb[:,:,0] = img_bgr[:,:,2]
img_rgb[:,:,1] = img_bgr[:,:,1]
img_rgb[:,:,2] = img_bgr[:,:,0]
name = f"{ip}:{port}-{user}-{passwd}.jpg"
img = Image.fromarray(img)
img = Image.fromarray(img_rgb)
img.save(os.path.join(sv_path, name))
break

Expand All @@ -59,10 +62,14 @@ def snapshot_rtsp_hb(ip, port, user, passwd, sv_path):
"""get hb-tech/hikvision snapshot through rtsp (multiplay, get channel 0)"""
with rtsp.Client(rtsp_server_uri=f"rtsp://{user}:{passwd}@{ip}:554/h264/ch0/main/av_stream", verbose=False) as client:
while client.isOpened():
img = client.read(raw=True)
if not img is None:
img_bgr = client.read(raw=True)
if not img_bgr is None:
img_rgb = img_bgr.copy()
img_rgb[:,:,0] = img_bgr[:,:,2]
img_rgb[:,:,1] = img_bgr[:,:,1]
img_rgb[:,:,2] = img_bgr[:,:,0]
name = f"{ip}:{port}-{user}-{passwd}.jpg"
img = Image.fromarray(img)
img = Image.fromarray(img_rgb)
img.save(os.path.join(sv_path, name))
break

Expand Down

0 comments on commit 724fe1b

Please sign in to comment.