Commit d057d3bc authored by Bruce's avatar Bruce

merge from Allen

parent eb45b60d
......@@ -522,7 +522,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"id": "78266468",
"metadata": {},
"outputs": [
......@@ -584,10 +584,68 @@
" save_i_keyframes(filename)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "e5b68fa5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"29.97002997002997\n"
]
}
],
"source": [
"# video writer per hour\n",
"import cv2\n",
"\n",
"source=\"rtsp://192.168.5.218/txg/01\"\n",
"\n",
"gst = \"filesrc location=/home/tx2/Videos/Kevin_Car.MOV ! qtdemux ! queue ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw,format=BGRx ! queue ! videoconvert ! queue ! video/x-raw, format=BGR ! appsink\"\n",
"\n",
"cap=cv2.VideoCapture(gst,cv2.CAP_GSTREAMER)\n",
"\n",
"\n",
"fps=cap.get(cv2.CAP_PROP_FPS)\n",
"print(fps)\n",
"\n",
"break_flag=False\n",
"try:\n",
" cv2.namedWindow(\"1\",cv2.WINDOW_NORMAL)\n",
" cv2.resizeWindow(\"1\",1280,720)\n",
" while True:\n",
" if break_flag:\n",
" break\n",
" ret,frame=cap.read()\n",
" if ret:\n",
" cv2.imshow(\"1\",frame)\n",
" key=cv2.waitKey(33)\n",
" if key==ord('q'):\n",
" break_flag=True\n",
" break\n",
"except Exception as e:\n",
" raise(e)\n",
" cap.release()\n",
" cv2.destroyAllWindows()\n",
" \n",
"finally:\n",
" cap.release()\n",
" cv2.destroyAllWindows()\n",
" \n",
" \n",
"\n",
" \n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9b758f80",
"id": "8befd1ac",
"metadata": {},
"outputs": [],
"source": []
......
......@@ -30,12 +30,12 @@ yolo = TrtYOLOSHM()
easyLPR=EZLPR()
#source="/home/tx2/Videos/20220504173000.mp4"
source="/home/tx2/Videos/Kevin_Car.MOV"
#source="/home/tx2/Videos/Kevin_Car.MOV"
#source = "../Ch17-20220314-190000.mp4"
#source="rtsp://192.168.5.218/txg/01"
source="rtsp://192.168.5.218/txg/01"
#source="rtsp://140.120.65.31/live.sdp"
cam=Camera(1,source,encoder = "h265",width=1920,height=1080)
cam=Camera(1,source,encoder = "h265",width=1920,height=1080,skip_frames=0)
camera_id=1
break_flag=False
......@@ -104,7 +104,7 @@ try:
TFMeta.UpdateTrafficFlow(objects)
TF_span,stime=time_span(stime) # !
if is_display:
if is_display and False:
displayMeta.frame = TFMeta.osd(frame) # 車流判斷的疊圖很耗時可考慮註解
for index,obj in objects.items():
# draw trajectory
......@@ -128,7 +128,6 @@ try:
CT.objects[index].update_lpr_candis(platNum)
OutputLPR_span,stime=time_span(stime) # !
CT.GetDisposeBuffer()
for obj in CT.GetDisposeBuffer():
pass
# InfluxWriter.put(obj)
......@@ -155,7 +154,8 @@ try:
# f"Influx_Buffer:{InfluxWriter.ObjectMetaUploadQueue.qsize()}")
if is_display:
cv2.imshow("1",displayMeta.frame)
key=cv2.waitKey(1)
waittime= 33 - int(total_span*1000) if 33 - int(total_span*1000) > 0 else 1
key=cv2.waitKey(waittime)
if key==ord('q'):
break_flag=True
break
......
......@@ -25,7 +25,7 @@ class Camera(object):
use_gstr: 是否使用gstreamer後台
skip_frames: 是否跳過部分幀,1 => 全部解碼, 2 => 只解碼 non-ref frames,3 => 只解碼 key-frames
skip_frames: 是否跳過部分幀,0 => 全部解碼, 1 => 只解碼 non-ref frames,2 => 只解碼 key-frames
"""
......
......@@ -586,9 +586,88 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"id": "e5b68fa5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"29.97002997002997\n"
]
}
],
"source": [
"# video writer per hour\n",
"import cv2\n",
"\n",
"source=\"rtsp://192.168.5.218/txg/01\"\n",
"\n",
"gst = \"filesrc location=/home/tx2/Videos/Kevin_Car.MOV ! qtdemux ! queue ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw,format=BGRx ! queue ! videoconvert ! queue ! video/x-raw, format=BGR ! appsink\"\n",
"\n",
"cap=cv2.VideoCapture(gst,cv2.CAP_GSTREAMER)\n",
"\n",
"\n",
"fps=cap.get(cv2.CAP_PROP_FPS)\n",
"print(fps)\n",
"\n",
"break_flag=False\n",
"try:\n",
" cv2.namedWindow(\"1\",cv2.WINDOW_NORMAL)\n",
" cv2.resizeWindow(\"1\",1280,720)\n",
" while True:\n",
" if break_flag:\n",
" break\n",
" ret,frame=cap.read()\n",
" if ret:\n",
" cv2.imshow(\"1\",frame)\n",
" key=cv2.waitKey(33)\n",
" if key==ord('q'):\n",
" break_flag=True\n",
" break\n",
"except Exception as e:\n",
" raise(e)\n",
" cap.release()\n",
" cv2.destroyAllWindows()\n",
" \n",
"finally:\n",
" cap.release()\n",
" cv2.destroyAllWindows()\n",
" \n",
" \n",
"\n",
" \n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "3f7ad718",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"35"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"int(0.035 *1000)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b964b08c",
"metadata": {},
"outputs": [],
"source": []
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment