How can I disable OpenCV writing image windows position and size to Windows Registry?

Every time I show an image with OpenCV (cv2) and use an image window label with cv2.imshow(label, image), OpenCV creates or updates keys with that window label and the image position and size as values in Windows Registry. The key is HKEY_CURRENT_USER\SOFTWARE\OpenCV\HighGUI\Windows. (See screenshot below.)

Is there a way to stop OpenCV from doing this?

(My opencv-python version is

Not possible. window_w32.cpp always saves window positions to registry.

You’d need to change OpenCV source to add this feature. And you’d need to think about how to convey this bit of information, either before you create any windows or when you create each window.


1 Like

Thank you for your reply @crackwitz. I have two questions though:

  1. What do you mean by “changing OpenCV source”? E.g. use C++ instead of Python?
  2. I guess that by “conveying this bit of information” you mean using code to instruct cv2 to do something, right? But then, if I had access to ‘window_w32.cpp’ couldn’t I edit its code to not update Windows Registry?

No, you can keep using Python. I mean editing the source code of the library. Yes, that will involve compiling the library.

That’s what I was suggesting.

1 Like

This is great! This is what I was talking about!
(See this place is much better for talking about OpenCV than stackoverflow, in which I could take a breath!)

So, can you tell me please how can I edit the library? By decompiling, edit and recomplining ‘cv2.pyd’?

Note: This intersests me a lot, because I use to edit quite often Python’s library and modules. So, I will be able to do it also with ‘window_w32.cpp’, and for more useful things than the one mentioned in this topic.

Thanks a lot, @crackwitz!