Skip to content

Instantly share code, notes, and snippets.

View diramazioni's full-sized avatar

Eli Spizzichino diramazioni

  • Italy (looking for other destination)
View GitHub Profile
@diramazioni
diramazioni / FileList.py
Created March 26, 2024 11:08
List files recursively from a json configuration passed as argument
import os
import fnmatch
import json
import argparse
def list_files_recursive(directory, include_patterns, exclude_dirs):
"""
List files recursively in the given directory,
filtering them by include patterns and excluding specified directories.
@diramazioni
diramazioni / ws_send_image.ino
Last active January 26, 2024 17:15
esp32 send image with websocket
#include "esp_camera.h"
#include <WiFi.h>
#include <ArduinoWebsockets.h>
// #include <algorithm>
// #include "soc/soc.h" //disable brownout problems
// #include "soc/rtc_cntl_reg.h" //disable brownout problems
#define CAMERA_MODEL_ESP32S3_EYE
#include "camera_pins.h"
@diramazioni
diramazioni / csv2latex.py
Last active June 22, 2023 23:48
Convert a CSV table into LaTeX
def csv2latex(file_path, sep):
with open(file_path, 'r') as file:
lines = file.readlines()
# count how many column there is
col = lines[0].count(sep) + 1
empty_line = sep*int(col-1)
start = ['\\begin{table} \n','\caption{Table captions should be placed above the tables.}\label{tab1} \n']
new = start
tabular = '\\begin{tabular}{'+'|l|'*col+'}\hline \n'
new.append(tabular)
@diramazioni
diramazioni / route.ts
Created June 11, 2023 13:58
Next.js endpoint to test strapi API requests
import { fetchAPI } from "../utils/fetch-api";
//import { NextRequest } from 'next/server';
import { NextResponse } from 'next/server';
export async function GET(request: Request) {
const query = {
filters: {
slug: {$eq:"home",},
},
populate: [
@diramazioni
diramazioni / rose2COCO.py
Created May 25, 2023 11:21
DIANNE annotation tool outputs xml annotations, this script was made to convert the dataset of the ROSE's chalange in COCO format
import os
import xml.etree.ElementTree as ET
import json
import cv2
from PIL import Image
def rose2COCO(coco_annotations, root_dir, name_ds, name_cls):
'''
root_dir = base directory of the dataset
name_ds = name of the dataset
@diramazioni
diramazioni / blurCV_detect.py
Last active April 11, 2023 20:46
Find out the "bluriness" of each extracted image-frame to select the best image out of N frames, copy the resulting frames in a new dir mantaining exif info
#!/usr/bin/env python
"""
### Find out the "bluriness" of each extracted image-frame to select the best image out of N frames,
### copy the resulting frames in a new dir mantaining exif info
### Arguments: image_directory best_of_n_frames method (1 or 2)
### python blurCV_detect.py /home/SfM/footage 30 1
"""
import sys, glob, os, shutil
@diramazioni
diramazioni / selectfile.py
Created September 23, 2019 17:25 — forked from DrDub/selectfile.py
A file selection class build for ipywidgets without any extra dependencies.
import os
import ipywidgets as widgets
class FileBrowser(object):
def __init__(self, init_path=None):
if init_path:
self.path = os.getcwd()+'/'+init_path
else:
@diramazioni
diramazioni / texture_change.py
Created February 27, 2014 17:54
blender python: texture change from command line
'''
texture image path are relative to the blend file directory. run from command line like this:
texture=img/2012720989_c.jpg blender -b mug.blend --python texture_change.py -F PNG -s 1 -e 1 -j 1 -t 0 -a
''''
import os
image_file = os.getenv('texture')
if not image_file:
image_file="img/2012720989_c.jpg"
@diramazioni
diramazioni / pdfimages2txt
Created September 15, 2013 18:17
A script I quickly come up for my needs to extract image from pdf, preprocess and extract text with tesseract
#!/bin/bash
STARTPAGE=2
ENDPAGE=75
SOURCE=book.pdf
OUTPUT=book.txt
RESOLUTION=600
LAYOUT="1"
[[ -e out.txt ]] && rm out.txt
for i in `seq $STARTPAGE $ENDPAGE`; do
@diramazioni
diramazioni / copy_particles_to_sim.py
Created August 7, 2013 02:33
This add-on bridge the particle system and Rigid Bodies system in blender: creates real rigid body object based on the original settings of the object instantiated by the particle system Instructions: · Create an emitter and an object/group that will be emitted · Assign a rigid body to the obj · Optionally create a field, like a force field, tha…
bl_info = {
"name": "Copy Particles to Rigid Bodies",
"version": (0, 0, 8),
"blender": (2, 6, 8),
"location": "View3D > Tool Shelf",
"description": "Transfers dupliobjects from a PS to a Rigid Bodies simulation",
"author": "Liero (on blenderartist), Eli Spizzichino",
"category": "Animation",
}