获取图像最亮的点
作者:互联网
#!/usr/bin/python # -*- coding: utf-8 -*- import cv2 import numpy as np cap = cv2.VideoCapture(1) # 为保存视频做准备 #cap.set(3,160)#宽 #cap.set(4,120)#高 #sz = (int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)), #int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))) #fourcc = cv2.VideoWriter_fourcc(*'MJPG') #fps=25 #out = cv2.VideoWriter('output2.avi', fourcc,fps,sz) while True: # 一帧一帧的获取图像 ret,frame = cap.read() if ret == True: # 开始保存视频 #out.write(frame) image_fire_re= cv2.resize(frame,(320,240),interpolation=cv2.INTER_CUBIC) image_fire_gary=cv2.cvtColor(image_fire_re,cv2.COLOR_RGB2GRAY) # 利用cv2.minMaxLoc寻找到图像中最亮和最暗的点 # 应用高斯模糊进行预处理 gray = cv2.GaussianBlur(image_fire_gary, (5, 5), 0) (minVal, maxVal, minLoc, maxLoc) = cv2.minMaxLoc(gray) # 在图像中绘制结果 cv2.circle(image, maxLoc, 5, (255, 0, 0), 2) # 显示结果帧 cv2.imshow("frame", image_fire_re) cv2.waitKey(3) cv2.imshow("framegray", image_fire_gary) cv2.waitKey(3) if cv2.waitKey(1) & 0xFF == ord('q'): break else: break # 释放摄像头资源 cap.release() #out.release()
标签:fire,最亮,image,cap,cv2,获取,图像,fourcc,frame 来源: https://www.cnblogs.com/kekeoutlook/p/13557207.html