apt離線安裝套件的方法

apt-offline

https://unix.stackexchange.com/questions/694346/transfering-and-offline-installing-net-tools-in-an-ubuntu-server-with-no-interne

https://gist.github.com/ycku/fa3110bce427cf2c1f1ca4a680d594e8#apt-install

1
2
3
4
offline$ sudo apt-offline set install.sig --install-packages apache2 libapache2-mod-php
online$ apt-offline get install.sig --threads 5 --bundle install.zip
offline$ sudo apt-offline install install.zip
offline$ sudo apt-get install apache2 libapache2-mod-php

串流相關知識

RTP/RTCP

跟TCP和UDP一樣為傳輸層協議
規範RFC3350
RTCP (RTP Control Protocol)專門用來處理服務品質(Qos)
RTP可以選擇用UDP或是TCP來進行傳輸

https://mark-lin.com/posts/20180912/(主要)
http://albert-oma.blogspot.com/2012/05/rtp.html

bps(bit Per Second)

位元率 (bps) = 採樣率(hz) x 採樣大小(bit) x 通道

編碼

將raw檔轉換壓縮

聲音編碼

例如MP3和AAC

色彩顏色編碼RGB與YUV

影像編碼H26X和VPX

主流有H264和VP8

封裝

將聲音和影像編碼後的結果放進容器的過程

容器

用來盛裝編碼,一種編碼可以放進各種容器,例如MP3編碼可以放進.mp3、.mp4、.avi容器裡面

網路協議

https://www.jianshu.com/p/9f3e879a4c9c

DTS和PTS

https://blog.csdn.net/aggie4628/article/details/130440133

2024-01-20-Elasticsearch-客製化搜尋條件

Painless Script

https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-walkthrough.html

只選擇夜間的資料

https://stackoverflow.com/a/35596907

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{
"query": {
"bool": {
"filter": [
{
"range": {
"OccurrenceTime": {
"gte": "2023-12-01",
"lt": "2024-01-20"
}
}
},
{
"script": {
"script": "doc.OccurrenceTime.value.hour >= 10 && doc.OccurrenceTime.value.hour <= 21"
}
}
]
}
}
}

2024-01-23-CMake編譯OpenCV-Python

Here is the minimal steps.
Here is my enviornment

  • Windows 10
  • Visual Studio Build Tools 2019
  • CMake 3.29.0-rc1 (use default install setting)
  • Gstreamer:(Use default install setting)
    MSVC 64-bit (VS 2019, Release CRT)
    1.22.10 runtime installer
    1.22.10 development installer
  • Python3.8.10

For example, my gstreamer is install in D disk by default.

  1. Add System Environment Variable GSTREAMER_ROOT_X86_64 value D:\gstreamer\1.0\msvc_x86_64
    gstreamer doc
  2. Add enviornment variable GST_PLUGIN_PATH value D:\gstreamer\1.0\msvc_x86_64\lib\gstreamer-1.0
  3. Add Path enviornment variable value D:\gstreamer\1.0\msvc_x86_64\bin
  4. re-login the computer
  5. create a Python venv and use it
  6. pip install --verbose --no-binary opencv-python opencv-python
  7. os.add_dll_directory() Shoud be add to code since from Python 3.8+, Python will NOT search DLL from PATH enviornment variable.ref
  8. test code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import os
os.add_dll_directory("D:\\gstreamer\\1.0\\msvc_x86_64\\bin")
import cv2
gst = 'rtspsrc location=rtsp://192.168.8.57/live1s3.sdp timeout= 30000 ! decodebin ! videoconvert ! video/x-raw,format=BGR ! appsink drop=1'

cap = cv2.VideoCapture(gst,cv2.CAP_GSTREAMER)
while(cap.isOpened()):
ret, frame = cap.read()
if not ret:
break
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break

cv2.destroyAllWindows()
cap.release()

安裝cmake(不一定要裝)

安裝msvc2019 build tool

安裝python3.8.10

設定GSTREAMER_ROOT_X86_64環境變數

gstreamer doc

<gstreamer資料夾>\1.0\msvc_x86_64

直接安裝source distributions版本的opencv-python(opencv 4.3.0之後的版本)

pip install --verbose --no-binary opencv-python opencv-python

GST_PLUGIN_PATH或是GST_PLUGIN_SYSTEM_PATH(不一定要加)

gstreamer預設尋找plugin的順序如下

  1. %HOMEDRIVE%%HOMEFOLDER%/.gstreamer-1.0/plugins
  2. C:\gstreamer\1.0\x86\lib\gstreamer-1.0
  3. ..\lib\gstreamer-1.0
  4. %GST_PLUGIN_PATH%
    <gstreamer資料夾>\1.0\msvc_x86_64\lib\gstreamer-1.0

gstreamer doc

Path變數

<gstreamer資料夾>\1.0\msvc_x86_64\bin

載入時手動加入dll路徑

os.add_dll_directory()
ref

測試

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import os
os.add_dll_directory("D:\\gstreamer\\1.0\\msvc_x86_64\\bin")
import cv2
gst = 'rtspsrc location=rtsp://192.168.8.57/live1s3.sdp timeout= 30000 ! decodebin ! videoconvert ! video/x-raw,format=BGR ! appsink drop=1'

cap = cv2.VideoCapture(gst,cv2.CAP_GSTREAMER)
while(cap.isOpened()):
ret, frame = cap.read()
if not ret:
break
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break

cv2.destroyAllWindows()
cap.release()

gstreamer載入時錯誤檢查

  1. Dependencies 軟體檢查dll缺少哪一些東西
  2. plugin找不到的錯誤可能是找不到plugin的dll本身,或是找不到plugin所需要的dll

安裝CUDA

CUDA 設定

從4.0之後CUDA相關的功能被移到opencv_contrib,必須要編一opencv_contrib才能啟用CUDA功能

  1. set CMAKE_ARGS="-DWITH_CUDA=ON"
  2. pip install –verbose –no-binary opencv-contrib-python opencv-contrib-python

(選擇性)G-API

G-API說明
https://github.com/opencv/opencv/wiki/Graph-API