Skip to content

Add Quicklook for Mat on iOS and macOS#20457

Merged
opencv-pushbot merged 1 commit intoopencv:masterfrom
komakai:ios-macos-mat-quicklook
Aug 9, 2021
Merged

Add Quicklook for Mat on iOS and macOS#20457
opencv-pushbot merged 1 commit intoopencv:masterfrom
komakai:ios-macos-mat-quicklook

Conversation

@komakai
Copy link
Copy Markdown
Contributor

@komakai komakai commented Jul 25, 2021

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 other license that is incompatible with OpenCV
  • The PR is proposed to proper branch

Sometime you want to see quickly the contents of a Mat object. This PR takes advantage of the Xcode Quicklook function to give a debug view of a Mat object as follows:

  • if the Mat has 2 dimensions and type CV_8U and 1 channel - show Xcode Quicklook as grayscale image
  • if the Mat has 2 dimensions and type CV_8U and 3 or 4 channel - show Xcode Quicklook as color image

ImageView

* if the Mat has 2 dimensions and 1 channel and number of rows and number of columns is less than 10 - display Xcode Quicklook as LaTeX style matrix

MatrixView

* if the Mat has 2 dimensions and 1 channel and type other than CV_8U - show Xcode Quicklook as a heat map

HeatMapView

@asmorkalov asmorkalov requested a review from vpisarev August 3, 2021 08:30
Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Well done! Thank you for contribution 👍

@opencv-pushbot opencv-pushbot merged commit 5e7f063 into opencv:master Aug 9, 2021
@alalek
Copy link
Copy Markdown
Member

alalek commented Oct 6, 2021

@komakai Hi! Could you please suggest how to handle a problem from here: #20816 ?

@komakai
Copy link
Copy Markdown
Contributor Author

komakai commented Oct 6, 2021

@komakai Hi! Could you please suggest how to handle a problem from here: #20816 ?

@alalek Will take a look

@komakai
Copy link
Copy Markdown
Contributor Author

komakai commented Oct 6, 2021

So we have already run-time checks like:

if (@available(iOS 13.0, *)) {     // runtime check
   return [UIFont fontWithDescriptor:[[UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleBody] fontDescriptorWithDesign:UIFontDescriptorSystemDesignSerif] size:SIZE];
} else {
    return nil;
}

but if you are building with a version of Xcode that doesn't know about iOS 13 then I guess these checks are not enough.
According to https://developer.apple.com/forums/thread/124278 it should be possible to do something like:

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000

Will try to prepare a fix.

@alalek alalek mentioned this pull request Oct 15, 2021
@komakai
Copy link
Copy Markdown
Contributor Author

komakai commented Dec 30, 2021

Equivalent functionality for Android/Java now also available: https://medium.com/@gilespayne/android-java-get-opencv-mat-visualization-plugin-8d1281047773

@wwwwwlllllllllll
Copy link
Copy Markdown

Equivalent functionality for Android/Java now also available: https://medium.com/@gilespayne/android-java-get-opencv-mat-visualization-plugin-8d1281047773

Hi, thanks for your contribution.
I find from your pictures where you directly use OpenCV in Swift but not via Object-C or C Wrapper interface.
I want to know how to do it?

@komakai
Copy link
Copy Markdown
Contributor Author

komakai commented Dec 7, 2022

@wwwwwlllllllllll

I find from your pictures where you directly use OpenCV in Swift but not via Object-C or C Wrapper interface.

Quicklook works exactly the same in Objective-C as in Swift. Just move the mouse cursor over a variable of type Mat and click the eye icon. Quicklook is not available in C/C++

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.

4 participants