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 / reduce_vertex_number_PyMeshLab.py
Created March 4, 2022 23:19
How to use PyMeshLab to reduce vertex number to a certain number
import pymeshlab as ml
ms = ml.MeshSet()
ms.load_new_mesh('input.ply')
m = ms.current_mesh()
print('input mesh has', m.vertex_number(), 'vertex and', m.face_number(), 'faces')
# Target number of vertex
TARGET=10000
@Merwanski
Merwanski / keras_data_augmentation.py
Created April 22, 2022 18:04
keras_data_augmentation
# Importing necessary functions
from keras.preprocessing.image import ImageDataGenerator,
array_to_img, img_to_array, load_img
# Initialising the ImageDataGenerator class.
# We will pass in the augmentation parameters in the constructor.
datagen = ImageDataGenerator(
rotation_range = 40,
shear_range = 0.2,
zoom_range = 0.2,
@Merwanski
Merwanski / conda_env_creation
Created May 11, 2022 20:35
conda python env creation
# Create The Sandbox You Play In
conda create --name your_env_name python=3.7 -y
conda create --name your_env_name python=3.7 scipy=0.15.0 astroid babel
conda env export > my_environment.yml
conda info --envs
conda activate your_env_name
@Merwanski
Merwanski / opencv_rstp.py
Created May 12, 2022 19:43
opencv-python_connect_to_android_camera_via_rstp
import cv2
import numpy as np
from matplotlib import pyplot as plt
import os
"""
source: https://medium.com/@nhancv/opencv-python-connect-to-android-camera-via-rstp-9eb78e2903d5
NB: Did not work on windows 10
"""
os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "rtsp_transport;0"
@Merwanski
Merwanski / read_image_resize_show.py
Created May 31, 2022 22:45
read_image_resize_show
# import necessary packages
import numpy as np
import cv2
# path to image
path_to_image = "data/cv_image_000.jpg"
# read the image with cv2
image = cv2.imread(path_to_image)
print('Original Dimensions : ', image.shape)
@Merwanski
Merwanski / photo_2_video.py
Last active April 8, 2024 09:46
photo_2_video
import cv2
import os
import numpy as np
import glob
video_file_name = 'FILE_NAME.mp4'
path_to_images = 'PATH'
extension = "png" # png, jpg, ...
@Merwanski
Merwanski / kinect_v2_ubuntu18.txt
Created June 10, 2022 02:47
kinect_v2_ubuntu18
kinect_v2_ubuntu18
Kinect2 Setup Guide
https://scazlab.github.io/kinect2_setup_guide.html
Welcome to the Setup Guide for Kinect2.
System
@Merwanski
Merwanski / importMnistTensorFlow.py
Created June 18, 2022 02:17
import minst dataset from tensorflow
# import necessary packages
import tensorflow as tf
import tensorflow_datasets as tfds
# Construct a tf.data.Dataset
# Data loaded into ~/tensorflow_datasets/mnist
ds = tfds.load('mnist', split='train', shuffle_files=True)
# Build your input pipeline
ds=ds.shuffle(1024).batch(32).prefetch(tf.data.experimental.AUTOTUNE)
@Merwanski
Merwanski / keras_h5_modelInference.py
Created June 18, 2022 02:42
How to use keras h5 model
from keras.models import load_model
from PIL import Image, ImageOps
import numpy as np
# Load the model
model = load_model('keras_model.h5')
# Create the array of the right shape to feed into the keras model
# The 'length' or number of images you can put into the array is
# determined by the first position in the shape tuple, in this case 1.
@Merwanski
Merwanski / main.py
Created August 21, 2022 17:20
read and display image in python
# import necessary packages
import numpy as np
import cv2
# path to image
path_to_image = "data/cv_image_000.jpg"
# read the image with cv2
image = cv2.imread(path_to_image)
print('Original Dimensions : ', image.shape)