Reputation: 1985
I want to drag and drop an image file to cv2.imshow()
window and fetch the filename path.
There is no event named drag and drop and I need some help.
In my project I remove the background image and I want to change the background with any image.
I did the hard part (removing the background) but I don't know how to handle drag/drop files event in OpenCV python.
def mouse_events(event, x,y, flags,param):
if event == cv2.EVENT_??: # ?? drag/drop a file event
# return the filename
while True:
...
cv2.setMouseCallback(windowName, mouse_events)
...
Thanks in advance
Upvotes: 1
Views: 751
Reputation: 4643
As @Christoph Rackwitz pointed out, you cannot do this using OpenCV alone. You have to use some GUI programming interface such as PyQt5
or pyside
.
This question demonstrates drag and drop functionality with file explorer.
Have a look at this tutorial for integrating with OpenCV
Upvotes: 1