What do you want to save?
Add Code snippet
New code examples
-
Python 2022-01-29 07:42:13
Image to grayscale using python
import numpy as np import matplotlib.pyplot as plt import matplotlib.image as mpimg def rgb2gray(rgb): return np.dot(rgb[...,:3], [0.299, 0.587, 0.144]) img = mpimg.imread('img.png') gray = rgb2gray(img) plt.imshow(gray, cmap='gray') plt.savefig(... Add solution -
Python 2021-09-21 12:42:03
ego vehicle coord system parallel to world z plane nuscenes
""" This code is to sort out a reply to https://github.com/nutonomy/nuscenes-devkit/issues/122 """ import numpy as np import matplotlib.pyplot as plt from pyquaternion import Quaternion from nuscenes import NuScenes GLOBA... Add solution -
Python 2021-09-18 17:19:03
euler angle to rotation vector python
import math import numpy as np # RPY/Euler angles to Rotation Vector def euler_to_rotVec(yaw, pitch, roll): # compute the rotation matrix Rmat = euler_to_rotMat(yaw, pitch, roll) theta = math.acos(((Rmat[0, 0] + Rmat[1, 1] + Rmat[2, 2]) ... Add solution -
Python 2021-09-15 07:08:02
jacobi method in python
import numpy as np from numpy.linalg import * def jacobi(A, b, x0, tol, maxiter=200): """ Performs Jacobi iterations to solve the line system of equations, Ax=b, starting from an initial guess, ``x0``. Terminates when the ... Add solution -
Python 2021-09-14 08:44:02
matrix multiplication python without numpy
The Numpythonic approach: (using numpy.dot in order to get the dot product of two matrices) In [1]: import numpy as np In [3]: np.dot([1,0,0,1,0,0], [[0,1],[1,1],[1,0],[1,0],[1,1],[0,1]]) Out[3]: array([1, 1]) The Pythonic approach: The length of your ... Add solution -
Python 2021-09-04 20:41:02
rotation matrix to euler angles python cv2
# Checks if a matrix is a valid rotation matrix. def isRotationMatrix(R) : Rt = np.transpose(R) shouldBeIdentity = np.dot(Rt, R) I = np.identity(3, dtype = R.dtype) n = np.linalg.norm(I - shouldBeIdentity) return n < 1e-6 # Calcula... Add solution -
Python 2021-08-29 11:30:01
scikit learn linear regression
from sklearn.linear_model import LinearRegression X = np.array([[1, 1], [1, 2], [2, 2], [2, 3]]) y = np.dot(X, np.array([1, 2])) + 3 reg = LinearRegression().fit(X, y) reg.score(X, y) reg.coef_ reg.intercept_ reg.predict(np.array([[3, 5]])) Add solution
Best helpers
Ranking is empty