简体   繁体   中英

How to import specific function from cv2 (opencv)?

How can I import only a specific function from cv2 (opencv) in python? I need only these function:

cv2.matchTemplate
cv2.minmaxLOC
cv2.cvtColor
cv2.color_RGB2BGR
cv2.TM_COEFF_NORMED
cv2.imread

I ask this question because I use pyinstaller --onefile to make python project one exe only. With standard import cv2 file is just too big (over 50mb).

You can import the specific functions with from library import function

In your case, you can use;

from cv2 import matchTemplate, minMaxLoc, cvtColor, COLOR_RGB2BGR, TM_CCOEFF_NORMED, imread

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM