Skip to content

Instantly share code, notes, and snippets.

View ialhashim's full-sized avatar

Ibraheem Alhashim ialhashim

View GitHub Profile
@ialhashim
ialhashim / download_earth_images.py
Created May 24, 2018 09:22
Download the Earth from World Imagery (Esri)
import subprocess
import pathlib
# Source
map_server = 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/'
# Output directory
outdir = 'images/'
pathlib.Path(outdir).mkdir(parents=True, exist_ok=True)
@ialhashim
ialhashim / screencapture.cpp
Last active October 28, 2023 20:41
Portable screen capture using C++ under Windows 10 (or 8)
#include "screengrab.h"
void capture()
{
CComPtr<ID3D11Device> pDevice;
CComPtr<IDXGIOutputDuplication> pDeskDupl;
//(...)create devices and duplication interface etc here..
DXGI_OUTDUPL_DESC OutputDuplDesc;
@ialhashim
ialhashim / fill_depth_colorization.py
Last active May 27, 2024 21:23
Python implementation of depth filling from NYU Depth v2 toolbox
# Original Matlab code https://cs.nyu.edu/~silberman/datasets/nyu_depth_v2.html
#
#
# Python port of depth filling code from NYU toolbox
# Speed needs to be improved
#
# Uses 'pypardiso' solver
#
import scipy
import skimage
from joblib import Parallel, delayed
import numpy as np
from skimage.transform import resize
files = list(data.keys())[1:]
def coords(filename):
filename = filename.replace('11_1024/', '').replace('.jpg', '').replace('11_', '')
filename = filename.replace('[','').replace(']','').split('_')
@ialhashim
ialhashim / drawPointCloud.py
Last active July 18, 2023 20:56
Quick python script to draw a dynamic point cloud with changing colors and positions (e.g. RGBD frames)
from OpenGL import GL, GLU
from OpenGL.arrays import vbo
# Prepare point cloud once
def makeCloud(self):
width, height = self.rgb.shape[1], self.rgb.shape[0]
# ...
# Compute 3D positions from depth
# ...
@ialhashim
ialhashim / Upsample.py
Last active October 19, 2020 14:48
Resize or interpolate tensors to any spatial dimension in Keras
import tensorflow as tf
import keras.backend as K
from keras.layers import Lambda
#
# Keras + TensorFlow
# Resize 'tensorA' to be of the same size as 'tensorB' using 'tf.image.resize_bilinear'
# Very useful for skip-connections and 'Concatenate' layers that might complain about being off by one column
# Only works when dimensions are provided since we use ' K.int_shape' that returns the static shape
#
@ialhashim
ialhashim / firebase_storage_web.dart
Created January 8, 2020 09:48
Flutter + Firebase storage on the web, work around
// Note this is just a workaround until the offical support of web
// We would need to add these as well
//// ignore_for_file: avoid_web_libraries_in_flutter
//import 'dart:html';
//import 'package:mime/mime.dart';
//import 'package:firebase/firebase.dart' as fb;
// Some upload button is pressed
onPressed: () async {
@ialhashim
ialhashim / azure_kinect_capture.cpp
Last active August 26, 2020 11:00
Azure Kinect basic capturing and visualization on Windows
/*
The most basic example to capture matching RGB and Depth images from an Azure Kinect DK device.
CImg is used to visualize the matching RGB and Depth.
*/
#pragma comment(lib, "gdi32.lib")
#pragma comment(lib, "user32.lib")
#pragma comment(lib, "shell32.lib")
@ialhashim
ialhashim / readme.md
Last active April 2, 2024 11:17
Reverse port forwarding via an AWS instance

If you want to connect to a local workstation behind a firewall you can do that by bouncing traffic off of an AWS instance.

An example would be accessing a Jupyter Lab from the outside world to a machine with no static IP or behind a firewall.

The steps are:

  1. Create a paid AWS Ubuntu instance and save the '.pem' file.
  2. Make sure the AWS instance's Security Rules allows traffic in.
  3. Test that you can connect to this instance from the outside world (e.g. python3 -m http.server or jupyter lab --ip=*) then visit the instance using its public IP.
  4. (optionally) Enable password login in /etc/ssh/sshd_config by setting PasswordAuthentication yes and sudo passwd $USER.
  5. Enable GatewayPorts yes and restart sshd. E.g. sudo nano /etc/ssh/sshd_config then sudo systemctl restart ssh.service.
@ialhashim
ialhashim / agora_linux_for_ai.cpp
Last active June 24, 2022 14:38
Modifications on the Agora on-premise SDK to enable AI applications
//
// Step 3: In the file 'AgoraSdk.cpp'
//
void AgoraSdk::videoFrameReceivedImpl(
agora::linuxsdk::uid_t uid,
const agora::linuxsdk::VideoFrame *pframe) const {
char uidbuf[65];
snprintf(uidbuf, sizeof(uidbuf), "%u", uid);