1 | initial version |
As I said, you should rewrite most of your code. It should look like something like this (pseudocode):
Global variables: R,G,B,erase,drawing
#Main application
Create window('image')
Add 3 trackbars to this window: cv2.createTrackbar('R','image',0,255,trackbarCallbackFunc) etc.
Add mouse callback function cv2.setMouseCallback('image',paint)
While 1:
leave only the keyboard code here
end main
#Trackbar callback: trackbarCallbackFunc
R = cv2.getTrackbarPos('R','trackbar') etc.
#Mouse callback: paint
This function is mostly OK, just delete the imShow and CreateTrackbar part
and draw the circle with (r,g,b) color and the rectangle with (0,0,0).