Monday, 12 May 2025

How to read a mp4 video with h265 codec using python opencv gstreamer in jetson?

import cv2

import numpy as np

# Replace with your H.265 video file


gst_pipeline = (

    "filesrc location=/home/ninja/test1.mp4 ! "

    "qtdemux ! h265parse ! nvv4l2decoder ! "

    "nvvidconv ! video/x-raw,width=1920,height=1080,format=NV12 ! "

    "appsink"

)


cap = cv2.VideoCapture(gst_pipeline, cv2.CAP_GSTREAMER)

h = 1080

w = 1920

if not cap.isOpened():

    print("Failed to open video")

    exit()


while True:

    ret, frame = cap.read()

    if not ret:

        break

    frame = np.fromstring(frame, dtype=np.uint8).reshape((int(h*3/2),w,1))

    frame = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_NV12)    


    print(frame.shape)

    #cv2.imshow("Jetson H.265 Video", frame)

    #if cv2.waitKey(1) & 0xFF == ord("q"):

    #    break


cap.release()

cv2.destroyAllWindows()

Tuesday, 29 April 2025

Failed to initialize NVML: Unknown Error

 RuntimeError: cuda runtime error (100) : no CUDA-capable device is detected at ../aten/src/THC/THCGeneral.cpp:47

root@ninja:/data# 

root@ninja:/data# nvidia-smi

Failed to initialize NVML: Unknown Error

root@ninja:/data# exit


---

When entering the docker, try to add --privileged into the script

Thursday, 3 April 2025

Thursday, 16 January 2025

How to mount and umount the device in ubuntu?

to mount the device:

sudo lsblk

sudo mkdir /mnt

sudo mount /dev/sdc1 /mnt


to umount the device

sudo umount /mnt

or 

sudo umount /dev/sdc1

sudo udisksctl power-off -b /dev/sdc1

Tuesday, 17 December 2024

How to setup NTP server in ubuntu20?

Reference: https://www.digitalocean.com/community/tutorials/how-to-set-up-time-synchronization-on-ubuntu-20-04 


First, run apt update to refresh your local package index:

  1. sudo apt update

Then, run apt install ntp to install this package:

  1. sudo apt install ntp

ntpd will begin automatically after your installation completes. You can verify that everything is working correctly by querying ntpd for status information:

  1. ntpq -p


If you want to setup a local server:

  1. sudo vim /etc/ntp.conf
  2. ---
  3. # Point to our network's master time server
    server 192.168.1.234 iburst
    restrict default
    driftfile /var/lib/ntp/ntp.drift
    minpoll 4
    maxpoll 5

Then, you can create a drift file as following:

  1. sudo vim /var/lib/ntp/ntp.drift
  2. ---
  3. 0.000

Finally you can restart the service:

  1. sudo service ntp restart
  2. sudo service ntp status

Monday, 23 September 2024

How to install wifi driver in ubuntu?

ref: https://github.com/McMCCRU/rtl8188gu


sudo apt-get install build-essential git dkms
git clone https://github.com/McMCCRU/rtl8188gu.git
cd rtl8188gu
make
sudo make install
cd .. 
rm -rf rtl8188gu
sudo reboot