import numpy as np import cv2 as cv from operator import itemgetter video_capture = cv.VideoCapture('D:\python2\opencv_test\\vedio\\52816D2BD5CA004EA544D74F552C7B0A.mp4') # video_capture.set(cv.CAP_PROP_POS_FRAMES, 200)#设置摄像头取的帧 while(1): flag, frame = video_capture.read()#把视频转化为图片帧 height0= frame.shape[0]#设置图像的垂直尺寸 frame_gray= cv.cvtColor(frame, cv.COLOR_BGR2GRAY)#转化为灰度图 height, width = frame_gray.shape[0:2]#取图片的高与宽 start_height1 = height0 // 4 start_height2 = height0 // 4 frame_ROI = frame_gray[start_height1:height0-start_height2, :] # cv.imshow('1',frame_ROI) ndiv = width#ndiv分几个块,div每一个块有几个像素 div = width//ndiv frame_result=frame_ROI[:,0:div] for i in range(ndiv): if i<(ndiv-1): frame_temp=frame_ROI[:,i*div:(i+1)*div] else: frame_temp=frame_ROI[:,(ndiv-1)*div:width] ret,frame_temp = cv.threshold
边缘检测项目(将边缘描绘出来)python opencv
最新推荐文章于 2023-07-13 16:25:33 发布