capture = cv2.VideoCapture(0)                
 while True:  
     #img = cv.QueryFrame(capture)   
    
     ret, frame = capture.read()  

 

两种方法的区别在于得到的类型不同,img和frame的类型分别是lplimage和array。

在绘图中,matplotlib和opencv也有不同。

plt.cla()
plt.gca().add_patch(plt.Rectangle((bbox[0], bbox[1]), bbox[2] - bbox[0], bbox[3] - bbox[1], fill=False, edgecolor='g', linewidth=3))
plt.show() im
=im.copy() size = im.shape[:2] h,w=size cv2.rectangle(im,(int(bbox[0]), int(bbox[3])),(int(bbox[2]), int(bbox[1])),(0,255,0),5);
cv2.imshow("im",im);
cv2.waitKey (0)

plt.show必须手动关闭。如果是操作视频或者图像,还是推荐使用opencv。并且二者的参数不同。这个需要注意。

相关文章:

  • 2021-04-16
  • 2021-11-21
  • 2022-12-23
  • 2021-12-17
  • 2021-08-22
  • 2021-12-02
猜你喜欢
  • 2021-11-22
  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
  • 2021-07-02
  • 2021-05-07
相关资源
相似解决方案