Skip to content

Instantly share code, notes, and snippets.

@adujardin
adujardin / BinaryVectorStream.hpp
Created March 8, 2024 10:49
fstream like interface for vector of uint8_t
#include <iostream>
#include <fstream>
#include <vector>
#include <cstdint>
class BinaryVectorStream {
private:
std::vector<uint8_t>& data;
size_t position;
@adujardin
adujardin / yolov8_trt.py
Last active February 26, 2024 17:24
YOLOv8 TensorRT Python
# From https://docs.ultralytics.com/fr/integrations/tensorrt/#installation
from ultralytics import YOLO
import os
import cv2
# Export the model to TensorRT format, this will take a long time but should be done only once (per GPU)
if not os.path.isfile('yolov8n.engine'):
# Load the YOLOv8 model
model = YOLO('yolov8n.pt')
@adujardin
adujardin / tsukuba_depth_to_disp.py
Created October 30, 2023 17:27
Simple conversion function to get precise disparity from depth data from NewTsukubaStereoDataset
import cv2
import numpy as np
calib_fx=615
calib_baseline=10
def depth_to_disp(depth_filename, disp_filename):
cv_file = cv2.FileStorage(depth_filename, cv2.FILE_STORAGE_READ)
matrix = cv_file.getNode("depth").mat()
cv_file.release()
@adujardin
adujardin / setup_mimalloc.sh
Last active July 19, 2023 15:04
Install mimalloc
# https://github.com/microsoft/mimalloc
VERSION="1.8.2"
wget https://github.com/microsoft/mimalloc/archive/refs/tags/v${VERSION}.zip
unzip v${VERSION}.zip
cd mimalloc-${VERSION}
mkdir build ; cd build ; cmake .. ; make -j ; sudo make install
cd ../../
rm -rf v${VERSION}.zip mimalloc-${VERSION}
sudo ln -s /usr/local/lib/libmimalloc.so /usr/lib/libmimalloc.so
@adujardin
adujardin / dataset_cleanup.py
Created July 18, 2023 14:26
Remove folder matching name recursively and file with specific extension
import os
import shutil
from concurrent.futures import ThreadPoolExecutor
def remove_file(file_path):
try:
os.remove(file_path)
print(f"File '{file_path}' removed successfully.")
except Exception as e:
print(f"Failed to remove file '{file_path}': {e}")
@adujardin
adujardin / create_ap.md
Last active June 15, 2023 14:41
Create WiFi AP Linux
@adujardin
adujardin / print_linux_hw_info.sh
Last active January 27, 2023 15:53
Simple script to get some info about a linux machine
#!/bin/bash
host=$(cat /etc/hostname)
echo "PC Name: ${host}"
cpu=$(cat /proc/cpuinfo | grep "model name" | head -1 | sed "s/model name : //")
echo "CPU: ${cpu}"
motherboard=$(sudo dmidecode -t 2 | grep "Product Name" | sed "s/ Product Name: //")
echo "Motherboard: ${motherboard}"
@adujardin
adujardin / upgrade_jetpack.sh
Created November 3, 2022 10:36
On device jetpack upgrade for jetson (from L4T 32.6 -> 32.7)
#!/usr/bin/env bash
set -x
LT4_MAJOR=32
LT4_MINOR_OLD=6
LT4_MINOR=7
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
@adujardin
adujardin / bulk_reboot_linux_ssh.sh
Created September 23, 2022 08:42
Script to reboot/run common command(s) to a list of linux machine through ssh
targets=(
192.168.1.83 # sl-u18-hlc1
192.168.2.253 # sl-nano-run5-46
192.168.3.220 # sl-tx2nx-run1-jp46
192.168.2.246 # sl-nx-run1-jp46
192.168.3.73 # sl-run-multicam
)
# all targets have the same user and password, this can be skipped if the ssh key is already registered
user="<user>"
pass="<password>" # security issue
@adujardin
adujardin / yolov7_val.sh
Last active July 18, 2022 09:41
yolov7_val.sh
#docker run --gpus=all -it -v /:/host/ nvcr.io/nvidia/pytorch:22.02-py3
host_folder="/host/tmp/yolov7_results.txt"
rm ${host_folder}
git clone https://github.com/WongKinYiu/yolov7
cd yolov7
pip install -qr requirements.txt
pip uninstall opencv-python
pip install opencv-python-headless==4.4.0.40