Skip to content

Instantly share code, notes, and snippets.

View rezamarzban's full-sized avatar
🎯
Focusing

rezamarzban

🎯
Focusing
View GitHub Profile
@rezamarzban
rezamarzban / image_moments.py
Created August 20, 2022 05:16
Image moments help you to calculate some features like center of mass of the object, area of the object etc. The function cv2.moments() gives a dictionary of all moment values calculated. See the code:
import cv2
import numpy as np
img = cv2.imread('star.jpg',0)
ret,thresh = cv2.threshold(img,127,255,0)
contours,hierarchy = cv2.findContours(thresh, 1, 2)
cnt = contours[0]
M = cv2.moments(cnt)
print(M)
@rezamarzban
rezamarzban / centroid.py
Created August 22, 2022 04:15
Function to calculate image centroid by using OpenCV in Python3
import cv2
i = cv2.imread('img6.jpg')
img_g = cv2.cvtColor(i, cv2.COLOR_BGR2GRAY)
ret,img = cv2.threshold(img_g,127,255,0)
M = cv2.moments(img)
X = int(M["m10"] / M["m00"])
Y = int(M["m01"] / M["m00"])
unset LD_PRELOAD
command="proot"
command+=" --link2symlink"
command+=" -0"
#archurl="arm64"
#wget https://raw.githubusercontent.com/EXALAB/AnLinux-Resources/master/Rootfs/Ubuntu/${archurl}/ubuntu-rootfs-${archurl}.tar.xz
#mkdir ubuntu-fs && proot --link2symlink tar -xJf ubuntu-rootfs-${archurl}.tar.xz -C ubuntu-fs
command+=" -r ubuntu-fs"
command+=" -b /dev"
command+=" -b /proc"
#!/usr/bin/env bash
#Bootstrap the system, Ex: ./bootstrap.sh arm64 ubuntu-rootfs
rm -rf $2
mkdir $2
if [ "$1" = "i386" ] || [ "$1" = "amd64" ] ; then
debootstrap --arch=$1 --variant=minbase --include=systemd,libsystemd0,wget,ca-certificates,busybox-static jammy $1 http://archive.ubuntu.com/ubuntu
else
qemu-debootstrap --arch=$1 --variant=minbase --include=systemd,libsystemd0,wget,ca-certificates,busybox-static jammy $1 http://ports.ubuntu.com/ubuntu-ports
fi
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
maven { url 'https://maven.aliyun.com/repository/apache-snapshots' }
compileSdk 33
buildToolsVersion "33.0.3"
minSdk 21
task getDeps(type: Copy) {
from new File(gradle.gradleUserHomeDir, "caches/modules-2/files-2.1")
into "build/libs"
includeEmptyDirs false
}
@rezamarzban
rezamarzban / foam graph.ipynb
Last active December 29, 2023 09:20
Foam Graph
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
pkg install -forge symbolic
pkg load symbolic
@rezamarzban
rezamarzban / IntegralPoyntingVector.m
Last active January 23, 2024 14:30
MATLAB Poynting Vector integral without symbolic pkg
% Define farfield radiation electric field (E) and magnetic field (H) functions
E = @(r, theta, phi) your_electric_field_function(r, theta, phi);
H = @(r, theta, phi) your_magnetic_field_function(r, theta, phi);
% Define spherical region of integration
rmin = your_min_r_value;
rmax = your_max_r_value;
thetamin = your_min_theta_value;
thetamax = your_max_theta_value;
phimin = your_min_phi_value;
@rezamarzban
rezamarzban / Integral.m
Last active January 21, 2024 04:33
MATLAB function integral without symbolic pkg
% Define the function to be integrated
fun = @(x) x.^2;
% Define the integration limits
lower_limit = 0;
upper_limit = 1;
% Calculate the definite integral
result = integral(fun, lower_limit, upper_limit);