opencv
今天使用opencv画bounding box
python下使用opencv修改图片:
import cv2
opencv2.4.13显示图片,等待按键输入
cv2.imshow("iamge",frame) cv2.waitKey(0)
opencv2.4.13添加文字cv2.putText,存在不支持 换行的问题,如果要输出换行,按如下所示:
https://blog.csdn.net/lanchunhui/article/details/71229235
putText(图片名,文字,文字位置,字体,大小,颜色,粗细)
str_to_write="line1 line2 line3 line4" y0, dy = 50, 25 for i, txt in enumerate(str_to_write.split(' ')): y = y0+i*dy cv2.putText(frame,txt,(50,y),cv2.FONT_HERSHEY_COMPLEX,0.4,(0,0,255),1)
添加文字:cv2.putText(),参考http://blog.csdn.net/gan_player/article/details/78155283?utm_source=debugrun&utm_medium=referral
获取图片宽/高:参考http://blog.csdn.net/jacke121/article/details/76152242
opencv3从视频中获取单帧图像
import cv2 videoCapture = cv2.VideoCapture() videoCapture.open('E:/video/1-1.avi') fps = videoCapture.get(cv2.CAP_PROP_FPS) frames = videoCapture.get(cv2.CAP_PROP_FRAME_COUNT) #fps是帧率,意思是每一秒刷新图片的数量,frames是一整段视频中总的图片数量。 print("fps=",fps,"frames=",frames) for i in range(int(frames)): ret,frame = videoCapture.read() cv2.imwrite("E:/video/pictures/1-1.avi(%d).jpg"%i,frame)
opencv2.4.13从视频中获取单帧图像
def drawpoint(filename): cap=cv2.VideoCapture() cap.open(filename) frames=cap.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT)#opencv2 获取总帧数 for i in range(int(frames)): ret,frame=cap.read()
#do sth to frame...
return