Skip to content

Instantly share code, notes, and snippets.

View mcarletti's full-sized avatar

Marco Carletti mcarletti

View GitHub Profile
@mcarletti
mcarletti / opera_x264_support.sh
Last active March 11, 2024 08:23
Enable H.264 codec support for Opera browser
#!/bin/bash
# Author: Marco Carletti
# Date: May 2022
# Version: 0.2.0
# Last update: July 17, 2023
# Changed comments, tested versions and added other distros info, such as Debian and Fedora.
# Thanks to everyone for comments, suggestions, fixes and testings!
@mcarletti
mcarletti / create_wordcloud.py
Last active March 7, 2024 11:35
Parse main CVF conference titles and abstracts (eg, CVPR, ICCV)
import sys
import numpy as np
import matplotlib.pyplot as plt
from wordcloud import WordCloud
filename = sys.argv[1]
print(filename)
text = open(filename, "r").read()
@mcarletti
mcarletti / http_server_auth.py
Created January 9, 2024 11:00
Share a folder to the local network in Python. Features: credentials, timeout.
# With this script you can easily share a folder from your PC to the local network.
# The script creates an HTTP server protected by credentials. Basic auth only: encryption certificate not included.
# The server stops after a timeout is triggered (default: 1h).
#
# Example
# -------
# python http_server_auth.py --username u53r --password p4Sw0rd --directory ~/Public
#
# Anyone on the local network can access your Public folder in your home, typing your local address+port in a browser (eg. 157.27.93.172:8000).
#
@mcarletti
mcarletti / cvutils.cpp
Last active February 8, 2024 15:43
Set of Qt / OpenCV snippets
/*
* Convert a cv::Mat frame to a QPixmap and show it in a Qt object.
*
* Parameters
* ----------
* frame : cv::Mat
* Input image in BGR format.
*/
void updateImageFrameToQLabel(cv::Mat& frame)
{
@mcarletti
mcarletti / cvtRGB2YUV.m
Created November 11, 2019 14:00
RGB-YUV color conversion (Matlab code)
function [Y,U,V] = cvtRGB2YUV(R,G,B)
R = double(R);
G = double(G);
B = double(B);
Y = 0.257 * R + 0.504 * G + 0.098 * B + 16;
U = -0.148 * R - 0.291 * G + 0.439 * B + 128;
V = 0.439 * R - 0.368 * G - 0.071 * B + 128;
@mcarletti
mcarletti / grep_in_files.sh
Created November 20, 2019 11:13
Search for a pattern (string) in all files
#!/bin/bash
EXTENSION=$1
PATTERN=$2
grep --include="*.${EXTENSION}" -nRHI "${PATTERN}" *
@mcarletti
mcarletti / auto_mount_instructions.md
Last active February 8, 2024 15:43
Instructions to mount at boot time an external disk on Ubuntu

Auto mount at boot time

Tested on Ubuntu 18.04.

Retrieve UUID

First of all, try with the command blkid (man: locate/print block device attributes) to show the UUID of the disk you want to mount. For example:

blkid /dev/nvme0n1

How to Valgrind

Install

sudo apt update
sudo apt install valgrind

Write code

hello_valgrind.c

def load_nv12_as_bgr(filename, shape, dtype=np.uint8):
with open(filename, "rb") as fp:
data = fp.read()
image = np.frombuffer(data, dtype=dtype).reshape(shape)
image = cv2.cvtColor(image, cv2.COLOR_YUV2BGR_NV12)
return image
@mcarletti
mcarletti / build_opencv.sh
Last active February 8, 2024 15:43
Compile OpenCV from source
#!/bin/bash
# Tested on
# ------------------------------
# OS Ubuntu 18.04
# Platform x86_64, aarch64
# Python 3.6
if [ $# != 1 ]; then
echo -e "Usage:\n\t./build_opencv.sh VERSION\n\nExample:\n\t./build_opencv.sh 4.2.0"