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

做网站编程需要学什么软件二次开发是什么意思

做网站编程需要学什么软件,二次开发是什么意思,邢台宇鹏网站建设,创建网站数据库利用opencv#xff0c;使用边缘检测、全局变化梯度阈值过滤、算子角度过滤、HLS阈值过滤的方法进行车道线分割检测#xff0c;综合多种阈值过滤进行检测提高检测精度。 1.利用cv2.Sobel()计算图像梯度(边缘检测) import cv2 import numpy as np import matplotlib.pyplot a…利用opencv使用边缘检测、全局变化梯度阈值过滤、算子角度过滤、HLS阈值过滤的方法进行车道线分割检测综合多种阈值过滤进行检测提高检测精度。 1.利用cv2.Sobel()计算图像梯度(边缘检测) import cv2 import numpy as np import matplotlib.pyplot as plt import ossrc np.float32([[200, 720], [1100, 720], [595, 450], [685, 450]]) #src 输入图像 dst np.float32([[300, 720], [980, 720], [300, 0], [980, 0]]) #dst 输出图像 m_inv cv2.getPerspectiveTransform(dst, src) m cv2.getPerspectiveTransform(src, dst)# 利用cv2.Sobel()计算图像梯度(边缘检测) def abs_sobel_threshold(img, orientx, thresh_min40, thresh_max255):###利用Xy方向上sobel二值化图像######gray cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)if orient x:abs_sobel np.absolute(cv2.Sobel(gray, cv2.CV_64F, 1, 0))if orient y:########参考求x方向的sobel算子计算y方向上sobel算子####################填空1 1行代码########################abs_sobel np.absolute(cv2.Sobel(gray, cv2.CV_64F, 0, 1))#############填空1 1行代码########################scaled_sobel np.uint8(255 * abs_sobel / np.max(abs_sobel))binary_output np.zeros_like(scaled_sobel)#############二值图像大于最小阈值并且小于最大阈值的区间置为255 其余为0可通过修改最大最小值查看差异####################填空21行代码########################binary_output[(scaled_sobel thresh_min) (scaled_sobel thresh_max)] 255#############填空2 1行代码########################return binary_output使用检测纵向边缘x方向的梯度 path rd:\Users\WYN\Desktop\temp\week1HomeWork\testImage path_list os.listdir(path) plt.figure(figsize(16, 9)) for i in range(len(path_list)):path_now \\.join([str(path), str(path_list[i])])img cv2.imread(path_now)img cv2.cvtColor(img, cv2.COLOR_BGR2RGB)plt.subplot(2, 3, i 1)plt.imshow(abs_sobel_threshold(img, orientx, thresh_min40, thresh_max255))plt.xticks([])plt.yticks([])plt.subplots_adjust(wspace0, hspace0) plt.show() 使用检测纵向边缘y方向的梯度 # 检测纵向边缘y方向的梯度 plt.figure(figsize(16, 9)) for i in range(len(path_list)):path_now \\.join([str(path), str(path_list[i])])img cv2.imread(path_now)img cv2.cvtColor(img, cv2.COLOR_BGR2RGB)plt.subplot(2, 3, i 1)plt.imshow(abs_sobel_threshold(img, orienty, thresh_min40, thresh_max255))plt.xticks([])plt.yticks([])plt.subplots_adjust(wspace0, hspace0) plt.show() 2.使用全局的变化梯度来进行阈值过滤 def mag_threshold(img, sobel_kernel3, mag_threshold(50, 255)):gray cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)sobelx cv2.Sobel(gray, cv2.CV_64F, 1, 0, ksizesobel_kernel)sobely cv2.Sobel(gray, cv2.CV_64F, 0, 1, ksizesobel_kernel)########根据x方向的sobel算子和y方向上sobel算子计算梯度公式为sqrtx^2 y ^2####################填空3 1行代码########################gradmag np.sqrt(sobelx ** 2 sobely ** 2)#############填空3 1行代码########################scale_factor np.max(gradmag) / 255gradmag (gradmag / scale_factor).astype(np.uint8)binary_out np.zeros_like(gradmag)########转换为二值图最大最小值可调kernel_size也可以调整看看差异####################填空4 1行代码########################binary_out[(gradmag mag_threshold[0]) (gradmag mag_threshold[1])] 255#############填空4 1行代码########################return binary_out通过全局阈值过滤来检测车道线 path rd:\Users\WYN\Desktop\temp\week1HomeWork\testImage path_list os.listdir(path) plt.figure(figsize(16, 9)) plt.figure(1) for i in range(len(path_list)):path_now \\.join([str(path), str(path_list[i])])img cv2.imread(path_now)img cv2.cvtColor(img, cv2.COLOR_BGR2RGB)plt.subplot(2, 3, i 1)plt.imshow(mag_threshold(img, sobel_kernel3, mag_threshold(50, 255)))plt.xticks([])plt.yticks([])plt.subplots_adjust(wspace0, hspace0) plt.show()3.通过算子角度来进行阈值过滤 def dir_threshold(img, sobel_kernel5, thresh(0.7, 1.3)):gray cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)sobelx cv2.Sobel(gray, cv2.CV_64F, 1, 0, ksizesobel_kernel)sobely cv2.Sobel(gray, cv2.CV_64F, 0, 1, ksizesobel_kernel)########根据x方向的sobel算子和y方向上sobel算子计算角度公式为arctany/x将倾斜角度过大的过滤掉####################填空5 1行代码########################absgraddir np.arctan(sobely / sobelx)#############填空5 1行代码########################binary_output np.zeros_like(absgraddir)########转换为二值图最大最小值可调kernel_size也可以调整看看差异####################填空6 1行代码########################binary_output[((absgraddir thresh[0]) (absgraddir thresh[1]))] 255#############填空6 1行代码########################return binary_output通过全局阈值过滤来检测车道线 path rd:\Users\WYN\Desktop\temp\week1HomeWork\testImage path_list os.listdir(path) plt.figure(figsize(16, 9)) plt.figure(1) for i in range(len(path_list)):path_now \\.join([str(path), str(path_list[i])])img cv2.imread(path_now)img cv2.cvtColor(img, cv2.COLOR_BGR2RGB)plt.subplot(2, 3, i 1)plt.imshow(dir_threshold(img, sobel_kernel5, thresh(np.pi/4, np.pi/3)))plt.xticks([])plt.yticks([])plt.subplots_adjust(wspace0, hspace0) plt.show()4.使用HLS进行阈值过滤 def hls_thresh(img, thresh(100, 255)):hls cv2.cvtColor(img, cv2.COLOR_RGB2HLS)########分离出s通道s_channel####################填空7 1行代码########################_, _, s_channel cv2.split(hls)#############填空7 1行代码########################binary_output np.zeros_like(s_channel)########转换为二值图最大最小值可调##################################填空8 1行代码########################binary_output[(s_channel thresh[0]) (s_channel thresh[1])] 255#############填空8 1行代码########################return binary_output5.综合多种阈值过滤方法 def combined_threshold(img):abs_bin abs_sobel_threshold(img, orientx, thresh_min50, thresh_max255)mag_bin mag_threshold(img, sobel_kernel3, mag_threshold(50, 255))dir_bin dir_threshold(img, sobel_kernel15, thresh(0.7, 1.3))hls_bin hls_thresh(img, thresh(170, 255))combined np.zeros_like(dir_bin)#############组合四个阈值结果判定车道线###################例如(abs_bin 255 | ((mag_bin 255) (dir_bin 255))) | hls_bin 25###########可以尝试不同的组合###################################填空91行代码######################### combined[(abs_bin 255 | ((mag_bin 255) (dir_bin 255))) | hls_bin 255] 255combined[(abs_bin 255) (mag_bin 255) (dir_bin 255) | (hls_bin 255)] 255#############填空9 1行代码########################return combined, abs_bin, mag_bin, dir_bin, hls_bin6.滑动窗口扫描 def line_fit_and_draw_line(binary_warped):# 查找拟合直线# 对图像对下半部分查找直方图#############填空101行代码截取图像高度的下方1/2处########################histogram np.sum(binary_warped[int(binary_warped.shape[0]//2):, :], axis0)#############填空101行代码截取图像高度的下方1/2处########################out_img (np.dstack((binary_warped, binary_warped, binary_warped)) * 255).astype(uint8)#查找直方图中左右两侧对峰值midpoint np.int(histogram.shape[0] / 2)#左侧从100到 midpoint的最大值转换成图像坐标还要加上100哦#############右侧从midpoint到图像宽度减100的最大值转换成图像坐标还要加上midpoint哦################也就是图像左右边缘100像素内不查找车道线###############################填空112行代码查找左侧右侧最大值基本点########################leftx_base np.argmax(histogram[100:midpoint])100rightx_base np.argmax(histogram[midpoint:binary_warped.shape[1]-100])midpoint#############填空112行代码查找左侧右侧最大值基本点##################################以下是关于滑动窗口查找车道线的代码#####################nwindows 9 # 将窗口划分为9行window_height np.int(binary_warped.shape[0] / nwindows)nonzero binary_warped.nonzero()nonzeroy np.array(nonzero[0]) # 非零元素所在行nonzerox np.array(nonzero[1]) # 非零元素所在列leftx_current leftx_baserightx_current rightx_basemargin 100minpix 10left_lane_inds []right_lane_inds []for window in range(nwindows):win_y_low binary_warped.shape[0] - (window 1) * window_heightwin_y_high binary_warped.shape[0] - window * window_heightwin_xleft_low leftx_current - marginwin_xleft_high leftx_current marginwin_xright_low rightx_current - marginwin_xright_high rightx_current margingood_left_inds ((nonzeroy win_y_low) (nonzeroy win_y_high) (nonzerox win_xleft_low) (nonzerox win_xleft_high)).nonzero()[0]good_right_inds ((nonzeroy win_y_low) (nonzeroy win_y_high) (nonzerox win_xright_low) (nonzerox win_xright_high)).nonzero()[0]left_lane_inds.append(good_left_inds)right_lane_inds.append(good_right_inds)if len(good_left_inds) minpix:leftx_current np.int(np.mean(nonzerox[good_left_inds]))if len(good_right_inds) minpix:rightx_current np.int(np.mean(nonzerox[good_right_inds]))left_lane_inds np.concatenate(left_lane_inds)right_lane_inds np.concatenate(right_lane_inds)leftx nonzerox[left_lane_inds]lefty nonzeroy[left_lane_inds]rightx nonzerox[right_lane_inds]righty nonzeroy[right_lane_inds]##########以上是关于滑动窗口查找车道线的代码######################将左侧右侧车道线3次拟合用函数np.polyfit#######################填空122行代码左侧、右侧车道线拟合#######################para_l np.polyfit(lefty, leftx, 3) #得到曲线参数para_r np.polyfit(righty, rightx, 3)#############填空122行代码左侧、右侧车道线拟合#######################################在图上画出拟合的线########################ploty np.linspace(0, undist.shape[0]-1, undist.shape[0])#########对y进行拟合x a * y ^ 2 b * y C#############填空132行代码左侧、右侧车道线方程坐标#######################left_fitx para_l[0] * ploty**3 para_l[1] * ploty**2 para_l[2] * ploty para_l[3]right_fitx para_r[0] * ploty**3 para_r[1] * ploty**2 para_r[2] * ploty para_r[3]#############填空132行代码左侧、右侧车道线方程坐标#############################生成一张黑图做mask将车道线区域标注出来##########color_warp np.zeros((720, 1280, 3), dtypeuint8)pts_left np.array([np.transpose(np.vstack([left_fitx, ploty]))])pts_right np.array([np.flipud(np.transpose(np.vstack([right_fitx, ploty])))])pts np.hstack((pts_left, pts_right))# 在透射变换后的图上画出车道线cv2.fillPoly(color_warp, np.int_([pts]), (0, 255, 0))# 将画出的车道线的图逆变换到原来的图上将color_warp逆变换为newwarp#############填空141行代码#######################newwarp cv2.warpPerspective(color_warp, m_inv, imgOut_size, flagscv2.INTER_LINEAR)#############填空141行代码######################## 将原来的图和标注好车道线的图叠加用cv2.addWeighted可画成半透明最终图为result#############填空151行代码#######################result cv2.addWeighted(img, 0.5, newwarp, 0.5, 0)#############填空151行代码#######################plt.figure(figsize (30, 30))plt.title(lane)plt.subplot(1, 1, 1)plt.imshow(result)plt.axis(off)7.图像显示 img cv2.imread(./testImage/test6.jpg) out1 mag_threshold(img) out2 abs_sobel_threshold(img) out3 dir_threshold(img) out4 hls_thresh(img) imgOut, abs_bin, mab_bin, dir_bin, hls_bin combined_threshold(img) plt.figure(figsize (30, 30)) plt.title(calibration) plt.subplot(1, 5, 1) plt.imshow(out1) plt.title(mag_threshold) plt.subplot(1, 5, 2) plt.imshow(out2) plt.title(abs_sobel_threshold) plt.subplot(1, 5, 3) plt.imshow(out3) plt.title(dir_threshold) plt.subplot(1, 5, 4) plt.imshow(out4) plt.title(hls_thresh) plt.subplot(1, 5, 5) plt.imshow(imgOut) plt.title(combined_threshold) plt.axis(off) imgOut_size (imgOut.shape[1], imgOut.shape[0]) binary_warped cv2.warpPerspective(imgOut, m, imgOut_size, flagscv2.INTER_LINEAR) undist cv2.imread(./testImage/test6.jpg) line_fit_and_draw_line(binary_warped) plt.show() 8.创建空白画布并绘制指定点 import numpy as np import cv2 import matplotlib.pyplot as plt ###在图中把点标记出来 plt.figure(figsize(30, 30)) img np.zeros((1000,1000,3),dtypenp.uint8) point_list [(200, 720), (1100, 720), (595, 450), (685, 450)] # src point_list2 [(300, 720), (980, 720), (300, 0), (980, 0)] # dst for point in point_list:cv2.circle(img, point, 10, (255, 0, 0), 3) for point in point_list2:cv2.circle(img, point, 10, (0, 0, 255), 3) plt.imshow(img) plt.show()
http://www.hkea.cn/news/14548210/

相关文章:

  • 武隆网站建设报价如何确认wordpress使用什么主题
  • 在喵窝网站怎么做图wordpress图片尺寸
  • 建设网站的内容规划刚刚地震最新消息今天 刚才
  • 美工模板网站如果使用自己电脑做网站
  • 国内网站建设发展公司部门主页设计方案
  • 网站建设陆金手指下拉贰拾台州网站公司建站
  • 做一个网站成本多少高端科研网站设计
  • 海南网站建设找哪家WordPress影视站源码
  • 误入网站退不了怎么做沈阳百度快照优化公司
  • 想自己搞一个视频网站怎么做呢喃wordpress 模板
  • 网站建设需要哪些费用做任务分享赚钱的网站
  • 网站如何导入百度地图百度最新秒收录方法2021
  • 大学生做家教比较好的网站肇庆市住房和城乡房屋建设局网站
  • 新建网站如何调试otc场外交易网站开发
  • 企业网站的建设包括wordpress制作xml
  • 做汽车网站怎么挣钱南京电商网站开发
  • 优化企业网站排名要多少钱如何用ai给网站做logo
  • 厅网站建设项目背景网站集群建设和网站集约化
  • 中国最好的域名注册网站网站建设可以资本化吗
  • 淘宝客网站需要备案网站中查看熊掌号怎么做的
  • 亳州做网站哪家好长春建设
  • app和手机网站wordpress 改成宽屏
  • 网站整体优化常州微信网站建设教程
  • 网站建设公司的重要性北京工程建设交易信息网站
  • 大连建设网节能办公室网站牙科网站模板
  • 做好的网站怎么注销芜湖县住房建设局网站
  • 成都网站建设sntuuhtml5国内网站欣赏
  • 建设旅游网站的功能定位欣赏艺术类的网站
  • 自己做网站卖货多少钱怎么去掉一页wordpress
  • 盐城做网站178网站建设