Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

thewoz
Copy link
Contributor

@thewoz thewoz commented Mar 23, 2023

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@asmorkalov
Copy link
Contributor

modules/highgui/src/window_cocoa.mm:909: trailing whitespace.

@thewoz
Copy link
Contributor Author

thewoz commented Mar 24, 2023

hi can I do something about trailing whitespace?

@asmorkalov
Copy link
Contributor

You just need to remove it and commit to git.

@cpoerschke
Copy link
Contributor

Tested locally with both mouse and trackpad using the code below.

Left "consider hasPreciseScrollingDeltas; differentiate CV_EVENT_MOUSEHWHEEL;" suggestions as cpoerschke@5f86d9c commit on https://github.com/cpoerschke/opencv/tree/Cocoa-Scroll-Wheel branch -- feel free to cherry-pick.

Looked a little into alternatives to 0.100006 hard-coding but did not find an obvious one.

#include <opencv2/opencv.hpp>

void mouseCallback(int event, int x, int y, int flags, void* userData)
{
    if (event != cv::EVENT_MOUSEMOVE)
    {
        std::cout << "mouseCallback"
                  << " event=" << event
                  << " x=" << x
                  << " y=" << y
                  << " flags=" << flags
                  << std::endl;
    }
}

int main(int argc, char* argv[])
{
    cv::imshow("winname", cv::imread("../opencv/samples/data/HappyFish.jpg"));
    cv::setMouseCallback("winname", mouseCallback);
    cv::waitKey();
    return 0;
}

@thewoz
Copy link
Contributor Author

thewoz commented Apr 2, 2023

The solution proposed by cpoerschke for me is fine.

@asmorkalov asmorkalov added this to the 4.8.0 milestone Apr 11, 2023
@VadimLevin
Copy link
Contributor

@cpoerschke Thank you for testing. @thewoz please consider to add hasPreciseScrollingDeltas check to PR, before merge

@thewoz
Copy link
Contributor Author

thewoz commented Apr 11, 2023

hi, @VadimLevin I add hasPreciseScrollingDeltas to the PR

@asmorkalov asmorkalov merged commit 097891e into opencv:4.x Apr 12, 2023
@asmorkalov asmorkalov mentioned this pull request May 31, 2023

if( mp.x >= 0 && mp.y >= 0 && mp.x < imageSize.width && mp.y < imageSize.height )
mouseCallback(type, mp.x, mp.y, flags, mouseParam);
if( [event type] == NSEventTypeScrollWheel ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not supported in macOS 10.9 (used in conda-forge)

$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-clang++ -DCVAPI_EXPORTS -DENABLE_PLUGINS -DHAVE_COCOA -DHAVE_WEBP -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I$SRC_DIR/build/3rdparty/ippicv/ippicv_mac/icv/include -I$SRC_DIR/build/3rdparty/ippicv/ippicv_mac/iw/include -I$SRC_DIR/build -I$SRC_DIR/modules/highgui/include -I$SRC_DIR/build/modules/highgui -I$SRC_DIR/modules/core/include -I$SRC_DIR/modules/imgproc/include -I$SRC_DIR/modules/imgcodecs/include -I$SRC_DIR/modules/videoio/include -isystem $PREFIX/include/eigen3 -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem $PREFIX/include -fdebug-prefix-map=$SRC_DIR=/usr/local/src/conda/libopencv-4.8.0 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix   -fsigned-char -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 -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections  -Wno-deprecated-declarations -O3 -DNDEBUG  -DNDEBUG -std=c++17 -isysroot /Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -fPIC -fobjc-exceptions -MD -MT modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_cocoa.mm.o -MF modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_cocoa.mm.o.d -o modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_cocoa.mm.o -c $SRC_DIR/modules/highgui/src/window_cocoa.mm
$SRC_DIR/modules/highgui/src/window_cocoa.mm:902:25: error: use of undeclared identifier 'NSEventTypeScrollWheel'; did you mean 'kCGEventScrollWheel'?
    if( [event type] == NSEventTypeScrollWheel ) {
                        ^~~~~~~~~~~~~~~~~~~~~~
                        kCGEventScrollWheel
/Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGEventTypes.h:120:3: note: 'kCGEventScrollWheel' declared here
  kCGEventScrollWheel = NX_SCROLLWHEELMOVED,
  ^
$SRC_DIR/modules/highgui/src/window_cocoa.mm:940:24: error: use of undeclared identifier 'NSEventTypeScrollWheel'; did you mean 'kCGEventScrollWheel'?
    if([event type] == NSEventTypeScrollWheel) {[self cvSendMouseEvent:event type:CV_EVENT_MOUSEWHEEL   flags:flags ];}
                       ^~~~~~~~~~~~~~~~~~~~~~
                       kCGEventScrollWheel
/Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGEventTypes.h:120:3: note: 'kCGEventScrollWheel' declared here
  kCGEventScrollWheel = NX_SCROLLWHEELMOVED,
  ^
2 errors generated.
[948/1540] $BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-clang++ -DCVAPI_EXPORTS -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I$SRC_DIR/build/3rdparty/ippicv/ippicv_mac/icv/include -I$SRC_DIR/build/3rdparty/ippicv/ippicv_mac/iw/include -I$SRC_DIR/build -I$SRC_DIR/opencv_contrib/modules/mcc/include -I$SRC_DIR/build/modules/mcc -I$SRC_DIR/modules/core/include -I$SRC_DIR/modules/flann/include -I$SRC_DIR/modules/imgproc/include -I$SRC_DIR/modules/dnn/include -I$SRC_DIR/modules/features2d/include -I$SRC_DIR/modules/calib3d/include -isystem $PREFIX/include/eigen3 -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem $PREFIX/include -fdebug-prefix-map=$SRC_DIR=/usr/local/src/conda/libopencv-4.8.0 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix   -fsigned-char -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 -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections  -O3 -DNDEBUG  -DNDEBUG -std=c++17 -isysroot /Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -fPIC -MD -MT modules/mcc/CMakeFiles/opencv_mcc.dir/src/bound_min.cpp.o -MF modules/mcc/CMakeFiles/opencv_mcc.dir/src/bound_min.cpp.o.d -o modules/mcc/CMakeFiles/opencv_mcc.dir/src/bound_min.cpp.o -c $SRC_DIR/opencv_contrib/modules/mcc/src/bound_min.cpp
ninja: build stopped: subcommand failed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VadimLevin could you take a look?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macOS 10.9 was released 10 yes from now (October 22, 2013), last security update was 7 years ago...
Do we actually want to keep such compatibility?

Copy link
Contributor

@asmorkalov asmorkalov Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenCV-Python builds use osx 10.16. It's minimal version provided by Github Actions in cloud.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose in conda-forge it can be fixed increasing macOS SDK version to 10.12
conda-forge/opencv-feedstock#371

thewoz added a commit to thewoz/opencv that referenced this pull request Jan 4, 2024
Add scrollWheel to Cocoa opencv#23394

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [ ] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
thewoz added a commit to thewoz/opencv that referenced this pull request May 29, 2024
Add scrollWheel to Cocoa opencv#23394

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [ ] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants