This simple extension can and only can let you view the image of a variable when you are debugging python codes with opencv.
Currently, It's only support python with opencv module (opencv-python) debugging.
There is a limition that's your python codes must import opencv as cv2 and import numpy as np.
For example:
import cv2
import numpy as np
Python debugger extension for vscode (vscode Microsoft official python extension recommend)
Python module of OpenCV support imwrite function installed (official module opencv-python recommend)
Due to vscode do not allow extension customizes hover when you are debugging so that this extension use the code action command to open a new editor to view the image.
Since 0.0.5 add a command "View Image(Python OpenCV Debug)" and a keybord shortcut "ctrl+alt+v" to open the image.
-
Open a python file which has "import cv2".
-
Start Debug
-
Break on a certain line
-
Click a variable that contains image data and waiting for the code action icon (a little yellow light bubble) popup.
-
Click the icon or press ctrl+. to popup a menu then click the menu to view image.
No settings, the initail version is hardcode.
The initail version is hardcode so there are some limitations:
-
Only work on python debugging with opencv module.
-
The python opencv module must support imwrite("filename to save", image_variable) function.
-
The python file must import opencv module as cv2 such as "import cv2" and import numpy as np such as "import numpy as np";
-
The extension use imwrite to save the temporary image file.
-
The temporary directory is hardcode.
-
The temporary image file type is png.
-
The temporary image files are removed on extension activation not deactivation.
-
Unsupport variable tracking while debugging so the image cannot be refreshed automatically. You must click the variable again to refresh.
Add a command "View Image(Python OpenCV Debug)".
Add a keyboard shortcut "ctrl+alt+Q" for quickly image viewing.
Add ndarray checking to avoid some exceptions.
Update README.md
Thanks to marisancans add support for float np array. Notice it's a hardcode workaround. Because of this fixing the python file must import numpy as np also.
Initial release
Enjoy!