1 - Show the list of conda virtual environment
conda env list
2 - Create a new virtual environment named trial
conda create --name trial
import os | |
import glob | |
from collections import defaultdict | |
def delete_m3u_files(): | |
""" | |
Deletes all .m3u files in the current directory, including the 'output' folder and any subfolders. | |
""" | |
m3u_files = glob.glob("**/*.m3u", recursive=True) # Find .m3u files in all subdirectories | |
for m3u_file in m3u_files: |
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. |
# 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 |
1 - Show the list of conda virtual environment
conda env list
2 - Create a new virtual environment named trial
conda create --name trial
# ======================================= IMPORTS ====================================# | |
''' | |
pip install Pillow | |
pip install numpy | |
''' | |
from PIL import Image, ImageDraw, ImageFont | |
import glob | |
import numpy as np | |
# ======================================= VARIABLES ====================================# |
# 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 |
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 |
(* 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 | |
} |
# 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 |