gdrive_path = "/content/gdrive" #Chemin monté
from google.colab import drive
drive.mount(gdrive_path)
for a in range(0, 1280, 10):
print(a)
import glob
files = glob.glob("/content/gdrive/My Drive/ColabExp/*.png ") #Seuls les fichiers avec l'extension png
files.sort() #Trier les fichiers trouvés
import tempfile
with tempfile.TemporaryDirectory() as tmpdir:
#Ecrivez le fichier dans tmpdir
Ou
import tempfile
tmpdir = tempfile.TemporaryDirectory().name
import os
os.path.basename(files[i])
from tqdm import tqdm
for i, file in enumerate(tqdm(src_files)):
#En traitement
from PIL import Image
img = Image.new('RGB', (1280, 720), (255, 255, 255)) # 1280 x 720px
from PIL import ImageDraw
draw = ImageDraw.Draw(img)
draw.rectangle(((x0, y0), (x1, y1)), fill=(255, 0, 0)) #Carré
import cv2
cv2.imwrite(save_path, image)
img.save(path)
!ffmpeg -framerate 30 -i "$dst_img_dir/%06d.png " -vcodec h264 -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" "$dst_mov_dir/out.mp4"
CSV
df = pd.read_csv(filepath)
CSV_DATA = StringIO("""x,y
10.0, 20.0
15.0, 30.0
20.0, 45.0
35.0, 80.0
""")
df = pd.read_csv(CSV_DATA, sep=",")
df.to_csv("out.csv")
from datetime import datetime
now_ts = int(datetime.now().timestamp())