jquery 视差滚动_带有jQuery的视差滑块

jquery 视差滚动

jquery 视差滚动

parallax_slider

Happy New Year! We will kick start 2011 with a vibrant image slider tutorial. We will make use of the parallax principle to move different backgrounds when we slide to an image in order to create some nice perspective. This will give a great depth to the whole slider when it’s in motion.

新年快乐! 我们将从充满活力的图像滑块教程开始2011年。 当我们滑动到图像上时,我们将使用视差原理移动不同的背景,以创建漂亮的透视图。 当移动时,这将为整个滑块提供很大的深度。

The wonderful images are taken from Tetsumo’s Flickr Photo Stream: http://www.flickr.com/photos/tetsumo/

精彩的图像来自Tetsumo的Flickr Photo Stream: http ://www.flickr.com/photos/tetsumo/

So, let’s start!

所以,让我们开始吧!

标记 (The Markup)

The HTML structure is going to consist of a main container with the class “pxs_container”. We will add a wrapper for the three different backgrounds which we will animate differently to create the parallax. The background images will have some transparency since we want to see them moving on top of each other.

HTML结构将由一个具有“ pxs_container”类的主容器组成。 我们将为三个不同的背景添加一个包装,然后对其进行不同的动画处理以创建视差。 背景图像将具有一定的透明度,因为我们希望看到它们彼此重叠。

We will also add a loading element and the two unordered lists for the full images and the thumbnails. Further, we will add the navigation elements.

我们还将为整个图像和缩略图添加一个loading元素和两个无序列表。 此外,我们将添加导航元素。


<div id="pxs_container" class="pxs_container">
	<div class="pxs_bg">
		<div class="pxs_bg1"></div>
		<div class="pxs_bg2"></div>
		<div class="pxs_bg3"></div>
	</div>
	<div class="pxs_loading">Loading images...</div>
	<div class="pxs_slider_wrapper">
		<ul class="pxs_slider">
			<li><img src="images/1.jpg" alt="First Image" /></li>
			<li><img src="images/2.jpg" alt="Second Image" /></li>
			...
		</ul>
		<div class="pxs_navigation">
			<span class="pxs_next"></span>
			<span class="pxs_prev"></span>
		</div>
		<ul class="pxs_thumbnails">
			<li><img src="images/thumbs/1.jpg" alt="First Image" /></li>
			<li><img src="images/thumbs/2.jpg" alt="Second Image" /></li>
			...
		</ul>
	</div>
</div>

Now, let’s take a look at the style.

现在,让我们看一下样式。

CSS (The CSS)

We will start with the main container. Since we will use the whole page for the width of the slider, we will set it to 100%. It will be of position relative because we will set all the element inside to

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
视差是指相机左右两个摄像头拍摄同一场景时,由于视角不同而导致的像素位移差异。NCC(Normalized Cross Correlation)视差匹配是一种常用的计算视差的方法之一。下面是在Python中实现NCC视差匹配计算视差图的步骤: 1. 读取左右两个摄像头拍摄的图像。 2. 对图像进行预处理,包括去噪、灰度化、归一化等。 3. 定义一个窗口大小,遍历左图像的每个像素点,在右图像中搜索与该像素点最相似的像素点。相似度可以通过计算两个窗口的NCC系数来得到。 4. 根据计算出的相似度,确定该像素点的视差值。 5. 对所有像素点都进行相似度计算和视差值确定,得到最终的视差图。 下面是一段Python代码示例,实现了NCC视差匹配计算视差图的功能: ```python import cv2 import numpy as np # 读取左右两张图像 imgL = cv2.imread('left.png', 0) imgR = cv2.imread('right.png', 0) # 图像预处理 imgL = cv2.GaussianBlur(imgL, (5, 5), 0) imgR = cv2.GaussianBlur(imgR, (5, 5), 0) imgL = cv2.normalize(imgL, None, 0, 255, cv2.NORM_MINMAX) imgR = cv2.normalize(imgR, None, 0, 255, cv2.NORM_MINMAX) # 定义窗口大小和搜索范围 winSize = 5 searchRange = 50 # 初始化视差图 disparity = np.zeros_like(imgL) # 遍历左图像的每个像素点 for i in range(winSize, imgL.shape[0] - winSize): for j in range(winSize, imgL.shape[1] - winSize): # 定义左图像窗口 leftWin = imgL[i - winSize:i + winSize + 1, j - winSize:j + winSize + 1] # 初始化最大相似度和视差值 maxCorr = -1 disp = 0 # 在右图像中搜索与左图像窗口最相似的窗口 for k in range(j - searchRange, j + searchRange): if k < winSize or k >= imgR.shape[1] - winSize: continue rightWin = imgR[i - winSize:i + winSize + 1, k - winSize:k + winSize + 1] corr = np.sum(leftWin * rightWin) / np.sqrt(np.sum(leftWin ** 2) * np.sum(rightWin ** 2)) if corr > maxCorr: maxCorr = corr disp = j - k # 将视差值保存到视差图中 disparity[i, j] = disp # 显示视差图 cv2.imshow('disparity', disparity) cv2.waitKey(0) cv2.destroyAllWindows() ``` 注意,此代码示例仅作为参考,实际应用中还需要根据具体情况进行调整和优化。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值