對OpenCV的destroyallWindows一些認知
- 前言
- 一、先看代碼
- 二、網上的資料
- 1.Stack Overflow的回答
- 2.官方回答
- 總結
前言
因為之前在學習OpenCV,當然了網路上有許多的資料,基本上都是在學習前人的造好的輪子,但是我這個人比較喜歡刨根問底,一直在寫代碼的程序中有的時候忘記寫destroyallWindos這個函式,代碼也可以正常運行,但是我看一些參考代碼里面都最后帶有destoryallWindos這個陳述句,有有些想法,于是找了一些資料,所以特地寫一片文章,來記錄一下,希望以后忘記了可以看看
一、先看代碼
import cv2
# 這里0.jpg是同目錄下的一張圖片
img = cv2.imread("0.jpg")
cv2.imshow("CHJ", img)
cv2.waitKey(0)
這樣的代碼是可以運行的,并且會一直等待鍵盤輸入,但是就是沒有destroyallWindows
二、網上的資料
1.Stack Overflow的回答
stackoverflow上的回答
大家可以看一看
2.官方回答
這個是官方鏈接:官方檔案
英文:
You can call destroyWindow() or destroyAllWindows() to close the window and de-allocate any associated memory usage. For a simple program, you do not really have to call these functions because all the resources and windows of the application are closed automatically by the operating system upon exit.
百度翻譯一下:
您可以呼叫destroyWindow()或destroyAllWindows()來關閉視窗并取消分配任何相關的記憶體使用,對于一個簡單的程式,實際上不必呼叫這些函式,因為退出時作業系統會自動關閉應用程式的所有資源和視窗
總結
如果之前沒有釋放掉記憶體的操作的話destroyallWIndows會釋放掉被那個變數占用的記憶體
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/190636.html
標籤:其他
上一篇:2020-10-24
下一篇:從控制理論的角度談資料分析
