Skip to content

Instantly share code, notes, and snippets.

View Merwanski's full-sized avatar
:electron:
Focusing

Merwanski

:electron:
Focusing
  • Belgium
  • Belgium
View GitHub Profile
@Merwanski
Merwanski / clear_docker
Created December 13, 2021 13:23
clear pc from docker images / containers
# REMOVE the containers no longer running
docker rm $(docker ps -a -q)
# REMOVE the images without any attached container to them
docker rmi $(docker images -q -f dangling=true)
@Merwanski
Merwanski / new_machine_ubuntu_2004.sh
Created December 20, 2021 12:08
new_machine_ubuntu_2004
!bash
# install docker
# Step 1 — Installing Docker
# First, update your existing list of packages:
sudo apt update
# Next, install a few prerequisite packages which let apt use packages over HTTPS:
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
@Merwanski
Merwanski / replace_cv_bridge.py
Last active February 17, 2022 00:45
replace cv bridge
# You could use numpy directly, instead of cv_bridge
import numpy as np
im = np.frombuffer(image_data.data, dtype=np.uint8).reshape(image_data.height, image_data.width, -1)
pi
# Another solution // Still not yet tested
# Beautiful solution is to use ros_numpy (https://github.com/eric-wieser/ros_numpy).
# It is similar to the function of cv_bridge, but without the dependency on cv2:
@Merwanski
Merwanski / readYaml.py
Created January 17, 2022 11:42
read yaml file content
# YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe.
# Please read https://msg.pyyaml.org/load for full details.
import yaml
f = open(filaname_path, 'r')
yaml.load(f, Loader=yaml.FullLoader)
f.close()
@Merwanski
Merwanski / photo2video.py
Last active January 22, 2022 21:30
photo2video.py
import cv2
import numpy as np
import glob
video_file_name = 'project.wmv'
path_to_images = 'path_2_video/*.bmp'
cmpt = 0
for filename in glob.glob(path_to_images):
@Merwanski
Merwanski / yolo_keras.py
Created January 24, 2022 00:13
yolo image using keras
# import necessary packages
from numpy import expand_dims
from keras.models import load_model
from keras.preprocessing.image import load_img
from keras.preprocessing.image import img_to_array
import time
import pdb
# load and prepare an image
def load_image_pixels(filename, shape):
@Merwanski
Merwanski / opencv_yolov3.py
Created January 24, 2022 00:25
opencv yolov3 detection
import argparse
import cv2
import numpy as np
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument("--image", default='samples/image.jpg', help="image for prediction")
parser.add_argument("--config", default='cfg/yolov3.cfg', help="YOLO config path")
parser.add_argument("--weights", default='yolov3.weights', help="YOLO weights path")
parser.add_argument("--names", default='data/coco.names', help="class names path")
@Merwanski
Merwanski / install_docker_with_nvidia.sh
Created February 2, 2022 22:32
How to Install Docker with NVIDIA support
# Docker-CE on Ubuntu can be installed using Docker's official convenience script:
curl https://get.docker.com | sh \
&& sudo systemctl --now enable docker
# Setting up NVIDIA Container Toolkit
# Setup the stable repository and the GPG key:
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - \
&& curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
@Merwanski
Merwanski / install_docker.sh
Created February 21, 2022 21:55
Install docker
#!/bin/bash
# Installation instructions from https://docs.docker.com/engine/install/ubuntu/
# Update the apt package index and install packages to allow apt to use a repository over HTTPS:
sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
# Add Docker’s official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# Use the following command to set up the stable repository
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# INSTALL DOCKER ENGINE
@Merwanski
Merwanski / cv_bridge_alternative.py
Created February 23, 2022 23:06
Alternative for the `cv_bridge` python library two most used functions.
# initial code from https://github.com/ros-perception/vision_opencv/blob/noetic/cv_bridge/python/cv_bridge/core.py
import cv2
import numpy as np
import sensor_msgs
def cv2_to_imgmsg(cvim, encoding="passthrough", header=None):
if not isinstance(cvim, (np.ndarray, np.generic)):
raise TypeError('Your input type is not a numpy array')
# prepare msg
img_msg = sensor_msgs.msg.Image()