lxy 1 year ago
parent
commit
2764221dc6

+ 2 - 2
Example/Podfile.lock

@@ -1,5 +1,5 @@
 PODS:
-  - LenzSDK (2.2.0):
+  - LenzSDK (2.3.2):
     - Masonry (= 1.1.0)
     - OpenCV2 (~> 4.3.0)
     - SVProgressHUD (~> 2.2.5)
@@ -27,7 +27,7 @@ EXTERNAL SOURCES:
     :path: "../"
 
 SPEC CHECKSUMS:
-  LenzSDK: d3e17d7ec74406de3153634788218aad8d791de4
+  LenzSDK: b4f646beafcf1e367274c023918e2fb5c4305f78
   Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
   OpenCV2: ffe82e5cb5d16dc3fc01a5f4127b9a5b3cfc7d1b
   SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6

+ 1 - 1
Example/Pods/Headers/Private/LenzSDK/CameraManager.h

@@ -1 +1 @@
-../../../../../LenzCameraNativeModuleForRN/Classes/inner/CameraManager/CameraManager.h
+../../../../../LenzCameraNativeModuleForRN/Classes/inner/Manager/CameraManager.h

+ 1 - 0
Example/Pods/Headers/Private/LenzSDK/PCSDeviceOrientationManager.h

@@ -0,0 +1 @@
+../../../../../LenzCameraNativeModuleForRN/Classes/inner/Manager/PCSDeviceOrientationManager.h

+ 0 - 1
Example/Pods/Headers/Private/LenzSDK/PCSSessionWrapper.h

@@ -1 +0,0 @@
-../../../../../LenzCameraNativeModuleForRN/Classes/inner/PCSSessionWrapper.h

+ 1 - 0
Example/Pods/Headers/Private/LenzSDK/UIImage+ImageRotate.h

@@ -0,0 +1 @@
+../../../../../LenzCameraNativeModuleForRN/Classes/inner/UI/UIView+tool/UIImage+ImageRotate.h

+ 2 - 2
Example/Pods/Local Podspecs/LenzSDK.podspec.json

@@ -1,6 +1,6 @@
 {
   "name": "LenzSDK",
-  "version": "2.2.0",
+  "version": "2.3.2",
   "summary": "A short description of LenzSDK.",
   "description": "this  is the long description",
   "homepage": "http://39.96.8.150:10080/l405023944/LenzSDK_iOS.git",
@@ -13,7 +13,7 @@
   },
   "source": {
     "git": "http://39.96.8.150:10080/l405023944/LenzSDK_iOS.git",
-    "tag": "2.2.0"
+    "tag": "2.3.2"
   },
   "platforms": {
     "ios": "12.0"

+ 2 - 2
Example/Pods/Manifest.lock

@@ -1,5 +1,5 @@
 PODS:
-  - LenzSDK (2.2.0):
+  - LenzSDK (2.3.2):
     - Masonry (= 1.1.0)
     - OpenCV2 (~> 4.3.0)
     - SVProgressHUD (~> 2.2.5)
@@ -27,7 +27,7 @@ EXTERNAL SOURCES:
     :path: "../"
 
 SPEC CHECKSUMS:
-  LenzSDK: d3e17d7ec74406de3153634788218aad8d791de4
+  LenzSDK: b4f646beafcf1e367274c023918e2fb5c4305f78
   Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
   OpenCV2: ffe82e5cb5d16dc3fc01a5f4127b9a5b3cfc7d1b
   SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6

File diff suppressed because it is too large
+ 323 - 339
Example/Pods/Pods.xcodeproj/project.pbxproj


+ 1 - 1
Example/Pods/Target Support Files/LenzSDK/ResourceBundle-LenzCameraNativeModuleForRN-LenzSDK-Info.plist

@@ -13,7 +13,7 @@
   <key>CFBundlePackageType</key>
   <string>BNDL</string>
   <key>CFBundleShortVersionString</key>
-  <string>2.2.0</string>
+  <string>2.3.2</string>
   <key>CFBundleSignature</key>
   <string>????</string>
   <key>CFBundleVersion</key>

+ 59 - 47
LenzCameraNativeModuleForRN/Classes/inner/PCSBaseViewController/PCSBaseViewController.m

@@ -164,6 +164,7 @@
     [SVProgressHUD setMinimumDismissTimeInterval:1.5];
     [SVProgressHUD setMaximumDismissTimeInterval:3];
     [SVProgressHUD setFont:[UIFont systemFontOfSize:14]];
+    self.stitchResult = -999;
     self.tensorFlow = [[LenzTensorFlow alloc]initWithFileName:@"moire_mobilenetv2_79"];
     if(@available(iOS 14, *)){
         self.videoQueue = dispatch_queue_create("com.lenzSDK.videoQueue", NULL);
@@ -1399,6 +1400,7 @@
     [camera unlockForConfiguration];
     [self.recordTimer invalidate];
     self.recordTimer = nil;
+    [self.timerLabel updateWith:0];
 }
 
 - (BOOL)startVideoDataOutputing{
@@ -3092,53 +3094,7 @@
 
                 
                 if (result == LenVideoStitchResultSuccess) {
-                    dispatch_async(dispatch_get_main_queue(), ^{
-                        
-                        if (self.isStitchBigImage) {
-                            //保存大图拼接路径
-                            [[SDKParameters shared].items enumerateObjectsUsingBlock:^(SDKParametersItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-                                if (obj.model == self.mode) {
-                                    model.cameraType = obj.cameraPositionString;
-                                }
-                            }];
-                            model.mode = self.mode;
-                            if ([LenStitcher getCurrentPanoramaShow]) {
-                                model.image = image;
-                                model.previewImage = saveImage;
-                                NSString *path = [LenzDataManager saveImageWith:UIImageJPEGRepresentation(saveImage, .8) mode:self.mode];
-                                model.path = path;
-                            }
-                            [self updateViewStatusWhenStitchSave:NO];
-                            self.isStitchBigImage = NO;
-                            [self.panoramaGuideView clearImage];
-                            [self updateViewStatus];
-                            [self.panoramaGuideView showImageWith:nil];
-                        } else {
-                            if (base.isRecording) {
-                                __block BOOL keyFrame = NO;
-                                [[SDKParameters shared].items enumerateObjectsUsingBlock:^(SDKParametersItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-                                    if (obj.model == self.mode) {
-                                        keyFrame = [obj.keyFrame boolValue];
-                                    }
-                                }];
-                                
-                                if (needSave && keyFrame) {
-                                    NSString *path = [LenzDataManager saveImageWith:UIImageJPEGRepresentation(saveImage, .6) mode:self.mode];
-                                    if (path) {
-                                        [model.keyFrame addObject:path];
-                                    }
-                                }
-                                if (self.panoramOrientationGuideView.selectedItemIndex != PanoramaOrientationViewAny) {
-                                    [self.panoramaGuideView showImageWith:image];
-                                } else {
-                                    self.ablumImageView.hidden = NO;
-                                    self.ablumImageView.image = saveImage;
-                                }
-                            }
-
-                        }
-                        self.resourceModel.lastIndex = self.mode;
-                    });
+                    [self saveStitch:model image:image saveImage:saveImage base:base needSave:needSave];
                 } else {
  
                     if (!base.isRecording) {
@@ -3173,6 +3129,7 @@
                         }
                         
                         self.isVideoStitchStopedWhenRecording = NO;
+                        self.isStitchBigImage = NO;
                         dispatch_async(dispatch_get_main_queue(), ^{
                             [base takePhotoButtonTouched];
                             [self stopMotion];
@@ -3187,10 +3144,13 @@
                         }];
                     } else if(result == LenVideoStitchResultSlowMore) {
                         [SVProgressHUD showImage:[UIImage imageNamed:@""] status:@"目标物较少,请对准目标物低速且匀速拍摄"];
+                        [self saveStitch:model image:image saveImage:saveImage base:base needSave:needSave];
                     } else if (result == LenVideoStitchResultSlow) {
                         [SVProgressHUD showImage:[UIImage imageNamed:@""] status:@"目标物较少,请对准目标物低速且匀速拍摄"];
+                        [self saveStitch:model image:image saveImage:saveImage base:base needSave:needSave];
                     } else {
 //                        [SVProgressHUD showImage:[UIImage imageNamed:@""] status:@"请勿往反方向移动"];
+                        [self saveStitch:model image:image saveImage:saveImage base:base needSave:needSave];
                     }
                 }
                 
@@ -3199,6 +3159,58 @@
         }
     }
 }
+
+- (void)saveStitch:(LenzResourceItemModel *)model image:(UIImage *)image saveImage:(UIImage *)saveImage base:(OperationNodeVideoBase *)base needSave:(LenVideoStitchNeedSave)needSave {
+    dispatch_async(dispatch_get_main_queue(), ^{
+        
+        if (self.isStitchBigImage) {
+            //保存大图拼接路径
+            [[SDKParameters shared].items enumerateObjectsUsingBlock:^(SDKParametersItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
+                if (obj.model == self.mode) {
+                    model.cameraType = obj.cameraPositionString;
+                }
+            }];
+            model.mode = self.mode;
+            if ([LenStitcher getCurrentPanoramaShow]) {
+                model.image = image;
+                model.previewImage = saveImage;
+                NSString *path = [LenzDataManager saveImageWith:UIImageJPEGRepresentation(saveImage, .8) mode:self.mode];
+                model.path = path;
+            }
+            [self updateViewStatusWhenStitchSave:NO];
+            self.isStitchBigImage = NO;
+            [self.panoramaGuideView clearImage];
+            [self updateViewStatus];
+            [self.panoramaGuideView showImageWith:nil];
+        } else {
+            if (base.isRecording) {
+                __block BOOL keyFrame = NO;
+                [[SDKParameters shared].items enumerateObjectsUsingBlock:^(SDKParametersItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
+                    if (obj.model == self.mode) {
+                        keyFrame = [obj.keyFrame boolValue];
+                    }
+                }];
+                
+                if (needSave && keyFrame) {
+                    NSString *path = [LenzDataManager saveImageWith:UIImageJPEGRepresentation(saveImage, .6) mode:self.mode];
+                    if (path) {
+                        [model.keyFrame addObject:path];
+                    }
+                }
+                if (self.panoramOrientationGuideView.selectedItemIndex != PanoramaOrientationViewAny) {
+                    [self.panoramaGuideView showImageWith:image];
+                } else {
+                    self.ablumImageView.hidden = NO;
+                    self.ablumImageView.image = saveImage;
+                }
+            }
+
+        }
+        self.resourceModel.lastIndex = self.mode;
+    });
+}
+
+
 - (void)removeLastStich {
     if (self.mode == SDK_CAPTURE_MODE_PANORAMA) {
         if (self.resourceModel.panoramArray.count > 0) {

+ 1 - 1
LenzSDK.podspec

@@ -8,7 +8,7 @@
 
 Pod::Spec.new do |s|
   s.name             = 'LenzSDK'
-  s.version          = '2.3.2'
+  s.version          = '2.3.3'
   s.summary          = 'A short description of LenzSDK.'
 
 # This description is used to generate tags and improve search results.

+ 2 - 0
LenzStitchSDK.framework/Headers/lenz_stitch_jni.hpp

@@ -46,6 +46,8 @@ const char* getTestCurrentPanoramaShow(void);
 
 cv::Mat getCurrentPanoramsShowMat(void);
 
+
+
 #endif
 
 

+ 138 - 0
LenzStitchSDK.framework/Headers/lenz_stitcher.hpp

@@ -0,0 +1,138 @@
+//
+//  lenz_stitcher.hpp
+//  LenzCameraNativeModuleForRN
+//
+//  Created by lr on 2023/2/8.
+//
+
+#ifndef lenz_stitcher_hpp
+#define lenz_stitcher_hpp
+
+#if __cplusplus && __has_include(<opencv2/imgcodecs/ios.h>)
+
+#import <opencv2/core/ocl.hpp>
+#import <opencv2/opencv.hpp>
+
+#include <iostream>
+#include <thread>
+#include <vector>
+#include <string>
+#include <random>
+#include <math.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+using namespace cv;
+using namespace cv::detail;
+using namespace cv::ocl;
+using namespace std;
+
+#define STITCH_STATUS_INIT 0
+#define STITCH_STATUS_CHECKING 1
+#define STITCH_STATUS_STITCHING 2
+#define STITCH_STATUS_FREE 3
+#define STITCH_STATUS_FAILED 4
+
+#define FEATURE_HEIGHT 300
+#define STITCH_HEIGHT 300
+#define BIG_STITCH_HEIGHT 1000
+#define BIG_FEATURE_HEIGHT 800
+
+#define MAX_SIZE 4000      // 缩略图的最大尺寸,长或宽都不能超过MAX_SIZE*MAX_SIZE,否则直接报错
+#define BIG_MAX_SIZE 10000 // 拼接大图的最大尺寸, 长或宽都不能超过BIG_MAX_SIZE
+
+struct stitch_data
+{
+    Mat scaled_gray_frame;
+    float work_scale;
+    vector<KeyPoint> keypoints;
+    Mat descriptors;
+    Mat homo = (Mat_<double>(3, 3) << 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0); // store homography matrix to base image
+    Mat base_homo = (Mat_<double>(3, 3) << 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0); // store homography matrix to last base image
+};
+
+struct LinePara
+{
+    float k;
+    float b;
+};
+
+string test_image_path = "";
+
+class LenzStitcher
+{
+public:
+    string task_id = "";
+    string local_path = "";
+    int stitcher_status = STITCH_STATUS_INIT; // 0: initialized, 1: checking, 2: stitching, 3: free
+
+    int failed_count = 0;  // 当前连续失败的帧数
+    int failed_thresh = 10; // 连续5帧失败才返回失败
+
+    float iou_thresh = 0.7;  // iou低于该阈值的时候把这张图片存下来
+    float area_thresh = 0.5; // area threshold for green box
+    float angle_thresh = 10; // angle threshold for green box
+    float inline_thresh = 0.1; // 光流法匹配的点的比例至少要大于这个值,才认为是正确的映射矩阵
+    int matches_thresh = 10; // 前后两帧基于光流的匹配点的个数的阈值,低于该值则无法进行拼接
+    float check_match_conf = 0.2f;
+    int frame_index = 0;
+    vector<Point2f> last_warp_points; // 上一张存下来的图的四个点在拼接图上的坐标
+    int big_frame_index = 0;          // 存下来的帧的信息
+    float total_shift_x = 0;
+    float total_shift_y = 0;
+
+    Mat last_frame;
+    Mat last_stitch_image = Mat(); // 最后一张拼接缩略图
+    int last_direction = 0;        // 上一帧的手机移动方向
+    vector<float> last_angles = vector<float>{90, 90, 90, 90};
+    string last_stitch_image_path = ""; // 拼接缩略图的本地路径
+    stitch_data last_check_data;        // 上一帧的数据
+    string big_stitch_image_path = "";  // 拼接大图的本地路径
+
+    string test_image_path = ""; // test
+
+    LenzStitcher(string input_id);
+    int *ofcheck_stitch(Mat &frame, int const direction, int const is_last_one); // 输入每一帧实时产生拼接缩略图
+
+    bool get_big_image(int get_big_image); // 在收到当前帧是最后一帧的时候运行,会用之前存下来的帧数据产生最后的拼接大图
+    void remove_local_path();
+};
+
+bool is_good_homo(const vector<Point2f> &corners, const Mat &frame, float area_thresh, float angle_thresh);
+bool is_convex(const vector<Point2f> &corners);
+float calc_area(const vector<Point2f> &corners, const Mat &frame);
+float min_axis(vector<float> input_list);
+float max_axis(vector<float> input_list);
+float calc_angle(const vector<cv::Point2f> &conners);
+float calc_vangle(const vector<cv::Point2f> &conners);
+float calc_hangle(const vector<cv::Point2f> &conners);
+void double_match(const Mat &query_des, const Mat &train_des, vector<DMatch> &good_matches, float check_match_conf);
+void single_match(const Mat &query_des, const Mat &train_des, vector<DMatch> &good_matches, float check_match_conf);
+void getFilePath(const char *path, const char *filename, char *filepath);
+void deleteFile(const char *path);
+bool isFloderexit(const char *path);
+void randomSelectKeyPoints(vector<KeyPoint> kpts, vector<Point2f> &pts, int max_num);
+void optimizeSeam(Mat &last_img, Mat &stitched_image, vector<Point2f> &corners);
+void getLinePara(float x1, float y1, float x2, float y2, LinePara &LP);
+float point_2_line(float k, float b, float k2, float x, float y);
+int get_direction(vector<Point2f> &frame_corners, vector<Point2f> &transpose_corners);
+int dcmp(float x);
+float cross(Point2f a, Point2f b, Point2f c);
+float CPIA(vector<Point2f> a, vector<Point2f> b, int na, int nb);
+float SPIA(vector<Point2f> a, vector<Point2f> b, int na, int nb);
+Point2f get_intersection_point(Point2f a, Point2f b, Point2f c, Point2f d);
+float PolygonArea(vector<Point2f> p, int n);
+float single_quadrangle_iou(vector<Point2f> pts1, vector<Point2f> pts2);
+float single_box_iou(vector<Point2f> pts1, vector<Point2f> pts2);
+void stitch_big_image(Mat frame, vector<float> angles, int direction, int big_frame_index);
+void cylindrical_projection(Mat &img, Mat &output, float angle);
+void fill_contours(vector<vector<Point>> contours, Mat &source_image, Mat &target_image);
+float angle_of_two_vector(Point2f &pt1, Point2f &pt2, Point2f &c);
+void calc_angles(vector<Point2f> &conners);
+
+
+#endif
+
+#endif

BIN
LenzStitchSDK.framework/LenzStitchSDK


BIN
LenzStitchSDK.framework/_CodeSignature/CodeDirectory


BIN
LenzStitchSDK.framework/_CodeSignature/CodeRequirements-1


+ 18 - 3
LenzStitchSDK.framework/_CodeSignature/CodeResources

@@ -14,7 +14,11 @@
 		</data>
 		<key>Headers/lenz_stitch_jni.hpp</key>
 		<data>
-		BiWMBnP4j0+CuhQUrzL60L65CHc=
+		eHEqnYRibWGq99OMfYh/tNt85zA=
+		</data>
+		<key>Headers/lenz_stitcher.hpp</key>
+		<data>
+		A8S3alqzGWa9zAKR1mtQZBDPstc=
 		</data>
 		<key>Info.plist</key>
 		<data>
@@ -53,11 +57,22 @@
 		<dict>
 			<key>hash</key>
 			<data>
-			BiWMBnP4j0+CuhQUrzL60L65CHc=
+			eHEqnYRibWGq99OMfYh/tNt85zA=
+			</data>
+			<key>hash2</key>
+			<data>
+			5fADOFBRoq2n70+yLTpvcgewJAj6mBdYeNV7ajolkls=
+			</data>
+		</dict>
+		<key>Headers/lenz_stitcher.hpp</key>
+		<dict>
+			<key>hash</key>
+			<data>
+			A8S3alqzGWa9zAKR1mtQZBDPstc=
 			</data>
 			<key>hash2</key>
 			<data>
-			XXLOZB3e0u9OU3Qqoad7mMTT7hgvQcpE4kDHoqMrF0A=
+			DtF2/KVgCGICzVxE8MASuJz6srILU91n1Ri4feqpjIY=
 			</data>
 		</dict>
 		<key>Modules/module.modulemap</key>

BIN
LenzStitchSDK.framework/_CodeSignature/CodeSignature


Some files were not shown because too many files changed in this diff