Skip to content

Instantly share code, notes, and snippets.

@adujardin
adujardin / check_cudaversion.sh
Last active October 19, 2016 07:20
Check which CUDA version has been linked against a given dynamic library
#!/bin/bash
# check which cuda version has been linked
# handles path like "/usr/local/lib/foo*.so*"
for lib in "$@"; do
cuda_version=$(ldd "$lib" | grep -Po '(?<=libcudart.so.)\d.\d.' | head -1);
if [ -n "$cuda_version" ]; then
printf "CUDA $cuda_version : $lib\n"
fi
@adujardin
adujardin / zed_ocv.cpp
Created June 29, 2016 16:22
ZED opencv
#include <stdio.h>
#include <string.h>
#include <opencv2/opencv.hpp>
int main(int argc, char **argv) {
cv::VideoCapture zed_cap(0);
cv::Mat sbs;
@adujardin
adujardin / dl_zed_calib.sh
Last active March 2, 2017 14:02
Script to download a ZED calibration file
#!/usr/bin/env bash
usage() {
echo "This script needs the serial number as argument like this :"
echo "bash dl_zed_calib.sh 1010 [path/]"
exit 1
}
conf_path="/usr/local/zed/settings/"
@adujardin
adujardin / docker_tex.sh
Created April 26, 2017 10:08
Latex document compilation using docker
#!/bin/sh
# Ressource: https://www.blang.io/posts/2015-04_docker-tooling-latex/
## Variables :
# https://hub.docker.com/r/fermiumlabs/latex-docker/
docker_img="fermiumlabs/latex-docker"
# The main file is named 'Main.tex'
main_doc="Main"
# This include full compilation (with bibtex)
@adujardin
adujardin / bitbucket-pipelines.yml
Created September 8, 2017 16:55
Bitbucket pipeline file for latex document (including bibtex and upload to dropbox)
# SETTING UP :
# Generate an application token for your dropbox account and set it as environment variable named "DROPBOX_TOKEN"
# - https://blogs.dropbox.com/developers/2014/05/generate-an-access-token-for-your-own-account/
# - https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html
# Edit TEX_FILE (see below) according to the main tex file name
image: fermiumlabs/latex-docker:latest
pipelines:
custom: # Manually only
@adujardin
adujardin / pre-receive-merge
Last active November 23, 2017 09:06 — forked from hartfordfive/pre-receive-puppet
Server-side pre-receive hook to check for merge artefacts such as '<<<<<<<' or '>>>>>>>'
#!/usr/bin/env bash
# pre-receive hook that check for merge artefacts such as '<<<<<<<' or '>>>>>>>'
# Possible improvements : https://gist.github.com/hartfordfive/9670011#gistcomment-2045250
COMMAND="grep -RI '<<<<<<<\|>>>>>>>'"
TEMPDIR=`mktemp -d`
# See https://www.kernel.org/pub/software/scm/git/docs/githooks.html#pre-receive
@adujardin
adujardin / ocv_sbs_capture.py
Last active February 14, 2018 17:25
Capture a ZED image with openCV from python without the SDK
import numpy as np
import cv2
cap = cv2.VideoCapture(0) # depending on the ZED ID
while(True):
ret, frame = cap.read() # Capture SbS frames
height, width = frame.shape[:2]
left = frame[0:height,0:int(width*0.5)]
@adujardin
adujardin / tegra_detection.sh
Last active February 13, 2018 15:21
NVIDIA Tegra version detection
#!/bin/bash
tegra_detection=$(
case "$(cat /sys/module/tegra_fuse/parameters/tegra_chip_id)" in
("64") echo "tegra_k1" ;;
("33") echo "tegra_x1" ;;
("24") echo "tegra_x2" ;;
(*) echo "unknown" ;;
esac)
@adujardin
adujardin / maxPerf.sh
Last active February 13, 2018 15:39 — forked from jmtatsch/maxPerf.sh
Nvidia's Max Performance Script for Tegra X1
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
enable_fan(){
# turn on fan for safety
echo "Enabling fan for safety..."
@adujardin
adujardin / castMatEigenSL.cpp
Created April 27, 2018 08:41
Functions to cast the ZED SDK sl::Matrix4f to Eigen::Matrix4f
void Transform2Matrix4f(const sl::Matrix4f &array_, Eigen::Matrix4f &mat_) {
for(int y = 0; y < 4; y++) {
for(int x = 0; x < 4; x++)
mat_(y, x) = array_.m[y * 4 + x];
}
}
void Matrix4f2Transform(const Eigen::Matrix4f &mat_, sl::Matrix4f &array_) {
for(int y = 0; y < 4; y++) {
for(int x = 0; x < 4; x++)