Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Mat conversions for macOS/AppKit#18547

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
alalek merged 12 commits intoopencv:masterfrommtfrctl:objc-conversions-macosx
Oct 14, 2020

Conversation

@mtfrctl
Copy link
Contributor

@mtfrctlmtfrctl commentedOct 9, 2020
edited by alalek
Loading

This PR solves#18546.
It consists

  • Extract CoreGraphics conversion logics from ios_conversions.mm to apple_conversions.h, apple_conversions.mm (MatToCGImage(), CGImageToMat())
  • Simplify ios_conversions.mm
  • Add macosx_conversions.mm for macOS/AppKit (MatToNSImage(), NSImageToMat())
  • Add Mat+Conversions.h and Mat+Conversions.mm for macOS/AppKit

Usage example in Swift:
※ Don't forget to set the-all_load flag to "Other Linker Flags" in "Build Settings" when using!#17532

// CGImage to Matlet sourceMat = Mat(cgImage: cgImage, alphaExist: true)// NSImage to Matlet sourceMat = Mat(nsImage: nsImage, alphaExist: true)// Something to processlet grayMat = Mat()Imgproc.cvtColor(src: sourceMat, dst: grayMat, code: .COLOR_RGBA2GRAY)// Mat to CGImagelet cgImage = grayMat.toCGImage().takeRetainedValue() // or .takeUnetainedValue()// Mat to NSImagelet nsImage = grayMat.toNSImage()

Pull Request Readiness Checklist

See details athttps://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 other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
force_builders=Custom Macbuild_image:Custom Mac=osx_frameworkbuildworker:iOS=macosx-1

komakai and treastrain reacted with heart emoji
@mtfrctlmtfrctl changed the titleMat conversions for macOS(AppKit)Mat conversions for macOS/AppKitOct 9, 2020
Copy link
Member

@alalekalalek left a comment

Choose a reason for hiding this comment

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

Thank you for contribution!

Please take a look on comments below.

mtfrctl reacted with heart emoji
//
//
// License Agreement
// For Open Source Computer Vision Library
Copy link
Member

Choose a reason for hiding this comment

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

Please use short license header:https://github.com/opencv/opencv/wiki/Coding_Style_Guide#file-structure

// This file is part of OpenCV project.// It is subject to the license terms in the LICENSE file found in the top-level directory// of this distribution and at http://opencv.org/license.html.

Copy link
ContributorAuthor

@mtfrctlmtfrctlOct 9, 2020
edited
Loading

Choose a reason for hiding this comment

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

🙆‍♂️
42a685c

Copy link
Member

Choose a reason for hiding this comment

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

Thank you for updates!
Please make similar update of license headers of new files in this PR.
Please remove empty first line in this file.

mtfrctl reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

#import <AVFoundation/AVFoundation.h>
#import <ImageIO/ImageIO.h>
#include "opencv2/core.hpp"
#include "precomp.hpp"
Copy link
Member

Choose a reason for hiding this comment

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

precomp.hpp

Please don't use this from header files. Move into .mm files instead

Copy link
ContributorAuthor

@mtfrctlmtfrctlOct 9, 2020
edited
Loading

Choose a reason for hiding this comment

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

Thank you. I moved it.
edfe785


CGColorSpaceRef colorSpace;

if (image.elemSize() == 1) {
Copy link
Member

Choose a reason for hiding this comment

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

.elemSize() =>.channels()

+CV_CheckDepth(image.depth(), CV_8U, ""); check on the first line.


OK, I see this code is just moved.

mtfrctl reacted with thumbs up emoji
@mtfrctlmtfrctl requested a review fromalalekOctober 9, 2020 11:50
@mtfrctlmtfrctl mentioned this pull requestOct 9, 2020
5 tasks
@komakai
Copy link
Contributor

@mtfrctl thanks for this - this is a great feature.
I checked the code and everything looks fine.
I have tried it quickly - after I remembered to set-all_load in theOther Linker Flags of my project everything worked well.
👍

mtfrctl reacted with heart emoji

@mtfrctl
Copy link
ContributorAuthor

mtfrctl commentedOct 10, 2020
edited
Loading

@komakai Thank you! Regarding the flag, people who come to check here will also check these@komakai and@treastrain conversations (#17532#18023), but it would be nice in the future so that it can be used immediately without being aware of these things ⭐

treastrain reacted with heart emoji

@mtfrctl
Copy link
ContributorAuthor

mtfrctl commentedOct 11, 2020
edited
Loading

@alalek By the way, I would like to add the following method tomodules/core/misc/objc/common/Mat.mm (and .h) for more flexibility, is it okay to include it in this PR, or is it better to separate it into another PR?

- (unsigned char*)dataPtr {    return _nativePtr->data;}

@alalek
Copy link
Member

If there is no strong dependency between patches, then separate PR is better.

mtfrctl reacted with thumbs up emoji

@mtfrctl
Copy link
ContributorAuthor

mtfrctl commentedOct 11, 2020
edited
Loading

@alalek I created a PR separately here#18566. I'm sorry to bother you, but I'd be happy if you could check it. 🙏

Copy link
Member

@alalekalalek left a comment

Choose a reason for hiding this comment

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

@mtfrctl Thank you for contribution 👍

@komakai Thank you for review!

komakai reacted with thumbs up emojimtfrctl reacted with heart emoji
@alalekalalek merged commit7de1891 intoopencv:masterOct 14, 2020
@mtfrctlmtfrctl deleted the objc-conversions-macosx branchOctober 15, 2020 06:13
@komakai
Copy link
Contributor

@mtfrctl keep the contributions coming!

mtfrctl reacted with laugh emoji

a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull requestMar 30, 2023
Mat conversions for macOS/AppKit* Extract CoreGraphics conversion logics from ios_conversions.mm to apple_conversions.h, apple_conversions. Add macosx_conversions.mm* Add macosx.h* Add Mat+Conversions.h and Mat+Conversions.mm* Delete duplicated declaration from apple_conversion.mm* Use short license header* Add compile guard* Delete unused imports* Move precomp.hpp import from header to implementation* Add macosx.h to skip headers* Fix compile guard condition* Use short license header* Remove commented out unused code
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@alalekalalekalalek approved these changes

@vpisarevvpisarevAwaiting requested review from vpisarev

Assignees

@alalekalalek

Projects

None yet

Milestone

4.5.1

Development

Successfully merging this pull request may close these issues.

3 participants

@mtfrctl@komakai@alalek

[8]ページ先頭

©2009-2025 Movatter.jp