├── OpenCV ├── Demo │ ├── Blur │ │ ├── Resources │ │ │ └── Blur.jpg │ │ └── Controller │ │ │ ├── BlurViewController.h │ │ │ └── BlurViewController.m │ ├── Hough │ │ ├── Resources │ │ │ └── Hough.png │ │ └── Controller │ │ │ ├── HoughViewController.h │ │ │ └── HoughViewController.m │ ├── MaxCut │ │ ├── Resources │ │ │ └── MaxCut.png │ │ └── Controller │ │ │ ├── MaxCutViewController.h │ │ │ └── MaxCutViewController.m │ ├── Repair │ │ ├── Resources │ │ │ └── Repair.jpg │ │ └── Controller │ │ │ ├── RepairViewController.h │ │ │ └── RepairViewController.m │ ├── Sobel │ │ ├── Resources │ │ │ └── Sobel.jpeg │ │ └── Controller │ │ │ ├── SobelViewController.h │ │ │ └── SobelViewController.m │ ├── Blend │ │ ├── Resources │ │ │ └── ImageBlend.png │ │ └── Controller │ │ │ ├── ImageBlendViewController.h │ │ │ └── ImageBlendViewController.m │ ├── Inpaint │ │ ├── Resources │ │ │ └── Inpaint.jpg │ │ └── Controller │ │ │ ├── InpaintViewController.h │ │ │ └── InpaintViewController.m │ ├── Morphology │ │ ├── Resources │ │ │ └── Morphology.png │ │ └── Controller │ │ │ ├── MorphologyViewController.h │ │ │ └── MorphologyViewController.m │ ├── Tiled │ │ ├── TiledViewController.h │ │ └── TiledViewController.m │ ├── ChangeColor │ │ ├── ChangeColorViewController.h │ │ └── ChangeColorViewController.m │ ├── Luminance │ │ ├── LuminanceViewController.h │ │ └── LuminanceViewController.m │ └── WarpPerspective │ │ ├── WarpPerspectiveViewController.h │ │ └── WarpPerspectiveViewController.m ├── Resource │ ├── Assets.xcassets │ │ ├── Contents.json │ │ ├── bear.imageset │ │ │ ├── bear.jpeg │ │ │ └── Contents.json │ │ ├── zuqiu.imageset │ │ │ ├── zuqiu.png │ │ │ └── Contents.json │ │ ├── Arrow.imageset │ │ │ ├── Arrow@2x.png │ │ │ ├── Arrow@3x.png │ │ │ └── Contents.json │ │ ├── pikaqiu.imageset │ │ │ ├── pikaqiu.png │ │ │ └── Contents.json │ │ ├── zuqiu2.imageset │ │ │ ├── zuqiu2.png │ │ │ └── Contents.json │ │ ├── wode_nor.imageset │ │ │ ├── wode_nor@2x.png │ │ │ ├── wode_nor@3x.png │ │ │ └── Contents.json │ │ ├── fish.imageset │ │ │ ├── IMG_4931store_1024pt.png │ │ │ └── Contents.json │ │ ├── AccentColor.colorset │ │ │ └── Contents.json │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── main.m │ ├── Info.plist │ └── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard ├── ATViewController.h ├── AppDelegate.h ├── AppDelegate.m ├── Extension │ ├── UIViewController+KJExtension.h │ ├── UIButton+KJBlock.h │ ├── UIView+KJGestureBlock.h │ ├── UIImage+KJCapture.h │ ├── UIView+KJXib.h │ ├── UINavigationItem+KJExtension.h │ ├── UIColor+KJExtension.h │ ├── UINavigationBar+KJExtension.h │ ├── UIView+KJFrame.h │ ├── UIView+KJGestureBlock.m │ ├── UIViewController+KJExtension.m │ ├── NSObject+KJGCDBox.h │ ├── UIView+KJXib.m │ ├── UIImage+KJCapture.m │ ├── UINavigationItem+KJExtension.m │ ├── UIColor+KJExtension.m │ └── NSObject+KJGCDBox.m ├── BaseViewController.h └── ATViewController.m ├── Pods ├── Target Support Files │ ├── Pods-OpenCV │ │ ├── Pods-OpenCV-frameworks-Debug-output-files.xcfilelist │ │ ├── Pods-OpenCV-frameworks-Release-output-files.xcfilelist │ │ ├── Pods-OpenCV.modulemap │ │ ├── Pods-OpenCV-dummy.m │ │ ├── Pods-OpenCV-frameworks-Debug-input-files.xcfilelist │ │ ├── Pods-OpenCV-frameworks-Release-input-files.xcfilelist │ │ ├── Pods-OpenCV-umbrella.h │ │ ├── Pods-OpenCV-Info.plist │ │ ├── Pods-OpenCV.debug.xcconfig │ │ ├── Pods-OpenCV.release.xcconfig │ │ ├── Pods-OpenCV-acknowledgements.markdown │ │ └── Pods-OpenCV-acknowledgements.plist │ ├── Masonry │ │ ├── Masonry.modulemap │ │ ├── Masonry-dummy.m │ │ ├── Masonry-prefix.pch │ │ ├── Masonry.debug.xcconfig │ │ ├── Masonry.release.xcconfig │ │ ├── Masonry-Info.plist │ │ └── Masonry-umbrella.h │ └── OpencvQueen │ │ ├── OpencvQueen.modulemap │ │ ├── OpencvQueen-dummy.m │ │ ├── OpencvQueen-prefix.pch │ │ ├── OpencvQueen-umbrella.h │ │ ├── OpencvQueen.debug.xcconfig │ │ ├── OpencvQueen.release.xcconfig │ │ └── OpencvQueen-Info.plist ├── Masonry │ ├── Masonry │ │ ├── MASLayoutConstraint.m │ │ ├── NSLayoutConstraint+MASDebugAdditions.h │ │ ├── MASLayoutConstraint.h │ │ ├── MASCompositeConstraint.h │ │ ├── Masonry.h │ │ ├── ViewController+MASAdditions.h │ │ ├── NSArray+MASShorthandAdditions.h │ │ ├── MASViewAttribute.m │ │ ├── MASViewAttribute.h │ │ ├── ViewController+MASAdditions.m │ │ ├── MASViewConstraint.h │ │ ├── MASConstraint+Private.h │ │ ├── NSArray+MASAdditions.h │ │ ├── View+MASAdditions.h │ │ ├── View+MASShorthandAdditions.h │ │ ├── MASCompositeConstraint.m │ │ ├── MASConstraintMaker.h │ │ ├── NSLayoutConstraint+MASDebugAdditions.m │ │ ├── MASUtilities.h │ │ ├── NSArray+MASAdditions.m │ │ └── View+MASAdditions.m │ └── LICENSE ├── Manifest.lock └── Local Podspecs │ └── OpencvQueen.podspec.json ├── OpenCV.xcodeproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ └── OpenCV.xcscheme ├── OpenCV.xcworkspace ├── contents.xcworkspacedata └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── Podfile.lock ├── Podfile ├── README_CN.md ├── LICENSE ├── OpencvQueen.podspec ├── Sources ├── OpencvQueen.h ├── KJOpencvType.h └── UIImage+Queen.h ├── .gitignore └── README.md /OpenCV/Demo/Blur/Resources/Blur.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangKJ/Opencv-ios/HEAD/OpenCV/Demo/Blur/Resources/Blur.jpg -------------------------------------------------------------------------------- /OpenCV/Demo/Hough/Resources/Hough.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangKJ/Opencv-ios/HEAD/OpenCV/Demo/Hough/Resources/Hough.png -------------------------------------------------------------------------------- /OpenCV/Demo/MaxCut/Resources/MaxCut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangKJ/Opencv-ios/HEAD/OpenCV/Demo/MaxCut/Resources/MaxCut.png -------------------------------------------------------------------------------- /OpenCV/Demo/Repair/Resources/Repair.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangKJ/Opencv-ios/HEAD/OpenCV/Demo/Repair/Resources/Repair.jpg -------------------------------------------------------------------------------- /OpenCV/Demo/Sobel/Resources/Sobel.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangKJ/Opencv-ios/HEAD/OpenCV/Demo/Sobel/Resources/Sobel.jpeg -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /OpenCV/Demo/Blend/Resources/ImageBlend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangKJ/Opencv-ios/HEAD/OpenCV/Demo/Blend/Resources/ImageBlend.png -------------------------------------------------------------------------------- /OpenCV/Demo/Inpaint/Resources/Inpaint.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangKJ/Opencv-ios/HEAD/OpenCV/Demo/Inpaint/Resources/Inpaint.jpg -------------------------------------------------------------------------------- /OpenCV/Demo/Morphology/Resources/Morphology.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangKJ/Opencv-ios/HEAD/OpenCV/Demo/Morphology/Resources/Morphology.png -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-OpenCV/Pods-OpenCV-frameworks-Debug-output-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Masonry.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-OpenCV/Pods-OpenCV-frameworks-Release-output-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Masonry.framework -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/bear.imageset/bear.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangKJ/Opencv-ios/HEAD/OpenCV/Resource/Assets.xcassets/bear.imageset/bear.jpeg -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/zuqiu.imageset/zuqiu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangKJ/Opencv-ios/HEAD/OpenCV/Resource/Assets.xcassets/zuqiu.imageset/zuqiu.png -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/Arrow.imageset/Arrow@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangKJ/Opencv-ios/HEAD/OpenCV/Resource/Assets.xcassets/Arrow.imageset/Arrow@2x.png -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/Arrow.imageset/Arrow@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangKJ/Opencv-ios/HEAD/OpenCV/Resource/Assets.xcassets/Arrow.imageset/Arrow@3x.png -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/pikaqiu.imageset/pikaqiu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangKJ/Opencv-ios/HEAD/OpenCV/Resource/Assets.xcassets/pikaqiu.imageset/pikaqiu.png -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/zuqiu2.imageset/zuqiu2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangKJ/Opencv-ios/HEAD/OpenCV/Resource/Assets.xcassets/zuqiu2.imageset/zuqiu2.png -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/wode_nor.imageset/wode_nor@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangKJ/Opencv-ios/HEAD/OpenCV/Resource/Assets.xcassets/wode_nor.imageset/wode_nor@2x.png -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/wode_nor.imageset/wode_nor@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangKJ/Opencv-ios/HEAD/OpenCV/Resource/Assets.xcassets/wode_nor.imageset/wode_nor@3x.png -------------------------------------------------------------------------------- /Pods/Target Support Files/Masonry/Masonry.modulemap: -------------------------------------------------------------------------------- 1 | framework module Masonry { 2 | umbrella header "Masonry-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Masonry/Masonry-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Masonry : NSObject 3 | @end 4 | @implementation PodsDummy_Masonry 5 | @end 6 | -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/fish.imageset/IMG_4931store_1024pt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangKJ/Opencv-ios/HEAD/OpenCV/Resource/Assets.xcassets/fish.imageset/IMG_4931store_1024pt.png -------------------------------------------------------------------------------- /Pods/Target Support Files/OpencvQueen/OpencvQueen.modulemap: -------------------------------------------------------------------------------- 1 | framework module OpencvQueen { 2 | umbrella header "OpencvQueen-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-OpenCV/Pods-OpenCV.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_OpenCV { 2 | umbrella header "Pods-OpenCV-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/OpencvQueen/OpencvQueen-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_OpencvQueen : NSObject 3 | @end 4 | @implementation PodsDummy_OpencvQueen 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-OpenCV/Pods-OpenCV-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_OpenCV : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_OpenCV 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-OpenCV/Pods-OpenCV-frameworks-Debug-input-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${PODS_ROOT}/Target Support Files/Pods-OpenCV/Pods-OpenCV-frameworks.sh 2 | ${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-OpenCV/Pods-OpenCV-frameworks-Release-input-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${PODS_ROOT}/Target Support Files/Pods-OpenCV/Pods-OpenCV-frameworks.sh 2 | ${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework -------------------------------------------------------------------------------- /OpenCV.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /OpenCV/ATViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ATViewController.h 3 | // OpenCV 4 | // 5 | // Created by Condy on 2021/2/8. 6 | // 7 | 8 | #import 9 | 10 | @interface ATViewController : UIViewController 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /OpenCV/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // OpenCV 4 | // 5 | // Created by Condy on 2021/2/8. 6 | // 7 | 8 | #import 9 | 10 | @interface AppDelegate : UIResponder 11 | 12 | @property (strong, nonatomic) UIWindow *window; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Masonry/Masonry-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /OpenCV.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/OpencvQueen/OpencvQueen-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /OpenCV.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASLayoutConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASLayoutConstraint.h" 10 | 11 | @implementation MASLayoutConstraint 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /OpenCV.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /OpenCV/Demo/Hough/Controller/HoughViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HoughViewController.h 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/21. 6 | // 7 | 8 | #import "BaseViewController.h" 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface HoughViewController : BaseViewController 13 | 14 | @end 15 | 16 | NS_ASSUME_NONNULL_END 17 | -------------------------------------------------------------------------------- /OpenCV/Demo/Inpaint/Controller/InpaintViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // InpaintViewController.h 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/22. 6 | // 7 | 8 | #import "BaseViewController.h" 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface InpaintViewController : BaseViewController 13 | 14 | @end 15 | 16 | NS_ASSUME_NONNULL_END 17 | -------------------------------------------------------------------------------- /OpenCV/Demo/Blur/Controller/BlurViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BlurViewController.h 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | #import "BaseViewController.h" 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface BlurViewController : BaseViewController 13 | 14 | @end 15 | 16 | NS_ASSUME_NONNULL_END 17 | -------------------------------------------------------------------------------- /OpenCV/Demo/Tiled/TiledViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TiledViewController.h 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | 9 | #import "BaseViewController.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface TiledViewController : BaseViewController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /OpenCV/Demo/Sobel/Controller/SobelViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SobelViewController.h 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/21. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | #import "BaseViewController.h" 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface SobelViewController : BaseViewController 13 | 14 | @end 15 | 16 | NS_ASSUME_NONNULL_END 17 | -------------------------------------------------------------------------------- /OpenCV/Demo/ChangeColor/ChangeColorViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ChangeColorViewController.h 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | #import "BaseViewController.h" 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface ChangeColorViewController : BaseViewController 13 | 14 | @end 15 | 16 | NS_ASSUME_NONNULL_END 17 | -------------------------------------------------------------------------------- /OpenCV/Demo/Luminance/LuminanceViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // LuminanceViewController.h 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | 9 | #import "BaseViewController.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface LuminanceViewController : BaseViewController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /OpenCV/Demo/MaxCut/Controller/MaxCutViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MaxCutViewController.h 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | 9 | #import "BaseViewController.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MaxCutViewController : BaseViewController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /OpenCV/Demo/Repair/Controller/RepairViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RepairViewController.h 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | 9 | #import "BaseViewController.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface RepairViewController : BaseViewController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /OpenCV/Demo/Blend/Controller/ImageBlendViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImageBlendViewController.h 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | #import "BaseViewController.h" 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface ImageBlendViewController : BaseViewController 13 | 14 | @end 15 | 16 | NS_ASSUME_NONNULL_END 17 | -------------------------------------------------------------------------------- /OpenCV/Demo/Morphology/Controller/MorphologyViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MorphologyViewController.h 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | 9 | #import "BaseViewController.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MorphologyViewController : BaseViewController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /OpenCV/Demo/WarpPerspective/WarpPerspectiveViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // WarpPerspectiveViewController.h 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | 9 | #import "BaseViewController.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface WarpPerspectiveViewController : BaseViewController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-OpenCV/Pods-OpenCV-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_OpenCVVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_OpenCVVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/bear.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "bear.jpeg", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * makes debug and log output of NSLayoutConstraints more readable 13 | */ 14 | @interface NSLayoutConstraint (MASDebugAdditions) 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/pikaqiu.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "pikaqiu.png", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/zuqiu.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "zuqiu.png", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/zuqiu2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "zuqiu2.png", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/fish.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "IMG_4931store_1024pt.png", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /OpenCV/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // OpenCV 4 | // 5 | // Created by Condy on 2021/2/8. 6 | // 7 | 8 | #import "AppDelegate.h" 9 | 10 | @interface AppDelegate () 11 | 12 | @end 13 | 14 | @implementation AppDelegate 15 | 16 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 17 | // Override point for customization after application launch. 18 | return YES; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/Arrow.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "filename" : "Arrow@2x.png", 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "filename" : "Arrow@3x.png", 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "author" : "xcode", 20 | "version" : 1 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/wode_nor.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "filename" : "wode_nor@2x.png", 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "filename" : "wode_nor@3x.png", 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "author" : "xcode", 20 | "version" : 1 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Masonry (1.1.0) 3 | - OpencvQueen (0.1.0) 4 | 5 | DEPENDENCIES: 6 | - Masonry 7 | - OpencvQueen (from `./`) 8 | 9 | SPEC REPOS: 10 | trunk: 11 | - Masonry 12 | 13 | EXTERNAL SOURCES: 14 | OpencvQueen: 15 | :path: "./" 16 | 17 | SPEC CHECKSUMS: 18 | Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 19 | OpencvQueen: db01ec55de60e72c8f2f9dd1c7904b25a54b117f 20 | 21 | PODFILE CHECKSUM: f09e249afc9241b120e49da1e1b391d69be56b57 22 | 23 | COCOAPODS: 1.11.3 24 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Masonry (1.1.0) 3 | - OpencvQueen (0.1.0) 4 | 5 | DEPENDENCIES: 6 | - Masonry 7 | - OpencvQueen (from `./`) 8 | 9 | SPEC REPOS: 10 | trunk: 11 | - Masonry 12 | 13 | EXTERNAL SOURCES: 14 | OpencvQueen: 15 | :path: "./" 16 | 17 | SPEC CHECKSUMS: 18 | Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 19 | OpencvQueen: db01ec55de60e72c8f2f9dd1c7904b25a54b117f 20 | 21 | PODFILE CHECKSUM: f09e249afc9241b120e49da1e1b391d69be56b57 22 | 23 | COCOAPODS: 1.11.3 24 | -------------------------------------------------------------------------------- /OpenCV/Resource/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // OpenCV 4 | // 5 | // Created by Condy on 2021/2/8. 6 | // 7 | 8 | #import 9 | #import "AppDelegate.h" 10 | 11 | int main(int argc, char * argv[]) { 12 | NSString * appDelegateClassName; 13 | @autoreleasepool { 14 | // Setup code that might create autoreleased objects goes here. 15 | appDelegateClassName = NSStringFromClass([AppDelegate class]); 16 | } 17 | return UIApplicationMain(argc, argv, nil, appDelegateClassName); 18 | } 19 | -------------------------------------------------------------------------------- /Pods/Target Support Files/OpencvQueen/OpencvQueen-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "KJOpencvType.h" 14 | #import "OpencvQueen.h" 15 | #import "UIImage+Queen.h" 16 | 17 | FOUNDATION_EXPORT double OpencvQueenVersionNumber; 18 | FOUNDATION_EXPORT const unsigned char OpencvQueenVersionString[]; 19 | 20 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * When you are debugging or printing the constraints attached to a view this subclass 13 | * makes it easier to identify which constraints have been created via Masonry 14 | */ 15 | @interface MASLayoutConstraint : NSLayoutConstraint 16 | 17 | /** 18 | * a key to associate with this constraint 19 | */ 20 | @property (nonatomic, strong) id mas_key; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | /** 13 | * A group of MASConstraint objects 14 | */ 15 | @interface MASCompositeConstraint : MASConstraint 16 | 17 | /** 18 | * Creates a composite with a predefined array of children 19 | * 20 | * @param children child MASConstraints 21 | * 22 | * @return a composite constraint 23 | */ 24 | - (id)initWithChildren:(NSArray *)children; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/OpencvQueen/OpencvQueen.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/OpencvQueen 3 | EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/.. 9 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 13 | -------------------------------------------------------------------------------- /Pods/Target Support Files/OpencvQueen/OpencvQueen.release.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/OpencvQueen 3 | EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/.. 9 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 13 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Masonry/Masonry.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/Masonry 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | OTHER_LDFLAGS = $(inherited) -framework "Foundation" -framework "UIKit" 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/Masonry 9 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 13 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Masonry/Masonry.release.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/Masonry 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | OTHER_LDFLAGS = $(inherited) -framework "Foundation" -framework "UIKit" 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/Masonry 9 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 13 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | target 'OpenCV' do 5 | # Comment the next line if you don't want to use dynamic frameworks 6 | use_frameworks! 7 | 8 | # Pods for OpenCV 9 | 10 | pod 'OpencvQueen', :path => './' 11 | 12 | pod 'Masonry' 13 | 14 | end 15 | 16 | ## Ignore CocoaPods warnings 17 | inhibit_all_warnings! 18 | post_install do |installer| 19 | installer.pods_project.targets.each do |target| 20 | target.build_configurations.each do |config| 21 | config.build_settings['COMPILER_INDEX_STORE_ENABLE'] = "NO" 22 | if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 10.0 23 | config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0' 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /Pods/Local Podspecs/OpencvQueen.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "OpencvQueen", 3 | "version": "0.1.0", 4 | "summary": "About Opencv graphics processing.", 5 | "homepage": "https://github.com/yangKJ/OpencvQueen", 6 | "license": { 7 | "type": "MIT", 8 | "file": "LICENSE" 9 | }, 10 | "authors": { 11 | "yangkejun": "ykj310@126.com" 12 | }, 13 | "source": { 14 | "git": "https://github.com/yangKJ/OpencvQueen.git", 15 | "tag": "0.1.0" 16 | }, 17 | "platforms": { 18 | "ios": "9.0" 19 | }, 20 | "requires_arc": true, 21 | "static_framework": true, 22 | "frameworks": [ 23 | "UIKit", 24 | "Foundation" 25 | ], 26 | "pod_target_xcconfig": { 27 | "EXCLUDED_ARCHS[sdk=iphonesimulator*]": "arm64" 28 | }, 29 | "user_target_xcconfig": { 30 | "EXCLUDED_ARCHS[sdk=iphonesimulator*]": "arm64" 31 | }, 32 | "source_files": "Sources/*.{h,mm}" 33 | } 34 | -------------------------------------------------------------------------------- /OpenCV/Demo/Sobel/Controller/SobelViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // SobelViewController.m 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/21. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | #import "SobelViewController.h" 9 | 10 | @interface SobelViewController () 11 | 12 | @end 13 | 14 | @implementation SobelViewController 15 | 16 | #if __has_include() 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view. 21 | self.topImageView.image = [UIImage imageNamed:@"Sobel.jpeg"]; 22 | __weak __typeof(self) weakself = self; 23 | self.kButtonAction = ^{ 24 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvFeatureExtractionFromSobel]; 25 | }; 26 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvFeatureExtractionFromSobel]; 27 | } 28 | 29 | #endif 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | // 2 | // Masonry.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Masonry. 12 | FOUNDATION_EXPORT double MasonryVersionNumber; 13 | 14 | //! Project version string for Masonry. 15 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[]; 16 | 17 | #import "MASUtilities.h" 18 | #import "View+MASAdditions.h" 19 | #import "View+MASShorthandAdditions.h" 20 | #import "ViewController+MASAdditions.h" 21 | #import "NSArray+MASAdditions.h" 22 | #import "NSArray+MASShorthandAdditions.h" 23 | #import "MASConstraint.h" 24 | #import "MASCompositeConstraint.h" 25 | #import "MASViewAttribute.h" 26 | #import "MASViewConstraint.h" 27 | #import "MASConstraintMaker.h" 28 | #import "MASLayoutConstraint.h" 29 | #import "NSLayoutConstraint+MASDebugAdditions.h" 30 | -------------------------------------------------------------------------------- /OpenCV/Demo/Hough/Controller/HoughViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HoughViewController.m 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/21. 6 | // 7 | 8 | #import "HoughViewController.h" 9 | 10 | @interface HoughViewController () 11 | 12 | @end 13 | 14 | @implementation HoughViewController 15 | 16 | #if __has_include() 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view. 21 | self.topImageView.image = [UIImage imageNamed:@"Hough"]; 22 | __weak __typeof(self) weakself = self; 23 | self.kButtonAction = ^{ 24 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvHoughLinesCorrectTextImageFillColor:UIColorFromHEXA(0x292a30, 1)]; 25 | }; 26 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvHoughLinesCorrectTextImageFillColor:UIColorFromHEXA(0x292a30, 1)]; 27 | } 28 | 29 | #endif 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Masonry/Masonry-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Masonry/Masonry-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "MASCompositeConstraint.h" 14 | #import "MASConstraint+Private.h" 15 | #import "MASConstraint.h" 16 | #import "MASConstraintMaker.h" 17 | #import "MASLayoutConstraint.h" 18 | #import "Masonry.h" 19 | #import "MASUtilities.h" 20 | #import "MASViewAttribute.h" 21 | #import "MASViewConstraint.h" 22 | #import "NSArray+MASAdditions.h" 23 | #import "NSArray+MASShorthandAdditions.h" 24 | #import "NSLayoutConstraint+MASDebugAdditions.h" 25 | #import "View+MASAdditions.h" 26 | #import "View+MASShorthandAdditions.h" 27 | #import "ViewController+MASAdditions.h" 28 | 29 | FOUNDATION_EXPORT double MasonryVersionNumber; 30 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[]; 31 | 32 | -------------------------------------------------------------------------------- /OpenCV/Demo/MaxCut/Controller/MaxCutViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MaxCutViewController.m 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | 9 | #import "MaxCutViewController.h" 10 | 11 | @interface MaxCutViewController () 12 | 13 | @end 14 | 15 | @implementation MaxCutViewController 16 | 17 | #if __has_include() 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | // Do any additional setup after loading the view. 22 | self.topImageView.image = [UIImage imageNamed:@"MaxCut"]; 23 | self.topImageView.backgroundColor = UIColor.blackColor; 24 | __weak __typeof(self) weakself = self; 25 | self.kButtonAction = ^{ 26 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvCutMaxRegionImage]; 27 | }; 28 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvCutMaxRegionImage]; 29 | } 30 | 31 | #endif 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Pods/Target Support Files/OpencvQueen/OpencvQueen-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 0.1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-OpenCV/Pods-OpenCV-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | #ifdef MAS_VIEW_CONTROLLER 14 | 15 | @interface MAS_VIEW_CONTROLLER (MASAdditions) 16 | 17 | /** 18 | * following properties return a new MASViewAttribute with appropriate UILayoutGuide and NSLayoutAttribute 19 | */ 20 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideTop; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideBottom; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideTop; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideBottom; 26 | 27 | 28 | @end 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | # OpencvQueen 2 | 3 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-brightgreen.svg?style=flat&colorA=28a745&&colorB=4E4E4E)](https://github.com/yangKJ/OpencvQueen) 4 | [![CocoaPods Compatible](https://img.shields.io/cocoapods/v/OpencvQueen.svg?style=flat&label=OpencvQueen&colorA=28a745&&colorB=4E4E4E)](https://cocoapods.org/pods/OpencvQueen) 5 | ![Platform](https://img.shields.io/badge/Platforms-iOS%20%7C%20macOS%20%7C%20watchOS-4E4E4E.svg?colorA=28a745) 6 | 7 | **[OpencvQueen](https://github.com/yangKJ/OpencvQueen)** 主要是用于学习图片处理相关记录,例如[OpenCV 4.0.1](https://docs.opencv.org/4.0.1/modules.html)图片处理、[Metal](https://objccn.io/issue-18-2/)图形滤镜处理等 8 | 9 | **图形处理和滤镜制作👒👒👒** 10 | 11 | ------- 12 | 13 | [English](README.md) | 简体中文 14 | 15 | ### CocoaPods 16 | 17 | 安装使用OpenCV模块: 18 | 19 | ``` 20 | pod 'OpencvQueen' 21 | ``` 22 | 23 | ----- 24 | 25 | > **觉得有帮助的老哥们,请帮忙点个星 ⭐..** 26 | 27 | **救救孩子吧,谢谢各位老板。** 28 | 29 | 🥺 - [**传送门**](https://github.com/yangKJ/OpencvQueen) 30 | 31 | ----- 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 yangkejun 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /OpenCV/Demo/Repair/Controller/RepairViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RepairViewController.m 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | 9 | #import "RepairViewController.h" 10 | 11 | @interface RepairViewController () 12 | 13 | @end 14 | 15 | @implementation RepairViewController 16 | 17 | #if __has_include() 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | // Do any additional setup after loading the view. 22 | __block UIImage *oldImage = self.topImageView.image = [UIImage imageNamed:@"Repair.jpg"]; 23 | __weak __typeof(self) weakself = self; 24 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 25 | UIImage *image = [oldImage kj_opencvRepairImage]; 26 | dispatch_async(dispatch_get_main_queue(), ^{ 27 | weakself.bottomImageView.image = image; 28 | }); 29 | }); 30 | self.kButtonAction = ^{ 31 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvRepairImage]; 32 | }; 33 | } 34 | 35 | #endif 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Pods/Masonry/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand array additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface NSArray (MASShorthandAdditions) 18 | 19 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 20 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 21 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 22 | 23 | @end 24 | 25 | @implementation NSArray (MASShorthandAdditions) 26 | 27 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 28 | return [self mas_makeConstraints:block]; 29 | } 30 | 31 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 32 | return [self mas_updateConstraints:block]; 33 | } 34 | 35 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 36 | return [self mas_remakeConstraints:block]; 37 | } 38 | 39 | @end 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /OpenCV/Extension/UIViewController+KJExtension.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+KJExtension.h 3 | // KJEmitterView 4 | // 5 | // Created by 77。 on 2021/5/28. 6 | // https://github.com/YangKJ/KJCategories 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface UIViewController (KJExtension) 13 | 14 | /// Jump back to the specified controller 15 | /// @param clazz specifies the controller class name 16 | /// @param complete successfully callback out the controller 17 | /// @return returns whether the jump was successful 18 | - (BOOL)kj_popTargetViewController:(Class)clazz complete:(void(^)(UIViewController * vc))complete; 19 | 20 | /// Switch the root view controller 21 | - (void)kj_changeRootViewController:(void(^)(BOOL success))complete; 22 | 23 | 24 | /// Whether to turn on the sliding back gesture 25 | - (void)kj_openPopGesture:(BOOL)open; 26 | 27 | /// The system comes with sharing 28 | /// @param items share data 29 | /// @param complete Sharing completion callback processing 30 | /// @return Return to share controller 31 | - (UIActivityViewController *)kj_shareActivityWithItems:(NSArray *)items 32 | complete:(nullable void(^)(BOOL success))complete; 33 | 34 | @end 35 | 36 | NS_ASSUME_NONNULL_END 37 | -------------------------------------------------------------------------------- /OpenCV/Resource/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /OpenCV/Demo/Inpaint/Controller/InpaintViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // InpaintViewController.m 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/22. 6 | // 7 | 8 | #import "InpaintViewController.h" 9 | 10 | @interface InpaintViewController () 11 | 12 | @end 13 | 14 | @implementation InpaintViewController 15 | 16 | #if __has_include() 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view. 21 | __block UIImage *_image = self.topImageView.image = [UIImage imageNamed:@"Inpaint.jpg"]; 22 | self.topSlider.value = 0.25; 23 | __weak __typeof(self) weakself = self; 24 | self.kButtonAction = ^{ 25 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvInpaintImage:10]; 26 | }; 27 | self.kSliderMoveEnd = ^(CGFloat value) { 28 | CGFloat x = 20 * value; 29 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvInpaintImage:x]; 30 | }; 31 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 32 | UIImage *image = [_image kj_opencvInpaintImage:5]; 33 | dispatch_async(dispatch_get_main_queue(), ^{ 34 | weakself.bottomImageView.image = image; 35 | }); 36 | }); 37 | } 38 | 39 | #endif 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /OpenCV/Extension/UIButton+KJBlock.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIButton+KJBlock.h 3 | // KJEmitterView 4 | // 5 | // Created by 77。 on 2019/4/4. 6 | // https://github.com/YangKJ/KJCategories 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | typedef void(^KJButtonBlock)(UIButton * kButton); 12 | IB_DESIGNABLE 13 | @interface UIButton (KJBlock) 14 | 15 | /// Add click event, default UIControlEventTouchUpInside 16 | - (void)kj_addAction:(void(^)(UIButton * kButton))block; 17 | 18 | /// Add event, does not support multiple enumeration forms 19 | - (void)kj_addAction:(KJButtonBlock)block forControlEvents:(UIControlEvents)controlEvents; 20 | 21 | /// Click the event interval, set a non-zero cancellation interval 22 | @property (nonatomic, assign) IBInspectable CGFloat timeInterval; 23 | 24 | #pragma mark - Expand the click field 25 | 26 | /// Expand the unified click domain, support Xib quick setting 27 | @property (nonatomic, assign) IBInspectable CGFloat enlargeClick; 28 | /// Set button extra hot zone 29 | @property (nonatomic, assign) UIEdgeInsets touchAreaInsets; 30 | 31 | /// Expand the click domain 32 | /// @param top Top 33 | /// @param left Left 34 | /// @param bottom Bottom 35 | /// @param right Right 36 | - (void)EnlargeEdgeTop:(CGFloat)top left:(CGFloat)left bottom:(CGFloat)bottom right:(CGFloat)right; 37 | 38 | @end 39 | 40 | NS_ASSUME_NONNULL_END 41 | -------------------------------------------------------------------------------- /OpenCV/Demo/ChangeColor/ChangeColorViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ChangeColorViewController.m 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | #import "ChangeColorViewController.h" 9 | 10 | @interface ChangeColorViewController () 11 | 12 | @end 13 | 14 | @implementation ChangeColorViewController 15 | 16 | #if __has_include() 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view. 21 | __weak __typeof(self) weakself = self; 22 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvChangeR:-1 g:-1 b:-1]; 23 | self.kButtonAction = ^{ 24 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvChangeR:-1 g:-1 b:-1]; 25 | }; 26 | self.kSliderMoveEnd = ^(CGFloat value) { 27 | CGFloat x = 255 * value; 28 | CGFloat y = 255 * weakself.bottomSlider.value; 29 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvChangeR:x g:y b:-1]; 30 | }; 31 | self.kSlider2MoveEnd = ^(CGFloat value) { 32 | CGFloat x = 255 * weakself.topSlider.value; 33 | CGFloat y = 255 * value; 34 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvChangeR:y g:-1 b:x]; 35 | }; 36 | } 37 | 38 | #endif 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-OpenCV/Pods-OpenCV.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Masonry" "${PODS_CONFIGURATION_BUILD_DIR}/OpencvQueen" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Masonry/Masonry.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/OpencvQueen/OpencvQueen.framework/Headers" 6 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 7 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Masonry/Masonry.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/OpencvQueen/OpencvQueen.framework/Headers" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Masonry" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/OpencvQueen" 8 | OTHER_LDFLAGS = $(inherited) -ObjC -framework "Foundation" -framework "Masonry" -framework "OpencvQueen" -framework "UIKit" 9 | PODS_BUILD_DIR = ${BUILD_DIR} 10 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 12 | PODS_ROOT = ${SRCROOT}/Pods 13 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 14 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 15 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-OpenCV/Pods-OpenCV.release.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Masonry" "${PODS_CONFIGURATION_BUILD_DIR}/OpencvQueen" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Masonry/Masonry.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/OpencvQueen/OpencvQueen.framework/Headers" 6 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 7 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Masonry/Masonry.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/OpencvQueen/OpencvQueen.framework/Headers" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Masonry" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/OpencvQueen" 8 | OTHER_LDFLAGS = $(inherited) -ObjC -framework "Foundation" -framework "Masonry" -framework "OpencvQueen" -framework "UIKit" 9 | PODS_BUILD_DIR = ${BUILD_DIR} 10 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 12 | PODS_ROOT = ${SRCROOT}/Pods 13 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 14 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 15 | -------------------------------------------------------------------------------- /OpenCV/BaseViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseViewController.h 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | #import "UIImage+KJCapture.h" 12 | #import "UIButton+KJBlock.h" 13 | #import "UIView+KJFrame.h" 14 | #import "UIView+KJXib.h" 15 | #import "UIView+KJGestureBlock.h" 16 | #import "UIColor+KJExtension.h" 17 | #import "UINavigationBar+KJExtension.h" 18 | #import "UINavigationItem+KJExtension.h" 19 | #import "UIViewController+KJExtension.h" 20 | 21 | NS_ASSUME_NONNULL_BEGIN 22 | 23 | @interface BaseViewController : UIViewController 24 | 25 | @property (nonatomic, strong) UIImageView *topImageView; 26 | @property (nonatomic, strong) UIImageView *bottomImageView; 27 | @property (nonatomic, strong) UIButton *changeButton; 28 | @property (nonatomic, strong) UISlider *topSlider; 29 | @property (nonatomic, strong) UISlider *bottomSlider; 30 | @property (nonatomic, copy, readwrite) void(^kSliderMoving)(CGFloat value); 31 | @property (nonatomic, copy, readwrite) void(^kSliderMoveEnd)(CGFloat value); 32 | @property (nonatomic, copy, readwrite) void(^kSlider2Moving)(CGFloat value); 33 | @property (nonatomic, copy, readwrite) void(^kSlider2MoveEnd)(CGFloat value); 34 | @property (nonatomic, copy, readwrite) void(^kButtonAction)(void); 35 | 36 | @end 37 | 38 | NS_ASSUME_NONNULL_END 39 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASViewAttribute.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewAttribute.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | 11 | @implementation MASViewAttribute 12 | 13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute { 14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute]; 15 | return self; 16 | } 17 | 18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute { 19 | self = [super init]; 20 | if (!self) return nil; 21 | 22 | _view = view; 23 | _item = item; 24 | _layoutAttribute = layoutAttribute; 25 | 26 | return self; 27 | } 28 | 29 | - (BOOL)isSizeAttribute { 30 | return self.layoutAttribute == NSLayoutAttributeWidth 31 | || self.layoutAttribute == NSLayoutAttributeHeight; 32 | } 33 | 34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute { 35 | if ([viewAttribute isKindOfClass:self.class]) { 36 | return self.view == viewAttribute.view 37 | && self.layoutAttribute == viewAttribute.layoutAttribute; 38 | } 39 | return [super isEqual:viewAttribute]; 40 | } 41 | 42 | - (NSUInteger)hash { 43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /OpenCV/Extension/UIView+KJGestureBlock.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+KJGestureBlock.h 3 | // KJEmitterView 4 | // 5 | // Created by 77。 on 2019/6/4. 6 | // https://github.com/YangKJ/KJCategories 7 | 8 | /* 使用示例 */ 9 | // [self.view kj_AddTapGestureRecognizerBlock:^(UIView *view, UIGestureRecognizer *gesture) { 10 | // [view removeGestureRecognizer:gesture]; 11 | // }]; 12 | 13 | #import 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | typedef void(^KJGestureRecognizerBlock)(UIView * view, UIGestureRecognizer * gesture); 18 | typedef NS_ENUM(NSUInteger, KJGestureType) { 19 | KJGestureTypeTap, // click 20 | KJGestureTypeDouble, // double click 21 | KJGestureTypeLongPress, // long press 22 | KJGestureTypeSwipe, // swipe 23 | KJGestureTypePan, // move 24 | KJGestureTypeRotate, // rotate 25 | KJGestureTypePinch, // zoom 26 | }; 27 | @interface UIView (KJGestureBlock) 28 | 29 | /// Click gesture 30 | /// @param block gesture response callback 31 | /// @return returns the corresponding gesture 32 | - (UIGestureRecognizer *)kj_AddTapGestureRecognizerBlock:(KJGestureRecognizerBlock)block; 33 | 34 | /// Gesture processing 35 | /// @param type gesture type 36 | /// @param block gesture response callback 37 | /// @return returns the corresponding gesture 38 | - (UIGestureRecognizer *)kj_AddGestureRecognizer:(KJGestureType)type block:(KJGestureRecognizerBlock)block; 39 | 40 | @end 41 | 42 | NS_ASSUME_NONNULL_END 43 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewAttribute.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * An immutable tuple which stores the view and the related NSLayoutAttribute. 13 | * Describes part of either the left or right hand side of a constraint equation 14 | */ 15 | @interface MASViewAttribute : NSObject 16 | 17 | /** 18 | * The view which the reciever relates to. Can be nil if item is not a view. 19 | */ 20 | @property (nonatomic, weak, readonly) MAS_VIEW *view; 21 | 22 | /** 23 | * The item which the reciever relates to. 24 | */ 25 | @property (nonatomic, weak, readonly) id item; 26 | 27 | /** 28 | * The attribute which the reciever relates to 29 | */ 30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute; 31 | 32 | /** 33 | * Convenience initializer. 34 | */ 35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute; 36 | 37 | /** 38 | * The designated initializer. 39 | */ 40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute; 41 | 42 | /** 43 | * Determine whether the layoutAttribute is a size attribute 44 | * 45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight 46 | */ 47 | - (BOOL)isSizeAttribute; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /OpenCV/Demo/Blur/Controller/BlurViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // BlurViewController.m 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | #import "BlurViewController.h" 9 | 10 | @interface BlurViewController () 11 | 12 | @end 13 | 14 | @implementation BlurViewController 15 | 16 | #if __has_include() 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view. 21 | self.topImageView.image = [UIImage imageNamed:@"Blur.jpg"]; 22 | __weak __typeof(self) weakself = self; 23 | self.kButtonAction = ^{ 24 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvBilateralFilterBlurRadio:15 sigma:100]; 25 | }; 26 | self.kSliderMoveEnd = ^(CGFloat value) { 27 | CGFloat x = 50 * value; 28 | CGFloat y = 150 * weakself.bottomSlider.value; 29 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvBilateralFilterBlurRadio:x sigma:y]; 30 | }; 31 | self.kSlider2MoveEnd = ^(CGFloat value) { 32 | CGFloat x = 50 * weakself.topSlider.value; 33 | CGFloat y = 150 * value; 34 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvBilateralFilterBlurRadio:x sigma:y]; 35 | }; 36 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvBilateralFilterBlurRadio:15 sigma:100]; 37 | } 38 | 39 | #endif 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/ViewController+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "ViewController+MASAdditions.h" 10 | 11 | #ifdef MAS_VIEW_CONTROLLER 12 | 13 | @implementation MAS_VIEW_CONTROLLER (MASAdditions) 14 | 15 | - (MASViewAttribute *)mas_topLayoutGuide { 16 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 17 | } 18 | - (MASViewAttribute *)mas_topLayoutGuideTop { 19 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 20 | } 21 | - (MASViewAttribute *)mas_topLayoutGuideBottom { 22 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 23 | } 24 | 25 | - (MASViewAttribute *)mas_bottomLayoutGuide { 26 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 27 | } 28 | - (MASViewAttribute *)mas_bottomLayoutGuideTop { 29 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 30 | } 31 | - (MASViewAttribute *)mas_bottomLayoutGuideBottom { 32 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 33 | } 34 | 35 | 36 | 37 | @end 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | #import "MASUtilities.h" 13 | 14 | /** 15 | * A single constraint. 16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view 17 | */ 18 | @interface MASViewConstraint : MASConstraint 19 | 20 | /** 21 | * First item/view and first attribute of the NSLayoutConstraint 22 | */ 23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute; 24 | 25 | /** 26 | * Second item/view and second attribute of the NSLayoutConstraint 27 | */ 28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute; 29 | 30 | /** 31 | * initialises the MASViewConstraint with the first part of the equation 32 | * 33 | * @param firstViewAttribute view.mas_left, view.mas_width etc. 34 | * 35 | * @return a new view constraint 36 | */ 37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute; 38 | 39 | /** 40 | * Returns all MASViewConstraints installed with this view as a first item. 41 | * 42 | * @param view A view to retrieve constraints for. 43 | * 44 | * @return An array of MASViewConstraints. 45 | */ 46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /OpenCV/Extension/UIImage+KJCapture.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+KJCapture.h 3 | // KJEmitterView 4 | // 5 | // Created by yangkejun on 2020/8/10. 6 | // https://github.com/YangKJ/KJCategories 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | /// Screenshot processing 13 | @interface UIImage (KJCapture) 14 | 15 | /// Screenshot of current view 16 | + (UIImage *)kj_captureScreen:(UIView *)view; 17 | 18 | /// Screen shot of specified location 19 | /// @param view screenshot control 20 | /// @param rect intercept size 21 | + (UIImage *)kj_captureScreen:(UIView *)view Rect:(CGRect)rect; 22 | 23 | /// Screenshot of custom quality 24 | /// @param view is intercepted view 25 | /// @param rect intercept size 26 | /// @param quality quality multiple 27 | /// @return return screenshot 28 | + (UIImage *)kj_captureScreen:(UIView *)view Rect:(CGRect)rect Quality:(NSInteger)quality; 29 | 30 | /// Take a screenshot of the current screen (window screenshot) 31 | + (UIImage *)kj_captureScreenWindow; 32 | 33 | /// Capture the current screen (rotate according to the direction of the phone) 34 | + (UIImage *)kj_captureScreenWindowForInterfaceOrientation; 35 | 36 | /// Take a screenshot of the scroll view 37 | /// @param scroll intercept view 38 | /// @param contentOffset start to intercept position 39 | /// @return return screenshot 40 | + (UIImage *)kj_captureScreenWithScrollView:(UIScrollView *)scroll 41 | contentOffset:(CGPoint)contentOffset; 42 | 43 | @end 44 | 45 | NS_ASSUME_NONNULL_END 46 | -------------------------------------------------------------------------------- /OpenCV/Demo/Morphology/Controller/MorphologyViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MorphologyViewController.m 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | #import "MorphologyViewController.h" 9 | 10 | @interface MorphologyViewController () 11 | 12 | @end 13 | 14 | @implementation MorphologyViewController 15 | 16 | #if __has_include() 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view. 21 | self.topImageView.image = [UIImage imageNamed:@"Morphology"]; 22 | __weak __typeof(self) weakself = self; 23 | weakself.bottomSlider.value = 0.42; 24 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvMorphology:KJOpencvMorphologyStyleOPEN element:42]; 25 | self.kButtonAction = ^{ 26 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvMorphology:KJOpencvMorphologyStyleOPEN element:42]; 27 | }; 28 | self.kSliderMoveEnd = ^(CGFloat value) { 29 | int x = 4 * value; 30 | int y = 100 * weakself.bottomSlider.value; 31 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvMorphology:x element:y]; 32 | }; 33 | self.kSlider2MoveEnd = ^(CGFloat value) { 34 | int x = 4 * weakself.topSlider.value; 35 | int y = 100 * value; 36 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvMorphology:x element:y]; 37 | }; 38 | } 39 | 40 | #endif 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /OpenCV/Demo/Luminance/LuminanceViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // LuminanceViewController.m 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | 9 | #import "LuminanceViewController.h" 10 | 11 | @interface LuminanceViewController () 12 | 13 | @end 14 | 15 | @implementation LuminanceViewController 16 | 17 | #if __has_include() 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | // Do any additional setup after loading the view. 22 | // self.orignalImageView.image = [UIImage imageNamed:@"banana"]; 23 | self.topSlider.value = 0; 24 | self.bottomSlider.value = 0.5; 25 | __weak __typeof(self) weakself = self; 26 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvChangeContrast:0 luminance:1]; 27 | self.kButtonAction = ^{ 28 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvChangeContrast:0 luminance:1]; 29 | }; 30 | self.kSliderMoveEnd = ^(CGFloat value) { 31 | CGFloat x = 100 * value; 32 | CGFloat y = 2 * weakself.bottomSlider.value; 33 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvChangeContrast:x luminance:y]; 34 | }; 35 | self.kSlider2MoveEnd = ^(CGFloat value) { 36 | CGFloat x = 100 * weakself.topSlider.value; 37 | CGFloat y = 2 * value; 38 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvChangeContrast:x luminance:y]; 39 | }; 40 | } 41 | 42 | #endif 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /OpencvQueen.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint OpencvQueen.podspec' to ensure this is a 3 | # valid spec before submitting. 4 | # 5 | # Any lines starting with a # are optional, but their use is encouraged 6 | # To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = 'OpencvQueen' 11 | s.version = '0.1.0' 12 | s.summary = 'About Opencv graphics processing.' 13 | 14 | # This description is used to generate tags and improve search results. 15 | # * Think: What does it do? Why did you write it? What is the focus? 16 | # * Try to keep it short, snappy and to the point. 17 | # * Write the description between the DESC delimiters below. 18 | # * Finally, don't worry about the indent, CocoaPods strips it! 19 | 20 | s.homepage = 'https://github.com/yangKJ/OpencvQueen' 21 | s.license = { :type => 'MIT', :file => 'LICENSE' } 22 | s.author = { 'yangkejun' => 'ykj310@126.com' } 23 | s.source = { :git => 'https://github.com/yangKJ/OpencvQueen.git', :tag => "#{s.version}" } 24 | 25 | s.platform = :ios 26 | s.ios.deployment_target = '9.0' 27 | s.requires_arc = true 28 | s.static_framework = true 29 | s.frameworks = "UIKit", "Foundation" 30 | 31 | s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } 32 | s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } 33 | 34 | s.source_files = "Sources/*.{h,mm}" 35 | s.dependency 'OpenCV', "~> 4.1.0" 36 | 37 | end 38 | -------------------------------------------------------------------------------- /OpenCV/Demo/Tiled/TiledViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TiledViewController.m 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | 9 | #import "TiledViewController.h" 10 | 11 | @interface TiledViewController () 12 | 13 | @end 14 | 15 | @implementation TiledViewController 16 | 17 | #if __has_include() 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | // Do any additional setup after loading the view. 22 | self.topSlider.value = 0.5; 23 | self.bottomSlider.value = 0.5; 24 | UIImage *temp = self.topImageView.image; 25 | __weak __typeof(self) weakself = self; 26 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 27 | UIImage *image = [temp kj_opencvTiledRows:5 cols:5]; 28 | dispatch_async(dispatch_get_main_queue(), ^{ 29 | weakself.bottomImageView.image = image; 30 | }); 31 | }); 32 | self.kButtonAction = ^{ 33 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvTiledRows:5 cols:5]; 34 | }; 35 | self.kSliderMoveEnd = ^(CGFloat value) { 36 | CGFloat x = 10 * value; 37 | CGFloat y = 10 * weakself.bottomSlider.value; 38 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvTiledRows:x cols:y]; 39 | }; 40 | self.kSlider2MoveEnd = ^(CGFloat value) { 41 | CGFloat x = 10 * weakself.topSlider.value; 42 | CGFloat y = 10 * value; 43 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvTiledRows:x cols:y]; 44 | }; 45 | } 46 | 47 | #endif 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /OpenCV/Resource/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /OpenCV/Demo/WarpPerspective/WarpPerspectiveViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // WarpPerspectiveViewController.m 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | 9 | #import "WarpPerspectiveViewController.h" 10 | 11 | @implementation WarpPerspectiveViewController 12 | 13 | #if __has_include() 14 | 15 | - (void)viewDidLoad { 16 | [super viewDidLoad]; 17 | // Do any additional setup after loading the view. 18 | 19 | __weak __typeof(self) weakself = self; 20 | CGFloat w = weakself.topImageView.frame.size.width; 21 | CGFloat h = weakself.topImageView.frame.size.height; 22 | self.bottomSlider.value = 0.5; 23 | weakself.bottomImageView.image = 24 | [weakself.topImageView.image kj_opencvWarpPerspectiveWithKnownPoints:KJKnownPointsMake(kPoint(0, 0), kPoint(w-50, 30), kPoint(w, h-20), kPoint(20, h)) size:CGSizeMake(w, h)]; 25 | self.kButtonAction = ^{ 26 | weakself.bottomImageView.image = 27 | [weakself.topImageView.image kj_opencvWarpPerspectiveWithKnownPoints:KJKnownPointsMake(kPoint(0, 0), kPoint(w-50, 30), kPoint(w, h-20), kPoint(20, h)) size:CGSizeMake(w, h)]; 28 | }; 29 | self.kSliderMoving = ^(CGFloat value) { 30 | CGFloat x = 100 * value; 31 | weakself.bottomImageView.image = 32 | [weakself.topImageView.image kj_opencvWarpPerspectiveWithKnownPoints:KJKnownPointsMake(kPoint(x, x), kPoint(w-50, 30+x/2), kPoint(w, h-20), kPoint(20, h)) size:CGSizeMake(w, h)]; 33 | }; 34 | self.kSlider2Moving = ^(CGFloat value) { 35 | CGFloat x = 100 * value; 36 | weakself.bottomImageView.image = 37 | [weakself.topImageView.image kj_opencvWarpPerspectiveWithKnownPoints:KJKnownPointsMake(kPoint(x, x), kPoint(w-x, x), kPoint(w, h), kPoint(0, h)) size:CGSizeMake(w, h)]; 38 | }; 39 | } 40 | 41 | #endif 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /Sources/OpencvQueen.h: -------------------------------------------------------------------------------- 1 | // OpencvQueen.h 2 | // 3 | // Copyright (c) 2021 Condy 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import 25 | 26 | //! Project version number for OpencvQueen. 27 | FOUNDATION_EXPORT double OpencvQueenVersionNumber; 28 | 29 | //! Project version string for OpencvQueen. 30 | FOUNDATION_EXPORT const unsigned char OpencvQueenVersionString[]; 31 | 32 | // In this header, you should import all the public headers of your framework 33 | // using statements like #import 34 | // or @import OpencvQueen; 35 | 36 | #if __has_include() 37 | #import 38 | #elif __has_include("UIImage+Queen.h") 39 | #import "UIImage+Queen.h" 40 | #else 41 | #endif 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | # CocoaPods 34 | # 35 | # We recommend against adding the Pods directory to your .gitignore. However 36 | # you should judge for yourself, the pros and cons are mentioned at: 37 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 38 | # 39 | # Pods/ 40 | # 41 | # Add this line if you want to avoid checking in source code from the Xcode workspace 42 | # *.xcworkspace 43 | 44 | # Carthage 45 | # 46 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 47 | # Carthage/Checkouts 48 | 49 | Carthage/Build/ 50 | 51 | # fastlane 52 | # 53 | # It is recommended to not store the screenshots in the git repo. 54 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 55 | # For more information about the recommended setup visit: 56 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 57 | 58 | fastlane/report.xml 59 | fastlane/Preview.html 60 | fastlane/screenshots/**/*.png 61 | fastlane/test_output 62 | 63 | # Code Injection 64 | # 65 | # After new code Injection tools there's a generated folder /iOSInjectionProject 66 | # https://github.com/johnno1962/injectionforxcode 67 | 68 | iOSInjectionProject/ 69 | -------------------------------------------------------------------------------- /Sources/KJOpencvType.h: -------------------------------------------------------------------------------- 1 | // 2 | // KJOpencvType.h 3 | // MetalQueen 4 | // 5 | // Created by 77。 on 2021/3/20. 6 | // 7 | 8 | #ifndef KJOpencvType_h 9 | #define KJOpencvType_h 10 | 11 | #import 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | // A ---- B 16 | // | | 17 | // | | 18 | // D ---- C 19 | // Four points of perspective selection, the style is as above 20 | typedef struct KJKnownPoints { 21 | CGPoint PointA; 22 | CGPoint PointB; 23 | CGPoint PointC; 24 | CGPoint PointD; 25 | } KJKnownPoints; 26 | 27 | // line, start -> end 28 | typedef struct KJLine { 29 | CGPoint start; 30 | CGPoint end; 31 | } KJLine; 32 | 33 | NS_INLINE KJLine KJLineMake(CGPoint start, CGPoint end) { 34 | KJLine line; 35 | line.start = start; 36 | line.end = end; 37 | return line; 38 | } 39 | 40 | NS_INLINE CGPoint kPoint(CGFloat x, CGFloat y) { 41 | return CGPointMake(x, y); 42 | } 43 | 44 | /// Convert perspective point 45 | NS_INLINE KJKnownPoints KJKnownPointsMake(CGPoint A, CGPoint B, CGPoint C, CGPoint D) { 46 | KJKnownPoints points; 47 | points.PointA = A; 48 | points.PointB = B; 49 | points.PointC = C; 50 | points.PointD = D; 51 | return points; 52 | } 53 | 54 | /// Morphological operation 55 | typedef NS_ENUM(NSInteger, KJOpencvMorphologyStyle) { 56 | KJOpencvMorphologyStyleOPEN = 0,/// Open operation, first corroded and then expanded, small objects can be removed 57 | KJOpencvMorphologyStyleCLOSE, /// Close operation, first expand and then corrode, can fill small holes 58 | KJOpencvMorphologyStyleGRADIENT,/// Morphology gradient, expansion minus corrosion 59 | KJOpencvMorphologyStyleTOPHAT, /// Top hat, the difference between the source image and the open operation 60 | KJOpencvMorphologyStyleBLACKHAT /// Black hat, the difference between the closing operation and the source image 61 | }; 62 | 63 | #endif /* KJOpencvType_h */ 64 | 65 | NS_ASSUME_NONNULL_END 66 | -------------------------------------------------------------------------------- /OpenCV/Resource/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint+Private.h 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 29/04/14. 6 | // Copyright (c) 2014 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | 11 | @protocol MASConstraintDelegate; 12 | 13 | 14 | @interface MASConstraint () 15 | 16 | /** 17 | * Whether or not to check for an existing constraint instead of adding constraint 18 | */ 19 | @property (nonatomic, assign) BOOL updateExisting; 20 | 21 | /** 22 | * Usually MASConstraintMaker but could be a parent MASConstraint 23 | */ 24 | @property (nonatomic, weak) id delegate; 25 | 26 | /** 27 | * Based on a provided value type, is equal to calling: 28 | * NSNumber - setOffset: 29 | * NSValue with CGPoint - setPointOffset: 30 | * NSValue with CGSize - setSizeOffset: 31 | * NSValue with MASEdgeInsets - setInsets: 32 | */ 33 | - (void)setLayoutConstantWithValue:(NSValue *)value; 34 | 35 | @end 36 | 37 | 38 | @interface MASConstraint (Abstract) 39 | 40 | /** 41 | * Sets the constraint relation to given NSLayoutRelation 42 | * returns a block which accepts one of the following: 43 | * MASViewAttribute, UIView, NSValue, NSArray 44 | * see readme for more details. 45 | */ 46 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation; 47 | 48 | /** 49 | * Override to set a custom chaining behaviour 50 | */ 51 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 52 | 53 | @end 54 | 55 | 56 | @protocol MASConstraintDelegate 57 | 58 | /** 59 | * Notifies the delegate when the constraint needs to be replaced with another constraint. For example 60 | * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks 61 | */ 62 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint; 63 | 64 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /OpenCV/Extension/UIView+KJXib.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+KJXib.h 3 | // KJEmitterView 4 | // 5 | // Created by yangkejun on 2020/8/10. 6 | // https://github.com/YangKJ/KJCategories 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | /// Show attributes in Xib IBInspectable can visually display related attributes 13 | @interface UIView (KJXib) 14 | 15 | /// Image attribute, note that this will overwrite the image set on UIImageView 16 | @property (nonatomic, strong) IBInspectable UIImage *viewImage; 17 | 18 | /// Rounded border 19 | @property (nonatomic, strong) IBInspectable UIColor *borderColor; 20 | @property (nonatomic, assign) IBInspectable CGFloat borderWidth; 21 | @property (nonatomic, assign) IBInspectable CGFloat cornerRadius; 22 | 23 | /// Shadow, note that the shadow will not take effect when the default color of View is ClearColor 24 | @property (nonatomic, strong) UIColor *shadowColor; 25 | @property (nonatomic, assign) CGFloat shadowRadius; 26 | @property (nonatomic, assign) CGFloat shadowWidth; 27 | @property (nonatomic, assign) CGFloat shadowOpacity; 28 | @property (nonatomic, assign) CGSize shadowOffset; 29 | 30 | /// Bezier round corners, a faster and more efficient way to round corners 31 | @property (nonatomic, assign) CGFloat bezierRadius; 32 | 33 | /// Set Bézier color border, more efficient 34 | /// @param radius radius 35 | /// @param borderWidth border size 36 | /// @param borderColor border color 37 | - (void)bezierBorderWithRadius:(CGFloat)radius 38 | borderWidth:(CGFloat)borderWidth 39 | borderColor:(UIColor *)borderColor; 40 | 41 | /// Set shadow 42 | /// @param color shadow color 43 | /// @param offset shadow displacement 44 | /// @param radius shadow radius 45 | - (void)shadowColor:(UIColor *)color offset:(CGSize)offset radius:(CGFloat)radius; 46 | 47 | /// Set the specified corner fillet 48 | /// @param rectCorner specifies the corner 49 | /// @param cornerRadius round corner radius 50 | - (void)cornerWithRectCorner:(UIRectCorner)rectCorner cornerRadius:(CGFloat)cornerRadius; 51 | 52 | @end 53 | 54 | NS_ASSUME_NONNULL_END 55 | -------------------------------------------------------------------------------- /OpenCV/Extension/UINavigationItem+KJExtension.h: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationItem+KJExtension.h 3 | // KJEmitterView 4 | // 5 | // Created by 77。 on 2018/12/1. 6 | // Copyright © 2018 77。. All rights reserved. 7 | // https://github.com/YangKJ/KJCategories 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @class KJNavigationItemInfo; 14 | @interface UINavigationItem (KJExtension) 15 | 16 | /// Chained generation 17 | - (instancetype)kj_makeNavigationItem:(void(^)(UINavigationItem *make))block; 18 | 19 | /// Shortcut generation method 20 | /// @param title title 21 | /// @param color title text color 22 | /// @param image image 23 | /// @param tintColor can modify the color of the picture 24 | /// @param block click callback 25 | /// @param withBlock return to the internal button 26 | - (UIBarButtonItem *)kj_barButtonItemWithTitle:(NSString *)title 27 | titleColor:(UIColor *)color 28 | image:(UIImage *)image 29 | tintColor:(UIColor *)tintColor 30 | buttonBlock:(void(^)(UIButton * kButton))block 31 | barButtonBlock:(void(^)(UIButton * kButton))withBlock; 32 | 33 | #pragma mark - chain parameter 34 | 35 | @property (nonatomic, strong, readonly) UINavigationItem *(^kAddBarButtonItemInfo) 36 | (void(^)(KJNavigationItemInfo *info), void(^)(UIButton * kButton)); 37 | @property (nonatomic, strong, readonly) UINavigationItem *(^kAddLeftBarButtonItem)(UIBarButtonItem *); 38 | @property (nonatomic, strong, readonly) UINavigationItem *(^kAddRightBarButtonItem)(UIBarButtonItem *); 39 | 40 | @end 41 | 42 | /// Configuration parameters 43 | @interface KJNavigationItemInfo: NSObject 44 | @property (nonatomic, strong) NSString *imageName; 45 | @property (nonatomic, strong) NSString *title; 46 | /// Picture color, default white 47 | @property (nonatomic, strong) UIColor *tintColor; 48 | /// Text color, default white 49 | @property (nonatomic, strong) UIColor *color; 50 | /// Whether it is the left item, the default yes 51 | @property (nonatomic, assign) BOOL isLeft; 52 | /// Internal button for external modification of parameters 53 | @property (nonatomic, copy, readwrite) void(^barButton)(UIButton * barButton); 54 | 55 | @end 56 | 57 | NS_ASSUME_NONNULL_END 58 | -------------------------------------------------------------------------------- /OpenCV/Extension/UIColor+KJExtension.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+KJExtension.h 3 | // KJEmitterView 4 | // 5 | // Created by 77。 on 2019/12/31. 6 | // https://github.com/YangKJ/KJCategories 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | #define UIColorFromHEXA(hex,a) [UIColor colorWithRed:((hex&0xFF0000)>>16)/255.0f \ 13 | green:((hex&0xFF00)>>8)/255.0f blue:(hex&0xFF)/255.0f alpha:a] 14 | #define UIColorFromRGBA(r,g,b,a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a] 15 | #define UIColorHexFromRGB(hex) UIColorFromHEXA(hex,1.0) 16 | #define kRGBA(r,g,b,a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a] 17 | #define kRGB(r,g,b) kRGBA(r,g,b,1.0f) 18 | 19 | @interface UIColor (KJExtension) 20 | 21 | @property (nonatomic, assign, readonly) CGFloat red; 22 | @property (nonatomic, assign, readonly) CGFloat green; 23 | @property (nonatomic, assign, readonly) CGFloat blue; 24 | @property (nonatomic, assign, readonly) CGFloat alpha; 25 | @property (nonatomic, assign, readonly) CGFloat hue; 26 | @property (nonatomic, assign, readonly) CGFloat saturation; 27 | @property (nonatomic, assign, readonly) CGFloat light; 28 | 29 | /// Get the RGBA corresponding to the color 30 | - (void)kj_rgba:(CGFloat *)r :(CGFloat *)g :(CGFloat *)b :(CGFloat *)a; 31 | 32 | /// Get the hue saturation and transparency corresponding to the color 33 | - (void)kj_HSL:(CGFloat *)hue :(CGFloat *)saturation :(CGFloat *)light; 34 | 35 | /// UIColor to hexadecimal string 36 | - (NSString *)kj_hexString; 37 | /// UIColor to hexadecimal string 38 | + (NSString *)hexStringFromColor:(UIColor *)color; 39 | FOUNDATION_EXPORT NSString * kDoraemonBoxHexStringFromColor(UIColor *color); 40 | 41 | /// Convert hexadecimal string to UIColor 42 | /// @param hexString hexadecimal, the beginning of `0x` or `#` are also supported 43 | + (UIColor *)colorWithHexString:(NSString *)hexString; 44 | FOUNDATION_EXPORT UIColor * kDoraemonBoxColorHexString(NSString *hexString); 45 | 46 | /// Convert hexadecimal string to UIColor 47 | /// @param hexString hexadecimal, the beginning of `0x` or `#` are also supported 48 | /// @param alpha transparency 49 | + (UIColor *)colorWithHexString:(NSString *)hexString alpha:(float)alpha; 50 | 51 | /// Random color 52 | FOUNDATION_EXPORT UIColor * kDoraemonBoxRandomColor(void); 53 | 54 | @end 55 | 56 | NS_ASSUME_NONNULL_END 57 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-OpenCV/Pods-OpenCV-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## Masonry 5 | 6 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | 26 | ## OpencvQueen 27 | 28 | Copyright (c) 2018 yangkejun 29 | 30 | Permission is hereby granted, free of charge, to any person obtaining a copy 31 | of this software and associated documentation files (the "Software"), to deal 32 | in the Software without restriction, including without limitation the rights 33 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 34 | copies of the Software, and to permit persons to whom the Software is 35 | furnished to do so, subject to the following conditions: 36 | 37 | The above copyright notice and this permission notice shall be included in all 38 | copies or substantial portions of the Software. 39 | 40 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 41 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 42 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 43 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 44 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 45 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 46 | SOFTWARE. 47 | 48 | Generated by CocoaPods - https://cocoapods.org 49 | -------------------------------------------------------------------------------- /OpenCV/Extension/UINavigationBar+KJExtension.h: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationBar+KJExtension.h 3 | // KJEmitterView 4 | // 5 | // Created by 77。 on 2018/12/1. 6 | // Copyright © 2018 77。. All rights reserved. 7 | // https://github.com/YangKJ/KJCategories 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface UINavigationBar (KJExtension) 14 | 15 | /// Set the background color of the navigation bar 16 | @property (nonatomic, strong) UIColor *navgationBackground; 17 | /// Set the picture background navigation bar 18 | @property (nonatomic, strong) UIImage *navgationImage; 19 | /// Set a custom back button 20 | @property (nonatomic, strong) NSString *navgationCustomBackImageName; 21 | /// System navigation bar dividing line 22 | @property (nonatomic, strong, readonly) UIImageView *navgationBarBottomLine; 23 | /// Set the color and font size of the navigation bar title 24 | @property (nonatomic, copy, readonly) UINavigationBar * (^kChangeNavigationBarTitle)(UIColor *, UIFont *); 25 | 26 | /// Set the title color and font size of the navigation bar, compatible with Swift and easy to use 27 | /// @param color Navigation bar title color 28 | /// @param font Font size of navigation bar title 29 | - (instancetype)setNavigationBarTitleColor:(UIColor *)color font:(UIFont *)font; 30 | /// Hide the underline at the bottom of the navigation bar 31 | - (UINavigationBar *)kj_hiddenNavigationBarBottomLine; 32 | /// Restore to the system color and underline by default 33 | - (void)kj_resetNavigationBarSystem; 34 | 35 | //************************ Custom navigation bar related ****************** ***** 36 | 37 | /// Change the navigation bar 38 | /// @param image Navigation bar image 39 | /// @param color Navigation bar background color 40 | - (instancetype)kj_customNavgationBackImage:(UIImage *_Nullable)image background:(UIColor *_Nullable)color; 41 | 42 | /// Change transparency 43 | - (instancetype)kj_customNavgationAlpha:(CGFloat)alpha; 44 | 45 | /// The height of the background of the navigation bar, 46 | /// Note: The height of the navigation bar is not changed here, but the height of the custom background is changed 47 | - (instancetype)kj_customNavgationHeight:(CGFloat)height; 48 | 49 | /// Hide bottom line 50 | - (instancetype)kj_customNavgationHiddenBottomLine:(BOOL)hidden; 51 | 52 | /// Change the color of the custom bottom line 53 | //- (instancetype)kj_customNavgationChangeBottomLineColor:(UIColor *)color; 54 | /// Restore back to the system navigation bar 55 | - (void)kj_customNavigationRestoreSystemNavigation; 56 | 57 | @end 58 | 59 | NS_ASSUME_NONNULL_END 60 | -------------------------------------------------------------------------------- /OpenCV/Demo/Blend/Controller/ImageBlendViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ImageBlendViewController.m 3 | // OpencvQueen 4 | // 5 | // Created by Condy on 2021/3/20. 6 | // https://github.com/YangKJ/OpencvQueen 7 | 8 | 9 | #import "ImageBlendViewController.h" 10 | 11 | @interface ImageBlendViewController () 12 | 13 | @end 14 | 15 | @implementation ImageBlendViewController 16 | 17 | #if __has_include() 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | // Do any additional setup after loading the view. 22 | UIImage *image = [UIImage imageNamed:@"ImageBlend"]; 23 | if (!CGSizeEqualToSize(self.topImageView.image.size, image.size)) { 24 | image = [ImageBlendViewController kj_BitmapChangeImageSize:self.topImageView.image.size image:image]; 25 | } 26 | self.topSlider.value = 0.5; 27 | __weak __typeof(self) weakself = self; 28 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvBlendImage:image alpha:0.5]; 29 | self.kButtonAction = ^{ 30 | weakself.bottomImageView.image = [weakself.topImageView.image kj_opencvBlendImage:image alpha:0.5]; 31 | }; 32 | self.kSliderMoving = ^(CGFloat value) { 33 | __block UIImage *img = weakself.topImageView.image; 34 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 35 | CGFloat x = 1 * value; 36 | img = [img kj_opencvBlendImage:image alpha:x]; 37 | dispatch_async(dispatch_get_main_queue(), ^{ 38 | weakself.bottomImageView.image = img; 39 | }); 40 | }); 41 | }; 42 | } 43 | 44 | #endif 45 | 46 | /// 图片压缩 47 | + (UIImage *)kj_BitmapChangeImageSize:(CGSize)size image:(UIImage *)image{ 48 | const size_t width = size.width, height = size.height; 49 | CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); 50 | CGContextRef context = CGBitmapContextCreate(NULL, 51 | width, 52 | height, 53 | 8, 54 | width * 4, 55 | space, 56 | kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast); 57 | CGColorSpaceRelease(space); 58 | if (!context) return nil; 59 | CGContextDrawImage(context, CGRectMake(0, 0, width, height), image.CGImage); 60 | UInt8 * data = (UInt8*)CGBitmapContextGetData(context); 61 | if (!data){ 62 | CGContextRelease(context); 63 | return nil; 64 | } 65 | CGImageRef imageRef = CGBitmapContextCreateImage(context); 66 | UIImage *newImage = [UIImage imageWithCGImage:imageRef]; 67 | CGImageRelease(imageRef); 68 | CGContextRelease(context); 69 | return newImage; 70 | } 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.h 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | typedef NS_ENUM(NSUInteger, MASAxisType) { 14 | MASAxisTypeHorizontal, 15 | MASAxisTypeVertical 16 | }; 17 | 18 | @interface NSArray (MASAdditions) 19 | 20 | /** 21 | * Creates a MASConstraintMaker with each view in the callee. 22 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view 23 | * 24 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 25 | * 26 | * @return Array of created MASConstraints 27 | */ 28 | - (NSArray *)mas_makeConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block; 29 | 30 | /** 31 | * Creates a MASConstraintMaker with each view in the callee. 32 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 33 | * If an existing constraint exists then it will be updated instead. 34 | * 35 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 36 | * 37 | * @return Array of created/updated MASConstraints 38 | */ 39 | - (NSArray *)mas_updateConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block; 40 | 41 | /** 42 | * Creates a MASConstraintMaker with each view in the callee. 43 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 44 | * All constraints previously installed for the views will be removed. 45 | * 46 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 47 | * 48 | * @return Array of created/updated MASConstraints 49 | */ 50 | - (NSArray *)mas_remakeConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block; 51 | 52 | /** 53 | * distribute with fixed spacing 54 | * 55 | * @param axisType which axis to distribute items along 56 | * @param fixedSpacing the spacing between each item 57 | * @param leadSpacing the spacing before the first item and the container 58 | * @param tailSpacing the spacing after the last item and the container 59 | */ 60 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; 61 | 62 | /** 63 | * distribute with fixed item size 64 | * 65 | * @param axisType which axis to distribute items along 66 | * @param fixedItemLength the fixed length of each item 67 | * @param leadSpacing the spacing before the first item and the container 68 | * @param tailSpacing the spacing after the last item and the container 69 | */ 70 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpencvQueen 2 | 3 | Set of **Extensions** and **Custom control** for standard types and classes. 4 | Just like Doraemon’s pocket, has an endless variety of props for us to use. 5 | 6 | --- 7 | 8 | ## Features 9 | At the moment, the most important features of [OpencvQueen](https://github.com/yangKJ/OpencvQueen) can be summarized as follows: 10 | 11 | - [x] Hough line detection and correction text. 12 | - [x] Feature extraction processing. 13 | - [x] Repair old photos. 14 | - [x] Repair the picture to remove the watermark. 15 | - [x] Maximum area cut. 16 | - [x] Morphology operation. 17 | - [x] Blurred skin whitening treatment. 18 | - [x] Picture perspective or blend. 19 | - [x] Modify brightness and contrast. 20 | - [x] Picture mosaic tile. 21 | 22 | ### Catalogue list ### 23 | - **[OpenCV](#OpenCV)** 24 | 25 | ### Methods and Functions 26 | - Opencv picture processing. 27 | 28 | | Name | Signatures | 29 | | :---- | ---- | 30 | | Picture Tile | kj_opencvTiledRows:cols: | 31 | | Four-point perspective image based on perspective | kj_opencvWarpPerspectiveWithKnownPoints:size: | 32 | | Eliminate image highlights | kj_opencvIlluminationChangeBeta:alpha: | 33 | | Picture Blending | kj_opencvBlendImage:alpha: | 34 | | Adjust picture brightness and contrast | kj_opencvChangeContrast:luminance: | 35 | | Modify the color of the picture channel value | kj_opencvChangeR:g:b: | 36 | | Blur processing | kj_opencvBlurX:y: | 37 | | Gaussian Blur | kj_opencvGaussianBlurX:y: | 38 | | Median Blur | kj_opencvMedianBlurksize: | 39 | | Gaussian Bilateral Blur | kj_opencvBilateralFilterBlurRadio:sigma: | 40 | | Custom linear blur | kj_opencvCustomBlurksize: | 41 | | Morphology operations | kj_opencvMorphology:element: | 42 | | Remove watermark | kj_opencvInpaintImage: | 43 | | Picture repair, effect enhancement processing | kj_opencvRepairImage | 44 | | Cut out the largest inner rectangular area | kj_opencvCutMaxRegionImage | 45 | | Feature extraction | kj_opencvFeatureExtractionFromSobel | 46 | | Hough line judgment and correction | kj_opencvHoughLinesCorrectTextImageFillColor: | 47 | 48 | ☝ **[Return to the catalogue list](#Catalogue list)** ☝ 49 | 50 | ### CocoaPods 51 | - If you want use this framework.☠️ 52 | 53 | ``` 54 | pod 'OpencvQueen' 55 | ``` 56 | 57 | ---- 58 | 59 | #### Ex 60 | * Download demo please execute first `pod install` 61 | 62 | ### Remarks 63 | 64 | > The general process is almost like this, the Demo is also written in great detail, you can check it out for yourself.🎷 65 | > 66 | > [**OpencvQueenDemo**](https://github.com/yangKJ/OpencvQueen) 67 | > 68 | > Tip: If you find it helpful, please help me with a star. If you have any questions or needs, you can also issue. 69 | > 70 | > Thanks.🎇 71 | 72 | ### About the author 73 | - 🎷 **E-mail address: [yangkj310@gmail.com](yangkj310@gmail.com) 🎷** 74 | - 🎸 **GitHub address: [yangKJ](https://github.com/yangKJ) 🎸** 75 | 76 | ----- 77 | 78 | ### License 79 | OpencvQueen is available under the [MIT](LICENSE) license. See the [LICENSE](LICENSE) file for more info. 80 | 81 | ----- 82 | -------------------------------------------------------------------------------- /OpenCV.xcodeproj/xcshareddata/xcschemes/OpenCV.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 45 | 51 | 52 | 53 | 54 | 60 | 62 | 68 | 69 | 70 | 71 | 73 | 74 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /OpenCV/Resource/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Sources/UIImage+Queen.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+Queen.h 3 | // MetalQueen 4 | // 5 | // Created by 77。 on 2021/3/20. 6 | // 7 | 8 | /* **************** Need to introduce OpenCV library, pod 'OpenCV','~> 4.1.0' *******************/ 9 | 10 | #import 11 | #import "KJOpencvType.h" 12 | 13 | #if __has_include() 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | /// https://docs.opencv.org/4.5.1/modules.html 18 | @interface UIImage (Queen) 19 | 20 | /// The picture is tiled 21 | /// @param row row 22 | /// @param col column 23 | - (UIImage *)kj_opencvTiledRows:(int)row cols:(int)col; 24 | 25 | /// Four-point perspective picture based on perspective 26 | /// @param points Four points of perspective 27 | /// @param size size 28 | - (UIImage *)kj_opencvWarpPerspectiveWithKnownPoints:(KJKnownPoints)points size:(CGSize)size; 29 | 30 | /// Eliminate image highlights 31 | /// @param beta ambiguity, 0-2 32 | /// @param alpha transparency, 0-2 33 | - (UIImage *)kj_opencvIlluminationChangeBeta:(double)beta alpha:(double)alpha; 34 | 35 | /// Picture mix 36 | /// @param image mixed pictures, the prerequisite for the two pictures must be the same size and type 37 | /// @param alpha transparency, 0-1 38 | - (UIImage *)kj_opencvBlendImage:(UIImage *)image alpha:(double)alpha; 39 | 40 | /// Adjust picture brightness and contrast 41 | /// @param contrast brightness, 0-100 42 | /// @param luminance contrast, 0-2 43 | - (UIImage *)kj_opencvChangeContrast:(int)contrast luminance:(double)luminance; 44 | 45 | /// Modify the color of the picture channel value, if you need to keep it unchanged, please pass -1 46 | /// @param r red, 0-255 47 | /// @param g green, 0-255 48 | /// @param b blue, 0-255 49 | - (UIImage *)kj_opencvChangeR:(int)r g:(int)g b:(int)b; 50 | 51 | #pragma mark - filter blur block 52 | 53 | /// Blur processing 54 | - (UIImage *)kj_opencvBlurX:(int)x y:(int)y; 55 | 56 | /// Gaussian blur, xy is positive and odd 57 | - (UIImage *)kj_opencvGaussianBlurX:(int)x y:(int)y; 58 | 59 | /// The median value is blurred, white particles can be removed, ksize must be positive and odd 60 | - (UIImage *)kj_opencvMedianBlurksize:(int)ksize; 61 | 62 | /// Gaussian bilateral blur, can be used for skin whitening effect 63 | /// @param radio radius 64 | /// @param sigma filter degree, 10-155 65 | - (UIImage *)kj_opencvBilateralFilterBlurRadio:(int)radio sigma:(int)sigma; 66 | 67 | /// Custom linear blur 68 | - (UIImage *)kj_opencvCustomBlurksize:(int)ksize; 69 | 70 | #pragma mark - Image morphology related 71 | 72 | /// Morphological operation 73 | /// @param type morphology style 74 | /// @param element Corrosion and expansion degree 75 | - (UIImage *)kj_opencvMorphology:(KJOpencvMorphologyStyle)type element:(int)element; 76 | 77 | #pragma mark - Comprehensive effect processing 78 | 79 | /// Repair the picture, you can remove the watermark 80 | - (UIImage *)kj_opencvInpaintImage:(int)radius; 81 | 82 | /// Picture repair, effect enhancement processing 83 | - (UIImage *)kj_opencvRepairImage; 84 | 85 | /// Image cropping algorithm, crop out the largest inner rectangular area 86 | - (UIImage *)kj_opencvCutMaxRegionImage; 87 | 88 | /// Picture stitching technology, combining multiple similar pictures into one 89 | - (UIImage *)kj_opencvCompoundMoreImage:(UIImage *)image,...; 90 | 91 | /// Feature extraction, based on Sobel operator 92 | - (UIImage *)kj_opencvFeatureExtractionFromSobel; 93 | 94 | /// Text type picture correction, straight line detection based on Hough line judgment correction 95 | - (UIImage *)kj_opencvHoughLinesCorrectTextImageFillColor:(UIColor *)color; 96 | 97 | @end 98 | 99 | NS_ASSUME_NONNULL_END 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-OpenCV/Pods-OpenCV-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | License 37 | MIT 38 | Title 39 | Masonry 40 | Type 41 | PSGroupSpecifier 42 | 43 | 44 | FooterText 45 | Copyright (c) 2018 yangkejun 46 | 47 | Permission is hereby granted, free of charge, to any person obtaining a copy 48 | of this software and associated documentation files (the "Software"), to deal 49 | in the Software without restriction, including without limitation the rights 50 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 51 | copies of the Software, and to permit persons to whom the Software is 52 | furnished to do so, subject to the following conditions: 53 | 54 | The above copyright notice and this permission notice shall be included in all 55 | copies or substantial portions of the Software. 56 | 57 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 58 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 59 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 60 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 61 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 62 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 63 | SOFTWARE. 64 | 65 | License 66 | MIT 67 | Title 68 | OpencvQueen 69 | Type 70 | PSGroupSpecifier 71 | 72 | 73 | FooterText 74 | Generated by CocoaPods - https://cocoapods.org 75 | Title 76 | 77 | Type 78 | PSGroupSpecifier 79 | 80 | 81 | StringsTable 82 | Acknowledgements 83 | Title 84 | Acknowledgements 85 | 86 | 87 | -------------------------------------------------------------------------------- /OpenCV/Extension/UIView+KJFrame.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+KJFrame.h 3 | // CategoryDemo 4 | // 5 | // Created by 77。 on 2018/7/12. 6 | // https://github.com/YangKJ/KJCategories 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | #define kKeyWindow \ 13 | ({UIWindow *window;\ 14 | if (@available(iOS 13.0, *)) {\ 15 | window = [UIApplication sharedApplication].windows.firstObject;\ 16 | } else {\ 17 | window = [UIApplication sharedApplication].keyWindow;\ 18 | }\ 19 | window;}) 20 | // Determine whether it is iPhone X series 21 | #define iPhoneX \ 22 | ({BOOL isPhoneX = NO;\ 23 | if (@available(iOS 13.0, *)) {\ 24 | isPhoneX = [UIApplication sharedApplication].windows.firstObject.safeAreaInsets.bottom > 0.0;\ 25 | } else if (@available(iOS 11.0, *)) {\ 26 | isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0;\ 27 | }\ 28 | (isPhoneX);}) 29 | // tabBar height 30 | #define kTABBAR_HEIGHT (iPhoneX ? (49.f + 34.f) : 49.f) 31 | // statusBar height 32 | #define kSTATUSBAR_HEIGHT (iPhoneX ? 44.0f : 20.f) 33 | // navigationBar height 34 | #define kNAVIGATION_HEIGHT (44.f) 35 | // (navigationBar + statusBar) height 36 | #define kSTATUSBAR_NAVIGATION_HEIGHT (iPhoneX ? 88.0f : 64.f) 37 | #define kBOTTOM_SPACE_HEIGHT (iPhoneX ? 34.0f : 0.0f) 38 | #define kScreenSize ([UIScreen mainScreen].bounds.size) 39 | #define kScreenW ([UIScreen mainScreen].bounds.size.width) 40 | #define kScreenH ([UIScreen mainScreen].bounds.size.height) 41 | #define kScreenRect CGRectMake(0, 0, kScreenW, kScreenH) 42 | // AutoSize 43 | #define kAutoW(x) (x * kScreenW / 375.0) 44 | #define kAutoH(x) (x * kScreenH / 667.0) 45 | #define kOnePixel (1.0 / [UIScreen mainScreen].scale) 46 | 47 | @interface UIView (KJFrame) 48 | 49 | @property (nonatomic, assign) CGSize size; 50 | @property (nonatomic, assign) CGPoint origin; 51 | @property (nonatomic, assign) CGFloat x; 52 | @property (nonatomic, assign) CGFloat y; 53 | @property (nonatomic, assign) CGFloat width; 54 | @property (nonatomic, assign) CGFloat height; 55 | @property (nonatomic, assign) CGFloat centerX; 56 | @property (nonatomic, assign) CGFloat centerY; 57 | @property (nonatomic, assign) CGFloat left; 58 | @property (nonatomic, assign) CGFloat right; 59 | @property (nonatomic, assign) CGFloat top; 60 | @property (nonatomic, assign) CGFloat bottom; 61 | @property (nonatomic, assign, readonly) CGFloat maxX; 62 | @property (nonatomic, assign, readonly) CGFloat maxY; 63 | @property (nonatomic, assign, readonly) CGFloat subviewMaxX; 64 | @property (nonatomic, assign, readonly) CGFloat subviewMaxY; 65 | @property (nonatomic, assign, readonly) CGFloat masonryX; 66 | @property (nonatomic, assign, readonly) CGFloat masonryY; 67 | @property (nonatomic, assign, readonly) CGFloat masonryWidth; 68 | @property (nonatomic, assign, readonly) CGFloat masonryHeight; 69 | @property (nonatomic, strong, readonly) UIViewController *viewController; 70 | @property (nonatomic, assign, readonly) BOOL showKeyWindow; 71 | @property (nonatomic, strong, class, readonly)UIViewController *topViewController; 72 | 73 | /// Place the center of the view in its parent view, support post-processing of the rotation direction 74 | - (void)kj_centerToSuperview; 75 | 76 | /// Distance from the right side of the parent view 77 | - (void)kj_rightToSuperview:(CGFloat)right; 78 | 79 | /// Distance from the bottom of the parent view 80 | - (void)kj_bottomToSuperview:(CGFloat)bottom; 81 | 82 | /// Hide/show all subviews 83 | - (void)kj_hideSubviews:(BOOL)hide operation:(BOOL(^)(UIView *subview))operation; 84 | 85 | /// Find subview 86 | - (UIView *)kj_findSubviewRecursively:(BOOL(^)(UIView *subview, BOOL * stop))recurse; 87 | 88 | /// Remove all subviews 89 | - (void)kj_removeAllSubviews; 90 | 91 | /// Update the size, when using autolayout layout, you need to refresh the constraints to get the real frame 92 | - (void)kj_updateFrame; 93 | 94 | @end 95 | 96 | NS_ASSUME_NONNULL_END 97 | -------------------------------------------------------------------------------- /OpenCV/Extension/UIView+KJGestureBlock.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+KJGestureBlock.m 3 | // KJEmitterView 4 | // 5 | // Created by 77。 on 2019/6/4. 6 | // https://github.com/YangKJ/KJCategories 7 | 8 | #import "UIView+KJGestureBlock.h" 9 | #import 10 | 11 | @implementation UIView (KJGestureBlock) 12 | static NSString * const _Nonnull KJGestureTypeStringMap[] = { 13 | [KJGestureTypeTap] = @"UITapGestureRecognizer", 14 | [KJGestureTypeDouble] = @"UITapGestureRecognizer", 15 | [KJGestureTypeLongPress] = @"UILongPressGestureRecognizer", 16 | [KJGestureTypeSwipe] = @"UISwipeGestureRecognizer", 17 | [KJGestureTypePan] = @"UIPanGestureRecognizer", 18 | [KJGestureTypeRotate] = @"UIRotationGestureRecognizer", 19 | [KJGestureTypePinch] = @"UIPinchGestureRecognizer", 20 | }; 21 | 22 | /// 单击手势 23 | - (UIGestureRecognizer *)kj_AddTapGestureRecognizerBlock:(KJGestureRecognizerBlock)block{ 24 | return [self kj_AddGestureRecognizer:KJGestureTypeTap block:block]; 25 | } 26 | 27 | - (UIGestureRecognizer *)kj_AddGestureRecognizer:(KJGestureType)type block:(KJGestureRecognizerBlock)block{ 28 | self.userInteractionEnabled = YES; 29 | if (block) { 30 | NSString *string = KJGestureTypeStringMap[type]; 31 | UIGestureRecognizer *gesture = [[NSClassFromString(string) alloc] initWithTarget:self action:@selector(category_gestureAction:)]; 32 | [gesture setDelaysTouchesBegan:YES]; 33 | [self addGestureRecognizer:gesture]; 34 | if (type == KJGestureTypeTap) { 35 | [self.gestureRecognizers enumerateObjectsUsingBlock:^(__kindof UIGestureRecognizer *recognizer, NSUInteger idx, BOOL *stop) { 36 | if ([recognizer isKindOfClass:[UITapGestureRecognizer class]] && ((UITapGestureRecognizer*)recognizer).numberOfTapsRequired == 2) { 37 | [gesture requireGestureRecognizerToFail:recognizer]; 38 | *stop = YES; 39 | } 40 | }]; 41 | string = [string stringByAppendingString:@"Tap"]; 42 | } else if (type == KJGestureTypeDouble) { 43 | [(UITapGestureRecognizer *)gesture setNumberOfTapsRequired:2]; 44 | [self.gestureRecognizers enumerateObjectsUsingBlock:^(__kindof UIGestureRecognizer *recognizer, NSUInteger idx, BOOL *stop) { 45 | if ([recognizer isKindOfClass:[UITapGestureRecognizer class]] && ((UITapGestureRecognizer*)recognizer).numberOfTapsRequired == 1) { 46 | [recognizer requireGestureRecognizerToFail:gesture]; 47 | *stop = YES; 48 | } 49 | }]; 50 | string = [string stringByAppendingString:@"Double"]; 51 | } 52 | self.selectorString = string; 53 | self.gesrureblock = block; 54 | return gesture; 55 | } 56 | return nil; 57 | } 58 | 59 | - (void)category_gestureAction:(UIGestureRecognizer *)gesture{ 60 | NSString *string = NSStringFromClass([gesture class]); 61 | if ([gesture isKindOfClass:[UITapGestureRecognizer class]]) { 62 | if (((UITapGestureRecognizer *)gesture).numberOfTapsRequired == 1) { 63 | string = [string stringByAppendingString:@"Tap"]; 64 | } else { 65 | string = [string stringByAppendingString:@"Double"]; 66 | } 67 | } 68 | self.selectorString = string; 69 | self.gesrureblock(gesture.view, gesture); 70 | } 71 | 72 | #pragma mark - associated 73 | 74 | - (NSString *)selectorString{ 75 | return objc_getAssociatedObject(self, @selector(selectorString)); 76 | } 77 | - (void)setSelectorString:(NSString *)selectorString{ 78 | objc_setAssociatedObject(self, @selector(selectorString), selectorString, OBJC_ASSOCIATION_COPY_NONATOMIC); 79 | } 80 | - (KJGestureRecognizerBlock)gesrureblock{ 81 | return (KJGestureRecognizerBlock)objc_getAssociatedObject(self, NSSelectorFromString(self.selectorString)); 82 | } 83 | - (void)setGesrureblock:(KJGestureRecognizerBlock)gesrureblock{ 84 | objc_setAssociatedObject(self, NSSelectorFromString(self.selectorString), gesrureblock, OBJC_ASSOCIATION_COPY_NONATOMIC); 85 | } 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /OpenCV/Extension/UIViewController+KJExtension.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+KJExtension.m 3 | // KJEmitterView 4 | // 5 | // Created by 77。 on 2021/5/28. 6 | // https://github.com/YangKJ/KJCategories 7 | 8 | #import "UIViewController+KJExtension.h" 9 | 10 | @implementation UIViewController (KJExtension) 11 | 12 | /// 跳转回指定控制器 13 | - (BOOL)kj_popTargetViewController:(Class)clazz complete:(void(^)(UIViewController *vc))complete{ 14 | UIViewController *vc = nil; 15 | for (UIViewController *__vc in self.navigationController.viewControllers) { 16 | if ([__vc isKindOfClass:clazz]) { 17 | vc = __vc; 18 | break; 19 | } 20 | } 21 | if (vc == nil) return NO; 22 | [self.navigationController popToViewController:vc animated:YES]; 23 | if (complete) complete(vc); 24 | return YES; 25 | } 26 | 27 | /// 切换根视图控制器 28 | - (void)kj_changeRootViewController:(void(^)(BOOL success))complete{ 29 | UIWindow *window = ({ 30 | UIWindow *window; 31 | if (@available(iOS 13.0, *)) { 32 | window = [UIApplication sharedApplication].windows.firstObject; 33 | } else { 34 | window = [UIApplication sharedApplication].keyWindow; 35 | } 36 | window; 37 | }); 38 | [UIView transitionWithView:window 39 | duration:0.5f 40 | options:UIViewAnimationOptionTransitionCrossDissolve 41 | animations:^{ 42 | BOOL oldState = [UIView areAnimationsEnabled]; 43 | [UIView setAnimationsEnabled:NO]; 44 | window.rootViewController = self; 45 | [UIView setAnimationsEnabled:oldState]; 46 | } completion:^(BOOL finished) { 47 | if (complete) complete(finished); 48 | }]; 49 | } 50 | 51 | #pragma mark - UINavigationControllerDelegate 52 | 53 | - (void)navigationController:(UINavigationController *)navigationController 54 | willShowViewController:(UIViewController *)viewController 55 | animated:(BOOL)animated { 56 | if (viewController == self) { 57 | [navigationController setNavigationBarHidden:YES animated:YES]; 58 | } else { 59 | if ([navigationController isKindOfClass:[UIImagePickerController class]]) { 60 | return; 61 | } 62 | [navigationController setNavigationBarHidden:NO animated:YES]; 63 | if (navigationController.delegate == self) { 64 | navigationController.delegate = nil; 65 | } 66 | } 67 | } 68 | 69 | /// 是否开启侧滑返回手势 70 | - (void)kj_openPopGesture:(BOOL)open{ 71 | if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { 72 | for (UIGestureRecognizer * popGesture in 73 | self.navigationController.interactivePopGestureRecognizer.view.gestureRecognizers) { 74 | popGesture.enabled = open; 75 | } 76 | } 77 | } 78 | 79 | /// 系统自带分享 80 | - (UIActivityViewController *)kj_shareActivityWithItems:(NSArray *)items complete:(void(^)(BOOL))complete{ 81 | if (items.count == 0) return nil; 82 | UIActivityViewController *vc = [[UIActivityViewController alloc] initWithActivityItems:items 83 | applicationActivities:nil]; 84 | if (@available(iOS 11.0, *)) { 85 | vc.excludedActivityTypes = @[ 86 | UIActivityTypeMessage, 87 | UIActivityTypeMail, 88 | UIActivityTypeOpenInIBooks, 89 | UIActivityTypeMarkupAsPDF 90 | ]; 91 | } else if (@available(iOS 9.0, *)) { 92 | vc.excludedActivityTypes = @[ 93 | UIActivityTypeMessage, 94 | UIActivityTypeMail, 95 | UIActivityTypeOpenInIBooks 96 | ]; 97 | } else { 98 | vc.excludedActivityTypes = @[UIActivityTypeMessage, UIActivityTypeMail]; 99 | } 100 | vc.completionWithItemsHandler = ^(UIActivityType activityType, BOOL completed, 101 | NSArray * returnedItems, NSError * activityError) { 102 | if (complete) complete(completed); 103 | }; 104 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 105 | vc.popoverPresentationController.sourceView = self.view; 106 | vc.popoverPresentationController.sourceRect = CGRectMake([UIScreen mainScreen].bounds.size.width/2, [UIScreen mainScreen].bounds.size.height, 0, 0); 107 | } 108 | [self presentViewController:vc animated:YES completion:nil]; 109 | return vc; 110 | } 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /OpenCV/Extension/NSObject+KJGCDBox.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+KJGCDBox.h 3 | // KJEmitterView 4 | // 5 | // Created by 77。 on 2019/3/17. 6 | // https://github.com/YangKJ/KJCategories 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | /// GCD box package, resident thread package 14 | @interface NSObject (KJGCDBox) 15 | 16 | /// Create an asynchronous timer, which is more accurate than NSTimer and CADisplayLink (both are based on runloop processing) 17 | /// @param async is asynchronous 18 | /// @param task event handling 19 | /// @param start start time 20 | /// @param interval interval time 21 | /// @param repeats whether to repeat 22 | /// @return returns the timer 23 | - (dispatch_source_t)kj_createGCDAsyncTimer:(BOOL)async 24 | task:(dispatch_block_t)task 25 | start:(NSTimeInterval)start 26 | interval:(NSTimeInterval)interval 27 | repeats:(BOOL)repeats; 28 | /// Cancel the timer 29 | - (void)kj_gcdStopTimer:(dispatch_source_t)timer; 30 | 31 | /// Pause the timer 32 | - (void)kj_gcdPauseTimer:(dispatch_source_t)timer; 33 | 34 | /// Continue timer 35 | - (void)kj_gcdResumeTimer:(dispatch_source_t)timer; 36 | 37 | /// Delayed execution 38 | /// @param task event handling 39 | /// @param time delay time 40 | /// @param async is asynchronous 41 | - (void)kj_gcdAfterTask:(dispatch_block_t)task 42 | time:(NSTimeInterval)time 43 | asyne:(BOOL)async; 44 | 45 | /// Asynchronous fast iteration 46 | /// @param task event handling 47 | /// @param count total number of iterations 48 | - (void)kj_gcdApplyTask:(BOOL(^)(size_t index))task 49 | count:(NSUInteger)count; 50 | 51 | #pragma mark - GCD threading 52 | 53 | /// Create a queue 54 | FOUNDATION_EXPORT dispatch_queue_t kGCD_queue(void); 55 | /// Main thread 56 | FOUNDATION_EXPORT void kGCD_main(dispatch_block_t block); 57 | /// Child thread 58 | FOUNDATION_EXPORT void kGCD_async(dispatch_block_t block); 59 | /// Asynchronous parallel queue, carrying variable parameters (need to end with nil) 60 | FOUNDATION_EXPORT void kGCD_group_notify(dispatch_block_t notify, dispatch_block_t block,...); 61 | /// Fence 62 | FOUNDATION_EXPORT dispatch_queue_t kGCD_barrier(dispatch_block_t block, dispatch_block_t barrier); 63 | /// The barrier implements multiple read and single write operations, 64 | /// the write operation is completed in the barrier, and the variable parameters are carried (need to end with nil) 65 | FOUNDATION_EXPORT void kGCD_barrier_read_write(dispatch_block_t barrier, dispatch_block_t block,...); 66 | /// One-time 67 | FOUNDATION_EXPORT void kGCD_once(dispatch_block_t block); 68 | /// Delayed execution 69 | FOUNDATION_EXPORT void kGCD_after(int64_t delayInSeconds, dispatch_block_t block); 70 | /// Delayed execution in the main thread 71 | FOUNDATION_EXPORT void kGCD_after_main(int64_t delayInSeconds, dispatch_block_t block); 72 | /// Fast iteration 73 | FOUNDATION_EXPORT void kGCD_apply(int iterations, void(^block)(size_t idx)); 74 | /// Quickly traverse the array 75 | FOUNDATION_EXPORT void kGCD_apply_array(NSArray * temp, void(^block)(id obj, size_t index)); 76 | 77 | @end 78 | 79 | #define _weakself __weak __typeof(self) weakself = self 80 | #define _strongself __strong __typeof(weakself) strongself = weakself 81 | #ifndef kWeakObject 82 | #if DEBUG 83 | #if __has_feature(objc_arc) 84 | #define kWeakObject(object) autoreleasepool{} __weak __typeof__(object) weak##_##object = object; 85 | #else 86 | #define kWeakObject(object) autoreleasepool{} __block __typeof__(object) block##_##object = object; 87 | #endif 88 | #else 89 | #if __has_feature(objc_arc) 90 | #define kWeakObject(object) try{} @finally{} {} __weak __typeof__(object) weak##_##object = object; 91 | #else 92 | #define kWeakObject(object) try{} @finally{} {} __block __typeof__(object) block##_##object = object; 93 | #endif 94 | #endif 95 | #endif 96 | 97 | #ifndef kStrongObject 98 | #if DEBUG 99 | #if __has_feature(objc_arc) 100 | #define kStrongObject(object) autoreleasepool{} __typeof__(object) object = weak##_##object; 101 | #else 102 | #define kStrongObject(object) autoreleasepool{} __typeof__(object) object = block##_##object; 103 | #endif 104 | #else 105 | #if __has_feature(objc_arc) 106 | #define kStrongObject(object) try{} @finally{} __typeof__(object) object = weak##_##object; 107 | #else 108 | #define kStrongObject(object) try{} @finally{} __typeof__(object) object = block##_##object; 109 | #endif 110 | #endif 111 | #endif 112 | 113 | NS_ASSUME_NONNULL_END 114 | -------------------------------------------------------------------------------- /OpenCV/Extension/UIView+KJXib.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+KJXib.m 3 | // KJEmitterView 4 | // 5 | // Created by yangkejun on 2020/8/10. 6 | // https://github.com/YangKJ/KJCategories 7 | 8 | #import "UIView+KJXib.h" 9 | 10 | @implementation UIView (KJXib) 11 | 12 | #pragma mark - Xib中显示的属性 13 | @dynamic viewImage; 14 | - (void)setViewImage:(UIImage *)viewImage{ 15 | if (viewImage) { 16 | CALayer *topLayer = [[CALayer alloc]init]; 17 | [topLayer setBounds:self.bounds]; 18 | [topLayer setPosition:CGPointMake(self.bounds.size.width*.5, self.bounds.size.height*.5)]; 19 | [topLayer setContents:(id)viewImage.CGImage]; 20 | [self.layer addSublayer:topLayer]; 21 | } 22 | } 23 | 24 | @dynamic borderColor,borderWidth,cornerRadius; 25 | - (void)setBorderColor:(UIColor *)borderColor { 26 | [self.layer setBorderColor:borderColor.CGColor]; 27 | } 28 | - (void)setBorderWidth:(CGFloat)borderWidth { 29 | if (borderWidth <= 0) return; 30 | [self.layer setBorderWidth:borderWidth]; 31 | } 32 | - (void)setCornerRadius:(CGFloat)cornerRadius { 33 | if (cornerRadius <= 0) return; 34 | [self.layer setCornerRadius:cornerRadius]; 35 | self.layer.masksToBounds = YES; 36 | self.layer.shouldRasterize = YES; 37 | self.layer.rasterizationScale = [UIScreen mainScreen].scale; 38 | } 39 | 40 | @dynamic shadowColor,shadowRadius,shadowWidth,shadowOffset,shadowOpacity; 41 | - (void)setShadowColor:(UIColor *)shadowColor{ 42 | [self.layer setShadowColor:shadowColor.CGColor]; 43 | } 44 | - (void)setShadowRadius:(CGFloat)shadowRadius{ 45 | if (shadowRadius <= 0) return; 46 | UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:shadowRadius]; 47 | [self.layer setShadowPath:path.CGPath]; 48 | } 49 | - (void)setShadowWidth:(CGFloat)shadowWidth{ 50 | if (shadowWidth <= 0) return; 51 | [self.layer setShadowRadius:shadowWidth]; 52 | } 53 | - (void)setShadowOpacity:(CGFloat)shadowOpacity{ 54 | [self.layer setShadowOpacity:shadowOpacity]; 55 | } 56 | - (void)setShadowOffset:(CGSize)shadowOffset{ 57 | [self.layer setShadowOffset:shadowOffset]; 58 | } 59 | @dynamic bezierRadius; 60 | - (void)setBezierRadius:(CGFloat)bezierRadius { 61 | if (bezierRadius <= 0) return; 62 | CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; 63 | maskLayer.frame = self.bounds; 64 | maskLayer.path = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:bezierRadius].CGPath; 65 | self.layer.mask = maskLayer; 66 | } 67 | 68 | /// 设置贝塞尔颜色边框,更高效 69 | /// @param radius 半径 70 | /// @param borderWidth 边框尺寸 71 | /// @param borderColor 边框颜色 72 | - (void)bezierBorderWithRadius:(CGFloat)radius borderWidth:(CGFloat)borderWidth borderColor:(UIColor *)borderColor{ 73 | CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; 74 | maskLayer.frame = self.bounds; 75 | 76 | UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:radius]; 77 | maskLayer.path = path.CGPath; 78 | 79 | CAShapeLayer *borderLayer = [[CAShapeLayer alloc] init]; 80 | borderLayer.frame = self.bounds; 81 | borderLayer.lineWidth = borderWidth; 82 | borderLayer.strokeColor = borderColor.CGColor; 83 | borderLayer.fillColor = [UIColor clearColor].CGColor; 84 | borderLayer.path = path.CGPath; 85 | 86 | [self.layer insertSublayer:borderLayer atIndex:0]; 87 | self.layer.mask = maskLayer; 88 | } 89 | 90 | /// 设置阴影 91 | /// @param color 阴影颜色 92 | /// @param offset 阴影位移 93 | /// @param radius 阴影半径 94 | - (void)shadowColor:(UIColor *)color offset:(CGSize)offset radius:(CGFloat)radius{ 95 | self.layer.shadowColor = color.CGColor; 96 | self.layer.shadowOffset = offset; 97 | self.layer.shadowRadius = radius; 98 | self.layer.shadowOpacity = 1; 99 | self.layer.shouldRasterize = YES; 100 | self.layer.rasterizationScale = [UIScreen mainScreen].scale; 101 | } 102 | 103 | /// 设置指定角落圆角 104 | /// @param rectCorner 指定角落 105 | /// @param cornerRadius 圆角半径 106 | - (void)cornerWithRectCorner:(UIRectCorner)rectCorner cornerRadius:(CGFloat)cornerRadius{ 107 | CGSize cornerSize = CGSizeMake(cornerRadius, cornerRadius); 108 | UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds 109 | byRoundingCorners:rectCorner 110 | cornerRadii:cornerSize]; 111 | CAShapeLayer *maskLayer = [CAShapeLayer layer]; 112 | maskLayer.frame = self.bounds; 113 | maskLayer.path = maskPath.CGPath; 114 | self.layer.mask = maskLayer; 115 | self.layer.masksToBounds = YES; 116 | } 117 | 118 | @end 119 | -------------------------------------------------------------------------------- /OpenCV/ATViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ATViewController.m 3 | // OpenCV 4 | // 5 | // Created by Condy on 2021/2/8. 6 | // 7 | 8 | #import "ATViewController.h" 9 | #import "UIView+KJFrame.h" 10 | 11 | @interface ATViewController () 12 | 13 | @property (nonatomic, strong) UILabel *tipLabel; 14 | @property (nonatomic, strong) NSArray *temps; 15 | @property (nonatomic, strong) UITableView *tableView; 16 | 17 | @end 18 | 19 | @implementation ATViewController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | // Do any additional setup after loading the view. 24 | [self setupUI]; 25 | } 26 | 27 | - (void)setupUI{ 28 | self.title = @"OpenCV Case"; 29 | if (@available(iOS 13.0, *)) { 30 | self.view.backgroundColor = [UIColor colorWithDynamicProvider:^UIColor * (UITraitCollection * train) { 31 | if ([train userInterfaceStyle] == UIUserInterfaceStyleLight) { 32 | return UIColor.whiteColor; 33 | } else { 34 | return UIColor.blackColor; 35 | } 36 | }]; 37 | } else { 38 | self.view.backgroundColor = UIColor.whiteColor; 39 | } 40 | [self.view addSubview:self.tipLabel]; 41 | [self.view addSubview:self.tableView]; 42 | } 43 | 44 | #pragma mark - UITableViewDataSource, UITableViewDelegate 45 | 46 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ 47 | return 1; 48 | } 49 | 50 | - (NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 51 | return [self.temps count]; 52 | } 53 | 54 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 55 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"]; 56 | NSDictionary *dic = self.temps[indexPath.row]; 57 | cell.textLabel.text = [NSString stringWithFormat:@"%ld. %@",indexPath.row + 1, dic[@"class"]]; 58 | cell.textLabel.font = [UIFont systemFontOfSize:16]; 59 | cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 60 | cell.detailTextLabel.text = dic[@"describeName"]; 61 | cell.detailTextLabel.font = [UIFont systemFontOfSize:13]; 62 | return cell; 63 | } 64 | 65 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 66 | NSDictionary *dic = self.temps[indexPath.row]; 67 | UIViewController *vc = [NSClassFromString(dic[@"class"]) new]; 68 | vc.title = dic[@"describeName"]; 69 | [self.navigationController pushViewController:vc animated:YES]; 70 | } 71 | 72 | #pragma mark - lazy 73 | 74 | - (UILabel *)tipLabel { 75 | if (!_tipLabel) { 76 | _tipLabel = [UILabel new]; 77 | _tipLabel.frame = CGRectMake(20, kSTATUSBAR_NAVIGATION_HEIGHT, self.view.frame.size.width-40, 40); 78 | _tipLabel.numberOfLines = 0; 79 | _tipLabel.textColor = [UIColor redColor]; 80 | _tipLabel.font = [UIFont systemFontOfSize:14]; 81 | _tipLabel.textAlignment = NSTextAlignmentCenter; 82 | _tipLabel.text = @"Remarks: This module needs to import the OpenCV, please execute the `pod install` operation first"; 83 | } 84 | return _tipLabel; 85 | } 86 | 87 | - (UITableView *)tableView { 88 | if (!_tableView) { 89 | CGFloat y = CGRectGetMaxY(self.tipLabel.frame); 90 | CGRect rect = CGRectMake(0, CGRectGetMaxY(self.tipLabel.frame), self.view.frame.size.width, self.view.frame.size.height-y); 91 | _tableView = [[UITableView alloc]initWithFrame:rect style:(UITableViewStylePlain)]; 92 | _tableView.rowHeight = 50; 93 | _tableView.sectionHeaderHeight = 0.0001f; 94 | _tableView.dataSource = self; 95 | _tableView.delegate = self; 96 | [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"]; 97 | } 98 | return _tableView; 99 | } 100 | 101 | - (NSArray *)temps { 102 | if (!_temps) { 103 | _temps = @[ 104 | @{@"class": @"HoughViewController", @"describeName": @"Hough line detection and correction text"}, 105 | @{@"class": @"SobelViewController", @"describeName": @"Feature Extraction Processing"}, 106 | @{@"class": @"RepairViewController", @"describeName": @"Old photo repair"}, 107 | @{@"class": @"InpaintViewController", @"describeName": @"Repair the picture to remove the watermark"}, 108 | @{@"class": @"MaxCutViewController", @"describeName": @"Maximum Area Cut"}, 109 | @{@"class": @"MorphologyViewController", @"describeName": @"Morphology Operation"}, 110 | @{@"class": @"BlurViewController", @"describeName": @"Blurred skin whitening treatment"}, 111 | @{@"class": @"WarpPerspectiveViewController", @"describeName": @"Picture Perspective"}, 112 | @{@"class": @"ImageBlendViewController", @"describeName": @"Picture Blend"}, 113 | @{@"class": @"LuminanceViewController", @"describeName": @"Modify brightness and contrast"}, 114 | @{@"class": @"TiledViewController", @"describeName": @"Picture mosaic tile"}, 115 | ]; 116 | } 117 | return _temps; 118 | } 119 | 120 | @end 121 | -------------------------------------------------------------------------------- /OpenCV/Extension/UIImage+KJCapture.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+KJCapture.m 3 | // KJEmitterView 4 | // 5 | // Created by yangkejun on 2020/8/10. 6 | // https://github.com/YangKJ/KJCategories 7 | 8 | 9 | #import "UIImage+KJCapture.h" 10 | 11 | @implementation UIImage (KJCapture) 12 | 13 | #pragma mark - 截图处理 14 | /// 屏幕截图 15 | + (UIImage *)kj_captureScreen:(UIView *)view{ 16 | return [UIImage kj_captureScreen:view Rect:view.frame]; 17 | } 18 | /// 指定位置屏幕截图 19 | + (UIImage *)kj_captureScreen:(UIView *)view Rect:(CGRect)rect{ 20 | return [self kj_captureScreen:view Rect:rect Quality:UIScreen.mainScreen.scale]; 21 | } 22 | /// 自定义质量的截图,quality质量倍数 23 | + (UIImage *)kj_captureScreen:(UIView *)view Rect:(CGRect)rect Quality:(NSInteger)quality{ 24 | return ({ 25 | CGSize size = view.bounds.size; 26 | size.width = floorf(size.width * quality) / quality; 27 | size.height = floorf(size.height * quality) / quality; 28 | rect = CGRectMake(rect.origin.x*quality, rect.origin.y*quality, rect.size.width*quality, rect.size.height*quality); 29 | UIGraphicsBeginImageContextWithOptions(size, NO, quality); 30 | [view.layer renderInContext:UIGraphicsGetCurrentContext()]; 31 | UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); 32 | UIGraphicsEndImageContext(); 33 | CGImageRef imageRef = CGImageCreateWithImageInRect([viewImage CGImage], rect); 34 | UIImage *newImage = [UIImage imageWithCGImage:imageRef]; 35 | CGImageRelease(imageRef); 36 | newImage; 37 | }); 38 | } 39 | /// 截取当前屏幕 40 | + (UIImage *)kj_captureScreenWindow{ 41 | CGSize imageSize = [UIScreen mainScreen].bounds.size; 42 | UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0); 43 | CGContextRef context = UIGraphicsGetCurrentContext(); 44 | for (UIWindow *window in [[UIApplication sharedApplication] windows]){ 45 | CGContextSaveGState(context); 46 | CGContextTranslateCTM(context, window.center.x, window.center.y); 47 | CGContextConcatCTM(context, window.transform); 48 | CGContextTranslateCTM(context, -window.bounds.size.width * window.layer.anchorPoint.x, 49 | -window.bounds.size.height * window.layer.anchorPoint.y); 50 | if ([window respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]){ 51 | [window drawViewHierarchyInRect:window.bounds afterScreenUpdates:YES]; 52 | } else { 53 | [window.layer renderInContext:context]; 54 | } 55 | CGContextRestoreGState(context); 56 | } 57 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 58 | UIGraphicsEndImageContext(); 59 | return image; 60 | } 61 | /// 截取当前屏幕 62 | + (UIImage *)kj_captureScreenWindowForInterfaceOrientation{ 63 | CGSize imageSize = CGSizeZero; 64 | UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; 65 | if (UIInterfaceOrientationIsPortrait(orientation)){ 66 | imageSize = [UIScreen mainScreen].bounds.size; 67 | } else { 68 | imageSize = CGSizeMake([UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width); 69 | } 70 | UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0); 71 | CGContextRef context = UIGraphicsGetCurrentContext(); 72 | for (UIWindow *window in [[UIApplication sharedApplication] windows]){ 73 | CGContextSaveGState(context); 74 | CGContextTranslateCTM(context, window.center.x, window.center.y); 75 | CGContextConcatCTM(context, window.transform); 76 | CGContextTranslateCTM(context, -window.bounds.size.width * window.layer.anchorPoint.x, 77 | -window.bounds.size.height * window.layer.anchorPoint.y); 78 | if (orientation == UIInterfaceOrientationLandscapeLeft){ 79 | CGContextRotateCTM(context, M_PI_2); 80 | CGContextTranslateCTM(context, 0, -imageSize.width); 81 | } else if (orientation == UIInterfaceOrientationLandscapeRight){ 82 | CGContextRotateCTM(context, -M_PI_2); 83 | CGContextTranslateCTM(context, -imageSize.height, 0); 84 | } else if (orientation == UIInterfaceOrientationPortraitUpsideDown) { 85 | CGContextRotateCTM(context, M_PI); 86 | CGContextTranslateCTM(context, -imageSize.width, -imageSize.height); 87 | } 88 | if ([window respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]){ 89 | [window drawViewHierarchyInRect:window.bounds afterScreenUpdates:YES]; 90 | } else { 91 | [window.layer renderInContext:context]; 92 | } 93 | CGContextRestoreGState(context); 94 | } 95 | 96 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 97 | UIGraphicsEndImageContext(); 98 | return image; 99 | } 100 | /// 截取滚动的长图 101 | + (UIImage *)kj_captureScreenWithScrollView:(UIScrollView *)scroll contentOffset:(CGPoint)offset{ 102 | UIGraphicsBeginImageContext(scroll.bounds.size); 103 | CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0.0f, -offset.y); 104 | [scroll.layer renderInContext:UIGraphicsGetCurrentContext()]; 105 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 106 | UIGraphicsEndImageContext(); 107 | return image; 108 | } 109 | 110 | @end 111 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | /** 14 | * Provides constraint maker block 15 | * and convience methods for creating MASViewAttribute which are view + NSLayoutAttribute pairs 16 | */ 17 | @interface MAS_VIEW (MASAdditions) 18 | 19 | /** 20 | * following properties return a new MASViewAttribute with current view and appropriate NSLayoutAttribute 21 | */ 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_left; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_top; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_right; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottom; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leading; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailing; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_width; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_height; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerX; 31 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerY; 32 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_baseline; 33 | @property (nonatomic, strong, readonly) MASViewAttribute *(^mas_attribute)(NSLayoutAttribute attr); 34 | 35 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 36 | 37 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_firstBaseline; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_lastBaseline; 39 | 40 | #endif 41 | 42 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 43 | 44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin; 45 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin; 46 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin; 47 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin; 48 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin; 49 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin; 50 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins; 51 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins; 52 | 53 | #endif 54 | 55 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 56 | 57 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuide API_AVAILABLE(ios(11.0),tvos(11.0)); 58 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTop API_AVAILABLE(ios(11.0),tvos(11.0)); 59 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideBottom API_AVAILABLE(ios(11.0),tvos(11.0)); 60 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeft API_AVAILABLE(ios(11.0),tvos(11.0)); 61 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideRight API_AVAILABLE(ios(11.0),tvos(11.0)); 62 | 63 | #endif 64 | 65 | /** 66 | * a key to associate with this view 67 | */ 68 | @property (nonatomic, strong) id mas_key; 69 | 70 | /** 71 | * Finds the closest common superview between this view and another view 72 | * 73 | * @param view other view 74 | * 75 | * @return returns nil if common superview could not be found 76 | */ 77 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; 78 | 79 | /** 80 | * Creates a MASConstraintMaker with the callee view. 81 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing 82 | * 83 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 84 | * 85 | * @return Array of created MASConstraints 86 | */ 87 | - (NSArray *)mas_makeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; 88 | 89 | /** 90 | * Creates a MASConstraintMaker with the callee view. 91 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 92 | * If an existing constraint exists then it will be updated instead. 93 | * 94 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 95 | * 96 | * @return Array of created/updated MASConstraints 97 | */ 98 | - (NSArray *)mas_updateConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; 99 | 100 | /** 101 | * Creates a MASConstraintMaker with the callee view. 102 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 103 | * All constraints previously installed for the view will be removed. 104 | * 105 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 106 | * 107 | * @return Array of created/updated MASConstraints 108 | */ 109 | - (NSArray *)mas_remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; 110 | 111 | @end 112 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand view additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface MAS_VIEW (MASShorthandAdditions) 18 | 19 | @property (nonatomic, strong, readonly) MASViewAttribute *left; 20 | @property (nonatomic, strong, readonly) MASViewAttribute *top; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *right; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *bottom; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *leading; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *trailing; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *width; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *height; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *centerX; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *centerY; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *baseline; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *(^attribute)(NSLayoutAttribute attr); 31 | 32 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 33 | 34 | @property (nonatomic, strong, readonly) MASViewAttribute *firstBaseline; 35 | @property (nonatomic, strong, readonly) MASViewAttribute *lastBaseline; 36 | 37 | #endif 38 | 39 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 40 | 41 | @property (nonatomic, strong, readonly) MASViewAttribute *leftMargin; 42 | @property (nonatomic, strong, readonly) MASViewAttribute *rightMargin; 43 | @property (nonatomic, strong, readonly) MASViewAttribute *topMargin; 44 | @property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin; 45 | @property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin; 46 | @property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin; 47 | @property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins; 48 | @property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins; 49 | 50 | #endif 51 | 52 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 53 | 54 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideTop API_AVAILABLE(ios(11.0),tvos(11.0)); 55 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideBottom API_AVAILABLE(ios(11.0),tvos(11.0)); 56 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideLeft API_AVAILABLE(ios(11.0),tvos(11.0)); 57 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideRight API_AVAILABLE(ios(11.0),tvos(11.0)); 58 | 59 | #endif 60 | 61 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 62 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 63 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 64 | 65 | @end 66 | 67 | #define MAS_ATTR_FORWARD(attr) \ 68 | - (MASViewAttribute *)attr { \ 69 | return [self mas_##attr]; \ 70 | } 71 | 72 | @implementation MAS_VIEW (MASShorthandAdditions) 73 | 74 | MAS_ATTR_FORWARD(top); 75 | MAS_ATTR_FORWARD(left); 76 | MAS_ATTR_FORWARD(bottom); 77 | MAS_ATTR_FORWARD(right); 78 | MAS_ATTR_FORWARD(leading); 79 | MAS_ATTR_FORWARD(trailing); 80 | MAS_ATTR_FORWARD(width); 81 | MAS_ATTR_FORWARD(height); 82 | MAS_ATTR_FORWARD(centerX); 83 | MAS_ATTR_FORWARD(centerY); 84 | MAS_ATTR_FORWARD(baseline); 85 | 86 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 87 | 88 | MAS_ATTR_FORWARD(firstBaseline); 89 | MAS_ATTR_FORWARD(lastBaseline); 90 | 91 | #endif 92 | 93 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 94 | 95 | MAS_ATTR_FORWARD(leftMargin); 96 | MAS_ATTR_FORWARD(rightMargin); 97 | MAS_ATTR_FORWARD(topMargin); 98 | MAS_ATTR_FORWARD(bottomMargin); 99 | MAS_ATTR_FORWARD(leadingMargin); 100 | MAS_ATTR_FORWARD(trailingMargin); 101 | MAS_ATTR_FORWARD(centerXWithinMargins); 102 | MAS_ATTR_FORWARD(centerYWithinMargins); 103 | 104 | #endif 105 | 106 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 107 | 108 | MAS_ATTR_FORWARD(safeAreaLayoutGuideTop); 109 | MAS_ATTR_FORWARD(safeAreaLayoutGuideBottom); 110 | MAS_ATTR_FORWARD(safeAreaLayoutGuideLeft); 111 | MAS_ATTR_FORWARD(safeAreaLayoutGuideRight); 112 | 113 | #endif 114 | 115 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute { 116 | return [self mas_attribute]; 117 | } 118 | 119 | - (NSArray *)makeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { 120 | return [self mas_makeConstraints:block]; 121 | } 122 | 123 | - (NSArray *)updateConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { 124 | return [self mas_updateConstraints:block]; 125 | } 126 | 127 | - (NSArray *)remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { 128 | return [self mas_remakeConstraints:block]; 129 | } 130 | 131 | @end 132 | 133 | #endif 134 | -------------------------------------------------------------------------------- /OpenCV/Extension/UINavigationItem+KJExtension.m: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationItem+KJExtension.m 3 | // KJEmitterView 4 | // 5 | // Created by 77。 on 2018/12/1. 6 | // Copyright © 2018 77。. All rights reserved. 7 | // https://github.com/YangKJ/KJCategories 8 | 9 | #import "UINavigationItem+KJExtension.h" 10 | #import 11 | 12 | @interface UIButton (UINavigationItemButtonExtension) 13 | 14 | - (void)navigationAddAction:(void(^)(UIButton * kButton))block; 15 | 16 | @end 17 | 18 | @implementation UIButton (UINavigationItemButtonExtension) 19 | 20 | - (void)navigationAddAction:(void(^)(UIButton * kButton))block{ 21 | SEL selector = NSSelectorFromString(@"kNavigationItemButtonAction"); 22 | objc_setAssociatedObject(self, selector, block, OBJC_ASSOCIATION_COPY_NONATOMIC); 23 | [self addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside]; 24 | } 25 | - (void)kNavigationItemButtonAction{ 26 | void (^withBlock)(UIButton *) = objc_getAssociatedObject(self, _cmd); 27 | if (withBlock) withBlock(self); 28 | } 29 | 30 | @end 31 | 32 | @implementation UINavigationItem (KJExtension) 33 | /// 链式生成 34 | - (instancetype)kj_makeNavigationItem:(void(^)(UINavigationItem *make))block{ 35 | if (block) block(self); 36 | return self; 37 | } 38 | - (UIBarButtonItem *)kj_barButtonItemWithTitle:(NSString *)title 39 | titleColor:(UIColor *)color 40 | image:(UIImage *)image 41 | tintColor:(UIColor *)tintColor 42 | buttonBlock:(void(^)(UIButton *))block 43 | barButtonBlock:(void(^)(UIButton *))withBlock{ 44 | UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 45 | if (image) { 46 | if (tintColor) { 47 | image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 48 | [button.imageView setTintColor:tintColor]; 49 | } else { 50 | image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; 51 | } 52 | [button setImage:image forState:UIControlStateNormal]; 53 | } 54 | if (title) { 55 | [button setTitle:title forState:UIControlStateNormal]; 56 | [button setTitleColor:color forState:UIControlStateNormal]; 57 | } 58 | [button sizeToFit]; 59 | [button navigationAddAction:block]; 60 | if (withBlock) withBlock(button); 61 | return [[UIBarButtonItem alloc] initWithCustomView:button]; 62 | } 63 | 64 | #pragma mark - chain parameter 65 | 66 | - (UINavigationItem * (^)(void(^)(KJNavigationItemInfo *),void(^)(UIButton *)))kAddBarButtonItemInfo{ 67 | return ^ UINavigationItem * (void(^xblock)(KJNavigationItemInfo *), void(^block)(UIButton *)){ 68 | KJNavigationItemInfo *info = [KJNavigationItemInfo new]; 69 | if (xblock) xblock(info); 70 | UIBarButtonItem * barButtonItem = [self kj_barButtonItemWithTitle:info.title 71 | titleColor:info.color 72 | image:[UIImage imageNamed:info.imageName] 73 | tintColor:info.tintColor 74 | buttonBlock:block 75 | barButtonBlock:info.barButton]; 76 | if (info.isLeft) { 77 | return self.kAddLeftBarButtonItem(barButtonItem); 78 | } else { 79 | return self.kAddRightBarButtonItem(barButtonItem); 80 | } 81 | }; 82 | } 83 | - (UINavigationItem * (^)(UIBarButtonItem *))kAddLeftBarButtonItem{ 84 | return ^ UINavigationItem * (UIBarButtonItem * barButtonItem){ 85 | if (self.leftBarButtonItem == nil) { 86 | self.leftBarButtonItem = barButtonItem; 87 | } else { 88 | if (self.leftBarButtonItems.count == 0) { 89 | self.leftBarButtonItems = @[self.leftBarButtonItem,barButtonItem]; 90 | } else { 91 | NSMutableArray * items = [NSMutableArray arrayWithArray:self.leftBarButtonItems]; 92 | [items addObject:barButtonItem]; 93 | self.leftBarButtonItems = items; 94 | } 95 | } 96 | return self; 97 | }; 98 | } 99 | - (UINavigationItem * (^)(UIBarButtonItem *))kAddRightBarButtonItem{ 100 | return ^ UINavigationItem * (UIBarButtonItem * barButtonItem){ 101 | if (self.rightBarButtonItem == nil) { 102 | self.rightBarButtonItem = barButtonItem; 103 | } else { 104 | if (self.rightBarButtonItems.count == 0) { 105 | self.rightBarButtonItems = @[self.rightBarButtonItem,barButtonItem]; 106 | } else { 107 | NSMutableArray * items = [NSMutableArray arrayWithArray:self.rightBarButtonItems]; 108 | [items addObject:barButtonItem]; 109 | self.rightBarButtonItems = items; 110 | } 111 | } 112 | return self; 113 | }; 114 | } 115 | 116 | @end 117 | 118 | @implementation KJNavigationItemInfo 119 | 120 | - (instancetype)init{ 121 | if (self = [super init]) { 122 | self.color = UIColor.whiteColor; 123 | self.isLeft = YES; 124 | } 125 | return self; 126 | } 127 | 128 | @end 129 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASCompositeConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASCompositeConstraint.h" 10 | #import "MASConstraint+Private.h" 11 | 12 | @interface MASCompositeConstraint () 13 | 14 | @property (nonatomic, strong) id mas_key; 15 | @property (nonatomic, strong) NSMutableArray *childConstraints; 16 | 17 | @end 18 | 19 | @implementation MASCompositeConstraint 20 | 21 | - (id)initWithChildren:(NSArray *)children { 22 | self = [super init]; 23 | if (!self) return nil; 24 | 25 | _childConstraints = [children mutableCopy]; 26 | for (MASConstraint *constraint in _childConstraints) { 27 | constraint.delegate = self; 28 | } 29 | 30 | return self; 31 | } 32 | 33 | #pragma mark - MASConstraintDelegate 34 | 35 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { 36 | NSUInteger index = [self.childConstraints indexOfObject:constraint]; 37 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); 38 | [self.childConstraints replaceObjectAtIndex:index withObject:replacementConstraint]; 39 | } 40 | 41 | - (MASConstraint *)constraint:(MASConstraint __unused *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 42 | id strongDelegate = self.delegate; 43 | MASConstraint *newConstraint = [strongDelegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 44 | newConstraint.delegate = self; 45 | [self.childConstraints addObject:newConstraint]; 46 | return newConstraint; 47 | } 48 | 49 | #pragma mark - NSLayoutConstraint multiplier proxies 50 | 51 | - (MASConstraint * (^)(CGFloat))multipliedBy { 52 | return ^id(CGFloat multiplier) { 53 | for (MASConstraint *constraint in self.childConstraints) { 54 | constraint.multipliedBy(multiplier); 55 | } 56 | return self; 57 | }; 58 | } 59 | 60 | - (MASConstraint * (^)(CGFloat))dividedBy { 61 | return ^id(CGFloat divider) { 62 | for (MASConstraint *constraint in self.childConstraints) { 63 | constraint.dividedBy(divider); 64 | } 65 | return self; 66 | }; 67 | } 68 | 69 | #pragma mark - MASLayoutPriority proxy 70 | 71 | - (MASConstraint * (^)(MASLayoutPriority))priority { 72 | return ^id(MASLayoutPriority priority) { 73 | for (MASConstraint *constraint in self.childConstraints) { 74 | constraint.priority(priority); 75 | } 76 | return self; 77 | }; 78 | } 79 | 80 | #pragma mark - NSLayoutRelation proxy 81 | 82 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { 83 | return ^id(id attr, NSLayoutRelation relation) { 84 | for (MASConstraint *constraint in self.childConstraints.copy) { 85 | constraint.equalToWithRelation(attr, relation); 86 | } 87 | return self; 88 | }; 89 | } 90 | 91 | #pragma mark - attribute chaining 92 | 93 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 94 | [self constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 95 | return self; 96 | } 97 | 98 | #pragma mark - Animator proxy 99 | 100 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 101 | 102 | - (MASConstraint *)animator { 103 | for (MASConstraint *constraint in self.childConstraints) { 104 | [constraint animator]; 105 | } 106 | return self; 107 | } 108 | 109 | #endif 110 | 111 | #pragma mark - debug helpers 112 | 113 | - (MASConstraint * (^)(id))key { 114 | return ^id(id key) { 115 | self.mas_key = key; 116 | int i = 0; 117 | for (MASConstraint *constraint in self.childConstraints) { 118 | constraint.key([NSString stringWithFormat:@"%@[%d]", key, i++]); 119 | } 120 | return self; 121 | }; 122 | } 123 | 124 | #pragma mark - NSLayoutConstraint constant setters 125 | 126 | - (void)setInsets:(MASEdgeInsets)insets { 127 | for (MASConstraint *constraint in self.childConstraints) { 128 | constraint.insets = insets; 129 | } 130 | } 131 | 132 | - (void)setInset:(CGFloat)inset { 133 | for (MASConstraint *constraint in self.childConstraints) { 134 | constraint.inset = inset; 135 | } 136 | } 137 | 138 | - (void)setOffset:(CGFloat)offset { 139 | for (MASConstraint *constraint in self.childConstraints) { 140 | constraint.offset = offset; 141 | } 142 | } 143 | 144 | - (void)setSizeOffset:(CGSize)sizeOffset { 145 | for (MASConstraint *constraint in self.childConstraints) { 146 | constraint.sizeOffset = sizeOffset; 147 | } 148 | } 149 | 150 | - (void)setCenterOffset:(CGPoint)centerOffset { 151 | for (MASConstraint *constraint in self.childConstraints) { 152 | constraint.centerOffset = centerOffset; 153 | } 154 | } 155 | 156 | #pragma mark - MASConstraint 157 | 158 | - (void)activate { 159 | for (MASConstraint *constraint in self.childConstraints) { 160 | [constraint activate]; 161 | } 162 | } 163 | 164 | - (void)deactivate { 165 | for (MASConstraint *constraint in self.childConstraints) { 166 | [constraint deactivate]; 167 | } 168 | } 169 | 170 | - (void)install { 171 | for (MASConstraint *constraint in self.childConstraints) { 172 | constraint.updateExisting = self.updateExisting; 173 | [constraint install]; 174 | } 175 | } 176 | 177 | - (void)uninstall { 178 | for (MASConstraint *constraint in self.childConstraints) { 179 | [constraint uninstall]; 180 | } 181 | } 182 | 183 | @end 184 | -------------------------------------------------------------------------------- /OpenCV/Extension/UIColor+KJExtension.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+KJExtension.m 3 | // KJEmitterView 4 | // 5 | // Created by 77。 on 2019/12/31. 6 | // https://github.com/YangKJ/KJCategories 7 | 8 | #import "UIColor+KJExtension.h" 9 | 10 | @implementation UIColor (KJExtension) 11 | - (CGFloat)red{ 12 | CGFloat r = 0, g, b, a; 13 | [self getRed:&r green:&g blue:&b alpha:&a]; 14 | return r; 15 | } 16 | - (CGFloat)green{ 17 | CGFloat r, g = 0, b, a; 18 | [self getRed:&r green:&g blue:&b alpha:&a]; 19 | return g; 20 | } 21 | - (CGFloat)blue{ 22 | CGFloat r, g, b = 0, a; 23 | [self getRed:&r green:&g blue:&b alpha:&a]; 24 | return b; 25 | } 26 | - (CGFloat)alpha{ 27 | return CGColorGetAlpha(self.CGColor); 28 | } 29 | - (CGFloat)hue{ 30 | CGFloat h = 0,s,l; 31 | [self kj_HSL:&h :&s :&l]; 32 | return h; 33 | } 34 | - (CGFloat)saturation{ 35 | CGFloat h,s = 0,l; 36 | [self kj_HSL:&h :&s :&l]; 37 | return s; 38 | } 39 | - (CGFloat)light{ 40 | CGFloat h,s,l = 0; 41 | [self kj_HSL:&h :&s :&l]; 42 | return l; 43 | } 44 | /// 获取颜色对应的RGBA 45 | - (void)kj_rgba:(CGFloat *)r :(CGFloat *)g :(CGFloat *)b :(CGFloat *)a{ 46 | NSString *colorString = [NSString stringWithFormat:@"%@",self]; 47 | NSArray *temps = [colorString componentsSeparatedByString:@" "]; 48 | if (temps.count == 3 || temps.count == 4) { 49 | *r = [temps[1] floatValue]; 50 | *g = [temps[2] floatValue]; 51 | *b = [temps[3] floatValue]; 52 | if (temps.count == 4) { 53 | *a = [temps[4] floatValue]; 54 | } 55 | } 56 | } 57 | /// 获取颜色对应的色相饱和度和透明度 58 | - (void)kj_HSL:(CGFloat *)h :(CGFloat *)s :(CGFloat *)l{ 59 | CGFloat red,green,blue,alpha = 0.0f; 60 | BOOL success = [self getRed:&red green:&green blue:&blue alpha:&alpha]; 61 | if (success == NO) { 62 | *h = 0;*s = 0;*l = 0; 63 | return; 64 | } 65 | CGFloat hue = 0; 66 | CGFloat saturation = 0; 67 | CGFloat light = 0; 68 | CGFloat min = MIN(red,MIN(green,blue)); 69 | CGFloat max = MAX(red,MAX(green,blue)); 70 | if (min == max) { 71 | hue = 0; 72 | saturation = 0; 73 | light = min; 74 | }else { 75 | CGFloat d = (red==min) ? green-blue : ((blue==min) ? red-green : blue-red); 76 | CGFloat h = (red==min) ? 3 : ((blue==min) ? 1 : 5); 77 | hue = (h - d / (max - min)) / 6.0; 78 | saturation = (max - min) / max; 79 | light = max; 80 | } 81 | hue = (2 * hue - 1) * M_PI; 82 | *h = hue; 83 | *s = saturation; 84 | *l = light; 85 | } 86 | // UIColor转#ffffff格式的16进制字符串 87 | - (NSString *)kj_hexString{ 88 | return [UIColor hexStringFromColor:self]; 89 | } 90 | + (NSString *)hexStringFromColor:(UIColor *)color { 91 | const CGFloat *components = CGColorGetComponents(color.CGColor); 92 | CGFloat r = components[0]; 93 | CGFloat g = components[1]; 94 | CGFloat b = components[2]; 95 | return [NSString stringWithFormat:@"#%02lX%02lX%02lX",lroundf(r*255),lroundf(g*255),lroundf(b*255)]; 96 | } 97 | NSString *kDoraemonBoxHexStringFromColor(UIColor *color){ 98 | return [UIColor hexStringFromColor:color]; 99 | } 100 | UIColor * kDoraemonBoxColorHexString(NSString *hexString){ 101 | return [UIColor colorWithHexString:hexString]; 102 | } 103 | /// 16进制字符串转UIColor 104 | + (UIColor *)colorWithHexString:(NSString *)hexString { 105 | return [self colorWithHexString:hexString alpha:1.0]; 106 | } 107 | /// 16进制字符串转UIColor 108 | /// @param hexString 十六进制 109 | /// @param alpha 透明度 110 | + (UIColor *)colorWithHexString:(NSString *)hexString alpha:(float)alpha{ 111 | NSString *string = [[hexString stringByReplacingOccurrencesOfString:@"#" withString:@""] uppercaseString]; 112 | if ([hexString hasPrefix:@"0x"]) { 113 | string = [hexString stringByReplacingOccurrencesOfString:@"0x" withString:@""]; 114 | } 115 | CGFloat red,blue,green; 116 | switch ([string length]) { 117 | case 3: // #RGB 118 | alpha = 1.0f; 119 | red = [self colorComponent:string start:0 length:1]; 120 | green = [self colorComponent:string start:1 length:1]; 121 | blue = [self colorComponent:string start:2 length:1]; 122 | break; 123 | case 4: // #ARGB 124 | alpha = [self colorComponent:string start:0 length:1]; 125 | red = [self colorComponent:string start:1 length:1]; 126 | green = [self colorComponent:string start:2 length:1]; 127 | blue = [self colorComponent:string start:3 length:1]; 128 | break; 129 | case 6: // #RRGGBB 130 | alpha = 1.0f; 131 | red = [self colorComponent:string start:0 length:2]; 132 | green = [self colorComponent:string start:2 length:2]; 133 | blue = [self colorComponent:string start:4 length:2]; 134 | break; 135 | case 8: // #AARRGGBB 136 | alpha = [self colorComponent:string start:0 length:2]; 137 | red = [self colorComponent:string start:2 length:2]; 138 | green = [self colorComponent:string start:4 length:2]; 139 | blue = [self colorComponent:string start:6 length:2]; 140 | break; 141 | default: 142 | return nil; 143 | } 144 | return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; 145 | } 146 | + (CGFloat)colorComponent:(NSString *)string start:(NSUInteger)start length:(NSUInteger)length { 147 | NSString *substring = [string substringWithRange:NSMakeRange(start,length)]; 148 | NSString *fullHex = length == 2 ? substring : [NSString stringWithFormat:@"%@%@",substring,substring]; 149 | unsigned hexComponent; 150 | [[NSScanner scannerWithString:fullHex] scanHexInt:&hexComponent]; 151 | return hexComponent / 255.0; 152 | } 153 | /// 随机颜色 154 | UIColor * kDoraemonBoxRandomColor(void){ 155 | return [UIColor colorWithRed:((float)arc4random_uniform(256)/255.0) 156 | green:((float)arc4random_uniform(256)/255.0) 157 | blue:((float)arc4random_uniform(256)/255.0) 158 | alpha:1.0]; 159 | } 160 | 161 | @end 162 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintMaker.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | typedef NS_OPTIONS(NSInteger, MASAttribute) { 13 | MASAttributeLeft = 1 << NSLayoutAttributeLeft, 14 | MASAttributeRight = 1 << NSLayoutAttributeRight, 15 | MASAttributeTop = 1 << NSLayoutAttributeTop, 16 | MASAttributeBottom = 1 << NSLayoutAttributeBottom, 17 | MASAttributeLeading = 1 << NSLayoutAttributeLeading, 18 | MASAttributeTrailing = 1 << NSLayoutAttributeTrailing, 19 | MASAttributeWidth = 1 << NSLayoutAttributeWidth, 20 | MASAttributeHeight = 1 << NSLayoutAttributeHeight, 21 | MASAttributeCenterX = 1 << NSLayoutAttributeCenterX, 22 | MASAttributeCenterY = 1 << NSLayoutAttributeCenterY, 23 | MASAttributeBaseline = 1 << NSLayoutAttributeBaseline, 24 | 25 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 26 | 27 | MASAttributeFirstBaseline = 1 << NSLayoutAttributeFirstBaseline, 28 | MASAttributeLastBaseline = 1 << NSLayoutAttributeLastBaseline, 29 | 30 | #endif 31 | 32 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 33 | 34 | MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin, 35 | MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin, 36 | MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin, 37 | MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin, 38 | MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin, 39 | MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin, 40 | MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins, 41 | MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins, 42 | 43 | #endif 44 | 45 | }; 46 | 47 | /** 48 | * Provides factory methods for creating MASConstraints. 49 | * Constraints are collected until they are ready to be installed 50 | * 51 | */ 52 | @interface MASConstraintMaker : NSObject 53 | 54 | /** 55 | * The following properties return a new MASViewConstraint 56 | * with the first item set to the makers associated view and the appropriate MASViewAttribute 57 | */ 58 | @property (nonatomic, strong, readonly) MASConstraint *left; 59 | @property (nonatomic, strong, readonly) MASConstraint *top; 60 | @property (nonatomic, strong, readonly) MASConstraint *right; 61 | @property (nonatomic, strong, readonly) MASConstraint *bottom; 62 | @property (nonatomic, strong, readonly) MASConstraint *leading; 63 | @property (nonatomic, strong, readonly) MASConstraint *trailing; 64 | @property (nonatomic, strong, readonly) MASConstraint *width; 65 | @property (nonatomic, strong, readonly) MASConstraint *height; 66 | @property (nonatomic, strong, readonly) MASConstraint *centerX; 67 | @property (nonatomic, strong, readonly) MASConstraint *centerY; 68 | @property (nonatomic, strong, readonly) MASConstraint *baseline; 69 | 70 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 71 | 72 | @property (nonatomic, strong, readonly) MASConstraint *firstBaseline; 73 | @property (nonatomic, strong, readonly) MASConstraint *lastBaseline; 74 | 75 | #endif 76 | 77 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 78 | 79 | @property (nonatomic, strong, readonly) MASConstraint *leftMargin; 80 | @property (nonatomic, strong, readonly) MASConstraint *rightMargin; 81 | @property (nonatomic, strong, readonly) MASConstraint *topMargin; 82 | @property (nonatomic, strong, readonly) MASConstraint *bottomMargin; 83 | @property (nonatomic, strong, readonly) MASConstraint *leadingMargin; 84 | @property (nonatomic, strong, readonly) MASConstraint *trailingMargin; 85 | @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins; 86 | @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins; 87 | 88 | #endif 89 | 90 | /** 91 | * Returns a block which creates a new MASCompositeConstraint with the first item set 92 | * to the makers associated view and children corresponding to the set bits in the 93 | * MASAttribute parameter. Combine multiple attributes via binary-or. 94 | */ 95 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs); 96 | 97 | /** 98 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges 99 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right) 100 | * with the first item set to the makers associated view 101 | */ 102 | @property (nonatomic, strong, readonly) MASConstraint *edges; 103 | 104 | /** 105 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize 106 | * which generates the appropriate MASViewConstraint children (width, height) 107 | * with the first item set to the makers associated view 108 | */ 109 | @property (nonatomic, strong, readonly) MASConstraint *size; 110 | 111 | /** 112 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter 113 | * which generates the appropriate MASViewConstraint children (centerX, centerY) 114 | * with the first item set to the makers associated view 115 | */ 116 | @property (nonatomic, strong, readonly) MASConstraint *center; 117 | 118 | /** 119 | * Whether or not to check for an existing constraint instead of adding constraint 120 | */ 121 | @property (nonatomic, assign) BOOL updateExisting; 122 | 123 | /** 124 | * Whether or not to remove existing constraints prior to installing 125 | */ 126 | @property (nonatomic, assign) BOOL removeExisting; 127 | 128 | /** 129 | * initialises the maker with a default view 130 | * 131 | * @param view any MASConstraint are created with this view as the first item 132 | * 133 | * @return a new MASConstraintMaker 134 | */ 135 | - (id)initWithView:(MAS_VIEW *)view; 136 | 137 | /** 138 | * Calls install method on any MASConstraints which have been created by this maker 139 | * 140 | * @return an array of all the installed MASConstraints 141 | */ 142 | - (NSArray *)install; 143 | 144 | - (MASConstraint * (^)(dispatch_block_t))group; 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSLayoutConstraint+MASDebugAdditions.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | 13 | @implementation NSLayoutConstraint (MASDebugAdditions) 14 | 15 | #pragma mark - description maps 16 | 17 | + (NSDictionary *)layoutRelationDescriptionsByValue { 18 | static dispatch_once_t once; 19 | static NSDictionary *descriptionMap; 20 | dispatch_once(&once, ^{ 21 | descriptionMap = @{ 22 | @(NSLayoutRelationEqual) : @"==", 23 | @(NSLayoutRelationGreaterThanOrEqual) : @">=", 24 | @(NSLayoutRelationLessThanOrEqual) : @"<=", 25 | }; 26 | }); 27 | return descriptionMap; 28 | } 29 | 30 | + (NSDictionary *)layoutAttributeDescriptionsByValue { 31 | static dispatch_once_t once; 32 | static NSDictionary *descriptionMap; 33 | dispatch_once(&once, ^{ 34 | descriptionMap = @{ 35 | @(NSLayoutAttributeTop) : @"top", 36 | @(NSLayoutAttributeLeft) : @"left", 37 | @(NSLayoutAttributeBottom) : @"bottom", 38 | @(NSLayoutAttributeRight) : @"right", 39 | @(NSLayoutAttributeLeading) : @"leading", 40 | @(NSLayoutAttributeTrailing) : @"trailing", 41 | @(NSLayoutAttributeWidth) : @"width", 42 | @(NSLayoutAttributeHeight) : @"height", 43 | @(NSLayoutAttributeCenterX) : @"centerX", 44 | @(NSLayoutAttributeCenterY) : @"centerY", 45 | @(NSLayoutAttributeBaseline) : @"baseline", 46 | 47 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 48 | @(NSLayoutAttributeFirstBaseline) : @"firstBaseline", 49 | @(NSLayoutAttributeLastBaseline) : @"lastBaseline", 50 | #endif 51 | 52 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 53 | @(NSLayoutAttributeLeftMargin) : @"leftMargin", 54 | @(NSLayoutAttributeRightMargin) : @"rightMargin", 55 | @(NSLayoutAttributeTopMargin) : @"topMargin", 56 | @(NSLayoutAttributeBottomMargin) : @"bottomMargin", 57 | @(NSLayoutAttributeLeadingMargin) : @"leadingMargin", 58 | @(NSLayoutAttributeTrailingMargin) : @"trailingMargin", 59 | @(NSLayoutAttributeCenterXWithinMargins) : @"centerXWithinMargins", 60 | @(NSLayoutAttributeCenterYWithinMargins) : @"centerYWithinMargins", 61 | #endif 62 | 63 | }; 64 | 65 | }); 66 | return descriptionMap; 67 | } 68 | 69 | 70 | + (NSDictionary *)layoutPriorityDescriptionsByValue { 71 | static dispatch_once_t once; 72 | static NSDictionary *descriptionMap; 73 | dispatch_once(&once, ^{ 74 | #if TARGET_OS_IPHONE || TARGET_OS_TV 75 | descriptionMap = @{ 76 | @(MASLayoutPriorityDefaultHigh) : @"high", 77 | @(MASLayoutPriorityDefaultLow) : @"low", 78 | @(MASLayoutPriorityDefaultMedium) : @"medium", 79 | @(MASLayoutPriorityRequired) : @"required", 80 | @(MASLayoutPriorityFittingSizeLevel) : @"fitting size", 81 | }; 82 | #elif TARGET_OS_MAC 83 | descriptionMap = @{ 84 | @(MASLayoutPriorityDefaultHigh) : @"high", 85 | @(MASLayoutPriorityDragThatCanResizeWindow) : @"drag can resize window", 86 | @(MASLayoutPriorityDefaultMedium) : @"medium", 87 | @(MASLayoutPriorityWindowSizeStayPut) : @"window size stay put", 88 | @(MASLayoutPriorityDragThatCannotResizeWindow) : @"drag cannot resize window", 89 | @(MASLayoutPriorityDefaultLow) : @"low", 90 | @(MASLayoutPriorityFittingSizeCompression) : @"fitting size", 91 | @(MASLayoutPriorityRequired) : @"required", 92 | }; 93 | #endif 94 | }); 95 | return descriptionMap; 96 | } 97 | 98 | #pragma mark - description override 99 | 100 | + (NSString *)descriptionForObject:(id)obj { 101 | if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) { 102 | return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]]; 103 | } 104 | return [NSString stringWithFormat:@"%@:%p", [obj class], obj]; 105 | } 106 | 107 | - (NSString *)description { 108 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"]; 109 | 110 | [description appendString:[self.class descriptionForObject:self]]; 111 | 112 | [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]]; 113 | if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) { 114 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.firstAttribute)]]; 115 | } 116 | 117 | [description appendFormat:@" %@", self.class.layoutRelationDescriptionsByValue[@(self.relation)]]; 118 | 119 | if (self.secondItem) { 120 | [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]]; 121 | } 122 | if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) { 123 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.secondAttribute)]]; 124 | } 125 | 126 | if (self.multiplier != 1) { 127 | [description appendFormat:@" * %g", self.multiplier]; 128 | } 129 | 130 | if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) { 131 | [description appendFormat:@" %g", self.constant]; 132 | } else { 133 | if (self.constant) { 134 | [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)]; 135 | } 136 | } 137 | 138 | if (self.priority != MASLayoutPriorityRequired) { 139 | [description appendFormat:@" ^%@", self.class.layoutPriorityDescriptionsByValue[@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]]; 140 | } 141 | 142 | [description appendString:@">"]; 143 | return description; 144 | } 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASUtilities.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 19/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | 13 | #if TARGET_OS_IPHONE || TARGET_OS_TV 14 | 15 | #import 16 | #define MAS_VIEW UIView 17 | #define MAS_VIEW_CONTROLLER UIViewController 18 | #define MASEdgeInsets UIEdgeInsets 19 | 20 | typedef UILayoutPriority MASLayoutPriority; 21 | static const MASLayoutPriority MASLayoutPriorityRequired = UILayoutPriorityRequired; 22 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh; 23 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 500; 24 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow; 25 | static const MASLayoutPriority MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel; 26 | 27 | #elif TARGET_OS_MAC 28 | 29 | #import 30 | #define MAS_VIEW NSView 31 | #define MASEdgeInsets NSEdgeInsets 32 | 33 | typedef NSLayoutPriority MASLayoutPriority; 34 | static const MASLayoutPriority MASLayoutPriorityRequired = NSLayoutPriorityRequired; 35 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = NSLayoutPriorityDefaultHigh; 36 | static const MASLayoutPriority MASLayoutPriorityDragThatCanResizeWindow = NSLayoutPriorityDragThatCanResizeWindow; 37 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 501; 38 | static const MASLayoutPriority MASLayoutPriorityWindowSizeStayPut = NSLayoutPriorityWindowSizeStayPut; 39 | static const MASLayoutPriority MASLayoutPriorityDragThatCannotResizeWindow = NSLayoutPriorityDragThatCannotResizeWindow; 40 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = NSLayoutPriorityDefaultLow; 41 | static const MASLayoutPriority MASLayoutPriorityFittingSizeCompression = NSLayoutPriorityFittingSizeCompression; 42 | 43 | #endif 44 | 45 | /** 46 | * Allows you to attach keys to objects matching the variable names passed. 47 | * 48 | * view1.mas_key = @"view1", view2.mas_key = @"view2"; 49 | * 50 | * is equivalent to: 51 | * 52 | * MASAttachKeys(view1, view2); 53 | */ 54 | #define MASAttachKeys(...) \ 55 | { \ 56 | NSDictionary *keyPairs = NSDictionaryOfVariableBindings(__VA_ARGS__); \ 57 | for (id key in keyPairs.allKeys) { \ 58 | id obj = keyPairs[key]; \ 59 | NSAssert([obj respondsToSelector:@selector(setMas_key:)], \ 60 | @"Cannot attach mas_key to %@", obj); \ 61 | [obj setMas_key:key]; \ 62 | } \ 63 | } 64 | 65 | /** 66 | * Used to create object hashes 67 | * Based on http://www.mikeash.com/pyblog/friday-qa-2010-06-18-implementing-equality-and-hashing.html 68 | */ 69 | #define MAS_NSUINT_BIT (CHAR_BIT * sizeof(NSUInteger)) 70 | #define MAS_NSUINTROTATE(val, howmuch) ((((NSUInteger)val) << howmuch) | (((NSUInteger)val) >> (MAS_NSUINT_BIT - howmuch))) 71 | 72 | /** 73 | * Given a scalar or struct value, wraps it in NSValue 74 | * Based on EXPObjectify: https://github.com/specta/expecta 75 | */ 76 | static inline id _MASBoxValue(const char *type, ...) { 77 | va_list v; 78 | va_start(v, type); 79 | id obj = nil; 80 | if (strcmp(type, @encode(id)) == 0) { 81 | id actual = va_arg(v, id); 82 | obj = actual; 83 | } else if (strcmp(type, @encode(CGPoint)) == 0) { 84 | CGPoint actual = (CGPoint)va_arg(v, CGPoint); 85 | obj = [NSValue value:&actual withObjCType:type]; 86 | } else if (strcmp(type, @encode(CGSize)) == 0) { 87 | CGSize actual = (CGSize)va_arg(v, CGSize); 88 | obj = [NSValue value:&actual withObjCType:type]; 89 | } else if (strcmp(type, @encode(MASEdgeInsets)) == 0) { 90 | MASEdgeInsets actual = (MASEdgeInsets)va_arg(v, MASEdgeInsets); 91 | obj = [NSValue value:&actual withObjCType:type]; 92 | } else if (strcmp(type, @encode(double)) == 0) { 93 | double actual = (double)va_arg(v, double); 94 | obj = [NSNumber numberWithDouble:actual]; 95 | } else if (strcmp(type, @encode(float)) == 0) { 96 | float actual = (float)va_arg(v, double); 97 | obj = [NSNumber numberWithFloat:actual]; 98 | } else if (strcmp(type, @encode(int)) == 0) { 99 | int actual = (int)va_arg(v, int); 100 | obj = [NSNumber numberWithInt:actual]; 101 | } else if (strcmp(type, @encode(long)) == 0) { 102 | long actual = (long)va_arg(v, long); 103 | obj = [NSNumber numberWithLong:actual]; 104 | } else if (strcmp(type, @encode(long long)) == 0) { 105 | long long actual = (long long)va_arg(v, long long); 106 | obj = [NSNumber numberWithLongLong:actual]; 107 | } else if (strcmp(type, @encode(short)) == 0) { 108 | short actual = (short)va_arg(v, int); 109 | obj = [NSNumber numberWithShort:actual]; 110 | } else if (strcmp(type, @encode(char)) == 0) { 111 | char actual = (char)va_arg(v, int); 112 | obj = [NSNumber numberWithChar:actual]; 113 | } else if (strcmp(type, @encode(bool)) == 0) { 114 | bool actual = (bool)va_arg(v, int); 115 | obj = [NSNumber numberWithBool:actual]; 116 | } else if (strcmp(type, @encode(unsigned char)) == 0) { 117 | unsigned char actual = (unsigned char)va_arg(v, unsigned int); 118 | obj = [NSNumber numberWithUnsignedChar:actual]; 119 | } else if (strcmp(type, @encode(unsigned int)) == 0) { 120 | unsigned int actual = (unsigned int)va_arg(v, unsigned int); 121 | obj = [NSNumber numberWithUnsignedInt:actual]; 122 | } else if (strcmp(type, @encode(unsigned long)) == 0) { 123 | unsigned long actual = (unsigned long)va_arg(v, unsigned long); 124 | obj = [NSNumber numberWithUnsignedLong:actual]; 125 | } else if (strcmp(type, @encode(unsigned long long)) == 0) { 126 | unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long); 127 | obj = [NSNumber numberWithUnsignedLongLong:actual]; 128 | } else if (strcmp(type, @encode(unsigned short)) == 0) { 129 | unsigned short actual = (unsigned short)va_arg(v, unsigned int); 130 | obj = [NSNumber numberWithUnsignedShort:actual]; 131 | } 132 | va_end(v); 133 | return obj; 134 | } 135 | 136 | #define MASBoxValue(value) _MASBoxValue(@encode(__typeof__((value))), (value)) 137 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/NSArray+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.m 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | #import "View+MASAdditions.h" 11 | 12 | @implementation NSArray (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block { 15 | NSMutableArray *constraints = [NSMutableArray array]; 16 | for (MAS_VIEW *view in self) { 17 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 18 | [constraints addObjectsFromArray:[view mas_makeConstraints:block]]; 19 | } 20 | return constraints; 21 | } 22 | 23 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block { 24 | NSMutableArray *constraints = [NSMutableArray array]; 25 | for (MAS_VIEW *view in self) { 26 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 27 | [constraints addObjectsFromArray:[view mas_updateConstraints:block]]; 28 | } 29 | return constraints; 30 | } 31 | 32 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 33 | NSMutableArray *constraints = [NSMutableArray array]; 34 | for (MAS_VIEW *view in self) { 35 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 36 | [constraints addObjectsFromArray:[view mas_remakeConstraints:block]]; 37 | } 38 | return constraints; 39 | } 40 | 41 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing { 42 | if (self.count < 2) { 43 | NSAssert(self.count>1,@"views to distribute need to bigger than one"); 44 | return; 45 | } 46 | 47 | MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews]; 48 | if (axisType == MASAxisTypeHorizontal) { 49 | MAS_VIEW *prev; 50 | for (int i = 0; i < self.count; i++) { 51 | MAS_VIEW *v = self[i]; 52 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 53 | if (prev) { 54 | make.width.equalTo(prev); 55 | make.left.equalTo(prev.mas_right).offset(fixedSpacing); 56 | if (i == self.count - 1) {//last one 57 | make.right.equalTo(tempSuperView).offset(-tailSpacing); 58 | } 59 | } 60 | else {//first one 61 | make.left.equalTo(tempSuperView).offset(leadSpacing); 62 | } 63 | 64 | }]; 65 | prev = v; 66 | } 67 | } 68 | else { 69 | MAS_VIEW *prev; 70 | for (int i = 0; i < self.count; i++) { 71 | MAS_VIEW *v = self[i]; 72 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 73 | if (prev) { 74 | make.height.equalTo(prev); 75 | make.top.equalTo(prev.mas_bottom).offset(fixedSpacing); 76 | if (i == self.count - 1) {//last one 77 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing); 78 | } 79 | } 80 | else {//first one 81 | make.top.equalTo(tempSuperView).offset(leadSpacing); 82 | } 83 | 84 | }]; 85 | prev = v; 86 | } 87 | } 88 | } 89 | 90 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing { 91 | if (self.count < 2) { 92 | NSAssert(self.count>1,@"views to distribute need to bigger than one"); 93 | return; 94 | } 95 | 96 | MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews]; 97 | if (axisType == MASAxisTypeHorizontal) { 98 | MAS_VIEW *prev; 99 | for (int i = 0; i < self.count; i++) { 100 | MAS_VIEW *v = self[i]; 101 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 102 | make.width.equalTo(@(fixedItemLength)); 103 | if (prev) { 104 | if (i == self.count - 1) {//last one 105 | make.right.equalTo(tempSuperView).offset(-tailSpacing); 106 | } 107 | else { 108 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1)); 109 | make.right.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset); 110 | } 111 | } 112 | else {//first one 113 | make.left.equalTo(tempSuperView).offset(leadSpacing); 114 | } 115 | }]; 116 | prev = v; 117 | } 118 | } 119 | else { 120 | MAS_VIEW *prev; 121 | for (int i = 0; i < self.count; i++) { 122 | MAS_VIEW *v = self[i]; 123 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 124 | make.height.equalTo(@(fixedItemLength)); 125 | if (prev) { 126 | if (i == self.count - 1) {//last one 127 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing); 128 | } 129 | else { 130 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1)); 131 | make.bottom.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset); 132 | } 133 | } 134 | else {//first one 135 | make.top.equalTo(tempSuperView).offset(leadSpacing); 136 | } 137 | }]; 138 | prev = v; 139 | } 140 | } 141 | } 142 | 143 | - (MAS_VIEW *)mas_commonSuperviewOfViews 144 | { 145 | MAS_VIEW *commonSuperview = nil; 146 | MAS_VIEW *previousView = nil; 147 | for (id object in self) { 148 | if ([object isKindOfClass:[MAS_VIEW class]]) { 149 | MAS_VIEW *view = (MAS_VIEW *)object; 150 | if (previousView) { 151 | commonSuperview = [view mas_closestCommonSuperview:commonSuperview]; 152 | } else { 153 | commonSuperview = view; 154 | } 155 | previousView = view; 156 | } 157 | } 158 | NSAssert(commonSuperview, @"Can't constrain views that do not share a common superview. Make sure that all the views in this array have been added into the same view hierarchy."); 159 | return commonSuperview; 160 | } 161 | 162 | @end 163 | -------------------------------------------------------------------------------- /OpenCV/Extension/NSObject+KJGCDBox.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+KJGCDBox.m 3 | // KJEmitterView 4 | // 5 | // Created by 77。 on 2019/3/17. 6 | // https://github.com/YangKJ/KJCategories 7 | 8 | #import "NSObject+KJGCDBox.h" 9 | #import 10 | 11 | @implementation NSObject (KJGCDBox) 12 | 13 | #pragma mark - Associated 14 | 15 | - (BOOL)isHangUp{ 16 | return [objc_getAssociatedObject(self, _cmd) boolValue]; 17 | } 18 | - (void)setIsHangUp:(BOOL)isHangUp{ 19 | objc_setAssociatedObject(self, @selector(isHangUp), @(isHangUp), OBJC_ASSOCIATION_ASSIGN); 20 | } 21 | 22 | /* 创建异步定时器 */ 23 | - (dispatch_source_t)kj_createGCDAsyncTimer:(BOOL)async 24 | task:(dispatch_block_t)task 25 | start:(NSTimeInterval)start 26 | interval:(NSTimeInterval)interval 27 | repeats:(BOOL)repeats{ 28 | if (!task || start < 0 || (interval <= 0 && repeats)) return nil; 29 | self.isHangUp = NO; 30 | dispatch_queue_t queue = async ? dispatch_get_global_queue(0, 0) : dispatch_get_main_queue(); 31 | __block dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); 32 | dispatch_source_set_timer(timer, dispatch_time(DISPATCH_TIME_NOW, start * NSEC_PER_SEC), interval * NSEC_PER_SEC, 0); 33 | __weak __typeof(self) weaktarget = self; 34 | dispatch_source_set_event_handler(timer, ^{ 35 | if (weaktarget == nil) { 36 | dispatch_source_cancel(timer); 37 | timer = nil; 38 | } else { 39 | if (repeats) { 40 | task(); 41 | } else { 42 | task(); 43 | [self kj_gcdStopTimer:timer]; 44 | } 45 | } 46 | }); 47 | dispatch_resume(timer); 48 | return timer; 49 | } 50 | /* 取消计时器 */ 51 | - (void)kj_gcdStopTimer:(dispatch_source_t)timer{ 52 | self.isHangUp = NO; 53 | dispatch_source_t __timer = timer; 54 | if (__timer) { 55 | dispatch_source_cancel(__timer); 56 | __timer = nil; 57 | } 58 | } 59 | /* 暂停计时器 */ 60 | - (void)kj_gcdPauseTimer:(dispatch_source_t)timer{ 61 | if (timer) { 62 | self.isHangUp = YES; 63 | dispatch_suspend(timer); 64 | } 65 | } 66 | /* 继续计时器 */ 67 | - (void)kj_gcdResumeTimer:(dispatch_source_t)timer{ 68 | if (timer && self.isHangUp) { 69 | self.isHangUp = NO; 70 | //挂起的时候注意,多次暂停的操作会导致线程锁的现象 71 | //dispatch_suspend和dispatch_resume是一对 72 | dispatch_resume(timer); 73 | } 74 | } 75 | 76 | /* 延时执行 */ 77 | - (void)kj_gcdAfterTask:(dispatch_block_t)task time:(NSTimeInterval)time asyne:(BOOL)async{ 78 | dispatch_queue_t queue = async ? dispatch_get_global_queue(0, 0) : dispatch_get_main_queue(); 79 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(time * NSEC_PER_SEC)), queue, ^{ 80 | if (task) { 81 | task(); 82 | } 83 | }); 84 | } 85 | /* 异步快速迭代 */ 86 | - (void)kj_gcdApplyTask:(BOOL(^)(size_t index))task count:(NSUInteger)count{ 87 | dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); 88 | dispatch_apply(count, queue, ^(size_t index) { 89 | if (task(index)) { } 90 | }); 91 | } 92 | 93 | #pragma mark - GCD 线程处理 94 | 95 | dispatch_queue_t kGCD_queue(void) { 96 | dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); 97 | return queue; 98 | } 99 | /// 主线程 100 | void kGCD_main(dispatch_block_t block) { 101 | dispatch_queue_t queue = dispatch_get_main_queue(); 102 | if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(queue)) == 0) { 103 | block(); 104 | } else { 105 | if ([[NSThread currentThread] isMainThread]) { 106 | dispatch_async(queue, block); 107 | } else { 108 | dispatch_sync(queue, block); 109 | } 110 | } 111 | } 112 | /// 子线程 113 | void kGCD_async(dispatch_block_t block) { 114 | dispatch_queue_t queue = kGCD_queue(); 115 | if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(queue)) == 0) { 116 | block(); 117 | } else { 118 | dispatch_async(queue, block); 119 | } 120 | } 121 | /// 异步并行队列,携带可变参数(需要nil结尾) 122 | void kGCD_group_notify(dispatch_block_t notify,dispatch_block_t block,...) { 123 | dispatch_queue_t queue = kGCD_queue(); 124 | dispatch_group_t group = dispatch_group_create(); 125 | dispatch_group_async(group, queue, block); 126 | va_list args;dispatch_block_t arg; 127 | va_start(args, block); 128 | while ((arg = va_arg(args, dispatch_block_t))) { 129 | dispatch_group_async(group, queue, arg); 130 | } 131 | va_end(args); 132 | dispatch_group_notify(group, queue, notify); 133 | } 134 | /// 栅栏 135 | dispatch_queue_t kGCD_barrier(dispatch_block_t block,dispatch_block_t barrier) { 136 | dispatch_queue_t queue = kGCD_queue(); 137 | dispatch_async(queue, block); 138 | dispatch_barrier_async(queue, ^{ dispatch_async(dispatch_get_main_queue(), barrier); }); 139 | return queue; 140 | } 141 | /// 栅栏实现多读单写操作,barrier当中完成写操作,携带可变参数(需要nil结尾) 142 | void kGCD_barrier_read_write(dispatch_block_t barrier, dispatch_block_t block,...){ 143 | dispatch_queue_t queue = kGCD_queue(); 144 | dispatch_async(queue, block); 145 | va_list args;dispatch_block_t arg; 146 | va_start(args, block); 147 | while ((arg = va_arg(args, dispatch_block_t))) { 148 | dispatch_async(queue, block); 149 | } 150 | va_end(args); 151 | dispatch_barrier_async(queue, ^{ 152 | dispatch_async(dispatch_get_main_queue(), barrier); 153 | }); 154 | } 155 | /// 一次性 156 | void kGCD_once(dispatch_block_t block) { 157 | static dispatch_once_t onceToken; 158 | dispatch_once(&onceToken, block); 159 | } 160 | /// 延时执行 161 | void kGCD_after(int64_t delayInSeconds, dispatch_block_t block) { 162 | dispatch_queue_t queue = kGCD_queue(); 163 | dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 164 | dispatch_after(time, queue, block); 165 | } 166 | /// 主线程当中延时执行 167 | void kGCD_after_main(int64_t delayInSeconds, dispatch_block_t block) { 168 | dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 169 | dispatch_after(time, dispatch_get_main_queue(), block); 170 | } 171 | /// 快速迭代 172 | void kGCD_apply(int iterations, void(^block)(size_t idx)) { 173 | dispatch_queue_t queue = kGCD_queue(); 174 | dispatch_apply(iterations, queue, block); 175 | } 176 | /// 快速遍历数组 177 | void kGCD_apply_array(NSArray * temp, void(^block)(id obj, size_t index)) { 178 | void (^xxblock)(size_t) = ^(size_t index){ 179 | block(temp[index], index); 180 | }; 181 | dispatch_apply(temp.count, kGCD_queue(), xxblock); 182 | } 183 | 184 | @end 185 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/View+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | #import 11 | 12 | @implementation MAS_VIEW (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *))block { 15 | self.translatesAutoresizingMaskIntoConstraints = NO; 16 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 17 | block(constraintMaker); 18 | return [constraintMaker install]; 19 | } 20 | 21 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *))block { 22 | self.translatesAutoresizingMaskIntoConstraints = NO; 23 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 24 | constraintMaker.updateExisting = YES; 25 | block(constraintMaker); 26 | return [constraintMaker install]; 27 | } 28 | 29 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 30 | self.translatesAutoresizingMaskIntoConstraints = NO; 31 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 32 | constraintMaker.removeExisting = YES; 33 | block(constraintMaker); 34 | return [constraintMaker install]; 35 | } 36 | 37 | #pragma mark - NSLayoutAttribute properties 38 | 39 | - (MASViewAttribute *)mas_left { 40 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeft]; 41 | } 42 | 43 | - (MASViewAttribute *)mas_top { 44 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTop]; 45 | } 46 | 47 | - (MASViewAttribute *)mas_right { 48 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRight]; 49 | } 50 | 51 | - (MASViewAttribute *)mas_bottom { 52 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottom]; 53 | } 54 | 55 | - (MASViewAttribute *)mas_leading { 56 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeading]; 57 | } 58 | 59 | - (MASViewAttribute *)mas_trailing { 60 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailing]; 61 | } 62 | 63 | - (MASViewAttribute *)mas_width { 64 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeWidth]; 65 | } 66 | 67 | - (MASViewAttribute *)mas_height { 68 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeHeight]; 69 | } 70 | 71 | - (MASViewAttribute *)mas_centerX { 72 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterX]; 73 | } 74 | 75 | - (MASViewAttribute *)mas_centerY { 76 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterY]; 77 | } 78 | 79 | - (MASViewAttribute *)mas_baseline { 80 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBaseline]; 81 | } 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))mas_attribute 84 | { 85 | return ^(NSLayoutAttribute attr) { 86 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:attr]; 87 | }; 88 | } 89 | 90 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 91 | 92 | - (MASViewAttribute *)mas_firstBaseline { 93 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeFirstBaseline]; 94 | } 95 | - (MASViewAttribute *)mas_lastBaseline { 96 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLastBaseline]; 97 | } 98 | 99 | #endif 100 | 101 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 102 | 103 | - (MASViewAttribute *)mas_leftMargin { 104 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin]; 105 | } 106 | 107 | - (MASViewAttribute *)mas_rightMargin { 108 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin]; 109 | } 110 | 111 | - (MASViewAttribute *)mas_topMargin { 112 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin]; 113 | } 114 | 115 | - (MASViewAttribute *)mas_bottomMargin { 116 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin]; 117 | } 118 | 119 | - (MASViewAttribute *)mas_leadingMargin { 120 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin]; 121 | } 122 | 123 | - (MASViewAttribute *)mas_trailingMargin { 124 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin]; 125 | } 126 | 127 | - (MASViewAttribute *)mas_centerXWithinMargins { 128 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 129 | } 130 | 131 | - (MASViewAttribute *)mas_centerYWithinMargins { 132 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 133 | } 134 | 135 | #endif 136 | 137 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 138 | 139 | - (MASViewAttribute *)mas_safeAreaLayoutGuide { 140 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 141 | } 142 | - (MASViewAttribute *)mas_safeAreaLayoutGuideTop { 143 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 144 | } 145 | - (MASViewAttribute *)mas_safeAreaLayoutGuideBottom { 146 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 147 | } 148 | - (MASViewAttribute *)mas_safeAreaLayoutGuideLeft { 149 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeLeft]; 150 | } 151 | - (MASViewAttribute *)mas_safeAreaLayoutGuideRight { 152 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeRight]; 153 | } 154 | 155 | #endif 156 | 157 | #pragma mark - associated properties 158 | 159 | - (id)mas_key { 160 | return objc_getAssociatedObject(self, @selector(mas_key)); 161 | } 162 | 163 | - (void)setMas_key:(id)key { 164 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 165 | } 166 | 167 | #pragma mark - heirachy 168 | 169 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view { 170 | MAS_VIEW *closestCommonSuperview = nil; 171 | 172 | MAS_VIEW *secondViewSuperview = view; 173 | while (!closestCommonSuperview && secondViewSuperview) { 174 | MAS_VIEW *firstViewSuperview = self; 175 | while (!closestCommonSuperview && firstViewSuperview) { 176 | if (secondViewSuperview == firstViewSuperview) { 177 | closestCommonSuperview = secondViewSuperview; 178 | } 179 | firstViewSuperview = firstViewSuperview.superview; 180 | } 181 | secondViewSuperview = secondViewSuperview.superview; 182 | } 183 | return closestCommonSuperview; 184 | } 185 | 186 | @end 187 | --------------------------------------------------------------------------------