{{ message }}

Instantly share code, notes, and snippets.

# Ibraheem Alhashim ialhashim

Last active Apr 19, 2021
Python implementation of depth filling from NYU Depth v2 toolbox
View fill_depth_colorization.py
 # 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
Created Nov 14, 2014
Fitting 3D points to a plane or a line
View fitting3D.cpp
 template std::pair best_plane_from_points(const std::vector & c) { // copy coordinates to matrix in Eigen format size_t num_atoms = c.size(); Eigen::Matrix< Vector3::Scalar, Eigen::Dynamic, Eigen::Dynamic > coord(3, num_atoms); for (size_t i = 0; i < num_atoms; ++i) coord.col(i) = c[i]; // calculate centroid Vector3 centroid(coord.row(0).mean(), coord.row(1).mean(), coord.row(2).mean());
Created Aug 29, 2015
Linear Angle Based Parameterization
View LABP.hpp
 #pragma once // Linear angle based parameterization SGP '07 - c++ code // Based on code by Rhaleb Zayer #include "SurfaceMeshModel.h" #include "SurfaceMeshHelper.h" using namespace SurfaceMesh; #include
Last active Mar 10, 2021
Portable Clustering Algorithms in C++ (DBSCAN) and (Mean-Shift) and (k-medoids)
View DBSCAN.hpp
 #pragma once // Code adapted from https://github.com/propanoid/DBSCAN #include #include #include // Any basic vector/matrix library should also work #include
Created Jul 27, 2014
Random colors Qt
View random_colors.hpp
 inline QVector rndColors(int count){ QVector colors; float currentHue = 0.0; for (int i = 0; i < count; i++){ colors.push_back( QColor::fromHslF(currentHue, 1.0, 0.5) ); currentHue += 0.618033988749895f; currentHue = std::fmod(currentHue, 1.0f); } return colors; }
Last active Jan 11, 2021
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. Enable `GatewayPorts yes` as mentioned here and restart `sshd` as mentioned.
5. On the local workstation (e.g. GPU workstation) run the following command: `ssh -i "YOUR_PEM_FILE.pem" -R AWS_PUBLIC_IP:2222:localhost:8888 ubuntu@AWS_PUBLIC_IP`
Created Jul 27, 2014
Eigen matrix helper functions - from and to std::vector and from and to file (Qt)
View eigen_matrix_helper.cpp
 template inline static Eigen::Matrix toEigenMatrix( const Container& vectors ){ typedef typename Container::value_type VectorType; typedef typename VectorType::value_type Scalar; Eigen::Matrix M(vectors.size(), vectors.front().size()); for(size_t i = 0; i < vectors.size(); i++) for(size_t j = 0; j < vectors.front().size(); j++) M(i,j) = vectors[i][j]; return M; }
Last active Dec 7, 2020
Portable screen capture using C++ under Windows 10 (or 8)
View screencapture.cpp
 #include "screengrab.h" void capture() { CComPtr pDevice; CComPtr pDeskDupl; //(...)create devices and duplication interface etc here.. DXGI_OUTDUPL_DESC OutputDuplDesc;
Last active Oct 19, 2020
Resize or interpolate tensors to any spatial dimension in Keras
View Upsample.py
 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 #
Last active Aug 26, 2020
Azure Kinect basic capturing and visualization on Windows
View azure_kinect_capture.cpp
 /* 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")