Skip to content

setTrackbarPos not working on MacOS #22483

@akkiss

Description

@akkiss
System information (version)
  • OpenCV 4.1.1, 4.6.0 and master (65d66a0)
  • MacOS Monterey 12.5.1
  • Apple clang version 13.0.0 (clang-1300.0.29.30)

Opencv's configuration:

-- General configuration for OpenCV 4.6.0-dev =====================================
-- Version control: 4.6.0-248-g65d66a05dd
--
-- Platform:
-- Timestamp: 2022-09-08T04:07:33Z
-- Host: Darwin 21.6.0 x86_64
-- CMake: 3.22.3
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/make
-- Configuration: Release
--
-- CPU/HW features:
-- Baseline: SSE SSE2 SSE3 SSSE3 SSE4_1
-- requested: DETECT
-- Dispatched code generation: SSE4_2 FP16 AVX AVX2 AVX512_SKX
-- requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
-- SSE4_2 (1 files): + POPCNT SSE4_2
-- FP16 (0 files): + POPCNT SSE4_2 FP16 AVX
-- AVX (3 files): + POPCNT SSE4_2 AVX
-- AVX2 (29 files): + POPCNT SSE4_2 FP16 FMA3 AVX AVX2
-- AVX512_SKX (3 files): + POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
--
-- C/C++:
-- Built as dynamic libs?: NO
-- C++ standard: 11
-- C++ Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ (ver 13.0.0.13000029)
-- C++ flags (Release): -fsigned-char -ffast-math -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
-- C++ flags (Debug): -fsigned-char -ffast-math -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
-- C Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- C flags (Release): -fsigned-char -ffast-math -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
-- C flags (Debug): -fsigned-char -ffast-math -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
-- Linker flags (Release): -Wl,-dead_strip
-- Linker flags (Debug): -Wl,-dead_strip
-- ccache: NO
-- Precompiled headers: NO
-- Extra dependencies: -framework AppKit -framework Cocoa -framework OpenCL
-- 3rdparty dependencies: libjpeg-turbo libpng libopenjp2 zlib ade
--
-- OpenCV modules:
-- To be built: calib3d core features2d flann gapi highgui imgcodecs imgproc video videoio world
-- Disabled: java_bindings_generator ml objdetect photo python_bindings_generator stitching
-- Disabled by dependency: -
-- Unavailable: dnn java python2 python2 python3 ts
-- Applications: -
-- Documentation: NO
-- Non-free algorithms: NO
--
-- GUI:
-- Cocoa: YES
--
-- Media I/O:
-- ZLib: build (ver 1.2.12)
-- JPEG: build-libjpeg-turbo (ver 2.1.3-62)
-- PNG: build (ver 1.6.37)
-- JPEG 2000: build (ver 2.4.0)
-- HDR: YES
-- SUNRASTER: NO
-- PXM: YES
-- PFM: YES
--
-- Video I/O:
-- FFMPEG: YES
-- avcodec: YES (58.134.100)
-- avformat: YES (58.76.100)
-- avutil: YES (56.70.100)
-- swscale: YES (5.9.100)
-- avresample: YES (4.0.0)
-- AVFoundation: YES
--
-- Parallel framework: GCD
--
-- Trace: YES (built-in)
--
-- Other third-party libraries:
-- Custom HAL: NO
--
-- OpenCL: YES (no extra features)
-- Include path: NO
-- Link libraries: -framework OpenCL
--
-- Python (for build): /opt/anaconda3/bin/python3
--

Detailed description

setTrackbarPos works well on both Windows and Ubuntu, but on MacOS it just doesn't change the position and doesn't trigger the onChange callback function.

Steps to reproduce
#include <opencv2/opencv.hpp>
#include <iostream>

using namespace std;
using namespace cv;

void on_trackbar(int frame, void *ptr)
{
	cout << "frameChange: " << frame << endl;
}

int main()
{
	int frameidx = 0;
	namedWindow("seek");
	createTrackbar( "frameid", "seek", &frameidx, 100, on_trackbar );
	while (true) {
		waitKey();
		cout << "before: " << frameidx << endl;
		setTrackbarPos("frameid","seek", frameidx+1);
		cout << "after: " << frameidx << endl;
	}
}

On Windows and Ubuntu works as expected: frameidx increases in setTrackbarPos and on_trackbar is called, but on MacOS frameidx does not change at setTrackbarPos and on_trackbar is not called (it is called though when moving the slider with the mouse).

The output on MacOS was the following (stragely the callback is invoked for small mouse motions, not just when the value actually changes):

...
frameChange: 15
frameChange: 16
frameChange: 16
frameChange: 16
frameChange: 16
frameChange: 16
frameChange: 16
frameChange: 16
frameChange: 16
frameChange: 16
frameChange: 16
frameChange: 16
frameChange: 16
before: 16
after: 16
before: 16
after: 16
before: 16
after: 16

The closest problem found was #5056 and indeed changing to 4.6.0 solved the issue of not showing the trackbar status but the problem with setTrackbarPos persists.

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 any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions