Monday 26 September 2022

How to monitor the firewall status either ip or port in ubuntu?

tail -f /var/log/ufw.log

(try to access pc1 from pc2 with portal ip and some port)

How to get list of files inside a folder using cpp opencv glob?

 const int getTotalFiles()
{
    vector<cv::String> fn;
    glob("/workspace/temp/*.jpg", fn, false);
    int count = fn.size(); //number of png files in images folder
    return count;
}

Wednesday 21 September 2022

How to delete files in a folder if the list is too long?

sudo find . -name '*.jpg' -type f -delete

sudo find . -name "0016*" -type d -exec rm -rf {} +

Monday 19 September 2022

How to use FFMpeg to record rtsp video? In Batch? Spawn?

record 5 minutes (300 seconds) video and save it using current date time:-

ffmpeg -i rtsp://admin:admin@192.168.1.231 -t 300 $(date +%F_%H-%M-%S).mp4


record video in 15fps:-

ffmpeg -i  rtsp://admin:admin@192.168.1.231 -t 300 -r 15 $(date +%F_%H-%M-%S).mp4


record 1 minute video from 2 / more rtsp address and save it using current date time:-

ffmpeg -i rtsp://192.168.80.107 -t 60 -map 0:v $(date +%F_%H-%M-%S)a.mp4 \
    -i rtsp://192.168.80.108 -t 60 -map 1:v $(date +%F_%H-%M-%S)b.mp4 \
    -i rtsp://192.168.80.109 -t 60 -map 2:v $(date +%F_%H-%M-%S)c.mp4 \
    -i rtsp://192.168.80.110 -t 60 -map 3:v -r 15 $(date +%F_%H-%M-%S)d.mp4 \ 

 

Which library we can use for c++ logging?

 https://github.com/gabime/spdlog

How to use Kmeans clustering for color estimation of a bbox object?

 ref: https://towardsdatascience.com/finding-most-common-colors-in-python-47ea0767a06a

ref: https://github.com/mrakelinggar/data-stuffs/tree/master/frequent_color

Tuesday 13 September 2022

How to select the network interface if there are multiples in ubuntu?

ref: https://www.cyberciti.biz/faq/ip-route-add-network-command-for-linux-explained/


ip route add {NETWORK/MASK} via {GATEWAYIP}
ip route add {NETWORK/MASK} dev {DEVICE}
ip route add default {NETWORK/MASK} dev {DEVICE}
ip route add default {NETWORK/MASK} via {GATEWAYIP}


For example, if there are multiple vlan, we can force the route to use a particular interface

For example, if you want to access vlan 192.168.2.0/24, you can do:

sudo ip route add 192.168.2.0/24 via 192.168.1.1 dev enp4s0

If you have another vlan 192.168.10.0/24 you want to access, you can do

sudo ip route add 192.168.10.0/24 via 192.168.1.1 dev enp4s0

Monday 12 September 2022

How to export and import docker?

First save the Docker image to a compressed archive:

docker save <docker image name> | gzip > <docker image name>.tar.gz 
 
 

Then load the Docker image as following:

docker load < <docker image name>.tar.gz