Skip to content

Instantly share code, notes, and snippets.

View Mohamedemad4's full-sized avatar

Mohamed Emad Mohamedemad4

View GitHub Profile
@Mohamedemad4
Mohamedemad4 / mpjpeg_streaming.conf
Created January 18, 2021 00:20
Low latency webcam streaming with ffmpeg
# ffmpeg -f v4l2 -i /dev/video0 http://localhost:8090/feed1.ffm
# and run the server with ffserver -c mpjpeg_streaming.conf
# go to your browser in http://localhost:8090/feed.mpjpg
HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 1000
CustomLog -
@Mohamedemad4
Mohamedemad4 / session_pool.py
Last active March 15, 2021 19:08
a usefull little class for running long running shell commands in the background and manging them in a python program or service
import os
import subprocess as sp
from multiprocessing import Process
class session_pool():
"""
Session_pool is used to run long running processes in the background
Usage:
sess_pool=session_pool()
@Mohamedemad4
Mohamedemad4 / download_kitti.py
Last active May 26, 2020 20:35
Downloads and Unzips the Entire KITTI dataset for the selected categories
import requests as req
from bs4 import BeautifulSoup
import pprint
import os
b_url="http://www.cvlibs.net/datasets/kitti/raw_data.php?type={0}"
cats=["city","residential","campus","road"]
all_data_files=[]
@Mohamedemad4
Mohamedemad4 / storeinPROGMEM.py
Created January 8, 2020 11:20
Stores all strings from println and print commands in PROGMEM. to minimaize the .data section.surprised GCC didn't already have this. put this script outside your code directory and run: python3 putStrInPROGMEM.py yourcodedir
#!/usr/bin/python3
#this but for arduino https://www.avrfreaks.net/forum/tut-c-gcc-and-progmem-attribute?page=all
import os
import re
import sys
import pprint
p=re.compile("println\(([^\)]+)\)|print\(([^\)]+)\)")
strings_vars=""
p2v_dict={}
<style id="jsbin-css">
@import url(https://fonts.googleapis.com/css?family=Roboto);
body {
font-family: Roboto, sans-serif;
}
#chart {
max-width: 650px;
@Mohamedemad4
Mohamedemad4 / MRSMontoCarloSim.py
Created July 4, 2019 12:34
a Monto Carlo Simulation to determine the needed time of motion for an MRS supervisor in minesweepers competition see: landminefree.org
import random
import numpy as np
import math
from pprint import pprint as p
LinearSpeed=0.5#linear speed of the Supervisor in m/s
class Arena:
def __init__(self):
self.mine_locs=np.zeros(shape=(20,20))
self.d_loc=[0,0] # x,y ,right hand vector system z is towards you x to the left y to the top of the screen
self.s_loc=[1,0]
@Mohamedemad4
Mohamedemad4 / usbswithcing.py
Created June 18, 2019 08:16
switch usbs in a chosen order ,can help if u have multipule USB devices with no uniq features .use lsusb -t ,to view the USB ports and their numbers ,made for the rpi
#based on:https://github.com/mvp/uhubctl
import os
import time
def turnthemAlloff():
os.system("./uhubctl -a off -p 4")
os.system("./uhubctl -a off -p 3")
os.system("./uhubctl -a off -p 5")
time.sleep(3)
import os
import sys
Switch_command="""ffmpeg -i {0}.noMdata.mp3 -i {1} -map 0:0 -map 1:0 -c copy -id3v2_version 3
-metadata:s:v title='{2}' {0}.mp3"""
work_dir=sys.argv[1]
splice="Kaleo - "
artist="Kaleo"
album_name="Kaleo Singles"
cover="uis/cover.jpg"

Keybase proof

I hereby claim:

  • I am mohamedemad4 on github.
  • I am mohamedemad4 (https://keybase.io/mohamedemad4) on keybase.
  • I have a public key whose fingerprint is 1A8E B5B7 5309 58EB FE7C DD15 22BE 7D0D C723 2BDF

To claim this, I am signing this object:

@Mohamedemad4
Mohamedemad4 / split_video_into_Frames.py
Created June 12, 2018 12:40
splits Videos into frames with multipule mods for different needs (docs in functions) uses OpenCV and Numpy
import cv2
import numpy as np
def gen_2to1(batch_size=100+1,video_path):
"split video into 2 lowQ frams with timestamps followed by an HD frame"
vidcap = cv2.VideoCapture(video_path)
success ,image = vidcap.read()
count_x=0
count_y=0
xtempC=0