elazarcoh / simply-view-image-for-python-debugging

visual studio code extension simply view the image of the image variables when debugging python
https://marketplace.visualstudio.com/items?itemName=elazarcoh.simply-view-image-for-python-debugging
MIT License
54 stars 6 forks source link

Feature request: Support "non-restricted types" in experimental viewer #99

Open dprov opened 3 months ago

dprov commented 3 months ago

Disabling svifpd.restrictImageTypes allows viewing other image types, which is great. Not sure of the extent of what can work, but just for context it works out of the box in my case for a C++ Image type bound with pybind11 that supports the buffer protocol / can be converted to a numpy array using np.asarray(). However, these "extra types", or at least he one I'm using, do not seem to be supported in the "new" image viewer (which is also great by the way). Would it be easy to add this support?

Not sure if my understaning is correct, but from (https://github.com/elazarcoh/simply-view-image-for-python-debugging/blob/369567964238e0e415828ef4cb3b23e8d503bf38/src/python/image_numpy.py#L3) it seems like the "other types" work if they are convertible to numpy arrays and are of correct dimensions. If that is the case, couldn't they use the same visualisation method / data transfer as numpy arrays?

Thanks

elazarcoh commented 3 months ago

For the new image viewer, the relevant code is here: https://github.com/elazarcoh/simply-view-image-for-python-debugging/blob/main/src%2Fpython%2Fsocket_client.py#L208

As you can see there, and the function below that is used for pillow images, it is simple enough if it conforms with the asarray protocol. I would prefer it if it can be checked to be conforming before trying to actually convert it.