# 加载,检测对象
net=cv2.dnn.readNet("./yolov3.weights", "./yolov3.cfg")
#用blob来检测
blob=cv2.dnn.blobFromImage(frame,1/255,(320,320),(0,0,0),True,crop=False)
net.setInput(blob)
#检测
outs=net.forward(output_layers)
# Non-max Suppression
indexes=cv2.dnn.NMSBoxes(boxes,confidences,0.4,0.6)
#打开视频
cap = cv2.VideoCapture('./video.mp4')
#保存视频
out_video = cv2.VideoWriter('human.avi', cv2.VideoWriter_fourcc(*'MJPG'), 15., (640,480))
out_video.write(frame)
#捕捉一帧
ret, frame = cap.read()
#调整大小
frame = cv2.resize(frame, (640, 480))
#帧图片的尺寸
height,width,channel = frame.shape
#画矩形
cv2.rectangle(frame,(x,y),(x+w,y+h),color,2)
#标注文字
cv2.putText(frame,label+" "+str(round(confidences[i],3)),(x,y-5),font,1, color, 1)
#显示图像
cv2.imshow("Detected_Images",frame)
//c++
//拷贝frame (cv::Mat)
img.copyTo(out);
//画圆
cv::circle(out, cv::Point(100,100),5,cv::Scalar(255,0,0),2);
//摄像头对象工作正常
if (!capture.isOpened())
return 1;
//获取帧率
double rate= capture.get(cv::CAP_PROP_FPS);
cv::Mat frame;
cv::namedWindow("Extracted Frame");
https://docs.opencv.org/master/d6/d00/tutorial_py_root.html
显示视频文件
cap.release()
out.release()
cv.destroyAllWindows()
numpy.argmax
numpy.argmax(a, axis=None, out=None)[source]
Returns the indices of the maximum values along an axis.