The python openCV module is a dynamically created wrapper for the C ++ core library. PyCharm relies on the availability of python source code to provide autocomplete functionality. When the source code is missing (as is the case with opencv), pycharm will generate skeletal files with function prototypes and rely on those used for autocompletion, but with reduced capabilities.
As a result, when you autofill
cv2.
you can understand that the cv2 module has the following members and provides suggestions.
On the other hand, when you
cap = cv2.VideoCapture(file_name)
PyCharm can understand that you just called a method from the cv2 module and assigned its cap , but you donβt have information about the type of the result of this method and you donβt know where to look for searches for
cap.
If you try the same things in shell mode, you will see the behavior that you actually expect to see, since in shell mode there will actually be an introspection of living objects (he will ask the created cover object what members he has and provide them as suggestions)
You can also write stubs for the opencv module yourself to enable proper autocomplete in edit mode.
Look here
Giannis spiliopoulos
source share