Skip to content

Instantly share code, notes, and snippets.

View ejs94's full-sized avatar

Estêvão J. dos Santos ejs94

  • Brasil
View GitHub Profile
@ejs94
ejs94 / signal_stop.py
Created February 7, 2022 18:41
Using signals to terminate a killable thread.
import time
import threading
import signal
class Job(threading.Thread):
def __init__(self):
super().__init__()
'''
The shutdown_flag is a threading.Event object that
indicates whether the thread should be terminated.
@ejs94
ejs94 / rapid-recording.py
Created August 30, 2021 11:46 — forked from RRMoelker/rapid-recording.py
YUV format picamera real time recording
# python3
# based on https://raspberrypi.stackexchange.com/questions/58871/pi-camera-v2-fast-full-sensor-capture-mode-with-downsampling/58941#58941
import time
import picamera
import numpy as np
from PIL import Image
RECORD_TIME = 5 # number of seconds to record
WRITE_IMAGES = False
@ejs94
ejs94 / conda_env_jupyter.md
Last active August 25, 2021 16:46
Using anaconda virtual enviroment inside a jupyter notebook

1 - Show the list of conda virtual environment

conda env list

2 - Create a new virtual environment named trial

conda create --name trial
@ejs94
ejs94 / resize_apriltag.py
Last active October 19, 2022 16:26
I created this script to use python and the pillow lib to increase the size of apriltags, I believe it's easier to adapt than a postscript. You need to change the data in the variables area for desired family and tag, put this in root of the cloned apriltags-imgs repository.
# ======================================= IMPORTS ====================================#
'''
pip install Pillow
pip install numpy
'''
from PIL import Image, ImageDraw, ImageFont
import glob
import numpy as np
# ======================================= VARIABLES ====================================#
@ejs94
ejs94 / raspberry_fast_capture.py
Created July 13, 2021 17:42 — forked from CarlosGS/raspberry_fast_capture.py
Fast reading from the raspberry camera with Python, Numpy, and OpenCV. See the comments for more details.
# Fast reading from the raspberry camera with Python, Numpy, and OpenCV
# Allows to process grayscale video up to 124 FPS (tested in Raspberry Zero Wifi with V2.1 camera)
#
# Made by @CarlosGS in May 2017
# Club de Robotica - Universidad Autonoma de Madrid
# http://crm.ii.uam.es/
# License: Public Domain, attribution appreciated
import cv2
import numpy as np
@ejs94
ejs94 / set_opencv_webcam.py
Created June 29, 2021 12:37 — forked from jwhendy/set_opencv_webcam.py
An example of setting webcam settings via v4l2-ctl in a python script. Some of the CAP_* settings in opencv didn't seem to work.
import cv2
import subprocess
### for reference, the output of v4l2-ctl -d /dev/video1 -l (helpful for min/max/defaults)
# brightness (int) : min=0 max=255 step=1 default=128 value=128
# contrast (int) : min=0 max=255 step=1 default=128 value=128
# saturation (int) : min=0 max=255 step=1 default=128 value=128
# white_balance_temperature_auto (bool) : default=1 value=1
# gain (int) : min=0 max=255 step=1 default=0 value=0
# power_line_frequency (menu) : min=0 max=2 default=2 value=2
@ejs94
ejs94 / how-is-pandas-python-more-powerful-than-excel_webscraping-example.ipynb
Created November 26, 2020 02:13
How is Pandas&Python more powerful than Excel_Webscraping Example.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ejs94
ejs94 / Sizing_Arrays.st
Created July 28, 2020 03:17
Returns the number of elements in an array in structured text (iec 61131-3)
(* Structured Text (IEC 61131-3) *)
SIZEOF(Array); // Return size of entire Array in bytes
SIZEOF(Array[0]); // Return size of one element
SIZEOF(Array)/SIZEOF(Array[0]); // Return number of elements
// Example use
for( i = 0 ; i < SIZEOF(Array)/SIZEOF(Array[0]) ; i++){
// loop
}
@ejs94
ejs94 / 11-Tips-And-Tricks-To-Write-Better-Python-Code.py
Created July 8, 2020 03:43
Tips from Python Enginner Youtube Channel
# 11 Tips And Tricks To Write Better Python Code
## Source: https://www.youtube.com/watch?v=8OKTAedgFYg
## Python Enginner
# 1) Iterate with enumerate() instead of range(len())
data = [1,2,-4,-3]
for i in range(len(data)):
if data[i] < 0:
data[i] = 0
@ejs94
ejs94 / monte-carlo-simulation-of-stock-prices.ipynb
Created May 20, 2020 01:31
Monte Carlo Simulation of Stock Prices
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.