Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vscode autocomplete not working for 'cv2.dnn_DetectionModel' Class #202

Closed
CCLings opened this issue Apr 7, 2022 · 2 comments · Fixed by #292
Closed

vscode autocomplete not working for 'cv2.dnn_DetectionModel' Class #202

CCLings opened this issue Apr 7, 2022 · 2 comments · Fixed by #292

Comments

@CCLings
Copy link

CCLings commented Apr 7, 2022

import cv2
net = cv2.dnn_DetectionModel(weightsPath='', configPath='')
net.setInputSize(320, 320)
  • conda environment
  • opnecv-python:4.5.5.64
  • python extension in vscode: v2022.4.0
  • pylance extension in vscode: v2022.4.0
@heejaechang
Copy link
Contributor

we only have auto generated stubs for cv2. we need real stub for anything more than the first level completion to work.

@judej judej transferred this issue from microsoft/pylance-release May 10, 2022
@Avasam
Copy link
Contributor

Avasam commented Jun 13, 2023

Given that opencv can now generates python stubs and opencv-python has been updated to ship them, you can try the in-development version using pip install git+https://github.com/opencv/opencv-python.git.

You can set the appropriate environment variables first if you'd like to install a specific package (like headless, contrib or healdless-contrib):

ENABLE_CONTRIB=1
ENABLE_HEADLESS=1

It should work as-is with pyright and mypy, but for Pylance you'll have to remove the bundled stubs every time you update the extension. It can be found at: %HOMEPATH%\.vscode\extensions\ms-python.vscode-pylance-<VERSION>\dist\bundled\stubs\cv2-stubs (where <VERSION> is your current Pylance version).

If the issue persists, you can raise it upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants