Reputation:
I'm trying to add a button to my image processing script to save the high and low HSV values for my binary threshold.
According to the OpenCV 3.0 documentation here, OpenCV evidently has a function which does that.
I am writing the function like this
cv2.createButton('Button',f)
Where Button
is the name of the button and f
is the callback function (just an empty function)
However I keep on getting:-
AttributeError: 'module' object has no attribute 'createButton'
Apparently the same function works fine with C/C++ but it isn't working with python. Most probably because it isn't there for python (maybe) ?
How do I get around this problem?
Upvotes: 8
Views: 35854
Reputation: 56
I was searching for the reason why the button was getting attached to the control panel of QT window. I think the following extract from CV2 home page would help
The function createButton attaches a button to the control panel. Each button is added to a buttonbar to the right of the last button. A new buttonbar is created if nothing was attached to the control panel before, or if the last element attached to the control panel was a trackbar or if the QT_NEW_BUTTONBAR flag is added to the type
open cv new qt functions page link
Upvotes: 1
Reputation: 127
cv2.namedWindow("Frame")
cv2.createButton("Back",back,None,cv2.QT_PUSH_BUTTON,1)
def back(*args):
pass
The above code shows how to implement the cv2.createButton() method.
Notes:
Upvotes: 7
Reputation: 527
I think it's unposible
cv2.createButton('test', GeekObject, None , cv2.QT_PUSH_BUTTON, 0)
cv2.error: OpenCV(3.4.6) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:579: error: (-213:The function/feature is not implemented) The library is compiled without QT support in function 'cv::createButton'
Upvotes: 1
Reputation: 3719
The documentation says
Another important application of trackbar is to use it as a button or switch. OpenCV, by default, doesn’t have button functionality. So you can use trackbar to get such functionality (found at Trackbar as the Color Palette).
There is a small example how to use it as button.
Upvotes: 10