python case when用法_Python numpy.mgrid() 使用实例

2023-10-27

The following are code examples for showing how to use . They are extracted from open source Python projects. You can vote up the examples you like or vote down the exmaples you don’t like. You can also save this page to your account.

Example 1

def get_points():

# prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0)

objp = np.zeros((6*8,3), np.float32)

objp[:,:2] = np.mgrid[0:8, 0:6].T.reshape(-1 , 2)

# Arrays to store object points and image points from all the images.

objpoints = [] # 3d points in real world space

imgpoints = [] # 2d points in image plane.

# Make a list of calibration images

images = glob.glob('calibration_wide/GO*.jpg')

# Step through the list and search for chessboard corners

for idx, fname in enumerate(images):

img = cv2.imread(fname)

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# Find the chessboard corners

ret, corners = cv2.findChessboardCorners(gray, (8,6), None)

# If found, add object points, image points

if ret == True:

objpoints.append(objp)

imgpoints.append(corners)

# Draw and display the corners

cv2.drawChessboardCorners(img, (8,6), corners, ret)

#write_name = 'corners_found'+str(idx)+'.jpg'

#cv2.imwrite(write_name, img)

cv2.imshow('img', img)

cv2.waitKey(500)

cv2.destroyAllWindows()

return objpoints, imgpoints

Example 2

def find_points(images):

pattern_size = (9, 6)

obj_points = []

img_points = []

# Assumed object points relation

a_object_point = np.zeros((PATTERN_SIZE[1] * PATTERN_SIZE[0], 3),

np.float32)

a_object_point[:, :2] = np.mgrid[0:PATTERN_SIZE[0],

0:PATTERN_SIZE[1]].T.reshape(-1, 2)

# Termination criteria for sub pixel corners refinement

stop_criteria = (cv.TERM_CRITERIA_EPS + cv.TERM_CRITERIA_MAX_ITER,

30, 0.001)

print('Finding points ', end='')

debug_images = []

for (image, color_image) in images:

found, corners = cv.findChessboardCorners(image, PATTERN_SIZE, None)

if found:

obj_points.append(a_object_point)

cv.cornerSubPix(image, corners, (11, 11), (-1, -1), stop_criteria)

img_points.append(corners)

print('.', end='')

else:

print('-', end='')

if DEBUG:

cv.drawChessboardCorners(color_image, PATTERN_SIZE, corners, found)

debug_images.append(color_image)

sys.stdout.flush()

if DEBUG:

display_images(debug_images, DISPLAY_SCALE)

print('\nWas able to find points in %s images' % len(img_points))

return obj_points, img_points

# images is a lis of tuples: (gray_image, color_image)

Example 3

def draw_flow(img, flow, step=16):

h, w = img.shape[:2]

y, x = np.mgrid[step/2:h:step, step/2:w:step].reshape(2,-1)

fx, fy = flow[y,x].T

m = np.bitwise_and(np.isfinite(fx), np.isfinite(fy))

lines = np.vstack([x[m], y[m], x[m]+fx[m], y[m]+fy[m]]).T.reshape(-1, 2, 2)

lines = np.int32(lines + 0.5)

vis = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)

cv2.polylines(vis, lines, 0, (0, 255, 0))

for (x1, y1), (x2, y2) in lines:

cv2.circle(vis, (x1, y1), 1, (0, 255, 0), -1)

return vis

Example 4

def draw_flow(img, flow, step=8):

h, w = img.shape[:2]

y, x = np.mgrid[step/2:h:step, step/2:w:step].reshape(2,-1).astype(int)

fx, fy = flow[y,x].T

lines = np.vstack([x, y, x+fx, y+fy]).T.reshape(-1, 2, 2)

lines = np.int32(lines + 0.5)

vis = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)

cv2.polylines(vis, lines, 0, (0, 255, 0))

for (x1, y1), (x2, y2) in lines:

cv2.circle(vis, (x1, y1), 1, (0, 255, 0), -1)

return vis

#####################################################################

# define video capture object

Example 5

def calculateExtrinsics(self, cameraParameters):

'''

Inputs:

cameraParameters is CameraParameters object

Calculate: rotate vector and transform vector

>>> marker.calculateExtrinsics(camera_matrix, dist_coeff)

>>> print(marker.rvec, marker.tvec)

'''

object_points = np.zeros((4,3), dtype=np.float32)

object_points[:,:2] = np.mgrid[0:2,0:2].T.reshape(-1,2)

# Test Code.

# object_points[:] -= 0.5

marker_points = self.corners

if marker_points is None: raise TypeError('The marker.corners is None')

camera_matrix = cameraParameters.camera_matrix

dist_coeff = cameraParameters.dist_coeff

ret, rvec, tvec = cv2.solvePnP(object_points, marker_points,

camera_matrix, dist_coeff)

if ret: self.rvec, self.tvec = rvec, tvec

return ret

Example 6

def __init__(self, pos, size):

"""

pos is (...,3) array of the bar positions (the corner of each bar)

size is (...,3) array of the sizes of each bar

"""

nCubes = reduce(lambda a,b: a*b, pos.shape[:-1])

cubeVerts = np.mgrid[0:2,0:2,0:2].reshape(3,8).transpose().reshape(1,8,3)

cubeFaces = np.array([

[0,1,2], [3,2,1],

[4,5,6], [7,6,5],

[0,1,4], [5,4,1],

[2,3,6], [7,6,3],

[0,2,4], [6,4,2],

[1,3,5], [7,5,3]]).reshape(1,12,3)

size = size.reshape((nCubes, 1, 3))

pos = pos.reshape((nCubes, 1, 3))

verts = cubeVerts * size + pos

faces = cubeFaces + (np.arange(nCubes) * 8).reshape(nCubes,1,1)

md = MeshData(verts.reshape(nCubes*8,3), faces.reshape(nCubes*12,3))

GLMeshItem.__init__(self, meshdata=md, shader='shaded', smooth=False)

Example 7

def __init__(self, pos, size):

"""

pos is (...,3) array of the bar positions (the corner of each bar)

size is (...,3) array of the sizes of each bar

"""

nCubes = reduce(lambda a,b: a*b, pos.shape[:-1])

cubeVerts = np.mgrid[0:2,0:2,0:2].reshape(3,8).transpose().reshape(1,8,3)

cubeFaces = np.array([

[0,1,2], [3,2,1],

[4,5,6], [7,6,5],

[0,1,4], [5,4,1],

[2,3,6], [7,6,3],

[0,2,4], [6,4,2],

[1,3,5], [7,5,3]]).reshape(1,12,3)

size = size.reshape((nCubes, 1, 3))

pos = pos.reshape((nCubes, 1, 3))

verts = cubeVerts * size + pos

faces = cubeFaces + (np.arange(nCubes) * 8).reshape(nCubes,1,1)

md = MeshData(verts.reshape(nCubes*8,3), faces.reshape(nCubes*12,3))

GLMeshItem.__init__(self, meshdata=md, shader='shaded', smooth=False)

Example 8

def make3dplot(ax, sample, density):

ax.scatter(sample[:,0], sample[:,1], zdir='z')

ax.set_aspect('equal', 'datalim')

xlim = ax.get_xlim()

ylim = ax.get_ylim()

gridsize=50

xs, ys = np.mgrid[xlim[0]:xlim[1]:(xlim[1]-xlim[0])/float(gridsize), ylim[0]:ylim[1]:(ylim[1]-ylim[0])/float(gridsize)]

pos = np.empty(xs.shape + (2,))

pos[:, :, 0] = xs; pos[:, :, 1] = ys

zs = density(pos)

surf = ax.plot_surface(xs, ys, zs, rstride=1, cstride=1, linewidth=0, antialiased=False, alpha=.3)

ax.set_xlabel('x')

ax.set_ylabel('y')

Example 9

def nufft_T(N, J, K, alpha, beta):

'''

equation (29) and (26)Fessler's paper

create the overlapping matrix CSSC (diagonal dominent matrix)

of J points

and then find out the pseudo-inverse of CSSC '''

# import scipy.linalg

L = numpy.size(alpha) - 1

# print('L = ', L, 'J = ',J, 'a b', alpha,beta )

cssc = numpy.zeros((J, J))

[j1, j2] = numpy.mgrid[1:J + 1, 1:J + 1]

overlapping_mat = j2 - j1

for l1 in range(-L, L + 1):

for l2 in range(-L, L + 1):

alf1 = alpha[abs(l1)]

# if l1 < 0: alf1 = numpy.conj(alf1)

alf2 = alpha[abs(l2)]

# if l2 < 0: alf2 = numpy.conj(alf2)

tmp = overlapping_mat + beta * (l1 - l2)

tmp = dirichlet(1.0 * tmp / (1.0 * K / N))

cssc = cssc + alf1 * numpy.conj(alf2) * tmp

return mat_inv(cssc)

Example 10

def nufft_T(N, J, K, alpha, beta):

'''

The Equation (29) and (26) in Fessler and Sutton 2003.

Create the overlapping matrix CSSC (diagonal dominent matrix)

of J points and find out the pseudo-inverse of CSSC '''

# import scipy.linalg

L = numpy.size(alpha) - 1

# print('L = ', L, 'J = ',J, 'a b', alpha,beta )

cssc = numpy.zeros((J, J))

[j1, j2] = numpy.mgrid[1:J + 1, 1:J + 1]

overlapping_mat = j2 - j1

for l1 in range(-L, L + 1):

for l2 in range(-L, L + 1):

alf1 = alpha[abs(l1)]

# if l1 < 0: alf1 = numpy.conj(alf1)

alf2 = alpha[abs(l2)]

# if l2 < 0: alf2 = numpy.conj(alf2)

tmp = overlapping_mat + beta * (l1 - l2)

tmp = dirichlet(1.0 * tmp / (1.0 * K / N))

cssc = cssc + alf1 * alf2 * tmp

return mat_inv(cssc)

Example 11

def x_frame2D(X, plot_limits=None, resolution=None):

"""

Internal helper function for making plots, returns a set of input values to plot as well as lower and upper limits

"""

assert X.shape[1] == 2, \

'x_frame2D is defined for two-dimensional inputs'

if plot_limits is None:

(xmin, xmax) = (X.min(0), X.max(0))

(xmin, xmax) = (xmin - 0.2 * (xmax - xmin), xmax + 0.2 * (xmax

- xmin))

elif len(plot_limits) == 2:

(xmin, xmax) = plot_limits

else:

raise ValueError, 'Bad limits for plotting'

resolution = resolution or 50

(xx, yy) = np.mgrid[xmin[0]:xmax[0]:1j * resolution, xmin[1]:

xmax[1]:1j * resolution]

Xnew = np.vstack((xx.flatten(), yy.flatten())).T

return (Xnew, xx, yy, xmin, xmax)

Example 12

def test_pdf(self):

'''

Tests the probability density function.

'''

# Calculate probability density function on lattice

bnds = np.empty((3), dtype=object)

bnds[0] = [-1, 1]

bnds[1] = [0, 2]

bnds[2] = [0.5, 2]

(x0g, x1g, x2g) = np.mgrid[bnds[0][0]:bnds[0][1],

bnds[1][0]:bnds[1][1],

bnds[2][0]:bnds[2][1]]

points = np.array([x0g.ravel(), x1g.ravel(), x2g.ravel()]).T

r_logpdf = np.array([-6.313469, -17.406428, -4.375992, -6.226508,

-8.836115, -20.430739, -5.107053, -6.687987])

p_logpdf = self.vine.logpdf(points)

assert_allclose(p_logpdf, r_logpdf)

r_pdf = np.array([1.811738e-03, 2.757302e-08, 1.257566e-02,

1.976342e-03, 1.453865e-04, 1.339808e-09,

6.053895e-03, 1.245788e-03])

p_pdf = self.vine.pdf(points)

assert_allclose(p_pdf, r_pdf, rtol=1e-5)

Example 13

def plotImage(dta, saveFigName):

plt.clf()

dx, dy = 1, 1

# generate 2 2d grids for the x & y bounds

with np.errstate(invalid='ignore'):

y, x = np.mgrid[

slice(0, len(dta) , dx),

slice(0, len(dta[0]), dy)

]

z = dta

z_min, z_max = -np.abs(z).max(), np.abs(z).max()

#try:

c = plt.pcolormesh(x, y, z, cmap='hsv', vmin=z_min, vmax=z_max)

#except ??? as err: # data not regular?

# c = plt.pcolor(x, y, z, cmap='hsv', vmin=z_min, vmax=z_max)

d = plt.colorbar(c, orientation='vertical')

lx = plt.xlabel("index")

ly = plt.ylabel("season length")

plt.savefig(str(saveFigName))

Example 14

def areaxy(self, lowerbound=-np.inf, upperbound=np.inf, spacing=0.1):

mask = (self.coord[:,2] > lowerbound) & (self.coord[:,2] < upperbound)

points = self.coord[mask, :2]

# The magic number factor 1.1 is not critical at all

# Just a number to set a margin to the bounding box and

# have all points fall within the boundaries

bbmin, bbmax = 1.1*points.min(axis=0), 1.1*points.max(axis=0)

size = bbmax - bbmin

cells = (size / spacing + 0.5).astype('int')

# Grid points over bounding box with specified spacing

grid = np.mgrid[bbmin[0]:bbmax[0]:(cells[0]*1j),

bbmin[1]:bbmax[1]:(cells[1]*1j)].reshape((2,-1)).T

# Occupied cells is approximately equal to grid points within

# gridspacing distance of points

occupied = occupancy(grid, points, spacing)

# The occupied area follows from the fraction of occupied

# cells times the area spanned by the bounding box

return size[0]*size[1]*sum(occupied > 0)/occupied.size

Example 15

def generate_hills(width, height, nhills):

'''

@param width float, terrain width

@param height float, terrain height

@param nhills int, #hills to gen. #hills actually generted is sqrt(nhills)^2

'''

# setup coordinate grid

xmin, xmax = -width/2.0, width/2.0

ymin, ymax = -height/2.0, height/2.0

x, y = np.mgrid[xmin:xmax:STEP, ymin:ymax:STEP]

pos = np.empty(x.shape + (2,))

pos[:, :, 0] = x; pos[:, :, 1] = y

# generate hilltops

xm, ym = np.mgrid[xmin:xmax:width/np.sqrt(nhills), ymin:ymax:height/np.sqrt(nhills)]

mu = np.c_[xm.flat, ym.flat]

sigma = float(width*height)/(nhills*8)

for i in range(mu.shape[0]):

mu[i] = multivariate_normal.rvs(mean=mu[i], cov=sigma)

# generate hills

sigma = sigma + sigma*np.random.rand(mu.shape[0])

rvs = [ multivariate_normal(mu[i,:], cov=sigma[i]) for i in range(mu.shape[0]) ]

hfield = np.max([ rv.pdf(pos) for rv in rvs ], axis=0)

return x, y, hfield

Example 16

def joint_density(X, Y, bounds=None):

"""

Plots joint distribution of variables.

Inherited from method in src/graphics.py module in project

git://github.com/aflaxman/pymc-example-tfr-hdi.git

"""

if bounds:

X_min, X_max, Y_min, Y_max = bounds

else:

X_min = X.min()

X_max = X.max()

Y_min = Y.min()

Y_max = Y.max()

pylab.plot(X, Y, linestyle='none', marker='o', color='green', mec='green', alpha=.2, zorder=-99)

gkde = scipy.stats.gaussian_kde([X, Y])

x,y = pylab.mgrid[X_min:X_max:(X_max-X_min)/25.,Y_min:Y_max:(Y_max-Y_min)/25.]

z = pylab.array(gkde.evaluate([x.flatten(), y.flatten()])).reshape(x.shape)

pylab.contour(x, y, z, linewidths=2)

pylab.axis([X_min, X_max, Y_min, Y_max])

Example 17

def hyperball(ndim, radius):

"""Return a binary morphological filter containing pixels within `radius`.

Parameters

----------

ndim : int

The number of dimensions of the filter.

radius : int

The radius of the filter.

Returns

-------

ball : array of bool, shape [2 * radius + 1,] * ndim

The required structural element

"""

size = 2 * radius + 1

center = [(radius,) * ndim]

coords = np.mgrid[[slice(None, size),] * ndim].reshape(ndim, -1).T

distances = np.ravel(spatial.distance_matrix(coords, center))

selector = distances <= radius

ball = np.zeros((size,) * ndim, dtype=bool)

ball.ravel()[selector] = True

return ball

Example 18

def _generate_random_grids(self):

if self.num_grids > 40:

starter = np.random.randint(0, 20)

random_sample = np.mgrid[starter:len(self.grids)-1:20j].astype("int32")

# We also add in a bit to make sure that some of the grids have

# particles

gwp = self.grid_particle_count > 0

if np.any(gwp) and not np.any(gwp[(random_sample,)]):

# We just add one grid. This is not terribly efficient.

first_grid = np.where(gwp)[0][0]

random_sample.resize((21,))

random_sample[-1] = first_grid

mylog.debug("Added additional grid %s", first_grid)

mylog.debug("Checking grids: %s", random_sample.tolist())

else:

random_sample = np.mgrid[0:max(len(self.grids),1)].astype("int32")

return self.grids[(random_sample,)]

Example 19

def test_linear_interpolator_2d():

random_data = np.random.random((64, 64))

# evenly spaced bins

fv = dict((ax, v) for ax, v in zip("xyz",

np.mgrid[0.0:1.0:64j, 0.0:1.0:64j]))

bfi = lin.BilinearFieldInterpolator(random_data,

(0.0, 1.0, 0.0, 1.0), "xy", True)

assert_array_equal(bfi(fv), random_data)

# randomly spaced bins

size = 64

bins = np.linspace(0.0, 1.0, size)

shifts = dict((ax, (1. / size) * np.random.random(size) - (0.5 / size)) \

for ax in "xy")

fv["x"] += shifts["x"][:, np.newaxis]

fv["y"] += shifts["y"]

bfi = lin.BilinearFieldInterpolator(random_data,

(bins + shifts["x"], bins + shifts["y"]), "xy", True)

assert_array_almost_equal(bfi(fv), random_data, 15)

Example 20

def test_linear_interpolator_3d():

random_data = np.random.random((64, 64, 64))

# evenly spaced bins

fv = dict((ax, v) for ax, v in zip("xyz",

np.mgrid[0.0:1.0:64j, 0.0:1.0:64j, 0.0:1.0:64j]))

tfi = lin.TrilinearFieldInterpolator(random_data,

(0.0, 1.0, 0.0, 1.0, 0.0, 1.0), "xyz", True)

assert_array_almost_equal(tfi(fv), random_data)

# randomly spaced bins

size = 64

bins = np.linspace(0.0, 1.0, size)

shifts = dict((ax, (1. / size) * np.random.random(size) - (0.5 / size)) \

for ax in "xyz")

fv["x"] += shifts["x"][:, np.newaxis, np.newaxis]

fv["y"] += shifts["y"][:, np.newaxis]

fv["z"] += shifts["z"]

tfi = lin.TrilinearFieldInterpolator(random_data,

(bins + shifts["x"], bins + shifts["y"],

bins + shifts["z"]), "xyz", True)

assert_array_almost_equal(tfi(fv), random_data, 15)

Example 21

def partition_index_2d(self, axis):

if not self._distributed:

return False, self.index.grid_collection(self.center,

self.index.grids)

xax = self.ds.coordinates.x_axis[axis]

yax = self.ds.coordinates.y_axis[axis]

cc = MPI.Compute_dims(self.comm.size, 2)

mi = self.comm.rank

cx, cy = np.unravel_index(mi, cc)

x = np.mgrid[0:1:(cc[0]+1)*1j][cx:cx+2]

y = np.mgrid[0:1:(cc[1]+1)*1j][cy:cy+2]

DLE, DRE = self.ds.domain_left_edge.copy(), self.ds.domain_right_edge.copy()

LE = np.ones(3, dtype='float64') * DLE

RE = np.ones(3, dtype='float64') * DRE

LE[xax] = x[0] * (DRE[xax]-DLE[xax]) + DLE[xax]

RE[xax] = x[1] * (DRE[xax]-DLE[xax]) + DLE[xax]

LE[yax] = y[0] * (DRE[yax]-DLE[yax]) + DLE[yax]

RE[yax] = y[1] * (DRE[yax]-DLE[yax]) + DLE[yax]

mylog.debug("Dimensions: %s %s", LE, RE)

reg = self.ds.region(self.center, LE, RE)

return True, reg

Example 22

def init_fill(self):

rext = 1.0

Ns = 51

x, y = np.mgrid[ -rext:rext:1j*Ns, -rext:rext:1j*Ns ]

z = np.zeros_like(x)

self.controller.ax_xstress.pcolor(x,y,z, cmap=plt.cm.coolwarm)

self.controller.ax_ystress.pcolor(x,y,z, cmap=plt.cm.coolwarm)

self.controller.ax_xystress.pcolor(x,y,z, cmap=plt.cm.coolwarm)

self.controller.ax_rstress.pcolor(x,y,z, cmap=plt.cm.coolwarm)

self.controller.ax_tstress.pcolor(x,y,z, cmap=plt.cm.coolwarm)

return

# =======================

Example 23

def evaluate_model(self, model):

"""

This function ...

:param model:

:return:

"""

# Make a local copy of the model so that we can adapt its position to be relative to this box

rel_model = fitting.shifted_model(model, -self.x_min, -self.y_min)

# Create x and y meshgrid for evaluating

y_values, x_values = np.mgrid[:self.ysize, :self.xsize]

# Evaluate the model

data = rel_model(x_values, y_values)

# Return a new box

return Box(data, self.x_min, self.x_max, self.y_min, self.y_max)

# -----------------------------------------------------------------

Example 24

def evaluate_model(self, model):

"""

This function ...

:param model:

:return:

"""

# Make a local copy of the model so that we can adapt its position to be relative to this box

rel_model = fitting.shifted_model(model, -self.x_min, -self.y_min)

# Create x and y meshgrid for evaluating

y_values, x_values = np.mgrid[:self.ysize, :self.xsize]

# Evaluate the model

data = rel_model(x_values, y_values)

# Return a new box

return Box(data, self.x_min, self.x_max, self.y_min, self.y_max)

# -----------------------------------------------------------------

Example 25

def polarToLinearMaps(orig_shape, out_shape=None, center=None):

s0, s1 = orig_shape

if out_shape is None:

out_shape = (int(round(2 * s0 / 2**0.5)) - (1 - s0 % 2),

int(round(2 * s1 / (2 * np.pi) / 2**0.5)))

ss0, ss1 = out_shape

if center is None:

center = ss1 // 2, ss0 // 2

yy, xx = np.mgrid[0:ss0:1., 0:ss1:1.]

r, phi = _cart2polar(xx, yy, center)

# scale-pi...pi->0...s1:

phi = (phi + np.pi) / (2 * np.pi) * (s1 - 2)

return phi.astype(np.float32), r.astype(np.float32)

Example 26

def calculateExtrinsics(self, cameraParameters):

'''

Inputs:

cameraParameters is CameraParameters object

Calculate: rotate vector and transform vector

>>> marker.calculateExtrinsics(camera_matrix, dist_coeff)

>>> print(marker.rvec, marker.tvec)

'''

object_points = np.zeros((4,3), dtype=np.float32)

object_points[:,:2] = np.mgrid[0:2,0:2].T.reshape(-1,2)

# Test Code.

# object_points[:] -= 0.5

marker_points = self.corners

if marker_points is None: raise TypeError('The marker.corners is None')

camera_matrix = cameraParameters.camera_matrix

dist_coeff = cameraParameters.dist_coeff

ret, rvec, tvec = cv2.solvePnP(object_points, marker_points,

camera_matrix, dist_coeff)

if ret: self.rvec, self.tvec = rvec, tvec

return ret

Example 27

def calculateExtrinsics(self, cameraParameters):

'''

Inputs:

cameraParameters is CameraParameters object

Calculate: rotate vector and transform vector

>>> marker.calculateExtrinsics(camera_matrix, dist_coeff)

>>> print(marker.rvec, marker.tvec)

'''

object_points = np.zeros((4,3), dtype=np.float32)

object_points[:,:2] = np.mgrid[0:2,0:2].T.reshape(-1,2)

# Test Code.

# object_points[:] -= 0.5

marker_points = self.corners

if marker_points is None: raise TypeError('The marker.corners is None')

camera_matrix = cameraParameters.camera_matrix

dist_coeff = cameraParameters.dist_coeff

ret, rvec, tvec = cv2.solvePnP(object_points, marker_points,

camera_matrix, dist_coeff)

if ret: self.rvec, self.tvec = rvec, tvec

return ret

Example 28

def calculateExtrinsics(self, cameraParameters):

'''

Inputs:

cameraParameters is CameraParameters object

Calculate: rotate vector and transform vector

>>> marker.calculateExtrinsics(camera_matrix, dist_coeff)

>>> print(marker.rvec, marker.tvec)

'''

object_points = np.zeros((4,3), dtype=np.float32)

object_points[:,:2] = np.mgrid[0:2,0:2].T.reshape(-1,2)

# Test Code.

# object_points[:] -= 0.5

marker_points = self.corners

if marker_points is None: raise TypeError('The marker.corners is None')

camera_matrix = cameraParameters.camera_matrix

dist_coeff = cameraParameters.dist_coeff

ret, rvec, tvec = cv2.solvePnP(object_points, marker_points,

camera_matrix, dist_coeff)

if ret: self.rvec, self.tvec = rvec, tvec

return ret

Example 29

def _compute_gaussian_kernel(histogram_shape, relative_bw):

"""Compute a gaussian kernel double the size of the histogram matrix"""

if len(histogram_shape) == 2:

kernel_shape = [2 * n for n in histogram_shape]

# Create a scaled grid in which the kernel is symmetric to avoid matrix

# inversion problems when the bandwiths are very different

bw_ratio = relative_bw[0] / relative_bw[1]

bw = relative_bw[0]

X, Y = np.mgrid[-bw_ratio:bw_ratio:kernel_shape[0] * 1j,

-1:1:kernel_shape[1] * 1j]

grid_points = np.vstack([X.ravel(), Y.ravel()]).T

Cov = np.array(((bw, 0), (0, bw)))**2

K = stats.multivariate_normal.pdf(grid_points, mean=(0, 0), cov=Cov)

return K.reshape(kernel_shape)

else:

grid = np.mgrid[-1:1:histogram_shape[0] * 2j]

return stats.norm.pdf(grid, loc=0, scale=relative_bw)

Example 30

def draw_flow(img, flow, step=16):

h, w = img.shape[:2]

y, x = np.mgrid[step/2:h:step, step/2:w:step].reshape(2, -1).astype(int) # ????????????????????????16?reshape?2??array

fx, fy = flow[y, x].T # ???????????????

lines = np.vstack([x, y, x+fx, y+fy]).T.reshape(-1, 2, 2) # ????????????2*2???

lines = np.int32(lines + 0.5) # ????????????

vis = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)

cv2.polylines(vis, lines, 0, (0, 255, 0)) # ???????????????

for (x1, y1), (x2, y2) in lines:

cv2.circle(vis, (x1, y1), 1, (0, 255, 0), -1) # ???????????????????

return vis

Example 31

def flow2parallax(u,v,q):

"""

Given the flow fields (after correction!) and the epipole,

return:

- The normalized parallax (HxW array)

- The vectors pointing to the epipoles (HxWx2 array)

- The distances of all points to the epipole (HxW array)

"""

h,w = u.shape

y,x = np.mgrid[:h,:w]

u_f = q[0] - x

v_f = q[1] - y

dists = np.sqrt(u_f**2 + v_f**2)

u_f_n = u_f / np.maximum(dists,1e-3)

v_f_n = v_f / np.maximum(dists,1e-3)

parallax = u * u_f_n + v * v_f_n

return parallax, np.dstack((u_f_n, v_f_n)), dists

Example 32

def create_test_dataset(image_shape, n, circle_radius, donut_radius):

img = np.zeros((image_shape[0], image_shape[1]))

y_pixels = np.arange(0, image_shape[0], 1)

x_pixels = np.arange(0, image_shape[1], 1)

cell_y_coords = np.random.choice(y_pixels, n, replace=False)

cell_x_coords = np.random.choice(x_pixels, n, replace=False)

for x, y in zip(cell_x_coords, cell_y_coords):

xx, yy = np.mgrid[:512, :512] # create mesh grid of image dimensions

circle = (xx - x) ** 2 + (yy - y) ** 2 # apply circle formula

donut = np.logical_and(circle < (circle_radius+donut_radius),

circle > (circle_radius-5)) # donuts are thresholded circles

thresholded_circle = circle < circle_radius

img[np.where(thresholded_circle)] = 1

img[np.where(donut)] = 2

return img

Example 33

def test_square_grid():

X = np.mgrid[0:16, 0:16]

X = X.reshape((len(X), -1)).T

name = 'square'

D, Q = test_toy_embedding(X, 32, 2, name, palette='hls')

def plot_mat_on_data(mat, sample):

plt.figure()

plot_data_embedded(X, palette='w')

alpha = np.maximum(mat[sample], 0) / mat[sample].max()

plot_data_embedded(X, palette='#FF0000', alpha=alpha)

pdf_file_name = '{}{}_plot_{}_on_data_{}{}'

plot_mat_on_data(D, 7 * 16 + 7)

plt.savefig(pdf_file_name.format(dir_name, name, 'D', 'middle', '.pdf'))

plot_mat_on_data(Q, 7 * 16 + 7)

plt.savefig(pdf_file_name.format(dir_name, name, 'Q', 'middle', '.pdf'))

# for s in range(len(X)):

# plot_mat_on_data(Q, s)

# plt.savefig(pdf_file_name.format(dir_name, name, 'Q', s, '.png'))

# plt.close()

Example 34

def plot(self, ax, idx1, idx2, range1, range2, n=100):

assert len(range1) == len(range2) == 2 and idx1 != idx2

x, y = np.mgrid[range1[0]:range1[1]:(n+0j), range2[0]:range2[1]:(n+0j)]

if isinstance(self.action_space, ContinuousSpace):

points_B_Doa = np.zeros((n*n, self.obsfeat_space.storage_size + self.action_space.storage_size))

points_B_Doa[:,idx1] = x.ravel()

points_B_Doa[:,idx2] = y.ravel()

obsfeat_B_Df, a_B_Da = points_B_Doa[:,:self.obsfeat_space.storage_size], points_B_Doa[:,self.obsfeat_space.storage_size:]

assert a_B_Da.shape[1] == self.action_space.storage_size

t_B = np.zeros(a_B_Da.shape[0]) # XXX make customizable

z = self.compute_reward(obsfeat_B_Df, a_B_Da, t_B).reshape(x.shape)

else:

obsfeat_B_Df = np.zeros((n*n, self.obsfeat_space.storage_size))

obsfeat_B_Df[:,idx1] = x.ravel()

obsfeat_B_Df[:,idx2] = y.ravel()

a_B_Da = np.zeros((obsfeat_B_Df.shape[0], 1), dtype=np.int32) # XXX make customizable

t_B = np.zeros(a_B_Da.shape[0]) # XXX make customizable

z = self.compute_reward(obsfeat_B_Df, a_B_Da, t_B).reshape(x.shape)

ax.pcolormesh(x, y, z, cmap='viridis')

ax.contour(x, y, z, levels=np.log(np.linspace(2., 3., 10)))

# ax.contourf(x, y, z, levels=[np.log(2.), np.log(2.)+.5], alpha=.5) # high-reward region is highlighted

Example 35

def calculate_scalar_matrix(values_a, values_b):

"""

convenience function wrapper of py:function:`calculate_scalar_product_matrix` for the case of scalar elements.

:param values_a:

:param values_b:

:return:

"""

return calculate_scalar_product_matrix(np.multiply,

sanitize_input(values_a, Number),

sanitize_input(values_b, Number))

# i, j = np.mgrid[0:values_a.shape[0], 0:values_b.shape[0]]

# vals_i = values_a[i]

# vals_j = values_b[j]

# return np.multiply(vals_i, vals_j)

Example 36

def gabor_2d(M, N, sigma, theta, xi, slant=1.0, offset=0, fft_shift=None):

gab = np.zeros((M, N), np.complex64)

R = np.array([[np.cos(theta), -np.sin(theta)], [np.sin(theta), np.cos(theta)]], np.float32)

R_inv = np.array([[np.cos(theta), np.sin(theta)], [-np.sin(theta), np.cos(theta)]], np.float32)

D = np.array([[1, 0], [0, slant * slant]])

curv = np.dot(R, np.dot(D, R_inv)) / ( 2 * sigma * sigma)

for ex in [-2, -1, 0, 1, 2]:

for ey in [-2, -1, 0, 1, 2]:

[xx, yy] = np.mgrid[offset + ex * M:offset + M + ex * M, offset + ey * N:offset + N + ey * N]

arg = -(curv[0, 0] * np.multiply(xx, xx) + (curv[0, 1] + curv[1, 0]) * np.multiply(xx, yy) + curv[

1, 1] * np.multiply(yy, yy)) + 1.j * (xx * xi * np.cos(theta) + yy * xi * np.sin(theta))

gab = gab + np.exp(arg)

norm_factor = (2 * 3.1415 * sigma * sigma / slant)

gab = gab / norm_factor

if (fft_shift):

gab = np.fft.fftshift(gab, axes=(0, 1))

return gab

Example 37

def test():

import PIL.Image

y, x = np.mgrid[0:256, 0:256]

z = np.ones((256,256)) * 128

img0 = np.dstack((x, y, z)).astype(np.uint8)

img1 = y.astype(np.uint8)

img2 = np.arange(256, dtype=np.uint8)

img3 = PIL.Image.open("pics/RGB.png")

img3 = np.array(img3)[:,:,0:3]

img4 = PIL.Image.open("pics/banff.jpg")

img4 = np.array(img4)[:,:,0:3]

img5, _ = (np.mgrid[0:1242, 0:1276] / 1242. * 255.).astype(np.uint8)

img6, _ = (np.mgrid[0:1007, 0:12] / 1007. * 255.).astype(np.uint8)

for i in (1, 2, 4, 8):

write_tiff("Test0_" + str(i) + ".TIF", img0, bit_depth=i)

write_tiff("Test1_" + str(i) + ".TIF", img1, bit_depth=i)

write_tiff("Test2_" + str(i) + ".TIF", img2, bit_depth=i)

write_tiff("Test3_" + str(i) + ".TIF", img3, bit_depth=i)

write_tiff("Test4_" + str(i) + ".TIF", img4, bit_depth=i)

write_tiff("Test5_" + str(i) + ".TIF", img5, bit_depth=i)

write_tiff("Test6_" + str(i) + ".TIF", img6, bit_depth=i)

Example 38

def gauss_kernel(size, sigma=None, size_y=None, sigma_y=None):

"""

Generates a 2D Gaussian kernel as a numpy array

Args:

size (int): 1/2 the width of the kernel; total width := 2*size+1

sigma (float): spread of the gaussian in the width direction

size_y (int): 1/2 the height of the kernel; defaults to size

sigma_y (float): spread of the gaussian in the height direction; defaults to sigma

Returns:

numpy array: normalized 2D gaussian array

"""

size = int(size)

if not size_y:

size_y = size

else:

size_y = int(size_y)

if not sigma:

sigma = 0.5 * size + .1

if not sigma_y:

sigma_y = sigma

x, y = np.mgrid[-size:size+1, -size_y:size_y+1]

g = np.exp(-0.5 * (x ** 2 / sigma ** 2 + y ** 2 / sigma_y ** 2))

return g / g.sum()

Example 39

def __init__(self, im, sigma_spatial=12, sigma_luma=4, sigma_chroma=4):

im_yuv = rgb2yuv(im)

# Compute 5-dimensional XYLUV bilateral-space coordinates

Iy, Ix = np.mgrid[:im.shape[0], :im.shape[1]]

x_coords = (Ix / sigma_spatial).astype(int)

y_coords = (Iy / sigma_spatial).astype(int)

luma_coords = (im_yuv[..., 0] /sigma_luma).astype(int)

chroma_coords = (im_yuv[..., 1:] / sigma_chroma).astype(int)

coords = np.dstack((x_coords, y_coords, luma_coords, chroma_coords))

coords_flat = coords.reshape(-1, coords.shape[-1])

self.npixels, self.dim = coords_flat.shape

# Hacky "hash vector" for coordinates,

# Requires all scaled coordinates be < MAX_VAL

self.hash_vec = (MAX_VAL**np.arange(self.dim))

# Construct S and B matrix

self._compute_factorization(coords_flat)

Example 40

def get_local_mesh(self):

# Create the mesh

X = np.mgrid[self.rank*self.Np[0]:(self.rank+1)*self.Np[0], :self.N[1]].astype(self.float)

X[0] *= self.L[0]/self.N[0]

X[1] *= self.L[1]/self.N[1]

return X

Example 41

def get_local_mesh(self):

xyrank = self.comm0.Get_rank() # Local rank in xz-plane

yzrank = self.comm1.Get_rank() # Local rank in xy-plane

# Create the physical mesh

x1 = slice(xyrank * self.N1[0], (xyrank+1) * self.N1[0], 1)

x2 = slice(yzrank * self.N2[1], (yzrank+1) * self.N2[1], 1)

X = np.mgrid[x1, x2, :self.N[2]].astype(self.float)

X[0] *= self.L[0]/self.N[0]

X[1] *= self.L[1]/self.N[1]

X[2] *= self.L[2]/self.N[2]

return X

Example 42

def get_tform_coords(im_size):

coords0, coords1, coords2 = np.mgrid[:im_size[0], :im_size[1], :im_size[2]]

coords = np.array([coords0 - im_size[0] / 2, coords1 - im_size[1] / 2, coords2 - im_size[2] / 2])

return np.append(coords.reshape(3, -1), np.ones((1, np.prod(im_size))), axis=0)

Example 43

def _FSpecialGauss(size, sigma):

"""Function to mimic the 'fspecial' gaussian MATLAB function."""

radius = size // 2

offset = 0.0

start, stop = -radius, radius + 1

if size % 2 == 0:

offset = 0.5

stop -= 1

x, y = np.mgrid[offset + start:stop, offset + start:stop]

assert len(x) == size

g = np.exp(-((x ** 2 + y ** 2) / (2.0 * sigma ** 2)))

return g / g.sum()

Example 44

def replace_field(f, mask):

"""Interpolates positions in field according to mask with a 2D cubic interpolator"""

lx, ly = f.shape

x, y = np.mgrid[0:lx, 0:ly]

C = CT_intp((x[~mask],y[~mask]),f[~mask], fill_value=0)

return C(x, y)

Example 45

def get_frame(self, i, j):

"""

Perform interpolation to produce the deformed window for correlation.

This function takes the previously set displacement and interpolates the image for these coordinates.

If the cubic interpolation method is chosen, the cubic interpolation of this API is use.

For the bilinear method the build in scipy method `map_coordinates `_ is used with *order* set to 1.

:param int i: first index in grid coordinates

:param int j: second index in grid coordinates

:returns: interpolated window for the grid coordinates i,j and the image set in initialization

"""

dws = self._shape[-1]

offset_x, offset_y = np.mgrid[-dws/2+0.5:dws/2+0.5, -dws/2+0.5:dws/2+0.5]

gx, gy = np.mgrid[0:dws, 0:dws]

grid_x = gx + self._distance*i

grid_y = gy + self._distance*j

ptsax = (grid_x + self._u_disp(i, j, offset_x, offset_y)).ravel()

ptsay = (grid_y + self._v_disp(i, j, offset_x, offset_y)).ravel()

p, q = self._shape[-2:]

if self._ipmethod == 'bilinear':

return map_coordinates(self._frame, [ptsax, ptsay], order=1).reshape(p, q)

if self._ipmethod == 'cubic':

return self._cube_ip.interpolate(ptsax, ptsay).reshape(p, q)

Example 46

def makeMTX(spat_coeffs, radial_filter, kr_IDX, viz_order=None, stepsize_deg=1):

"""Returns a plane wave decomposition over a full sphere

Parameters

----------

spat_coeffs : array_like

Spatial fourier coefficients

radial_filter : array_like

Modal radial filters

kr_IDX : int

Index of kr to be computed

viz_order : int, optional

Order of the spatial fourier transform [Default: Highest available]

stepsize_deg : float, optional

Integer Factor to increase the resolution. [Default: 1]

Returns

-------

mtxData : array_like

Plane wave decomposition (frequency domain)

Note

----

The file generates a Matrix of 181x360 pixels for the

visualisation with visualize3D() in 1[deg] Steps (65160 plane waves).

"""

if not viz_order:

viz_order = _np.int(_np.ceil(_np.sqrt(spat_coeffs.shape[0]) - 1))

angles = _np.mgrid[0:360:stepsize_deg, 0:181:stepsize_deg].reshape((2, -1)) * _np.pi / 180

Y = plane_wave_decomp(viz_order, angles, spat_coeffs[:, kr_IDX], radial_filter[:, kr_IDX])

return Y.reshape((360, -1)).T # Return pwd data as [181, 360] matrix

Example 47

def plot3Dgrid(rows, cols, viz_data, style, normalize=True, title=None):

if len(viz_data) > rows * cols:

raise ValueError('Number of plot data is more than the specified rows and columns.')

fig = tools.make_subplots(rows, cols, specs=[[{'is_3d': True}] * cols] * rows, print_grid=False)

if style == 'flat':

layout_3D = dict(

xaxis=dict(range=[0, 360]),

yaxis=dict(range=[0, 181]),

aspectmode='manual',

aspectratio=dict(x=3.6, y=1.81, z=1)

)

else:

layout_3D = dict(

xaxis=dict(range=[-1, 1]),

yaxis=dict(range=[-1, 1]),

zaxis=dict(range=[-1, 1]),

aspectmode='cube'

)

rows, cols = _np.mgrid[1:rows + 1, 1: cols + 1]

rows = rows.flatten()

cols = cols.flatten()

for IDX in range(0, len(viz_data)):

cur_row = rows[IDX]

cur_col = cols[IDX]

fig.append_trace(genVisual(viz_data[IDX], style=style, normalize=normalize), cur_row, cur_col)

fig.layout['scene' + str(IDX + 1)].update(layout_3D)

if title is not None:

fig.layout.update(title=title)

filename = title + '.html'

else:

filename = str(current_time()) + '.html'

if env_info() == 'jupyter_notebook':

plotly_off.iplot(fig)

else:

plotly_off.plot(fig, filename=filename)

Example 48

def gk(c1,r1,c2,r2):

# First, create X and Y arrays indicating distance to the boundaries of the paintbrush

# In this current context, im is the ordinal number of pixels (64 typically)

sigma = 0.3

im = 64

x = np.repeat([np.concatenate([np.mgrid[-c1:0],np.zeros(c2-c1),np.mgrid[1:1+im-c2]])],im,axis=0)

y = np.repeat(np.vstack(np.concatenate([np.mgrid[-r1:0],np.zeros(r2-r1),np.mgrid[1:1+im-r2]])),im,axis=1)

g = np.exp(-(x**2/float(im)+y**2/float(im))/(2*sigma**2))

return np.repeat([g],3,axis=0) # remove the 3 if you want to apply this to mask rather than an RGB channel

# This function reduces the likelihood of a change based on how close each individual pixel is to a maximal value.

# Consider conditioning this based on the gK value and the requested color. I.E. instead of just a flat distance from 128,

# have it be a difference from the expected color at a given location. This could also be used to "weight" the image towards staying the same.

Example 49

def fcn_FDEM_InductionSpherePlaneWidget(xtx,ytx,ztx,m,orient,x0,y0,z0,a,sig,mur,xrx,yrx,zrx,logf,Comp,Phase):

sig = 10**sig

f = 10**logf

fvec = np.logspace(0,8,41)

xmin, xmax, dx, ymin, ymax, dy = -30., 30., 0.3, -30., 30., 0.4

X,Y = np.mgrid[xmin:xmax+dx:dx, ymin:ymax+dy:dy]

X = np.transpose(X)

Y = np.transpose(Y)

Obj = SphereFEM(m,orient,xtx,ytx,ztx)

Hx,Hy,Hz,Habs = Obj.fcn_ComputeFrequencyResponse(f,sig,mur,a,x0,y0,z0,X,Y,zrx)

Hxi,Hyi,Hzi,Habsi = Obj.fcn_ComputeFrequencyResponse(fvec,sig,mur,a,x0,y0,z0,xrx,yrx,zrx)

fig1 = plt.figure(figsize=(17,6))

Ax1 = fig1.add_axes([0.04,0,0.43,1])

Ax2 = fig1.add_axes([0.6,0,0.4,1])

if Comp == 'x':

Ax1 = plotAnomalyXYplane(Ax1,f,X,Y,ztx,Hx,Comp,Phase)

Ax1 = plotPlaceTxRxSphereXY(Ax1,xtx,ytx,xrx,yrx,x0,y0,a)

Ax2 = plotResponseFEM(Ax2,f,fvec,Hxi,Comp)

elif Comp == 'y':

Ax1 = plotAnomalyXYplane(Ax1,f,X,Y,ztx,Hy,Comp,Phase)

Ax1 = plotPlaceTxRxSphereXY(Ax1,xtx,ytx,xrx,yrx,x0,y0,a)

Ax2 = plotResponseFEM(Ax2,f,fvec,Hyi,Comp)

elif Comp == 'z':

Ax1 = plotAnomalyXYplane(Ax1,f,X,Y,ztx,Hz,Comp,Phase)

Ax1 = plotPlaceTxRxSphereXY(Ax1,xtx,ytx,xrx,yrx,x0,y0,a)

Ax2 = plotResponseFEM(Ax2,f,fvec,Hzi,Comp)

elif Comp == 'abs':

Ax1 = plotAnomalyXYplane(Ax1,f,X,Y,ztx,Habs,Comp,Phase)

Ax1 = plotPlaceTxRxSphereXY(Ax1,xtx,ytx,xrx,yrx,x0,y0,a)

Ax2 = plotResponseFEM(Ax2,f,fvec,Habsi,Comp)

plt.show(fig1)

Example 50

def rebin(a, newshape):

"""Rebin an array to a new shape."""

assert len(a.shape) == len(newshape)

slices = [slice(0, old, float(old) / new)

for old, new in zip(a.shape, newshape)]

coordinates = np.mgrid[slices]

indices = coordinates.astype('i')

return a[tuple(indices)]

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

python case when用法_Python numpy.mgrid() 使用实例 的相关文章

  • 解决unity的the type or namespace name 'ui' does not exist in the namespace 'unityengine'问题,非忘记引用导致

    我在导入某个插件后引起了这个问题 当然 并不是忘记写UnityEngine UI引起的 解决后才想着来记录一下 因此没有报错时的截图 不过问题表现为所有的UnityEngine UI的引用都报标题的错误 之前以为是UIElements的原因
  • ROS机器人建模与仿真(一)--URDF机器人建模

    前言 经过ROS的保姆级教程之后 相信大家对ROS应该有一个基本的认识了 关于各种工具的使用其实等到真正有所需求之后再去查找即可 roswiki始终是最好的最一手的信息来源 本系列的博客主要用来记录如何让在ROS的环境下进行机器人的建模与仿
  • Oracle,PL/SQL常用函数列表

    常用字符函数 函数 描述 LOWER char 将字符串表达式char中的所有大写字母转换为小写字母 UPPER char 将字符串表达式char中的所有小写字母转换为大写字母 INITCAP char 首字母转换成大写 SUBSTR ch
  • 模板方法模式与策略模式的区别

    原文 http www tuicool com articles 6JBN7z3 如果你还不了解模板方法模式和策略模式 请先阅读 策略模式 strategy 和 模板方法模式 模板方法模式的主要思想 定义一个算法流程 将一些特定步骤的具体实
  • 安利一个快速后台开发框架(ruoyi)

    http www ruoyi vip
  • 19年11月最新Win10 LTSC系统封装部署教程(超详细)

    写在前面 在本着认真负责 不交差 不敷衍的情况下 尽可能详细的描述整个过程 本文的经验方法大多数来自于网上朋友们的无私分享 在实际操作中遇到的坑我会在下文中进行标注 有任何意见或疑问欢迎留言讨论 感谢平台提供一个舒适的交流环境 v 0 15
  • (差分)曼彻斯特编码及NRZ

    曼彻斯特编码 Manchester Encoding 也叫做相位 编码 Phase Encode 简写PE 是一个同步时钟编码技术 被 物理层使用来编码一个同步位流的时钟和数据 它在 以太网媒介系统中的应用属于数据通信中的两种位同步方法里的
  • 【const】与指针、数组、结构体的使用

    目录 指针与数组 指针与const const const的作用 const int 与 int const const的错误使用 const char arr和char arr 10 的区别 结构体与const 指针与数组 指针可访问数组
  • vue3.0 PC端自适应不同分辨率电脑

    使用rem单位去做页面的适配 先来了解一下什么是rem rem是CSS3新增的一个相对单位 root em 根em 我们可以通过去设定X rem Y px x和y为自定义数值 如图设定1rem 10px 第一步 安装相应的依赖为我们自动将全
  • Masked Autoencoders Are Scalable Vision Learners(屏蔽自编码器是可扩展的视觉学习器)--文献翻译和笔记

    论文链接 2111 06377 Masked Autoencoders Are Scalable Vision Learners arxiv org 论文标题 Masked Autoencoders Are Scalable Vision
  • Entity Framework中使用SQLite的一些问题

    SQLite数据相当的不错 我目前在一些小型网站都用这个数据库来取代Access 下面就是关于在ASP NET的Entity Framework当中使用SQLite的一些经验和一些小问题的解决办法 想要在ASP NET中使用SQLite 首
  • js md5 解密_JS逆向小结(开始)

    最近想研究一下JS逆向的相关知识 先分享一篇大佬的小总结 明天正式开搞 1 我的逆向分析流程 对于js逆向来说 基本遵循一个简单的流程 我是先进行刷新网页进行抓包 找到自己的目标请求 大部分时候是一个 但是有时回事多个 先前返回的数据可能在
  • 【Linux】Linux常用快捷键

    前言 由于需要 梳理了一下常用的快捷键 以便忘记时查找 Linux系统快捷键 Bash解释器 1 Tab键 补齐命令 补齐路径 显示当前目录下的所有目录 2 清屏 clear Ctrl L L 大小写均可 3 中断 暂停进程 ctrl c
  • bmFont的使用方法

    1 打开 bmfont exe 2 字体设置 选择 Font settings 在这里我们选择微软雅黑 微软雅黑支持中文 字符编码 选择 Unicode 你还可以在 Font settings 对话框里进行字体大小 字体平滑程度等设置 3
  • Qt开发教程:实现全屏显示

    Qt开发教程 实现全屏显示 在Qt开发中 有时候需要让程序窗口全屏显示 以提升用户体验 本教程将介绍如何使用Qt实现全屏显示 设置窗口属性 在Qt中 我们可以通过设置窗口属性来控制窗口显示方式 在此之前 我们需要在 pro文件中添加以下代码

随机推荐

  • IDEA中用java建库、建表、插入、打印的方法

    数据库 mysql 连接方式 jdbc 文件组织结构 create db java package jdbc import java sql public class create db 建立数据库连接 并创建一个新数据库 按照传入的参数
  • Sourcetree连接远程仓库需要登陆,但是一直登陆不上的问题解决方法

    授权类型选用 基础 只需要登陆你用户名和密码 将https作为首选协议 连接成功后可改ssh
  • 机器学习大作业---文献综述

    机器学习大作业 文献综述 机器学习技术在材料化学预测方面最新应用综述 怎么写综述 摘抄自https www zhihu com question 303494762 answer 555476024 文献综述和综述论文是有区别的 文献综述可
  • 飞天平台安全相关

    飞天平台安全相关 1 capability机制 用户的身份认证 authentication 是基于密钥机制的 用户对资源的访问控制是基于权能 capability 机制进行授权 authorization 的 capability是用于访
  • c++入门系列(二)之标识符

    什么是标识符 标识符是指用来标识某个实体的一个符号 在不同的应用环境下有不用的含义 这句话相当于废话 在计算机编程语言中 标识符是用户编程时使用的名字 用于给变量 常量 函数 语句块等命名 以建立起名称与使用之间的关系 通俗的话说 标识符是
  • 模式识别课程:目标检测②传统检测算法

    title 目标检测 传统检测算法 目标检测实验报告 检测所用软硬件 云服务器 硬件 macOS或者windows电脑 软件 pycharm 生成的测试集 云服务器 滴滴云 https www didiyun com activity ht
  • ##清理memcached缓存

    清理memcached缓存 连接 telnet 127 0 0 1 8088 flush all quit 重启下脚本就可以生效了 ps ef grep mem kill 进程PID 重启脚本 etc init d memcached st
  • 时序区间预测

    文章目录 效果一览 文章概述 部分源码 参考资料 效果一览 文章概述 基于高斯过程回归 GPR 时间序列区间预测 matlab代码 单变量输入模型 基于高斯过程回归 GPR 时间序列区间预测 matiab代码 单变量输入模型 评价指标包括
  • 2023年有哪些值得推荐的深度学习书?

    深度学习指的是用一种特定的方法来解决一些机器学习的问题 这种方法的中心思想是 基于一系列的离散的层 layer 构建机器学习算法 如果将这些层 垂直堆叠 就说这个结果是有深度 depth 的 或者说算法是有深度的 构建深度网络的方法有很多种
  • Lombok 注解及实例大全

    Project Lombok是一个java库 它可以自动插入到编辑器和构建工具中 为Java增添趣味 永远不要再编写另一个getter或equals方法 只要有一个注释 你的类就有一个功能齐全的构建器 自动化你的日志变量 等等 val 用在
  • Android 动画---布局动画(三)

    布局动画就是在给ViewGroup增加子View的动画过度效果 最简单的布局动画就是在ViewGroup的XML中打开一个系统默认的效果 android animateLayoutChanges true 还可以通过LayoutAnimat
  • 考研政治——学习心得

    政治教材万不可使用往年资料 因为周年纪念对考试影响非常大 有的知识点往年是重点 今年就不是了 文章目录 选择题 大题 选择题 练习时 单选1分钟1个 多选2分钟1个 单选题尽量不要错 多选题保持在7个以内 复习资料 多选一 杨娅娟考研政治刷
  • 【MAC】Mac下配置perl的DBD::MySQL模块

    1 概述 pt variable advisor是pt工具集的一个子工具 主要用来诊断你的参数设置是否合理 我想运行这个结果报错如下 base lcc lcc percona toolkit 3 2 0 bin pt variable ad
  • Clion this file does not belong to any project target问题解决方案

    如题
  • Unicode CString 转char数组

    2019独角兽企业重金招聘Python工程师标准 gt gt gt CString cs T 测试字符串 int n cs GetLength 获取str的字符数 int len WideCharToMultiByte CP ACP 0 c
  • 【C++】21年精通C++之类与对象(中)——类的默认成员函数

    目录 前言 正文 构造函数 析构函数 拷贝构造函数 赋值运算符重载 普通对象和const对象取地址 自增自减操作符重载 const成员 实现一个简单的日期类 结语 前言 今天这篇博客的内容主要是关于类和对象中类的6个默认成员函数 希望能对大
  • 安装ORB_SLAM2

    安装ORB SLAM2 参考链接https github com Ewenwan ORB SLAM2 SSD Semantic 安装Pangolin 要安装0 6版本 参考链接https blog csdn net Dbojuedzw ar
  • UFS系列八:RPMB(Replay Protected Memory Block)

    转载 蛋蛋读UFS之八 RPMB 在UFS里 有这么一个LU 主机往该LU写数据时 UFS设备会校验数据的合法性 只有特定的主机才能写入 同时 主机在读取数据时 也提供了校验机制 保证了主机读取到的数据是从该LU上读的数据 而不是攻击者伪造
  • JavaSE 计算机基础知识 Java语言概述 JDK的下载,安装 HelloWorld案例 环境变量的配置 注释 关键字 标识符

    JavaSE 第一章 本章内容 计算机基础知识 计算机 计算机硬件 计算机软件 软件开发 计算机语言 人机交互方式 键盘功能键及快捷键介绍 常用的DOS命令 Java语言概述 JDK的下载 安装 HelloWorld案例 环境变量的配置 注
  • python case when用法_Python numpy.mgrid() 使用实例

    The following are code examples for showing how to use They are extracted from open source Python projects You can vote