Issue 1:
System information (version)

OpenCV => 4.5.3

Operating System / Platform => Windows 64 Bit

Compiler => VSC

Detailed description

I've been trying to create a trackbar. I've also tried the solutions provided in Github by Berak (https://www.gitmemory.com/issue/opencv/opencv/20408/880533612) but I am still getting the same errors.

Steps to reproduce

import cv2
import numpy as np

lowH = 0
highH = 180

lowS = 0
highS = 255

lowV = 0
highV = 255

cap = cv2.VideoCapture(0)
cv2.createTrackbar("l-h", "frame", lowH, 180, lambda x:x)
cv2.createTrackbar("h-h", "frame", highH, 180, lambda x:x)
cv2.createTrackbar("l-s", "frame", lowS, 255, lambda x:x)
cv2.createTrackbar("h-s", "frame", highS, 255, lambda x:x)
cv2.createTrackbar("l-v", "frame", lowV, 255, lambda x:x)
cv2.createTrackbar("h-v", "frame", highV, 255, lambda x:x)

Issue 2:
System information (version)

OpenCV == 4.5.3.56 (latest)

Operating System / Platform => Windows 10 Pro

Compiler => Python 3.7

Detailed description

After updating to the most recent version of opencv-contrib-python, now when creating a trackbar using

cv2.createTrackbar(TRACKBAR_NAME, WINDOW_NAME, 0, MAX_VAL, on_trackbar_foo)

the following warning is printed in the terminal:

[ WARN:0] global C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-_xlv4eex\opencv\modules\highgui\src\window.cpp (704) cv::createTrackbar UI/Trackbar(Source@Navigation controls): Using 'value' pointer is unsafe and deprecated. Use NULL as value pointer. To fetch trackbar value setup callback

I'm not exactly sure what that means in the context of the Python API.

Furthermore, if I then try to dynamically change the maximum value of the trackbar like this

cv2.setTrackbarMax(TRACKBAR_NAME, WINDOW_NAME, N)

the trackbar itself is now stuck at 0 (or whatever the minimum is set to) and cannot be moved with the mouse cursor.

This used to be fine in the previous versions. For example, it works fine in 4.5.2.52.

Steps to reproduce

Just creating a trackbar in Python using a most recent version of OpenCV, e.g. in my case:

import cv2
from functools import partial

def on_trackbar_class(value, param):
param['current_class'] = int(value)
param['CHANGED_CLASS'] = True # signal that the class-trackbar was moved

# ...

# this gets the list of classes from the dataset metadata
# CLASSES = dataset.get_classes()
CLASSES = ["head", "left_hand", "right_hand", "right_leg", "left_leg"]

# this data is modified via the trackbar and then used elsewhere
current_class = 0 # this is passed down as a function argument from elsewhere, use '0' here for testing
trackbar_data = {'current_class': current_class}

# create window
WINDOW_NAME = "Navigation controls"
cv2.namedWindow(WINDOW_NAME, cv2.WINDOW_AUTOSIZE)

# create trackbar
TRACKBAR_NAME = 'Class'
max_classes = (len(CLASSES) - 1) if len(CLASSES) > 1 else 1
cv2.createTrackbar(TRACKBAR_NAME, WINDOW_NAME, 0, max_classes, partial(on_trackbar_class, param=trackbar_data))

# the length of the CLASSES might change at some point
# this actually happens elsewhere, but I'm putting this in the same function right here
cv2.setTrackbarMax(TRACKBAR_NAME, WINDOW_NAME, len(CLASSES) - 1)

# keep the window opened for testing
cv2.waitKey(0)

Issue submission checklist

[ * ] I report the issue, it's not a question

[ * ] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found solution

[ * ] I updated to latest OpenCV version and the issue is still there

[ * ] There is reproducer code and related data files: videos, images, onnx, etc