Skip to content

Instantly share code, notes, and snippets.

View haipnh's full-sized avatar

Hoang Hai haipnh

View GitHub Profile
haipnh /
Last active July 17, 2024 00:58
Intel for display, NVIDIA for computing and offload rendering


  1. iGPU will be used for main display and rendering daily-use softwares in default
  2. Dedicated GPUs will be used for computing or offload rendering
  3. Reduce the used VRAM of Dedicated GPU, which is mostly used for X11 server rendering

Tested Hardware Configuration

OS: Ubuntu 18.04.4 LTS
├── iGPU
haipnh /
Created June 27, 2022 11:25
Instruction to run HW-accelerated Python scripts on PYNQ
sudo -s
echo "source /etc/profile.d/" >> ~/.bashrc
echo "export XILINX_XRT=/usr" >> ~/.bashrc
source ~/.bashrc
haipnh /
Created June 22, 2022 04:06
This is an example how to play video on Jupyter using OpenCV and IPythone
import numpy as np
import cv2
from IPython.display import display, Image
import time
video_path = "./HowDeepIsYourLove.mp4"
video = cv2.VideoCapture(video_path)
display_handle=display(None, display_id=True)
kernel = np.ones((5,5),np.float32)/25
haipnh /
Created June 15, 2022 12:28
Instruction to install OpenCV on Ubuntu 16.04 | NeuronBot
# Summary: We will create a virtual environment of Python-3.9 and install OpenCV-Python to it.
# 1. Add 3rd-party OpenCV-3.9 repository
sudo apt-key adv --refresh-keys --keyserver
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
# 2. Install packages
sudo apt-get install -y software-properties-common python3-pip python3.9 python3.9-dev python3.9-venv
haipnh /
Last active June 1, 2022 10:15
Verify CUDA-enabled system for ML/DL framework
# This gist provides several test cases to verify a host machine using NVIDIA graphics card if it's ready for tensorflow and pytorch.
### TC#1: Verify hardware information
# Expectation: The OS shows hardware bare information
lspci | grep -i nvidia
sudo lshw -C display
### TC#2: Verify nvidia-driver-X
libdir = /opt/opencv-4.0.0/lib
includedir = /opt/opencv-4.0.0/include/opencv4
Name: OpenCV
Description: OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library.
Version: 4.0.0
Libs: -L${libdir} -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_calib3d -lopencv_ccalib -lopencv_core -lopencv_datasets -lopencv_dnn_objdetect -lopencv_dnn -lopencv_dpm -lopencv_face -lopencv_features2d -lopencv_flann -lopencv_freetype -lopencv_fuzzy -lopencv_gapi -lopencv_hfs -lopencv_highgui -lopencv_imgcodecs -lopencv_img_hash -lopencv_imgproc -lopencv_line_descriptor -lopencv_ml -lopencv_objdetect -lopencv_optflow -lopencv_phase_unwrapping -lopencv_photo -lopencv_plot -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_shape -lopencv_stereo -lopencv_stitching -lopencv_structured_light -lopencv_superres -lopencv_surface_matching -lopencv_text -lopencv_tracking -lopencv_videoio -lopencv_video -lopencv_videostab -lopencv_xfeatures2d -lopencv_ximgproc -lopenc
haipnh / build_opencv_ARM_cross
Created June 15, 2019 18:43 — forked from manashmandal/build_opencv_ARM_cross
Cross compile opencv3.3.0 for your raspberry pi and similar ARM devices with python support
This is a note on how to cross compile opencv for pretty much any ARM device(HardFP supported in this case) and deploy. Native
compiling in ARM devices can be painfully slow and they seem to hang often during build(mine got stuck at 43%). So if you happen
to have a desktop/laptop/server running ubuntu or similar linux distro, u can build opencv in fractionth of the time taken for
native compiling without any issues.
Building opencv3 with TBB and NEON and VFP support can boost opencv performance. Thanks to Adrian at pyimagesearch for pointing that out.
Both my PC and target machine aka orange pi zero are running ubuntu 16.04 with python2.7 and python 3.5.
1.Run the following commands in both machines to install the necessary libraries etc.(mine worked with them,so they should be enough
sudo apt-get update && sudo apt-get upgrade