当前位置: 首页 > news >正文

怎么做网站的需求怎么做flash网站

怎么做网站的需求,怎么做flash网站,备案老域名,网站改版升级通知目录 一.简介 1.双目视觉 2 YOLOv5 二.双目准备 1双目矫正 2.测距部分代码和函数 三.yolov5部分代码代码展示 效果展示 一.简介 1.双目视觉 双目视觉是通过两个摄像机同时拍摄同一场景#xff0c;通过计算两幅图像的差异来获取深度信息的一种计算机视觉技术。在双目视…目录 一.简介 1.双目视觉 2 YOLOv5 二.双目准备 1双目矫正 2.测距部分代码和函数 三.yolov5部分代码代码展示 效果展示 一.简介 1.双目视觉 双目视觉是通过两个摄像机同时拍摄同一场景通过计算两幅图像的差异来获取深度信息的一种计算机视觉技术。在双目视觉中两个摄像机的成像位置和角度是预先确定的它们之间的距离被称为基线通过计算两个相机拍摄的图像中对应像素点的视差可以计算出每个像素点的深度。 双目视觉的主要优势在于其可以通过将两个视角的信息进行比较来消除图像中的噪声和误差从而获得更准确的深度信息。此外在近距离测量和物体检测等领域中都有广泛的应用。 双目视觉的基本流程包括以下几个步骤 相机标定确定相机的内外参数包括焦距、畸变系数、旋转和平移矩阵等以及两个摄像机之间的基线长度和相对位置关系。 图像获取使用两个摄像机同时拍摄同一个场景获取两幅图像。 特征提取从两幅图像中提取特征点或者特征区域例如SIFT或SURF算法生成特征点集合。 特征匹配通过比较两个图像中的特征点集合找出相同的特征建立对应关系。 视差计算根据特征点间的视差大小结合相机标定参数计算出每个像素点的深度值。 深度图生成将深度信息转换为灰度图像生成深度图。 虽然双目视觉技术能够提供准确的深度信息并可以运用在机器人导航、三维重建等领域但是该技术还面临一些挑战例如光照变化、遮挡和反射等问题这些问题可能会影响特征提取和匹配从而影响深度信息的准确性。 2 YOLOv5 YOLOv5是一种目标检测算法由美国加州大学伯克利分校的研究团队开发。与其前身YOLOv4相比YOLOv5在速度和检测精度方面有了非常显著的提升。 YOLOv5的全称是You Only Look Once version 5意为“你只需要看一次”即可完成目标检测任务。它采用深度神经网络架构在单张图像上进行物体检测可以同时检测出多个物体并得到它们的位置、类别和置信度等信息具有高效、准确的特点。 YOLOv5的主要优势包括 1. 高速度相较于其前身YOLOv4YOLOv5平均检测速度提高了65%同时还具有更小的模型尺寸和更少的计算量。 2. 高检测精度通过采用新的网络架构和数据增强技术YOLOv5在检测精度方面取得了突破性的进展。 3. 简单易用相对于其他目标检测算法YOLOv5的代码量较小易于实现和调试能够应用于多种不同的应用场景。 目前YOLOv5已经被广泛应用于自动驾驶、智能安防、工业自动化等领域在实时物体检测和跟踪任务中具有广泛的应用前景。 二.双目准备 原理参考双目标定之张正友标定法数学原理详解matlab版-CSDN博客 棋盘格图片自提 链接https://pan.baidu.com/s/1W31fTtr6db8qgTevulWeMA  提取码ybca 二.双目准备 1双目矫正 打开Matlab 上方的工具栏APP找到图像处理和计算机视觉下的Stereo Camera Calibration工具打开并将分割后的图片导入 设置参数对于一般的相机选择2 Coefficients选项即可对于大视场相机则选择3 Coefficients选项。拉线删除误差较大的画面 获取参数 在matlab控制台分别输入 stereoParams.CameraParameters1.IntrinsicMatrix 和stereoParams.CameraParameters2.IntrinsicMatrix 获得左右相机的参数下边填写时请注意进行矩阵的转置 为了获取左相机的畸变系数:[k1, k2, p1, p2, k3]我们需要分别输入stereoParams.CameraParameters1.RadialDistortion 和 stereoParams.CameraParameters1.TangentialDistortion 分别输入 stereoParams.RotationOfCamera2 和 stereoParams 来获取双目的旋转矩阵和平移矩阵 将以上参数填写进stereoconfig.py文件里注意转置 import numpy as np# 双目相机参数 class stereoCamera(object):def __init__(self):# 左相机内参self.cam_matrix_left np.array([ [479.6018, -0.0769, 652.6060],[ 0, 478.0229, 352.3870],[ 0, 0, 1]])# 右相机内参self.cam_matrix_right np.array([ [489.9354, 0.2789, 641.6219],[ 0, 487.9356, 354.5612],[ 0, 0, 1]])# 左右相机畸变系数:[k1, k2, p1, p2, k3]self.distortion_l np.array([[-0.0791, 0.0309, -0.0009, -0.0004, -0.0091]])self.distortion_r np.array([[-0.1153, 0.1021, -0.0011, -0.0005, -0.0459]])# 旋转矩阵self.R np.array([ [1.0000, 0.0005, -0.0184],[-0.0005, 1.0000, 0.0001],[ 0.0184, -0.0001, 1.0000] ])# 平移矩阵self.T np.array([[121.4655], [0.2118], [0.5950]])# 焦距self.focal_length 749.402 # 默认值一般取立体校正后的重投影矩阵Q中的 Q[2,3]# 基线距离self.baseline 121.4655 # 单位mm 为平移向量的第一个参数取绝对值 2.测距部分代码和函数 import sys import cv2 import numpy as np import stereoconfig# 预处理 def preprocess(img1, img2):# 彩色图-灰度图if (img1.ndim 3): # 判断是否为三维数组img1 cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY) # 通过OpenCV加载的图像通道顺序是BGRif (img2.ndim 3):img2 cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)# 直方图均衡img1 cv2.equalizeHist(img1)img2 cv2.equalizeHist(img2)return img1, img2# 消除畸变 def undistortion(image, camera_matrix, dist_coeff):undistortion_image cv2.undistort(image, camera_matrix, dist_coeff)return undistortion_image# 获取畸变校正和立体校正的映射变换矩阵、重投影矩阵 # paramconfig是一个类存储着双目标定的参数:config stereoconfig.stereoCamera() def getRectifyTransform(height, width, config):# 读取内参和外参left_K config.cam_matrix_leftright_K config.cam_matrix_rightleft_distortion config.distortion_lright_distortion config.distortion_rR config.RT config.T# 计算校正变换R1, R2, P1, P2, Q, roi1, roi2 cv2.stereoRectify(left_K, left_distortion, right_K, right_distortion,(width, height), R, T, alpha0)map1x, map1y cv2.initUndistortRectifyMap(left_K, left_distortion, R1, P1, (width, height), cv2.CV_32FC1)map2x, map2y cv2.initUndistortRectifyMap(right_K, right_distortion, R2, P2, (width, height), cv2.CV_32FC1)return map1x, map1y, map2x, map2y, Q# 畸变校正和立体校正 def rectifyImage(image1, image2, map1x, map1y, map2x, map2y):rectifyed_img1 cv2.remap(image1, map1x, map1y, cv2.INTER_AREA)rectifyed_img2 cv2.remap(image2, map2x, map2y, cv2.INTER_AREA)return rectifyed_img1, rectifyed_img2# 立体校正检验----画线 def draw_line(image1, image2):# 建立输出图像height max(image1.shape[0], image2.shape[0])width image1.shape[1] image2.shape[1]output np.zeros((height, width, 3), dtypenp.uint8)output[0:image1.shape[0], 0:image1.shape[1]] image1output[0:image2.shape[0], image1.shape[1]:] image2# 绘制等间距平行线line_interval 50 # 直线间隔50for k in range(height // line_interval):cv2.line(output, (0, line_interval * (k 1)), (2 * width, line_interval * (k 1)), (0, 255, 0), thickness2,lineTypecv2.LINE_AA)return output# 视差计算 def stereoMatchSGBM(left_image, right_image, down_scaleFalse):# SGBM匹配参数设置if left_image.ndim 2:img_channels 1else:img_channels 3blockSize 3paraml {minDisparity: 0,numDisparities: 64,blockSize: blockSize,P1: 8 * img_channels * blockSize ** 2,P2: 32 * img_channels * blockSize ** 2,disp12MaxDiff: 1,preFilterCap: 63,uniquenessRatio: 15,speckleWindowSize: 100,speckleRange: 1,mode: cv2.STEREO_SGBM_MODE_SGBM_3WAY}# 构建SGBM对象left_matcher cv2.StereoSGBM_create(**paraml)paramr paramlparamr[minDisparity] -paraml[numDisparities]right_matcher cv2.StereoSGBM_create(**paramr)# 计算视差图size (left_image.shape[1], left_image.shape[0])if down_scale False:disparity_left left_matcher.compute(left_image, right_image)disparity_right right_matcher.compute(right_image, left_image)else:left_image_down cv2.pyrDown(left_image)right_image_down cv2.pyrDown(right_image)factor left_image.shape[1] / left_image_down.shape[1]disparity_left_half left_matcher.compute(left_image_down, right_image_down)disparity_right_half right_matcher.compute(right_image_down, left_image_down)disparity_left cv2.resize(disparity_left_half, size, interpolationcv2.INTER_AREA)disparity_right cv2.resize(disparity_right_half, size, interpolationcv2.INTER_AREA)disparity_left factor * disparity_leftdisparity_right factor * disparity_right# 真实视差因为SGBM算法得到的视差是×16的trueDisp_left disparity_left.astype(np.float32) / 16.trueDisp_right disparity_right.astype(np.float32) / 16.return trueDisp_left, trueDisp_rightdef getDepthMapWithQ(disparityMap: np.ndarray, Q: np.ndarray) - np.ndarray:points_3d cv2.reprojectImageTo3D(disparityMap, Q) # points_3d 是一个三维的数组前面两个是宽和高第三维是一个xyz的坐标points points_3d[:, :, 0:3]depthMap points_3d[:, :, 2] # 索引三维数组的最后一维就是深度信息reset_index np.where(np.logical_or(depthMap 0.0, depthMap 65535.0))depthMap[reset_index] 0return depthMap.astype(np.float32)if __name__ __main__:# 读取图片cap cv2.VideoCapture(0)cap.set(3, 1280)cap.set(4, 480) # 打开并设置摄像头while True:ret, frame cap.read()iml frame[0:480, 0:640]imr frame[0:480, 640:1280] # 分割双目图像if (iml is None) or (imr is None):print(Error: Images are empty, please check your images path!)sys.exit(0)height, width iml.shape[0:2] # 对图像进行切片操作前面两位是高和宽iml_, imr_ preprocess(iml, imr) # 预处理一般可以削弱光照不均的影响不做也可以# 读取相机内参和外参# 使用之前先将标定得到的内外参数填写到stereoconfig.py中的StereoCamera类中config stereoconfig.stereoCamera()# print(config.cam_matrix_left)# 立体校正map1x, map1y, map2x, map2y, Q getRectifyTransform(height, width, config) # 获取用于畸变校正和立体校正的映射矩阵以及用于计算像素空间坐标的重投影矩阵iml_rectified, imr_rectified rectifyImage(iml, imr, map1x, map1y, map2x, map2y)# print(Q)# 绘制等间距平行线检查立体校正的效果line draw_line(iml_rectified, imr_rectified)cv2.imwrite(check_rectification.png, line)# 立体匹配disp, _ stereoMatchSGBM(iml_rectified, imr_rectified, False) # 这里传入的是经立体校正的图像cv2.imwrite(disaprity.png, disp * 4)# fx config.cam_matrix_left[0, 0]# fy fx# cx config.cam_matrix_left[0, 2]# cy config.cam_matrix_left[1, 2]# print(fx, fy, cx, cy)# 计算像素点的3D坐标左相机坐标系下points_3d cv2.reprojectImageTo3D(disp, Q) # 参数中的Q就是由getRectifyTransform()函数得到的重投影矩阵# 设置想要检测的像素点坐标x,yx 120y 360cv2.circle(iml, (x, y), 5, (0, 0, 255), -1)# x1 points_3d[y, x] # 索引 (y, x) 对应的是三维坐标 (x1, y1, z1)# print(x1)print(x:, points_3d[int(y), int(x), 0], y:, points_3d[int(y), int(x), 1], z:,points_3d[int(y), int(x), 2]) # 得出像素点的三维坐标单位mmprint(distance:, (points_3d[int(y), int(x), 0] ** 2 points_3d[int(y), int(x), 1] ** 2 points_3d[int(y), int(x), 2] ** 2) ** 0.5) # 计算距离单位mmcv2.namedWindow(disparity, 0)cv2.imshow(disparity, iml)# cv2.setMouseCallback(disparity, onMouse, 0)# 等待用户按键如果按下 q 键或者 Esc 键则退出循环c cv2.waitKey(1) 0xFFif c 27 or c ord(q):break# 释放视频对象并关闭窗口cap.release()cv2.destroyAllWindows() 三.yolov5部分代码代码展示 # 读取相机内参和外参config stereoconfig_040_2.stereoCamera()# 立体校正map1x, map1y, map2x, map2y, Q getRectifyTransform(720, 1280, config) # 获取用于畸变校正和立体校正的映射矩阵以及用于计算像素空间坐标的重投影矩阵for path, img, im0s, vid_cap in dataset:img torch.from_numpy(img).to(device)img img.half() if half else img.float() # uint8 to fp16/32img / 255.0 # 0 - 255 to 0.0 - 1.0if img.ndimension() 3:img img.unsqueeze(0)# Inferencet1 time_synchronized()pred model(img, augmentopt.augment)[0]# Apply NMSpred non_max_suppression(pred, opt.conf_thres, opt.iou_thres, classesopt.classes, agnosticopt.agnostic_nms)t2 time_synchronized()# Apply Classifierif classify:pred apply_classifier(pred, modelc, img, im0s)# Process detectionsfor i, det in enumerate(pred): # detections per imageif webcam: # batch_size 1p, s, im0, frame path[i], %g: % i, im0s[i].copy(), dataset.countelse:p, s, im0, frame path, , im0s, getattr(dataset, frame, 0)################################stereo codefps_set 10 #setting the frameif(accel_frame % fps_set 0):#t3 time.time() # stereo time start 0.510s#string #thread threading.Thread(target mythread,args ((config,im0,map1x, map1y, map2x, map2y,Q)) )thread MyThread(stereo_threading,args (config,im0,map1x, map1y, map2x, map2y,Q))thread.start()#if(accel_frame % fps_set 0):# thread.join()#points_3d thread.get_result()print()print(threading.active_count()) #获取已激活的线程数print(threading.enumerate()) # see the thread list查看所有线程信息一个_MainThread(...) 带多个 Thread(...)print()print(############## Frame is %d !################## %accel_frame)p Path(p) # to Pathif webcam:save_stream_path str(save_stream_dir / stream0.mp4) # save streams pathelse: save_path str(save_dir / p.name) # img.jpgtxt_path str(save_dir / labels / p.stem) ( if dataset.mode image else f_{frame}) # img.txts %gx%g % img.shape[2:] # print string#print(txt_path is %s%txt_path)gn torch.tensor(im0.shape)[[1, 0, 1, 0]] # normalization gain whwhif len(det):# Rescale boxes from img_size to im0 sizedet[:, :4] scale_coords(img.shape[2:], det[:, :4], im0.shape).round()# Print resultsfor c in det[:, -1].unique():n (det[:, -1] c).sum() # detections per classs f{n} {names[int(c)]} {s * (n 1)} , # add to string 本项目不开源需要的私聊 谢谢
http://www.sadfv.cn/news/137852/

相关文章:

  • 企业网站策划书下载济南网站建设培训学校
  • 个人怎么建立网站吗伊春网站制作
  • 航运网站建设计划书网站被加入js广告
  • 如何更换网站空间杭州哪里做网站好
  • 做网站有前景吗国外网站建设素材
  • 高端网站建设设计邯郸信息网平台
  • 郑州制作个人网站网站怎么添加关键词 好让百度收入_ 现在网站用的是模板做的
  • 网站错误代码301上海广告公司
  • 做爰全过程网站制作一份网站建设的简要任务执行书
  • 长宁网站建设制作小红书怎么推广自己的产品
  • 创新的网站建设大连凯杰建设有限公司官方网站
  • 网站开发需要多少钱推荐黑科技网站
  • 简单网站开发项目实例搭建一个影视网站
  • 免费申请com网站wordpress子目录404
  • 吉安做网站公司高校网站推广方案
  • 杭州的网站建设公司济南网站制作推广
  • 长宁移动网站建设住宅城乡建设部门户网站
  • 网站关键词设置技巧长沙官网制作
  • 网站开发成本如何入账智慧团建网页电脑版登录网站
  • 网站首页快照应该怎么南宁建站服务公司
  • 中小型门户网站企业网站排行
  • 网站被挂马做js跳转wordpress 页面美化
  • 物流网站 源码国外网站建设软件
  • 做网站首页ps分辨率多少五合一小程序网站
  • 广州网站建设十年乐云seo腕表网
  • weex做网站wordpress怎样搭建
  • 网站开发技术期中试题wordpress编辑器增强代码
  • php网站做退出的代码西安观止软件科技有限公司
  • 改进网站建设做网站的qq兼职
  • 深圳网站设计公司如何网站常用字号