Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python binding errors #691

Closed
4 tasks done
rvalue opened this issue Jul 15, 2022 · 1 comment
Closed
4 tasks done

Python binding errors #691

rvalue opened this issue Jul 15, 2022 · 1 comment

Comments

@rvalue
Copy link

rvalue commented Jul 15, 2022

Expected behaviour

When trackbar is created using a callback function, and the trackbar is used, the callback function is called

Actual behaviour

When trackbar is created using a callback function, and the trackbar is used, program outputs a segfault and terminates.

$ python trackbar.py
Scale: 10
[1]    2896 segmentation fault  python trackbar.py

See Also: https://gist.github.com/rvalue/85247541e298fb01451c5679c3bb8a45

Steps to reproduce

  • example code
  • operating system = macOS Monterey 12.4
  • architecture = arm64 (M1 Apple Silicon)
  • opencv-python version = 4.6.0.66
Issue submission checklist
  • This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
  • I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)
  • The issue is related to the build scripts in this repository, to the pre-built binaries or is a feature request (such as "please enable this additional dependency")
  • I'm using the latest version of opencv-python
@rvalue
Copy link
Author

rvalue commented Jul 15, 2022

Moreover, there does not seem to be any problem when purely in C++. The following program gives no error with OpenCV 4.6.0

#include <iostream>
#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

static void on_trackbar(int, void*);

const auto WINDOW_NAME = "Trackbar Example";
const auto TRACKBAR_NAME = "Scale";

int main() {
    auto image = Mat(Size(500, 500), CV_8UC3, Scalar(0, 0, 0));
    auto slider_value = 0;
    auto slider_max = 100;

    namedWindow(WINDOW_NAME, WINDOW_NORMAL);
    createTrackbar(TRACKBAR_NAME, WINDOW_NAME, &slider_value, slider_max, on_trackbar);
    imshow(WINDOW_NAME, image);
    waitKey(0);
    return 0;
}

static void on_trackbar(int pos, void* userdata) {
    cout << "Pos: " << pos << endl;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants