網頁

2023年9月28日 星期四

Ubuntu 安裝 exiv2, 開發 exif 相關程式

參考 https://github.com/Exiv2/exiv2/tree/main
參考 https://github.com/Exiv2/exiv2/tree/main#PlatformLinux

download cmake from https://cmake.org/download/
$ tar xvfz cmake-3.27.6.tar.gz
$ cd cmake-3.27.6
$ sudo apt-get install libssl-dev
$ ./bootstrap
$ make -j4
$ sudo make install

$ git clone https://github.com/Exiv2/exiv2.git
$ cd exiv2
$ sudo apt-get install --yes build-essential ccache clang cmake git google-mock libbrotli-dev libcurl4-openssl-dev libexpat1-dev libgtest-dev libinih-dev libssh-dev libxml2-utils libz-dev python3 zlib1g-dev
$ cmake -S . -B build -G "Unix Makefiles"
$ cmake --build build
$ ctest --test-dir build --verbose
$ sudo cmake --install build

$ g++ -o exifprint exifprint.cpp -lexiv2

2023年8月28日 星期一

使用 sudo 不輸入密碼

增加可以 reboot 的 myuser

$ sudo deluser myuser
$ adduser myuser
$ sudo gpasswd -a myuser sudo
$ echo "myuser ALL = NOPASSWD: /usr/sbin/reboot" | sudo tee /etc/sudoers.d/60_myuser
$ sudo chmod 0440 /etc/sudoers.d/60_myuser

若不幸輸入錯字,會產生如下錯誤
>>> /etc/sudoers: syntax error near line 24 <<<
sudo: parse error in /etc/sudoers near line 24
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

使用下列方法修復
$ pkexec visudo
What now? 會停在此處,別怕按下 Enter
Options are:
  (e)dit sudoers file again
  e(x)it without saving changes to sudoers file
  (Q)uit and save changes to sudoers file (DANGER!)

使用 ssh 不用輸入密碼

hostA$ ssh-keygen
hostA$ ssh-copy-id "user@hostB -p 22"
hostA$ ssh user@hostB "command.sh arg1 arg2"

2023年7月18日 星期二

gstreamer fpsdisplaysink videorate

$ export URI=rtsp://root:A1234567@192.168.112.202:554/live1s1.sdp
$ export GST_DEBUG=fpsdisplaysink:5

利用 videotestsrc 測試 fpsdisplaysink
$ gst-launch-1.0 videotestsrc ! 'video/x-raw,width=1280,height=720,framerate=60/1' ! videoconvert ! fpsdisplaysink text-overlay=true

fpsdisplaysink 不使用 text-overlay
$ gst-launch-1.0 rtspsrc location=$URI protocols=tcp+udp ! application/x-rtp, media=video ! decodebin  ! nvvideoconvert ! nvegltransform ! fpsdisplaysink text-overlay=0 video-sink=nveglglessink

fpsdisplaysink 使用 text-overlay
$ gst-launch-1.0 rtspsrc location=$URI protocols=tcp+udp ! application/x-rtp, media=video ! decodebin  ! nvvideoconvert ! fpsdisplaysink text-overlay=1 video-sink=autovideosink

利用 videorate 設定 framerate
$ gst-launch-1.0 rtspsrc location=$URI protocols=tcp+udp ! application/x-rtp, media=video ! decodebin ! nvvideoconvert ! videorate ! video/x-raw,framerate=60/1 ! nvvideoconvert ! fpsdisplaysink text-overlay=1 video-sink=autovideosink

加入 rtpjitterbuffer,  但好像沒用
$ gst-launch-1.0 rtspsrc location=$URI protocols=tcp+udp ! application/x-rtp, media=video ! rtpjitterbuffer latency=0 ! decodebin  ! nvvideoconvert ! fpsdisplaysink text-overlay=1 video-sink=autovideosink

不顯示, 但從 log 中可查看出 fps
$ gst-launch-1.0 rtspsrc location=$URI protocols=tcp+udp ! application/x-rtp, media=video ! decodebin  ! nvvideoconvert ! fpsdisplaysink text-overlay=0 video-sink=fakesink
輸出
:00:02.590692019 1665816 0xffff6001d700 DEBUG         fpsdisplaysink fpsdisplaysink.c:372:display_current_fps:<fpsdisplaysink0> Updated max-fps to 1.102534
0:00:02.590778644 1665816 0xffff6001d700 DEBUG         fpsdisplaysink fpsdisplaysink.c:376:display_current_fps:<fpsdisplaysink0> Updated min-fps to 1.102534


$ gst-launch-1.0 rtspsrc location=$URI protocols=tcp+udp ! application/x-rtp, media=video ! decodebin  ! nvvideoconvert ! videorate ! video/x-raw,framerate=60/1 ! nvvideoconvert ! fpsdisplaysink text-overlay=0 video-sink=fakesink

2023年7月14日 星期五

ubuntu 多網卡之 default route

$ cd /etc/NetworkManager/system-connections/
編輯相對網卡的檔案, 在 [ipv4] 下, 加入 route
$ sudo vi 'Wired connection 1.nmconnection'
[ipv4]
route1=0.0.0.0/0,192.168.0.254,1

2023年7月12日 星期三

install pytorch in ubuntu


$ python3 -m venv pytorch
$ source pytorch/bin/activate
$ pip3 install --upgrade --no-cache-dir pip
$ sudo update-alternatives --config cuda
$ pip3 install torch==1.10.2+cu113 torchvision==0.11.3+cu113 torchaudio==0.10.2+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html

2023年7月5日 星期三

DeepStream 之 nvinfer(primary mode) 執行 classifier, 使用在 ROI 上

試了很久, 無法利用 nvdspreprocess 的 ROI 放在 nvinfer 之前
發現直接使用 nvvideoconvert 的 ROI 可以正常運作

參數設定 src-crop="left:top:width:height", 如
g_object_set(G_OBJECT(pre_proc), "src-crop", "50:0:320:240", NULL);