python+opencv保存图片以系统时间命名怎么敲?
opencv吧
全部回复
仅看楼主
level 2
Moon冻龄 楼主
mport numpy as np
import cv2
import time
cap = cv2.VideoCapture(0)
time = time.localtime(time.time())
color = (0,255,0)
line_width = 3
radius = 100
point = (0,0)
def click(event, x, y, flags, param):
global point, pressed
if event == cv2.EVENT_LBUTTONDOWN:
# 如果点击窗口,则打印鼠标点击的相对坐标
print(time.tm_hour,time.tm_min,time.tm_sec,x,y)
name = time.tm_hour,time.tm_min,time.tm_sec
print(name)
frame = cv2.imread(im_name)
cv2.imwrite('D/:' + name, frame)
point = (x,y)
cv2.namedWindow("Frame")
cv2.setMouseCallback("Frame",click)
while(True):
ret, frame = cap.read()
frame = cv2.resize(frame, (0,0), fx=1.3,fy=1.3)
cv2.circle(frame, point, radius, color, line_width)
cv2.imshow("Frame",frame)
ch = cv2.waitKey(1)
if ch & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
这里只能保存自己设置命名的时间
2021年03月19日 04点03分 1
level 12
time.asctime获取系统时间,然后作为cv2.imwrite的参数传进去就是了
2021年03月23日 07点03分 2
完成,str带入变量值懂了。
2021年03月30日 12点03分
@Moon冻龄 要加路径怎么写#cv2.imwrite("D:/XUNIJI/cam/test.jpg", frame)
2021年12月01日 05点12分
1