Skip to content

Instantly share code, notes, and snippets.

@alvonx
alvonx / sample.js
Created December 5, 2022 05:40
Tainted canvases may not be exported
mainVideo = container.querySelector("video");
mainVideo.crossOrigin = "anonymous";
var dataURI = canvas.toDataURL('image/jpeg');
ctx.drawImage(mainVideo, 0, 0, canvas.width, canvas.height);
@alvonx
alvonx / colored_python_output.py
Created October 14, 2022 16:35
Print coloured output in python console
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
@alvonx
alvonx / xml_editor.py
Created October 12, 2022 13:13
Edit xml using python
import glob
import xml.etree.ElementTree as ET
png_images = glob.glob('<folder_containing_xml>/*.xml')
saving_path = '<saving_folder_path>'
for i in png_images:
print(i)
splitted_path = i.split('/')
path = '/'.join(splitted_path[:-1])
name_ext = splitted_path[-1]
@alvonx
alvonx / url_2_blob.js
Created July 26, 2022 03:34
Convert video URL to BLOB (to hide the video url from accessing to outside world)
async function createFile(){
let response = await fetch('<video_url>');
let data = await response.blob();
console.log(data)
var url = URL.createObjectURL(data);
document.getElementById('video-player').src = url;
let metadata = {
type: 'video/mp4'
};
let file = new File([data], "test.jpg", metadata);
@alvonx
alvonx / FaceDetectionModule.py
Created May 5, 2021 08:09
Using mediapipe for detecting face in the video
import cv2
import time
import mediapipe as mp
class FaceDetector:
def __init__(self, minDetectionConf=0.5):
self.minDetectionConf = minDetectionConf
self.mpFaceDetection = mp.solutions.face_detection
self.mpDraw = mp.solutions.drawing_utils
self.faceDetection = self.mpFaceDetection.FaceDetection(min_detection_confidence=self.minDetectionConf)