lxy 2 anos atrás
pai
commit
a6a0b9c33a

+ 1 - 1
SDK/LenzCameraNativeModuleForRN/LenzCameraNativeModuleForRN/Classes/VideoStitch/LenStitcher.mm

@@ -46,7 +46,7 @@ dispatch_queue_t queue(void) {
         cv::Mat mat(imageHeight, imageWidth, CV_8UC4, sourceBaseAddr, CVPixelBufferGetBytesPerRow(imageBuffer));
         
         int* result = videoStitch(mat, dirction, [[NSNumber numberWithBool:isStop] intValue]);
-//        NSLog(@"~~~~~~~~~:%d, ~~~~~~~~~:%d", result[0], result[1]);
+        NSLog(@"~~~~~~~~~:%d, ~~~~~~~~~:%d", result[0], result[1]);
         LenVideoStitchResult stitchResult = (LenVideoStitchResult)result[0];
         LenVideoStitchNeedSave stitchNeedSave = (LenVideoStitchNeedSave)result[1];
         if (complete) {

+ 1 - 1
SDK/LenzCameraNativeModuleForRN/LenzCameraNativeModuleForRN/Classes/inner/OperationNode/OperationNodeVideoBase.m

@@ -201,7 +201,7 @@
     } else {
         [self.controller.takePhotoButton setImage:img forState:UIControlStateNormal];
     }
-    
+
     if (!self.isRecording) {
         [self.controller.timerLabel updateWith:0];
         self.controller.flashButton.hidden = NO;

+ 49 - 18
SDK/LenzCameraNativeModuleForRN/LenzCameraNativeModuleForRN/Classes/inner/PCSBaseViewController/PCSBaseViewController.m

@@ -815,14 +815,14 @@
             LenVideoStitchDirction dir = (LenVideoStitchDirction)wearSelf.panoramOrientationGuideView.selectedItemIndex;
             if (dir == LenVideoStitchDirctionLeft || dir == LenVideoStitchDirctionRight) {
                 if (fabs(x) < 3) {
-                    NSLog(@"~~~~~~~~~~水平");
+//                    NSLog(@"~~~~~~~~~~水平");
                     [wearSelf.panoramaGuideView updateArrowWith:PanoramaArrowDirCenter dir:dir];
                 } else {
                     if (x > 0) {
-                        NSLog(@"~~~~~~~~~~向下");
+//                        NSLog(@"~~~~~~~~~~向下");
                         [wearSelf.panoramaGuideView updateArrowWith:PanoramaArrowDirDown dir:dir];
                     } else {
-                        NSLog(@"~~~~~~~~~~向上");
+//                        NSLog(@"~~~~~~~~~~向上");
                         [wearSelf.panoramaGuideView updateArrowWith:PanoramaArrowDirUp dir:dir];
                     }
                 }
@@ -1226,6 +1226,8 @@
         self.discardPhotoButton.hidden = NO;
         self.backButton.hidden = YES;
         self.ablumImageView.hidden = NO;
+        [self.takePhotoButton setImage:[UIImage loadNamed:@"take-photo-btn"] forState:UIControlStateNormal];
+
 //        self.timerLabel.hidden = isSaveIng;
     
     });
@@ -2364,6 +2366,8 @@
             if ([self.currentOperationNode isKindOfClass:[OperationNodeVideoBase class]]) {
                 base = (OperationNodeVideoBase *)self.currentOperationNode;
             }
+            NSLog(@"2222");
+
             if (self.isVideoStitchStopedWhenRecording &&
                 (self.stitchResult != LenVideoStitchResultFail && self.stitchResult != LenVideoStitchResultStitchFail)) {
                 [self updateViewStatusWhenStitchSave:YES];
@@ -2375,6 +2379,8 @@
                                   isStop:self.isVideoStitchStopedWhenRecording
                                 complete:^(LenVideoStitchResult result, LenVideoStitchNeedSave needSave) {
                 self.stitchResult = result;
+                NSLog(@"333");
+
                 self.isVideoStitchStopedWhenRecording = NO;
                 UIImage *image = [LenStitcher getCurrentPanoramaShowImage];
                 LenzResourceItemModel *model = nil;
@@ -2396,8 +2402,10 @@
                             //保存大图拼接路径
                             model.cameraType = [SDKParameters shared].cameraPositionString;
                             model.mode = self.mode;
-                            model.image = image;
-                            model.path = [LenStitcher getCurrentPanoramaShow];
+                            if ([LenStitcher getCurrentPanoramaShow]) {
+                                model.image = image;
+                                model.path = [LenStitcher getCurrentPanoramaShow];
+                            }
                             [self updateViewStatusWhenStitchSave:NO];
                             self.isStitchBigImage = NO;
                             [self.panoramaGuideView clearImage];
@@ -2426,6 +2434,25 @@
                 } else {
  
                     if (!base.isRecording) {
+//                        [self removeLastStich];
+                        //停止拼接,移除保存中 非success数据
+                        if (self.mode == SDK_CAPTURE_MODE_PANORAMA) {
+                            NSMutableArray *array = [NSMutableArray array];
+                            [self.resourceModel.panoramArray enumerateObjectsUsingBlock:^(LenzResourceItemModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
+                                if (obj.path.length) {
+                                    [array addObject:obj];
+                                }
+                            }];
+                            self.resourceModel.panoramArray = array;
+                        } else if (self.mode == SDK_CAPTURE_MODE_INTELLEGENCE_PANORAMA) {
+                            NSMutableArray *array = [NSMutableArray array];
+                            [self.resourceModel.aiPanoramArray enumerateObjectsUsingBlock:^(LenzResourceItemModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
+                                if (obj.path.length) {
+                                    [array addObject:obj];
+                                }
+                            }];
+                            self.resourceModel.aiPanoramArray = array;
+                        }
                         [self.stitchkLock unlock];
                         return;
                     }
@@ -2435,19 +2462,14 @@
                         } else {
                             [SVProgressHUD showImage:[UIImage imageNamed:@""] status:@"拼接大图失败,流程结束"];
                         }
+                        
+                        self.isVideoStitchStopedWhenRecording = NO;
+                        base.isRecording = NO;
+
                         dispatch_async(dispatch_get_main_queue(), ^{
                             [self stopMotion];
-                            [self takePhotoButtonTouchUpInside:[NSObject new]];
-                            if (self.mode == SDK_CAPTURE_MODE_PANORAMA) {
-                                if (self.resourceModel.panoramArray.count > 0) {
-                                    [self.resourceModel.panoramArray removeLastObject];
-                                }
-                            } else if (self.mode == SDK_CAPTURE_MODE_INTELLEGENCE_PANORAMA) {
-                                if (self.resourceModel.aiPanoramArray.count > 0) {
-                                    [self.resourceModel.aiPanoramArray removeLastObject];
-                                }
-                            }
-                            
+//                            [self takePhotoButtonTouchUpInside:[NSObject new]];
+                            [self removeLastStich];
                             [self updateViewStatusWhenStitchFail];
                             [self.panoramaGuideView clearImage];
                             [self updateViewStatus];
@@ -2460,7 +2482,6 @@
                         [SVProgressHUD showImage:[UIImage imageNamed:@""] status:@"特征点变少,放慢速度"];
                     } else if (result == LenVideoStitchResultSlow) {
                         [SVProgressHUD showImage:[UIImage imageNamed:@""] status:@"特征点极少,即将失败"];
-
                     } else {
                         [SVProgressHUD showImage:[UIImage imageNamed:@""] status:@"请勿往反方向移动"];
                     }
@@ -2474,7 +2495,17 @@
         }
     }
 }
-
+- (void)removeLastStich {
+    if (self.mode == SDK_CAPTURE_MODE_PANORAMA) {
+        if (self.resourceModel.panoramArray.count > 0) {
+            [self.resourceModel.panoramArray removeLastObject];
+        }
+    } else if (self.mode == SDK_CAPTURE_MODE_INTELLEGENCE_PANORAMA) {
+        if (self.resourceModel.aiPanoramArray.count > 0) {
+            [self.resourceModel.aiPanoramArray removeLastObject];
+        }
+    }
+}
 //*
 #pragma mark - Navigation
 

+ 9 - 6
SDK/LenzCameraNativeModuleForRN/LenzCameraNativeModuleForRN/Classes/inner/PCSBaseViewController/PCSPreviewViewController.m

@@ -199,7 +199,7 @@
     layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
     layout.minimumLineSpacing = 0;
     layout.minimumInteritemSpacing = 0;
-    layout.itemSize = CGSizeMake([UIScreen mainScreen].bounds.size.width - 40, [UIScreen mainScreen].bounds.size.height - top - 214);
+    layout.itemSize = CGSizeMake([UIScreen mainScreen].bounds.size.width - 40, [UIScreen mainScreen].bounds.size.height - top - 224);
     self.collectionView = [[UICollectionView alloc] initWithFrame:self.view.frame collectionViewLayout:layout];
     self.collectionView.delegate = self;
     self.collectionView.dataSource = self;
@@ -211,7 +211,7 @@
     [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.mas_offset(20);
         make.right.mas_offset(-20);
-        make.top.mas_equalTo(self.countLabel.mas_bottom);
+        make.top.mas_equalTo(self.countLabel.mas_bottom).mas_offset(10);
         make.bottom.mas_equalTo(self.bottomView.mas_top);
     }];
 
@@ -357,6 +357,7 @@
 - (void)setupModeView {
     [self.modeView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
 //    self.currentModeDataIndex = 0;
+    CGFloat margin = [UIScreen mainScreen].bounds.size.width == 375 ? 20 : 30;
     UIView *lastView = nil;
     NSInteger count = 0;
     self.currentIndex = 0;
@@ -393,7 +394,7 @@
         [self.modeView addSubview:label];
         [label mas_makeConstraints:^(MASConstraintMaker *make) {
             if (lastView) {
-                make.left.mas_equalTo(lastView.mas_right).mas_offset(30);
+                make.left.mas_equalTo(lastView.mas_right).mas_offset(margin);
             } else {
                 make.left.mas_equalTo(20);
             }
@@ -416,7 +417,7 @@
         [self.modeView addSubview:label];
         [label mas_makeConstraints:^(MASConstraintMaker *make) {
             if (lastView) {
-                make.left.mas_equalTo(lastView.mas_right).mas_offset(30);
+                make.left.mas_equalTo(lastView.mas_right).mas_offset(margin);
             } else {
                 make.left.mas_equalTo(20);
             }
@@ -439,7 +440,7 @@
         [self.modeView addSubview:label];
         [label mas_makeConstraints:^(MASConstraintMaker *make) {
             if (lastView) {
-                make.left.mas_equalTo(lastView.mas_right).mas_offset(30);
+                make.left.mas_equalTo(lastView.mas_right).mas_offset(margin);
             } else {
                 make.left.mas_equalTo(20);
             }
@@ -495,6 +496,7 @@
         }];
     }
     
+    self.currentIndex = index;
 
     
 }
@@ -627,7 +629,8 @@
             [self setupModeView];
 //            [self updateScrollWith:self.currentIndex];
             [self.collectionView reloadData];
-            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+            
+            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                 [self updateViewWhenDelete];
             });
             if (self.dataChangeBlock) {

+ 86 - 79
SDK/LenzCameraNativeModuleForRN/LenzCameraNativeModuleForRN/Classes/inner/UI/PanoramaGuideView/PanoramaGuideView.m

@@ -247,9 +247,13 @@ CGFloat const PanoramaGuideViewWOrH = 120;
     dispatch_async(dispatch_get_main_queue(), ^{
         CGFloat imageWH = 0;
         if (image) {
-            imageWH = (PanoramaGuideViewWOrH * image.size.width)/image.size.height;
+            if (dir == PanoramaOrientationViewDown || dir == PanoramaOrientationViewUp) {
+                imageWH = (PanoramaGuideViewWOrH * image.size.height)/image.size.width;
+            } else {
+                imageWH = (PanoramaGuideViewWOrH * image.size.width)/image.size.height;
+            }
         }
-        
+
     //    UIImage *resultImage = [self showDir:dir image:image];
         self.showImageView.image = image;
         [UIView animateWithDuration:.15 animations:^{
@@ -339,100 +343,103 @@ CGFloat const PanoramaGuideViewWOrH = 120;
         if (dir == PanoramaOrientationViewDown || dir == PanoramaOrientationViewUp) {
             if (arrowDir == PanoramaArrowDirCenter) {
                 self.offSetLeft = @((120-38)/2);
-                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
-                    make.bottom.offset(-(PanoramaGuideViewWOrH * imageWidth)/imageHight);
-//                    make.centerX.mas_equalTo(self);
-                    make.left.mas_offset(self.offSetLeft.doubleValue);
-                }];
+//                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
+//                    make.bottom.offset(-(PanoramaGuideViewWOrH * imageWidth)/imageHight);
+////                    make.centerX.mas_equalTo(self);
+//                    make.left.mas_offset(self.offSetLeft.doubleValue);
+//                }];
             } else if (arrowDir == PanoramaArrowDirLeft) {
                 self.offSetLeft = @(0);
-                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
-                    make.bottom.offset(-(PanoramaGuideViewWOrH * imageWidth)/imageHight);
-//                    make.left.mas_equalTo(self).mas_offset(10);
-                    make.left.mas_offset(self.offSetLeft.doubleValue);
-
-                }];
+//                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
+//                    make.bottom.offset(-(PanoramaGuideViewWOrH * imageWidth)/imageHight);
+////                    make.left.mas_equalTo(self).mas_offset(10);
+//                    make.left.mas_offset(self.offSetLeft.doubleValue);
+//
+//                }];
             } else if (arrowDir == PanoramaArrowDirRight) {
                 self.offSetLeft = @(120-38);
 
-                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
-                    make.bottom.offset(-(PanoramaGuideViewWOrH * imageWidth)/imageHight);
-//                    make.right.mas_equalTo(self).mas_offset(-10);
-                    make.left.mas_offset(self.offSetLeft.doubleValue);
-
-                }];
-            }
-        } else if (dir == PanoramaOrientationViewUp) {
-            if (arrowDir == PanoramaArrowDirCenter) {
-                self.offSetTop = @((120-38)/2);
-
-                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
-                    make.top.offset((PanoramaGuideViewWOrH * imageWidth)/imageHight);
-//                    make.centerX.mas_equalTo(self);
-                    make.top.mas_offset(self.offSetTop.doubleValue);
-                }];
-            } else if (arrowDir == PanoramaArrowDirLeft) {
-                self.offSetTop = @((120-38)/2);
-
-                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
-                    make.top.offset((PanoramaGuideViewWOrH * imageWidth)/imageHight);
-                    make.left.mas_equalTo(self).mas_offset(10);
-                }];
-            } else if (arrowDir == PanoramaArrowDirRight) {
-                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
-                    make.top.offset((PanoramaGuideViewWOrH * imageWidth)/imageHight);
-                    make.right.mas_equalTo(self).mas_offset(-10);
-                }];
+//                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
+//                    make.bottom.offset(-(PanoramaGuideViewWOrH * imageWidth)/imageHight);
+////                    make.right.mas_equalTo(self).mas_offset(-10);
+//                    make.left.mas_offset(self.offSetLeft.doubleValue);
+//
+//                }];
             }
-            
-        } else if (dir == PanoramaOrientationViewLeft || dir == PanoramaOrientationViewRight) {
+        }
+//        else if (dir == PanoramaOrientationViewUp) {
+//            if (arrowDir == PanoramaArrowDirCenter) {
+//                self.offSetTop = @((120-38)/2);
+//
+////                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
+////                    make.top.offset((PanoramaGuideViewWOrH * imageWidth)/imageHight);
+//////                    make.centerX.mas_equalTo(self);
+////                    make.top.mas_offset(self.offSetTop.doubleValue);
+////                }];
+//            } else if (arrowDir == PanoramaArrowDirLeft) {
+//                self.offSetTop = @((120-38)/2);
+//
+//                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
+//                    make.top.offset((PanoramaGuideViewWOrH * imageWidth)/imageHight);
+//                    make.left.mas_equalTo(self).mas_offset(10);
+//                }];
+//            } else if (arrowDir == PanoramaArrowDirRight) {
+//                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
+//                    make.top.offset((PanoramaGuideViewWOrH * imageWidth)/imageHight);
+//                    make.right.mas_equalTo(self).mas_offset(-10);
+//                }];
+//            }
+//
+//        }
+        else if (dir == PanoramaOrientationViewLeft || dir == PanoramaOrientationViewRight) {
             if (arrowDir == PanoramaArrowDirCenter) {
                 self.offSetTop = @((120-38)/2);
-
-                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
-                    make.left.offset((PanoramaGuideViewWOrH * imageWidth)/imageHight);
-//                    make.centerY.mas_equalTo(self);
-                    make.top.mas_offset(self.offSetTop.doubleValue);
-
-                }];
+//
+//                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
+//                    make.left.offset((PanoramaGuideViewWOrH * imageWidth)/imageHight);
+////                    make.centerY.mas_equalTo(self);
+//                    make.top.mas_offset(self.offSetTop.doubleValue);
+//
+//                }];
             } else if (arrowDir == PanoramaArrowDirUp) {
                 self.offSetTop = @(0);
 
-                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
-                    make.left.offset((PanoramaGuideViewWOrH * imageWidth)/imageHight);
-//                    make.top.mas_equalTo(self).mas_offset(10);
-                    make.top.mas_offset(self.offSetTop.doubleValue);
-
-                }];
+//                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
+//                    make.left.offset((PanoramaGuideViewWOrH * imageWidth)/imageHight);
+////                    make.top.mas_equalTo(self).mas_offset(10);
+//                    make.top.mas_offset(self.offSetTop.doubleValue);
+//
+//                }];
             } else if (arrowDir == PanoramaArrowDirDown) {
                 self.offSetTop = @(120-38);
 
-                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
-                    make.left.offset((PanoramaGuideViewWOrH * imageWidth)/imageHight);
-//                    make.bottom.mas_equalTo(self).mas_offset(-10);
-                    make.top.mas_offset(self.offSetTop.doubleValue);
-
-                }];
+//                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
+//                    make.left.offset((PanoramaGuideViewWOrH * imageWidth)/imageHight);
+////                    make.bottom.mas_equalTo(self).mas_offset(-10);
+//                    make.top.mas_offset(self.offSetTop.doubleValue);
+//
+//                }];
             }
             
-        } else if (dir == PanoramaOrientationViewRight) {
-            if (arrowDir == PanoramaArrowDirCenter) {
-                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
-                    make.left.offset((PanoramaGuideViewWOrH * imageWidth)/imageHight);
-                    make.centerY.mas_equalTo(self);
-                }];
-            } else if (arrowDir == PanoramaArrowDirUp) {
-                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
-                    make.left.offset((PanoramaGuideViewWOrH * imageWidth)/imageHight);
-                    make.top.mas_equalTo(self).mas_offset(10);
-                }];
-            } else if (arrowDir == PanoramaArrowDirDown) {
-                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
-                    make.right.offset(-(PanoramaGuideViewWOrH * imageWidth)/imageHight);
-                    make.bottom.mas_equalTo(self).mas_offset(-10);
-                }];
-            }
         }
+//        else if (dir == PanoramaOrientationViewRight) {
+//            if (arrowDir == PanoramaArrowDirCenter) {
+//                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
+//                    make.left.offset((PanoramaGuideViewWOrH * imageWidth)/imageHight);
+//                    make.centerY.mas_equalTo(self);
+//                }];
+//            } else if (arrowDir == PanoramaArrowDirUp) {
+//                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
+//                    make.left.offset((PanoramaGuideViewWOrH * imageWidth)/imageHight);
+//                    make.top.mas_equalTo(self).mas_offset(10);
+//                }];
+//            } else if (arrowDir == PanoramaArrowDirDown) {
+//                [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
+//                    make.right.offset(-(PanoramaGuideViewWOrH * imageWidth)/imageHight);
+//                    make.bottom.mas_equalTo(self).mas_offset(-10);
+//                }];
+//            }
+//        }
         
     });
 }